Skip to content

Commit 13303c0

Browse files
sara-slucacoelho
authored andcommitted
iwlwifi: mvm: use helpers to get iwl_mvm_sta
Getting the mvm station out of station id requires dereferencing the station id to get ieee80211_sta, then checking for pointer validity and only then extract mvm station out. Given that there are helpers to do it - use them instead of duplicating the code whenever we need only mvm station. Signed-off-by: Sara Sharon <[email protected]> Signed-off-by: Luca Coelho <[email protected]>
1 parent ce1f277 commit 13303c0

File tree

6 files changed

+14
-31
lines changed

6 files changed

+14
-31
lines changed

drivers/net/wireless/intel/iwlwifi/mvm/d3.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,6 @@ static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
18041804
struct iwl_wowlan_status *fw_status;
18051805
int i;
18061806
bool keep;
1807-
struct ieee80211_sta *ap_sta;
18081807
struct iwl_mvm_sta *mvm_ap_sta;
18091808

18101809
fw_status = iwl_mvm_get_wakeup_status(mvm, vif);
@@ -1823,13 +1822,10 @@ static bool iwl_mvm_query_wakeup_reasons(struct iwl_mvm *mvm,
18231822
status.wake_packet = fw_status->wake_packet;
18241823

18251824
/* still at hard-coded place 0 for D3 image */
1826-
ap_sta = rcu_dereference_protected(
1827-
mvm->fw_id_to_mac_id[0],
1828-
lockdep_is_held(&mvm->mutex));
1829-
if (IS_ERR_OR_NULL(ap_sta))
1825+
mvm_ap_sta = iwl_mvm_sta_from_staid_protected(mvm, 0);
1826+
if (!mvm_ap_sta)
18301827
goto out_free;
18311828

1832-
mvm_ap_sta = iwl_mvm_sta_from_mac80211(ap_sta);
18331829
for (i = 0; i < IWL_MAX_TID_COUNT; i++) {
18341830
u16 seq = status.qos_seq_ctr[i];
18351831
/* firmware stores last-used value, we store next value */

drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -281,13 +281,10 @@ static ssize_t iwl_dbgfs_mac_params_read(struct file *file,
281281

282282
if (vif->type == NL80211_IFTYPE_STATION &&
283283
ap_sta_id != IWL_MVM_STATION_COUNT) {
284-
struct ieee80211_sta *sta;
285-
286-
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[ap_sta_id],
287-
lockdep_is_held(&mvm->mutex));
288-
if (!IS_ERR_OR_NULL(sta)) {
289-
struct iwl_mvm_sta *mvm_sta = iwl_mvm_sta_from_mac80211(sta);
284+
struct iwl_mvm_sta *mvm_sta;
290285

286+
mvm_sta = iwl_mvm_sta_from_staid_protected(mvm, ap_sta_id);
287+
if (mvm_sta) {
291288
pos += scnprintf(buf+pos, bufsz-pos,
292289
"ap_sta_id %d - reduced Tx power %d\n",
293290
ap_sta_id,

drivers/net/wireless/intel/iwlwifi/mvm/ops.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,6 @@ static bool iwl_mvm_disallow_offloading(struct iwl_mvm *mvm,
12101210
struct iwl_d0i3_iter_data *iter_data)
12111211
{
12121212
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1213-
struct ieee80211_sta *ap_sta;
12141213
struct iwl_mvm_sta *mvmsta;
12151214
u32 available_tids = 0;
12161215
u8 tid;
@@ -1219,11 +1218,10 @@ static bool iwl_mvm_disallow_offloading(struct iwl_mvm *mvm,
12191218
mvmvif->ap_sta_id == IWL_MVM_STATION_COUNT))
12201219
return false;
12211220

1222-
ap_sta = rcu_dereference(mvm->fw_id_to_mac_id[mvmvif->ap_sta_id]);
1223-
if (IS_ERR_OR_NULL(ap_sta))
1221+
mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, mvmvif->ap_sta_id);
1222+
if (!mvmsta)
12241223
return false;
12251224

1226-
mvmsta = iwl_mvm_sta_from_mac80211(ap_sta);
12271225
spin_lock_bh(&mvmsta->lock);
12281226
for (tid = 0; tid < IWL_MAX_TID_COUNT; tid++) {
12291227
struct iwl_mvm_tid_data *tid_data = &mvmsta->tid_data[tid];

drivers/net/wireless/intel/iwlwifi/mvm/sta.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,17 +1756,12 @@ static struct iwl_mvm_sta *iwl_mvm_get_key_sta(struct iwl_mvm *mvm,
17561756
mvmvif->ap_sta_id != IWL_MVM_STATION_COUNT) {
17571757
u8 sta_id = mvmvif->ap_sta_id;
17581758

1759-
sta = rcu_dereference_check(mvm->fw_id_to_mac_id[sta_id],
1760-
lockdep_is_held(&mvm->mutex));
17611759
/*
17621760
* It is possible that the 'sta' parameter is NULL,
17631761
* for example when a GTK is removed - the sta_id will then
17641762
* be the AP ID, and no station was passed by mac80211.
17651763
*/
1766-
if (IS_ERR_OR_NULL(sta))
1767-
return NULL;
1768-
1769-
return iwl_mvm_sta_from_mac80211(sta);
1764+
return iwl_mvm_sta_from_staid_protected(mvm, sta_id);
17701765
}
17711766

17721767
return NULL;

drivers/net/wireless/intel/iwlwifi/mvm/tt.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -359,16 +359,14 @@ static void iwl_mvm_tt_smps_iterator(void *_data, u8 *mac,
359359

360360
static void iwl_mvm_tt_tx_protection(struct iwl_mvm *mvm, bool enable)
361361
{
362-
struct ieee80211_sta *sta;
363362
struct iwl_mvm_sta *mvmsta;
364363
int i, err;
365364

366365
for (i = 0; i < IWL_MVM_STATION_COUNT; i++) {
367-
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[i],
368-
lockdep_is_held(&mvm->mutex));
369-
if (IS_ERR_OR_NULL(sta))
366+
mvmsta = iwl_mvm_sta_from_staid_protected(mvm, i);
367+
if (!mvmsta)
370368
continue;
371-
mvmsta = iwl_mvm_sta_from_mac80211(sta);
369+
372370
if (enable == mvmsta->tt_tx_protection)
373371
continue;
374372
err = iwl_mvm_tx_protection(mvm, mvmsta, enable);

drivers/net/wireless/intel/iwlwifi/mvm/tx.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,7 +1464,7 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
14641464
int sta_id = IWL_MVM_TX_RES_GET_RA(tx_resp->ra_tid);
14651465
int tid = IWL_MVM_TX_RES_GET_TID(tx_resp->ra_tid);
14661466
u16 sequence = le16_to_cpu(pkt->hdr.sequence);
1467-
struct ieee80211_sta *sta;
1467+
struct iwl_mvm_sta *mvmsta;
14681468

14691469
if (WARN_ON_ONCE(SEQ_TO_QUEUE(sequence) < mvm->first_agg_queue))
14701470
return;
@@ -1476,10 +1476,9 @@ static void iwl_mvm_rx_tx_cmd_agg(struct iwl_mvm *mvm,
14761476

14771477
rcu_read_lock();
14781478

1479-
sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
1479+
mvmsta = iwl_mvm_sta_from_staid_rcu(mvm, sta_id);
14801480

1481-
if (!WARN_ON_ONCE(IS_ERR_OR_NULL(sta))) {
1482-
struct iwl_mvm_sta *mvmsta = iwl_mvm_sta_from_mac80211(sta);
1481+
if (!WARN_ON_ONCE(!mvmsta)) {
14831482
mvmsta->tid_data[tid].rate_n_flags =
14841483
le32_to_cpu(tx_resp->initial_rate);
14851484
mvmsta->tid_data[tid].tx_time =

0 commit comments

Comments
 (0)