[PATCH 2/2] Move sta_index to wcn36xx_sta struct
Eugene Krasnikov
k.eugene.e at gmail.com
Fri Jul 26 13:31:31 EDT 2013
sta_index and dpu_desc_index belong to wcn36xx_sta so move it
to this structure. But bss_sta_index must be stored as well.
Depends on the mode sometimes bss_sta_index must be used and
sometimes sta_index.
Signed-off-by: Eugene Krasnikov <k.eugene.e at gmail.com>
---
main.c | 52 ++++++++++++++++++++++++++++++----------------------
smd.c | 45 +++++++++++++++++++++++++--------------------
smd.h | 15 +++++++++------
txrx.c | 23 +++++++++++++++++++++--
wcn36xx.h | 30 +++++++++++++++++++++++++++---
5 files changed, 112 insertions(+), 53 deletions(-)
diff --git a/main.c b/main.c
index b1a4fec..d21a37e 100644
--- a/main.c
+++ b/main.c
@@ -186,6 +186,13 @@ static const struct wiphy_wowlan_support wowlan_support = {
};
#endif
+static inline u8 get_sta_index(struct ieee80211_vif *vif,
+ struct wcn36xx_sta *sta_priv)
+{
+ return NL80211_IFTYPE_STATION == vif->type ?
+ sta_priv->bss_sta_index :
+ sta_priv->sta_index;
+}
static int wcn36xx_start(struct ieee80211_hw *hw)
{
struct wcn36xx *wcn = hw->priv;
@@ -400,7 +407,8 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
wcn->encrypt_type,
key_conf->keyidx,
key_conf->keylen,
- key);
+ key,
+ get_sta_index(vif, sta_priv));
} else {
wcn36xx_smd_set_bsskey(wcn,
wcn->encrypt_type,
@@ -419,8 +427,9 @@ static int wcn36xx_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
/* do not remove key if disassociated */
if (wcn->aid)
wcn36xx_smd_remove_stakey(wcn,
- wcn->encrypt_type,
- key_conf->keyidx);
+ wcn->encrypt_type,
+ key_conf->keyidx,
+ get_sta_index(vif, sta_priv));
}
break;
default:
@@ -544,6 +553,7 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
wcn->is_joining = false;
if (bss_conf->assoc) {
struct ieee80211_sta *sta;
+ struct wcn36xx_sta *sta_priv;
wcn36xx_dbg(WCN36XX_DBG_MAC,
"mac assoc bss %pM vif %pM AID=%d",
@@ -561,15 +571,17 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
rcu_read_unlock();
goto out;
}
+ sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
+
wcn36xx_update_allowed_rates(wcn, sta);
wcn36xx_smd_set_link_st(wcn, bss_conf->bssid,
vif->addr,
WCN36XX_HAL_LINK_POSTASSOC_STATE);
+ wcn->sta = sta_priv;
wcn36xx_smd_config_bss(wcn, vif, sta,
bss_conf->bssid,
true);
- wcn36xx_smd_config_sta(wcn, vif, sta);
rcu_read_unlock();
} else {
wcn36xx_dbg(WCN36XX_DBG_MAC,
@@ -578,7 +590,6 @@ static void wcn36xx_bss_info_changed(struct ieee80211_hw *hw,
vif->addr,
bss_conf->aid);
wcn->aid = 0;
- wcn36xx_smd_delete_sta(wcn);
wcn36xx_smd_set_link_st(wcn,
bss_conf->bssid,
vif->addr,
@@ -682,12 +693,9 @@ static int wcn36xx_sta_add(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta add vif %p sta %pM",
vif, sta->addr);
- if (vif->type == NL80211_IFTYPE_ADHOC ||
- vif->type == NL80211_IFTYPE_AP ||
- vif->type == NL80211_IFTYPE_MESH_POINT) {
- wcn->aid = sta->aid;
- wcn36xx_smd_config_sta(wcn, vif, sta);
- }
+ wcn->sta = (struct wcn36xx_sta *)sta->drv_priv;
+ wcn->aid = sta->aid;
+ wcn36xx_smd_config_sta(wcn, vif, sta);
return 0;
}
@@ -696,14 +704,12 @@ static int wcn36xx_sta_remove(struct ieee80211_hw *hw,
struct ieee80211_sta *sta)
{
struct wcn36xx *wcn = hw->priv;
+ struct wcn36xx_sta *sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
- wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM",
- vif, sta->addr);
+ wcn36xx_dbg(WCN36XX_DBG_MAC, "mac sta remove vif %p sta %pM index %d",
+ vif, sta->addr, sta_priv->sta_index);
- if (vif->type == NL80211_IFTYPE_ADHOC ||
- vif->type == NL80211_IFTYPE_AP ||
- vif->type == NL80211_IFTYPE_MESH_POINT)
- wcn36xx_smd_delete_sta(wcn);
+ wcn36xx_smd_delete_sta(wcn, sta_priv->sta_index);
return 0;
}
@@ -761,23 +767,25 @@ int wcn36xx_ampdu_action(struct ieee80211_hw *hw,
struct wcn36xx_sta *sta_priv = NULL;
wcn36xx_dbg(WCN36XX_DBG_MAC, "mac ampdu action action %d tid %d",
action, tid);
+ sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
switch (action) {
case IEEE80211_AMPDU_RX_START:
- sta_priv = (struct wcn36xx_sta *)sta->drv_priv;
sta_priv->tid = tid;
- wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 0);
+ wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 0,
+ get_sta_index(vif, sta_priv));
wcn36xx_smd_add_ba(wcn);
- wcn36xx_smd_trigger_ba(wcn);
+ wcn36xx_smd_trigger_ba(wcn, get_sta_index(vif, sta_priv));
ieee80211_start_tx_ba_session(sta, tid, 0);
break;
case IEEE80211_AMPDU_RX_STOP:
- wcn36xx_smd_del_ba(wcn, tid);
+ wcn36xx_smd_del_ba(wcn, tid, get_sta_index(vif, sta_priv));
break;
case IEEE80211_AMPDU_TX_START:
ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break;
case IEEE80211_AMPDU_TX_OPERATIONAL:
- wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 1);
+ wcn36xx_smd_add_ba_session(wcn, sta, tid, ssn, 1,
+ get_sta_index(vif, sta_priv));
break;
/* Not supported so far*/
case IEEE80211_AMPDU_TX_STOP_CONT:
diff --git a/smd.c b/smd.c
index 46b9a0c..4924e6c 100644
--- a/smd.c
+++ b/smd.c
@@ -514,13 +514,13 @@ int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr)
return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
}
-int wcn36xx_smd_delete_sta(struct wcn36xx *wcn)
+int wcn36xx_smd_delete_sta(struct wcn36xx *wcn, u8 sta_index)
{
struct wcn36xx_hal_delete_sta_req_msg msg_body;
INIT_HAL_MSG(msg_body, WCN36XX_HAL_DELETE_STA_REQ);
- msg_body.sta_index = 1;
+ msg_body.sta_index = sta_index;
PREPARE_HAL_BUF(wcn->smd_buf, msg_body);
@@ -661,9 +661,6 @@ static int wcn36xx_smd_config_sta_rsp(struct wcn36xx *wcn, void *buf,
{
struct wcn36xx_hal_config_sta_rsp_msg *rsp;
struct config_sta_rsp_params *params;
- struct ieee80211_vif *vif = container_of((void *)wcn->current_vif,
- struct ieee80211_vif,
- drv_priv);
if (len < sizeof(*rsp))
return -EINVAL;
@@ -677,9 +674,10 @@ static int wcn36xx_smd_config_sta_rsp(struct wcn36xx *wcn, void *buf,
return -EIO;
}
- if (vif->type == NL80211_IFTYPE_AP) {
- wcn->current_vif->sta_index = params->sta_index;
- wcn->current_vif->dpu_desc_index = params->dpu_index;
+ if (wcn->sta) {
+ wcn->sta->sta_index = params->sta_index;
+ wcn->sta->dpu_desc_index = params->dpu_index;
+ wcn->sta = NULL;
}
wcn36xx_dbg(WCN36XX_DBG_HAL,
"hal config sta rsp status %d sta_index %d bssid_index %d p2p %d",
@@ -940,8 +938,11 @@ static int wcn36xx_smd_config_bss_rsp(struct wcn36xx *wcn, void *buf, size_t len
params->tx_mgmt_power, params->ucast_dpu_signature);
wcn->current_vif->bss_index = params->bss_index;
- wcn->current_vif->sta_index = params->bss_sta_index;
- wcn->current_vif->dpu_desc_index = params->dpu_desc_index;
+ if (wcn->sta) {
+ wcn->sta->bss_sta_index = params->bss_sta_index;
+ wcn->sta->bss_dpu_desc_index = params->dpu_desc_index;
+ wcn->sta = NULL;
+ }
wcn->current_vif->ucast_dpu_signature = params->ucast_dpu_signature;
return 0;
}
@@ -1026,13 +1027,14 @@ int wcn36xx_smd_set_stakey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
u8 keyidx,
u8 keylen,
- u8 *key)
+ u8 *key,
+ u8 sta_index)
{
struct wcn36xx_hal_set_sta_key_req_msg msg_body;
INIT_HAL_MSG(msg_body, WCN36XX_HAL_SET_STAKEY_REQ);
- msg_body.set_sta_key_params.sta_index = wcn->current_vif->sta_index;
+ msg_body.set_sta_key_params.sta_index = sta_index;
msg_body.set_sta_key_params.enc_type = enc_type;
msg_body.set_sta_key_params.key[0].id = keyidx;
@@ -1074,12 +1076,14 @@ int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
- u8 keyidx)
+ u8 keyidx,
+ u8 sta_index)
{
struct wcn36xx_hal_remove_sta_key_req_msg msg_body;
INIT_HAL_MSG(msg_body, WCN36XX_HAL_RMV_STAKEY_REQ);
- msg_body.sta_idx = wcn->current_vif->sta_index;
+
+ msg_body.sta_idx = sta_index;
msg_body.enc_type = enc_type;
msg_body.key_id = keyidx;
@@ -1245,13 +1249,14 @@ int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
struct ieee80211_sta *sta,
u16 tid,
u16 *ssn,
- u8 direction)
+ u8 direction,
+ u8 sta_index)
{
struct wcn36xx_hal_add_ba_session_req_msg msg_body;
INIT_HAL_MSG(msg_body, WCN36XX_HAL_ADD_BA_SESSION_REQ);
- msg_body.sta_index = wcn->current_vif->sta_index;
+ msg_body.sta_index = sta_index;
memcpy(&msg_body.mac_addr, sta->addr, ETH_ALEN);
msg_body.dialog_token = 0x10;
msg_body.tid = tid;
@@ -1282,13 +1287,13 @@ int wcn36xx_smd_add_ba(struct wcn36xx *wcn)
return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
}
-int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid)
+int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid, u8 sta_index)
{
struct wcn36xx_hal_del_ba_req_msg msg_body;
INIT_HAL_MSG(msg_body, WCN36XX_HAL_DEL_BA_REQ);
- msg_body.sta_index = wcn->current_vif->sta_index;
+ msg_body.sta_index = sta_index;
msg_body.tid = tid;
msg_body.direction = 0;
PREPARE_HAL_BUF(wcn->smd_buf, msg_body);
@@ -1296,7 +1301,7 @@ int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid)
return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
}
-int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn)
+int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index)
{
struct wcn36xx_hal_trigger_ba_req_msg msg_body;
struct wcn36xx_hal_trigget_ba_req_candidate *candidate;
@@ -1310,7 +1315,7 @@ int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn)
candidate = (struct wcn36xx_hal_trigget_ba_req_candidate *)
(wcn->smd_buf + sizeof(msg_body));
- candidate->sta_index = wcn->current_vif->sta_index;
+ candidate->sta_index = sta_index;
candidate->tid_bitmap = 1;
return wcn36xx_smd_send_and_wait(wcn, msg_body.header.len);
}
diff --git a/smd.h b/smd.h
index 1faf08b..c80624c 100644
--- a/smd.h
+++ b/smd.h
@@ -57,7 +57,7 @@ int wcn36xx_smd_finish_scan(struct wcn36xx *wcn);
int wcn36xx_smd_update_scan_params(struct wcn36xx *wcn);
int wcn36xx_smd_add_sta_self(struct wcn36xx *wcn, u8 *addr, u32 status);
int wcn36xx_smd_delete_sta_self(struct wcn36xx *wcn, u8 *addr);
-int wcn36xx_smd_delete_sta(struct wcn36xx *wcn);
+int wcn36xx_smd_delete_sta(struct wcn36xx *wcn, u8 sta_index);
int wcn36xx_smd_join(struct wcn36xx *wcn, const u8 *bssid, u8 *vif, u8 ch);
int wcn36xx_smd_set_link_st(struct wcn36xx *wcn, const u8 *bssid,
const u8 *sta_mac,
@@ -76,7 +76,8 @@ int wcn36xx_smd_set_stakey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
u8 keyidx,
u8 keylen,
- u8 *key);
+ u8 *key,
+ u8 sta_index);
int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
u8 keyidx,
@@ -84,7 +85,8 @@ int wcn36xx_smd_set_bsskey(struct wcn36xx *wcn,
u8 *key);
int wcn36xx_smd_remove_stakey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
- u8 keyidx);
+ u8 keyidx,
+ u8 sta_index);
int wcn36xx_smd_remove_bsskey(struct wcn36xx *wcn,
enum ani_ed_type enc_type,
u8 keyidx);
@@ -99,10 +101,11 @@ int wcn36xx_smd_add_ba_session(struct wcn36xx *wcn,
struct ieee80211_sta *sta,
u16 tid,
u16 *ssn,
- u8 direction);
+ u8 direction,
+ u8 sta_index);
int wcn36xx_smd_add_ba(struct wcn36xx *wcn);
-int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid);
-int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn);
+int wcn36xx_smd_del_ba(struct wcn36xx *wcn, u16 tid, u8 sta_index);
+int wcn36xx_smd_trigger_ba(struct wcn36xx *wcn, u8 sta_index);
/* WCN36XX configuration parameters */
struct wcn36xx_fw_cfg {
u16 id;
diff --git a/txrx.c b/txrx.c
index fa3b996..754625f 100644
--- a/txrx.c
+++ b/txrx.c
@@ -96,10 +96,29 @@ static void wcn36xx_set_tx_data(struct wcn36xx_tx_bd *bd,
struct ieee80211_hdr *hdr,
bool bcast)
{
+ struct ieee80211_vif *vif = container_of((void *)wcn->current_vif,
+ struct ieee80211_vif,
+ drv_priv);
bd->bd_rate = WCN36XX_BD_RATE_DATA;
bd->dpu_sign = wcn->current_vif->ucast_dpu_signature;
- bd->sta_index = wcn->current_vif->sta_index;
- bd->dpu_desc_idx = wcn->current_vif->dpu_desc_index;
+ /*
+ * For not unicast frames mac80211 will not set sta pointer so use
+ * self_sta_index instead.
+ */
+ if (sta_priv) {
+ if (vif->type == NL80211_IFTYPE_STATION) {
+ bd->sta_index = sta_priv->bss_sta_index;
+ bd->dpu_desc_idx = sta_priv->bss_dpu_desc_index;
+ } else if (vif->type == NL80211_IFTYPE_AP ||
+ vif->type == NL80211_IFTYPE_ADHOC ||
+ vif->type == NL80211_IFTYPE_MESH_POINT) {
+ bd->sta_index = sta_priv->sta_index;
+ bd->dpu_desc_idx = sta_priv->dpu_desc_index;
+ }
+ } else {
+ bd->sta_index = wcn->current_vif->self_sta_index;
+ bd->dpu_desc_idx = wcn->current_vif->self_dpu_desc_index;
+ }
if (ieee80211_is_nullfunc(hdr->frame_control) ||
(sta_priv && !sta_priv->is_data_encrypted))
bd->dpu_ne = 1;
diff --git a/wcn36xx.h b/wcn36xx.h
index 389a9a4..88a0b02 100644
--- a/wcn36xx.h
+++ b/wcn36xx.h
@@ -106,17 +106,40 @@ struct nv_data {
*/
struct wcn36xx_vif {
u8 bss_index;
- u8 sta_index;
- u8 dpu_desc_index;
u8 ucast_dpu_signature;
/* Returned from WCN36XX_HAL_ADD_STA_SELF_RSP */
u8 self_sta_index;
u8 self_dpu_desc_index;
};
+/**
+ * struct wcn36xx_sta - holds STA related fields
+ *
+ * @tid: traffic ID that is used during AMPDU and in TX BD.
+ * @sta_index: STA index is returned from HW after config_sta call and is
+ * used in both SMD channel and TX BD.
+ * @dpu_desc_index: DPU descriptor index is returned from HW after config_sta
+ * call and is used in TX BD.
+ * @bss_sta_index: STA index is returned from HW after config_bss call and is
+ * used in both SMD channel and TX BD. See table bellow when it is used.
+ * @bss_dpu_desc_index: DPU descriptor index is returned from HW after
+ * config_bss call and is used in TX BD.
+ * ______________________________________________
+ * | | STA | AP |
+ * |______________|_____________|_______________|
+ * | TX BD |bss_sta_index| sta_index |
+ * |______________|_____________|_______________|
+ * |all SMD calls |bss_sta_index| sta_index |
+ * |______________|_____________|_______________|
+ * |smd_delete_sta| sta_index | sta_index |
+ * |______________|_____________|_______________|
+ */
struct wcn36xx_sta {
u16 tid;
- u8 sta_id;
+ u8 sta_index;
+ u8 dpu_desc_index;
+ u8 bss_sta_index;
+ u8 bss_dpu_desc_index;
bool is_data_encrypted;
};
struct wcn36xx_dxe_ch;
@@ -128,6 +151,7 @@ struct wcn36xx {
struct wcn36xx_hal_mac_ssid ssid;
u16 aid;
struct wcn36xx_vif *current_vif;
+ struct wcn36xx_sta *sta;
u8 dtim_period;
enum ani_ed_type encrypt_type;
--
1.8.2.2
More information about the wcn36xx
mailing list