[PATCH] Store AID after association

Eugene Krasnikov k.eugene.e at gmail.com
Fri May 24 07:23:28 EDT 2013


Mac80211 is associated after BSS_CHANGED_ASSOC.
Store AID and use it everywhere.

Also fix rewriting bssid in smd_config_bss function
that caused config_sta to fail with error 5.

Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
 main.c    | 61 ++++++++++++++++++++++++++++++++++---------------------------
 smd.c     |  7 +++----
 smd.h     |  2 +-
 wcn36xx.h |  2 +-
 4 files changed, 39 insertions(+), 33 deletions(-)

diff --git a/main.c b/main.c
index e3363ea..c9f452d 100644
--- a/main.c
+++ b/main.c
@@ -248,6 +248,39 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
 		memcpy(&wcn->ssid.ssid, bss_conf->ssid, bss_conf->ssid_len);
 	}
 
+	if (changed & BSS_CHANGED_ASSOC) {
+		if(bss_conf->assoc) {
+			wcn36xx_dbg(WCN36XX_DBG_MAC,
+				    "mac assoc bss %pM vif %pM AID=%d",
+				     bss_conf->bssid,
+				     vif->addr,
+				     bss_conf->aid);
+
+			wcn->aid = bss_conf->aid;
+
+			wcn36xx_smd_set_link_st(wcn, (u8*)bss_conf->bssid,
+						vif->addr,
+						WCN36XX_HAL_LINK_POSTASSOC_STATE);
+			wcn36xx_smd_config_bss(wcn, NL80211_IFTYPE_STATION,
+					       (u8*)bss_conf->bssid,
+					       true);
+			wcn36xx_smd_config_sta(wcn, (u8*)bss_conf->bssid, vif->addr);
+
+		} else {
+			wcn36xx_dbg(WCN36XX_DBG_MAC,
+				    "disassociated bss %pM vif %pM AID=%d",
+				    (u8*)bss_conf->bssid,
+				    vif->addr,
+				    bss_conf->aid);
+			wcn->aid = 0;
+			wcn36xx_smd_delete_sta(wcn);
+			wcn36xx_smd_delete_bss(wcn);
+			wcn36xx_smd_set_link_st(wcn,
+						(u8*)bss_conf->bssid,
+						vif->addr,
+						WCN36XX_HAL_LINK_IDLE_STATE);
+		}
+	}
 	if (changed & BSS_CHANGED_AP_PROBE_RESP) {
 		wcn36xx_dbg(WCN36XX_DBG_MAC, "mac bss changed ap probe resp");
 		skb = ieee80211_proberesp_get(hw, vif);
@@ -314,31 +347,6 @@ static int wcn36xx_add_interface(struct ieee80211_hw *hw,
 	return 0;
 }
 
-static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-		       struct ieee80211_sta *sta)
-{
-	struct wcn36xx *wcn = hw->priv;
-
-	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM", vif, sta->addr);
-
-	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, NL80211_IFTYPE_STATION, sta->addr, true);
-	return 0;
-}
-static int wcn36xx_sta_remove(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
-			  struct ieee80211_sta *sta)
-{
-	struct wcn36xx *wcn = hw->priv;
-
-	wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM", vif, sta->addr);
-
-	wcn36xx_smd_delete_sta(wcn);
-	wcn36xx_smd_delete_bss(wcn);
-	wcn36xx_smd_set_link_st(wcn, sta->addr, vif->addr, WCN36XX_HAL_LINK_IDLE_STATE);
-	return 0;
-}
-
 static const struct ieee80211_ops wcn36xx_ops = {
 	.start 			= wcn36xx_start,
 	.stop	 		= wcn36xx_stop,
@@ -352,8 +360,6 @@ static const struct ieee80211_ops wcn36xx_ops = {
 	.sw_scan_complete       = wcn36xx_sw_scan_complete,
 	.bss_info_changed 	= wcn36xx_bss_info_changed,
 	.set_rts_threshold	= wcn36xx_set_rts_threshold,
-	.sta_add 		= wcn36xx_sta_add,
-	.sta_remove	 	= wcn36xx_sta_remove,
 };
 
 static struct ieee80211_hw *wcn36xx_alloc_hw(void)
@@ -654,6 +660,7 @@ static int __init wcn36xx_init(void)
 
 	wcn->supported_rates.supported_mcs_set[0] = 0xFF;
 
+	wcn->aid = 0;
 	wcn->hw->wiphy->n_addresses = ARRAY_SIZE(wcn->addresses);
 	wcn->hw->wiphy->addresses = wcn->addresses;
 
diff --git a/smd.c b/smd.c
index b5fd0d5..f8e6458 100644
--- a/smd.c
+++ b/smd.c
@@ -441,7 +441,7 @@ static int wcn36xx_smd_config_sta_v1(struct wcn36xx *wcn,
 	return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
 }
 
-int wcn36xx_smd_config_sta(struct wcn36xx *wcn, u8 *bssid, u16 ass_id, u8 *sta_mac)
+int wcn36xx_smd_config_sta(struct wcn36xx *wcn, u8 *bssid, u8 *sta_mac)
 {
 	struct wcn36xx_hal_config_sta_req_msg msg_body;
 
@@ -449,7 +449,7 @@ int wcn36xx_smd_config_sta(struct wcn36xx *wcn, u8 *bssid, u16 ass_id, u8 *sta_m
 
 	memcpy(&msg_body.sta_params.bssid, bssid, ETH_ALEN);
 	memcpy(&msg_body.sta_params.mac, sta_mac, ETH_ALEN);
-	msg_body.sta_params.aid = 1;
+	msg_body.sta_params.aid = wcn->aid;
 	msg_body.sta_params.type = 0;
 	msg_body.sta_params.listen_interval = 0x8;
 	msg_body.sta_params.ht_capable = 1;
@@ -624,7 +624,6 @@ int wcn36xx_smd_config_bss(struct wcn36xx *wcn, enum nl80211_iftype type,
 	WARN_ON(is_zero_ether_addr(bssid));
 
 	memcpy(&bss->bssid, bssid, ETH_ALEN);
-	memcpy(&bss->bssid, &wcn->addresses[0], ETH_ALEN);
 
 	memcpy(&bss->self_mac_addr, &wcn->addresses[0], ETH_ALEN);
 
@@ -665,7 +664,7 @@ int wcn36xx_smd_config_bss(struct wcn36xx *wcn, enum nl80211_iftype type,
 	bss->reserved = 0;
 
 	memcpy(&sta->bssid, &wcn->addresses[0], ETH_ALEN);
-	sta->aid = 0;
+	sta->aid = wcn->aid;
 	sta->type = 1;
 	sta->short_preamble_supported = 1;
 	memcpy(&sta->mac, &wcn->addresses[0], ETH_ALEN);
diff --git a/smd.h b/smd.h
index 47a6645..8be34cd 100644
--- a/smd.h
+++ b/smd.h
@@ -63,7 +63,7 @@ int wcn36xx_smd_set_link_st(struct wcn36xx *wcn, u8 *bssid, u8 *sta_mac, enum wc
 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_config_sta(struct wcn36xx *wcn, u8 *bssid, u8 *sta_mac);
 int wcn36xx_smd_send_beacon(struct wcn36xx *wcn, struct sk_buff *skb_beacon, u16 tim_off, u16 p2p_off);
 int wcn36xx_smd_switch_channel_req(struct wcn36xx *wcn, int ch);
 int wcn36xx_smd_update_proberesp_tmpl(struct wcn36xx *wcn, struct sk_buff *skb);
diff --git a/wcn36xx.h b/wcn36xx.h
index 86d1f8c..4fb26b6 100644
--- a/wcn36xx.h
+++ b/wcn36xx.h
@@ -100,7 +100,7 @@ struct wcn36xx {
 	struct ieee80211_channel *current_channel;
 	struct wcn36xx_hal_mac_ssid ssid;
 	enum nl80211_iftype iftype;
-
+	u16 aid;
 	u8 fw_revision;
 	u8 fw_version;
 	u8 fw_minor;
-- 
1.7.11.3




More information about the wcn36xx mailing list