[PATCH 09/13] smd: cleanup wcn36xx_smd_config_bss()
Kalle Valo
kvalo at qca.qualcomm.com
Thu May 23 07:07:26 EDT 2013
Preparation for adding more interface types. No functional changes.
Signed-off-by: Kalle Valo <kvalo at qca.qualcomm.com>
---
main.c | 8 ++--
smd.c | 139 +++++++++++++++++++++++++++++++++++-----------------------------
smd.h | 3 +
3 files changed, 84 insertions(+), 66 deletions(-)
diff --git a/main.c b/main.c
index 416ed2b..285159f 100644
--- a/main.c
+++ b/main.c
@@ -197,7 +197,8 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
if(!is_zero_ether_addr(bss_conf->bssid)) {
wcn36xx_smd_join(wcn, (u8*)bss_conf->bssid, vif->addr, wcn->ch);
- wcn36xx_smd_config_bss(wcn, true, (u8*)bss_conf->bssid, 0);
+ wcn36xx_smd_config_bss(wcn, NL80211_IFTYPE_STATION,
+ bss_conf->bssid, false);
}
}
@@ -225,7 +226,8 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
if (bss_conf->enable_beacon) {
wcn->beacon_enable = true;
skb = ieee80211_beacon_get_tim(hw, vif, &tim_off, &tim_len);
- wcn36xx_smd_config_bss(wcn, false, NULL, 0);
+ wcn36xx_smd_config_bss(wcn, NL80211_IFTYPE_AP,
+ NULL, false);
wcn36xx_smd_send_beacon(wcn, skb, tim_off, 0);
} else {
/* FIXME: disable beaconing */
@@ -282,7 +284,7 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
wcn36xx_smd_set_link_st(wcn, sta->addr, vif->addr, WCN36XX_HAL_LINK_POSTASSOC_STATE);
wcn36xx_smd_config_sta(wcn, sta->addr, sta->aid, vif->addr);
- wcn36xx_smd_config_bss(wcn, true, sta->addr, 1);
+ wcn36xx_smd_config_bss(wcn, NL80211_IFTYPE_STATION, sta->addr, true);
return 0;
}
static int wcn36xx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
diff --git a/smd.c b/smd.c
index 1c9c02e..1daa726 100644
--- a/smd.c
+++ b/smd.c
@@ -579,88 +579,103 @@ static int wcn36xx_smd_config_bss_v1(struct wcn36xx *wcn,
return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
}
-int wcn36xx_smd_config_bss(struct wcn36xx *wcn, bool sta_mode, u8 *bssid, u8 update)
+int wcn36xx_smd_config_bss(struct wcn36xx *wcn, enum nl80211_iftype type,
+ const u8 *bssid, bool update)
{
- struct wcn36xx_hal_config_bss_req_msg msg_body;
-
- INIT_HAL_MSG(msg_body, WCN36XX_HAL_CONFIG_BSS_REQ);
-
- if(sta_mode) {
- memcpy(&msg_body.bss_params.bssid, bssid, ETH_ALEN);
- memcpy(&msg_body.bss_params.self_mac_addr, &wcn->addresses[0], ETH_ALEN);
- msg_body.bss_params.bss_type = WCN36XX_HAL_INFRASTRUCTURE_MODE;
- //TODO define enum for oper_mode
- msg_body.bss_params.oper_mode = 1; //0 - AP, 1-STA
- msg_body.bss_params.llg_coexist = 1;
- msg_body.bss_params.beacon_interval = 0x64;
-
- msg_body.bss_params.oper_channel = wcn->ch;
- memcpy(&msg_body.bss_params.sta.bssid, bssid, ETH_ALEN);
- msg_body.bss_params.sta.type = 1;
- msg_body.bss_params.sta.listen_interval = 0x64;
- msg_body.bss_params.sta.wmm_enabled = 1;
-
- msg_body.bss_params.sta.max_ampdu_size = 3;
- msg_body.bss_params.sta.max_ampdu_density = 5;
- msg_body.bss_params.sta.dsss_cck_mode_40mhz = 1;
- } else {
- memcpy(&msg_body.bss_params.bssid, &wcn->addresses[0], ETH_ALEN);
- memcpy(&msg_body.bss_params.self_mac_addr, &wcn->addresses[0], ETH_ALEN);
+ struct wcn36xx_hal_config_bss_req_msg msg;
+ struct wcn36xx_hal_config_bss_params *bss;
+ struct wcn36xx_hal_config_sta_params *sta;
+
+ INIT_HAL_MSG(msg, WCN36XX_HAL_CONFIG_BSS_REQ);
+
+ bss = &msg.bss_params;
+ sta = &bss->sta;
+
+ if (type == NL80211_IFTYPE_STATION) {
+ memcpy(&bss->bssid, bssid, ETH_ALEN);
+ memcpy(&bss->self_mac_addr, &wcn->addresses[0], ETH_ALEN);
+ bss->bss_type = WCN36XX_HAL_INFRASTRUCTURE_MODE;
+
+ /*
+ * 0 - AP, 1 - STA
+ *
+ * TODO define enum for oper_mode
+ */
+ bss->oper_mode = 1;
+
+ bss->llg_coexist = 1;
+ bss->beacon_interval = 0x64;
+
+ bss->oper_channel = wcn->ch;
+ memcpy(&sta->bssid, bssid, ETH_ALEN);
+ sta->type = 1;
+ sta->listen_interval = 0x64;
+ sta->wmm_enabled = 1;
+
+ sta->max_ampdu_size = 3;
+ sta->max_ampdu_density = 5;
+ sta->dsss_cck_mode_40mhz = 1;
+ } else if (type == NL80211_IFTYPE_AP) {
+ memcpy(&bss->bssid, &wcn->addresses[0], ETH_ALEN);
+ memcpy(&bss->self_mac_addr, &wcn->addresses[0], ETH_ALEN);
//TODO do all this configurabel
- msg_body.bss_params.bss_type = WCN36XX_HAL_INFRA_AP_MODE;
- msg_body.bss_params.oper_mode = 0; //0 - AP, 1-STA
+ bss->bss_type = WCN36XX_HAL_INFRA_AP_MODE;
+ bss->oper_mode = 0; //0 - AP, 1-STA
- msg_body.bss_params.short_slot_time_supported = 1;
- msg_body.bss_params.beacon_interval = 0x64;
- msg_body.bss_params.dtim_period = 2;
- msg_body.bss_params.oper_channel = 1;
+ bss->short_slot_time_supported = 1;
+ bss->beacon_interval = 0x64;
+ bss->dtim_period = 2;
+ bss->oper_channel = 1;
- msg_body.bss_params.ssid.length = wcn->ssid.length;
- memcpy(msg_body.bss_params.ssid.ssid,
+ bss->ssid.length = wcn->ssid.length;
+ memcpy(bss->ssid.ssid,
wcn->ssid.ssid, wcn->ssid.length);
- msg_body.bss_params.obss_prot_enabled = 1;
- msg_body.bss_params.wcn36xx_hal_persona = 1;
- msg_body.bss_params.max_tx_power = 0x10;
+ bss->obss_prot_enabled = 1;
+ bss->wcn36xx_hal_persona = 1;
+ bss->max_tx_power = 0x10;
- memcpy(&msg_body.bss_params.sta.bssid, &wcn->addresses[0], ETH_ALEN);
- msg_body.bss_params.sta.short_preamble_supported = 1;
- memcpy(&msg_body.bss_params.sta.mac, &wcn->addresses[0], ETH_ALEN);
- msg_body.bss_params.sta.listen_interval = 8;
+ memcpy(&sta->bssid, &wcn->addresses[0], ETH_ALEN);
+ sta->short_preamble_supported = 1;
+ memcpy(&sta->mac, &wcn->addresses[0], ETH_ALEN);
+ sta->listen_interval = 8;
}
- msg_body.bss_params.nw_type = WCN36XX_HAL_11G_NW_TYPE;
- msg_body.bss_params.sta.ht_capable = 1;
- msg_body.bss_params.sta.sgi_40mhz = 1;
- msg_body.bss_params.sta.sgi_20Mhz = 1;
+
+ bss->nw_type = WCN36XX_HAL_11G_NW_TYPE;
+ sta->ht_capable = 1;
+ sta->sgi_40mhz = 1;
+ sta->sgi_20Mhz = 1;
+
if (update == 1) {
- msg_body.bss_params.short_slot_time_supported = 1;
- msg_body.bss_params.lln_non_gf_coexist = 1;
- msg_body.bss_params.dtim_period = 0;
- msg_body.bss_params.sta.aid = 1;
- msg_body.bss_params.sta.bssid_index = 0;
- msg_body.bss_params.action = 1;
- msg_body.bss_params.tx_mgmt_power = 6;
- msg_body.bss_params.max_tx_power = 0x10;
+ bss->short_slot_time_supported = 1;
+ bss->lln_non_gf_coexist = 1;
+ bss->dtim_period = 0;
+ sta->aid = 1;
+ sta->bssid_index = 0;
+ bss->action = 1;
+ bss->tx_mgmt_power = 6;
+ bss->max_tx_power = 0x10;
} else {
- msg_body.bss_params.max_tx_power = 0x14;
- msg_body.bss_params.dtim_period = 1;
- msg_body.bss_params.sta.bssid_index = 0xff;
+ bss->max_tx_power = 0x14;
+ bss->dtim_period = 1;
+ sta->bssid_index = 0xff;
}
- msg_body.bss_params.sta.sta_index = 0xff;
- memcpy(&msg_body.bss_params.sta.supported_rates, &wcn->supported_rates, sizeof(wcn->supported_rates));
+ sta->sta_index = 0xff;
+
+ memcpy(&sta->supported_rates, &wcn->supported_rates, sizeof(wcn->supported_rates));
if (wcn->fw_minor <= 3)
- return wcn36xx_smd_config_bss_v1(wcn, &msg_body);
+ return wcn36xx_smd_config_bss_v1(wcn, &msg);
- PREPARE_HAL_BUF(wcn->smd_buf, msg_body);
+ PREPARE_HAL_BUF(wcn->smd_buf, msg);
wcn36xx_dbg(WCN36XX_DBG_HAL,
"hal config bss bss_type %d",
- msg_body.bss_params.bss_type);
+ bss->bss_type);
- return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
+ return wcn36xx_smd_send_and_wait(wcn, msg.header.len);
}
static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn, void *buf, size_t len)
diff --git a/smd.h b/smd.h
index e6ad2d0..188a2c3 100644
--- a/smd.h
+++ b/smd.h
@@ -60,7 +60,8 @@ int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr);
int wcn36xx_smd_delete_sta(struct wcn36xx *wcn);
int wcn36xx_smd_join(struct wcn36xx *wcn, u8 *bssid, u8 *vif, u8 ch);
int wcn36xx_smd_set_link_st(struct wcn36xx *wcn, u8 *bssid, u8 *sta_mac, enum wcn36xx_hal_link_state state);
-int wcn36xx_smd_config_bss(struct wcn36xx *wcn, bool sta_mode, u8 *bssid, u8 update);
+int wcn36xx_smd_config_bss(struct wcn36xx *wcn, enum nl80211_iftype type,
+ const u8 *bssid, bool update);
int wcn36xx_smd_delete_bss(struct wcn36xx *wcn);
int wcn36xx_smd_config_sta(struct wcn36xx *wcn, u8 *bssid, u16 ass_id, u8 *sta_mac);
int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct sk_buff *skb_beacon, u16 tim_off, u16 p2p_off);
More information about the wcn36xx
mailing list