Commit 7f549e2c authored by Luciano Coelho's avatar Luciano Coelho Committed by Emmanuel Grumbach

iwlwifi: mvm: change the iwl_mvm_d3_iface_iterator into a generic function

Getting the BSS station vif is something that may be needed by other
parts of the code.  So, instead of having an iterator specifically for
d3, change it into a generic one in utils.c.  Additionally, add a
iwl_mvm_get_bss_vif() function to make it easier to retrieving it.
Signed-off-by: default avatarLuciano Coelho <luciano.coelho@intel.com>
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
parent 3c2f3b20
...@@ -601,29 +601,6 @@ static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm, ...@@ -601,29 +601,6 @@ static int iwl_mvm_send_remote_wake_cfg(struct iwl_mvm *mvm,
return ret; return ret;
} }
struct iwl_d3_iter_data {
struct iwl_mvm *mvm;
struct ieee80211_vif *vif;
bool error;
};
static void iwl_mvm_d3_iface_iterator(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
struct iwl_d3_iter_data *data = _data;
if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
return;
if (data->vif) {
IWL_ERR(data->mvm, "More than one managed interface active!\n");
data->error = true;
return;
}
data->vif = vif;
}
static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif, static int iwl_mvm_d3_reprogram(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
struct ieee80211_sta *ap_sta) struct ieee80211_sta *ap_sta)
{ {
...@@ -990,9 +967,6 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw, ...@@ -990,9 +967,6 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
bool test) bool test)
{ {
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw); struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
struct iwl_d3_iter_data suspend_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif = NULL; struct ieee80211_vif *vif = NULL;
struct iwl_mvm_vif *mvmvif = NULL; struct iwl_mvm_vif *mvmvif = NULL;
struct ieee80211_sta *ap_sta = NULL; struct ieee80211_sta *ap_sta = NULL;
...@@ -1025,17 +999,12 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw, ...@@ -1025,17 +999,12 @@ static int __iwl_mvm_suspend(struct ieee80211_hw *hw,
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
/* see if there's only a single BSS vif */ vif = iwl_mvm_get_bss_vif(mvm);
ieee80211_iterate_active_interfaces_atomic( if (IS_ERR_OR_NULL(vif)) {
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_d3_iface_iterator, &suspend_iter_data);
if (suspend_iter_data.error || !suspend_iter_data.vif) {
ret = 1; ret = 1;
goto out_noreset; goto out_noreset;
} }
vif = suspend_iter_data.vif;
mvmvif = iwl_mvm_vif_from_mac80211(vif); mvmvif = iwl_mvm_vif_from_mac80211(vif);
/* if we're associated, this is wowlan */ /* if we're associated, this is wowlan */
...@@ -1639,9 +1608,6 @@ static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac, ...@@ -1639,9 +1608,6 @@ static void iwl_mvm_d3_disconnect_iter(void *data, u8 *mac,
static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
{ {
struct iwl_d3_iter_data resume_iter_data = {
.mvm = mvm,
};
struct ieee80211_vif *vif = NULL; struct ieee80211_vif *vif = NULL;
int ret; int ret;
enum iwl_d3_status d3_status; enum iwl_d3_status d3_status;
...@@ -1650,15 +1616,10 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) ...@@ -1650,15 +1616,10 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test)
mutex_lock(&mvm->mutex); mutex_lock(&mvm->mutex);
/* get the BSS vif pointer again */ /* get the BSS vif pointer again */
ieee80211_iterate_active_interfaces_atomic( vif = iwl_mvm_get_bss_vif(mvm);
mvm->hw, IEEE80211_IFACE_ITER_NORMAL, if (IS_ERR_OR_NULL(vif))
iwl_mvm_d3_iface_iterator, &resume_iter_data);
if (WARN_ON(resume_iter_data.error || !resume_iter_data.vif))
goto out_unlock; goto out_unlock;
vif = resume_iter_data.vif;
ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test); ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test);
if (ret) if (ret)
goto out_unlock; goto out_unlock;
......
...@@ -1214,6 +1214,8 @@ void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif, ...@@ -1214,6 +1214,8 @@ void iwl_mvm_recalc_tdls_state(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw, void iwl_mvm_mac_mgd_protect_tdls_discover(struct ieee80211_hw *hw,
struct ieee80211_vif *vif); struct ieee80211_vif *vif);
struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm);
void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error); void iwl_mvm_nic_restart(struct iwl_mvm *mvm, bool fw_error);
#ifdef CONFIG_IWLWIFI_DEBUGFS #ifdef CONFIG_IWLWIFI_DEBUGFS
void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm); void iwl_mvm_fw_error_dump(struct iwl_mvm *mvm);
......
...@@ -734,3 +734,40 @@ bool iwl_mvm_is_idle(struct iwl_mvm *mvm) ...@@ -734,3 +734,40 @@ bool iwl_mvm_is_idle(struct iwl_mvm *mvm)
return idle; return idle;
} }
struct iwl_bss_iter_data {
struct ieee80211_vif *vif;
bool error;
};
static void iwl_mvm_bss_iface_iterator(void *_data, u8 *mac,
struct ieee80211_vif *vif)
{
struct iwl_bss_iter_data *data = _data;
if (vif->type != NL80211_IFTYPE_STATION || vif->p2p)
return;
if (data->vif) {
data->error = true;
return;
}
data->vif = vif;
}
struct ieee80211_vif *iwl_mvm_get_bss_vif(struct iwl_mvm *mvm)
{
struct iwl_bss_iter_data bss_iter_data = {};
ieee80211_iterate_active_interfaces_atomic(
mvm->hw, IEEE80211_IFACE_ITER_NORMAL,
iwl_mvm_bss_iface_iterator, &bss_iter_data);
if (bss_iter_data.error) {
IWL_ERR(mvm, "More than one managed interface active!\n");
return ERR_PTR(-EINVAL);
}
return bss_iter_data.vif;
}
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