Skip to content

Commit 34cc3a4

Browse files
egrumbachjmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: fix the PHY context resolution for p2p device
We seem to have an issue in case we had a BSS and a P2P device on channel 1 and then, the P2P device gets an ROC on channel 6. We would change the channel of the PHY context to channel 6 even if the BSS was using that same PHY context. Revamp that code and don't try to change a PHY context, it doesn't mean much for the firmware anyway. Just remove it and allocate a new one. This makes the logic easier to follow. Signed-off-by: Emmanuel Grumbach <[email protected]> Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20231011130030.4bc8b90d7be0.I1232dca3fe007362ec0ae0cf1d96217f2544e0d2@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent a32a849 commit 34cc3a4

File tree

1 file changed

+49
-52
lines changed

1 file changed

+49
-52
lines changed

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

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4634,18 +4634,61 @@ static int iwl_mvm_roc_station(struct iwl_mvm *mvm,
46344634
return ret;
46354635
}
46364636

4637+
static int iwl_mvm_p2p_find_phy_ctxt(struct iwl_mvm *mvm,
4638+
struct ieee80211_vif *vif,
4639+
struct ieee80211_channel *channel)
4640+
{
4641+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
4642+
struct cfg80211_chan_def chandef;
4643+
int i;
4644+
4645+
lockdep_assert_held(&mvm->mutex);
4646+
4647+
if (mvmvif->deflink.phy_ctxt &&
4648+
channel == mvmvif->deflink.phy_ctxt->channel)
4649+
return 0;
4650+
4651+
/* Try using a PHY context that is already in use */
4652+
for (i = 0; i < NUM_PHY_CTX; i++) {
4653+
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[i];
4654+
4655+
if (!phy_ctxt->ref || mvmvif->deflink.phy_ctxt == phy_ctxt)
4656+
continue;
4657+
4658+
if (channel == phy_ctxt->channel) {
4659+
if (mvmvif->deflink.phy_ctxt)
4660+
iwl_mvm_phy_ctxt_unref(mvm,
4661+
mvmvif->deflink.phy_ctxt);
4662+
4663+
mvmvif->deflink.phy_ctxt = phy_ctxt;
4664+
iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
4665+
return 0;
4666+
}
4667+
}
4668+
4669+
/* We already have a phy_ctxt, but it's not on the right channel */
4670+
if (mvmvif->deflink.phy_ctxt)
4671+
iwl_mvm_phy_ctxt_unref(mvm, mvmvif->deflink.phy_ctxt);
4672+
4673+
mvmvif->deflink.phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
4674+
if (!mvmvif->deflink.phy_ctxt)
4675+
return -ENOSPC;
4676+
4677+
cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
4678+
4679+
return iwl_mvm_phy_ctxt_add(mvm, mvmvif->deflink.phy_ctxt,
4680+
&chandef, 1, 1);
4681+
}
4682+
46374683
/* Execute the common part for MLD and non-MLD modes */
46384684
int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
46394685
struct ieee80211_channel *channel, int duration,
46404686
enum ieee80211_roc_type type,
46414687
const struct iwl_mvm_roc_ops *ops)
46424688
{
46434689
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
4644-
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
4645-
struct cfg80211_chan_def chandef;
4646-
struct iwl_mvm_phy_ctxt *phy_ctxt;
4647-
int ret, i;
46484690
u32 lmac_id;
4691+
int ret;
46494692

46504693
IWL_DEBUG_MAC80211(mvm, "enter (%d, %d, %d)\n", channel->hw_value,
46514694
duration, type);
@@ -4676,57 +4719,11 @@ int iwl_mvm_roc_common(struct ieee80211_hw *hw, struct ieee80211_vif *vif,
46764719
goto out_unlock;
46774720
}
46784721

4679-
/* Try using a PHY context that is already in use */
4680-
for (i = 0; i < NUM_PHY_CTX; i++) {
4681-
phy_ctxt = &mvm->phy_ctxts[i];
4682-
if (!phy_ctxt->ref || mvmvif->deflink.phy_ctxt == phy_ctxt)
4683-
continue;
4684-
4685-
if (channel == phy_ctxt->channel) {
4686-
if (mvmvif->deflink.phy_ctxt)
4687-
iwl_mvm_phy_ctxt_unref(mvm,
4688-
mvmvif->deflink.phy_ctxt);
4689-
4690-
mvmvif->deflink.phy_ctxt = phy_ctxt;
4691-
iwl_mvm_phy_ctxt_ref(mvm, mvmvif->deflink.phy_ctxt);
4692-
goto link_and_start_p2p_roc;
4693-
}
4694-
}
46954722

4696-
/* Configure the PHY context */
4697-
cfg80211_chandef_create(&chandef, channel, NL80211_CHAN_NO_HT);
4698-
4699-
/* If the currently used PHY context is configured with a matching
4700-
* channel use it
4701-
*/
4702-
if (mvmvif->deflink.phy_ctxt) {
4703-
if (channel == mvmvif->deflink.phy_ctxt->channel)
4704-
goto link_and_start_p2p_roc;
4705-
} else {
4706-
phy_ctxt = iwl_mvm_get_free_phy_ctxt(mvm);
4707-
if (!phy_ctxt) {
4708-
ret = -ENOSPC;
4709-
goto out_unlock;
4710-
}
4711-
4712-
mvmvif->deflink.phy_ctxt = phy_ctxt;
4713-
ret = iwl_mvm_phy_ctxt_add(mvm, phy_ctxt, &chandef, 1, 1);
4714-
if (ret) {
4715-
IWL_ERR(mvm, "Failed to change PHY context\n");
4716-
goto out_unlock;
4717-
}
4718-
4719-
goto link_and_start_p2p_roc;
4720-
}
4721-
4722-
ret = iwl_mvm_phy_ctxt_changed(mvm, phy_ctxt, &chandef,
4723-
1, 1);
4724-
if (ret) {
4725-
IWL_ERR(mvm, "Failed to change PHY context\n");
4723+
ret = iwl_mvm_p2p_find_phy_ctxt(mvm, vif, channel);
4724+
if (ret)
47264725
goto out_unlock;
4727-
}
47284726

4729-
link_and_start_p2p_roc:
47304727
ret = ops->link(mvm, vif);
47314728
if (ret)
47324729
goto out_unlock;

0 commit comments

Comments
 (0)