Commit f327b04c authored by Emmanuel Grumbach's avatar Emmanuel Grumbach

iwlwifi: mvm: provide helper to fetch the iwl_mvm_sta from sta_id

We somtimes need to fetch the iwl_mvm_sta structure from a
station index - provide a helper to do that.
Reviewed-by: default avatarJohannes Berg <johannes.berg@intel.com>
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
parent 33b2f684
...@@ -500,23 +500,13 @@ static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id, ...@@ -500,23 +500,13 @@ static int iwl_mvm_bt_coex_reduced_txp(struct iwl_mvm *mvm, u8 sta_id,
.dataflags = { IWL_HCMD_DFL_DUP, }, .dataflags = { IWL_HCMD_DFL_DUP, },
.flags = CMD_ASYNC, .flags = CMD_ASYNC,
}; };
struct ieee80211_sta *sta;
struct iwl_mvm_sta *mvmsta; struct iwl_mvm_sta *mvmsta;
int ret; int ret;
if (sta_id == IWL_MVM_STATION_COUNT) mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
return 0; if (!mvmsta)
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
lockdep_is_held(&mvm->mutex));
/* This can happen if the station has been removed right now */
if (IS_ERR_OR_NULL(sta))
return 0; return 0;
mvmsta = iwl_mvm_sta_from_mac80211(sta);
/* nothing to do */ /* nothing to do */
if (mvmsta->bt_reduced_txpower == enable) if (mvmsta->bt_reduced_txpower == enable)
return 0; return 0;
......
...@@ -90,7 +90,7 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf, ...@@ -90,7 +90,7 @@ static ssize_t iwl_dbgfs_tx_flush_write(struct iwl_mvm *mvm, char *buf,
static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
size_t count, loff_t *ppos) size_t count, loff_t *ppos)
{ {
struct ieee80211_sta *sta; struct iwl_mvm_sta *mvmsta;
int sta_id, drain, ret; int sta_id, drain, ret;
if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR) if (!mvm->ucode_loaded || mvm->cur_ucode != IWL_UCODE_REGULAR)
...@@ -105,13 +105,12 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf, ...@@ -105,13 +105,12 @@ static ssize_t iwl_dbgfs_sta_drain_write(struct iwl_mvm *mvm, char *buf,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id], mvmsta = iwl_mvm_sta_from_staid_protected(mvm, sta_id);
lockdep_is_held(&mvm->mutex));
if (IS_ERR_OR_NULL(sta)) if (!mvmsta)
ret = -ENOENT; ret = -ENOENT;
else else
ret = iwl_mvm_drain_sta(mvm, (void *)sta->drv_priv, drain) ? : ret = iwl_mvm_drain_sta(mvm, mvmsta, drain) ? : count;
count;
mutex_unlock(&mvm->mutex); mutex_unlock(&mvm->mutex);
......
...@@ -595,6 +595,24 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm) ...@@ -595,6 +595,24 @@ static inline bool iwl_mvm_is_radio_killed(struct iwl_mvm *mvm)
test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status); test_bit(IWL_MVM_STATUS_HW_CTKILL, &mvm->status);
} }
static inline struct iwl_mvm_sta *
iwl_mvm_sta_from_staid_protected(struct iwl_mvm *mvm, u8 sta_id)
{
struct ieee80211_sta *sta;
if (sta_id >= ARRAY_SIZE(mvm->fw_id_to_mac_id))
return NULL;
sta = rcu_dereference_protected(mvm->fw_id_to_mac_id[sta_id],
lockdep_is_held(&mvm->mutex));
/* This can happen if the station has been removed right now */
if (IS_ERR_OR_NULL(sta))
return NULL;
return iwl_mvm_sta_from_mac80211(sta);
}
extern const u8 iwl_mvm_ac_to_tx_fifo[]; extern const u8 iwl_mvm_ac_to_tx_fifo[];
struct iwl_rate_info { struct iwl_rate_info {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment