Skip to content

Commit a8b5d48

Browse files
ilanpeer2jmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: Configure the link mapping for non-MLD FW
In the non MLD firmware flows, although the deflink is used, the mapping of link ID to BSS configuration was missing, which causes flows that need this mapping to crash. Fix this by adding the link ID to BSS configuration mapping to non MLD flows as well. Signed-off-by: Ilan Peer <ilan.peer@intel.com> Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com> Link: https://msgid.link/20240311081938.0b5c361e8f0c.Ib11f41815d2efa5d1ec57f855de4c8563142987b@changeid Signed-off-by: Johannes Berg <johannes.berg@intel.com>
1 parent 847d735 commit a8b5d48

3 files changed

Lines changed: 56 additions & 14 deletions

File tree

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

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,27 @@ static int iwl_mvm_link_cmd_send(struct iwl_mvm *mvm,
4646
return ret;
4747
}
4848

49+
int iwl_mvm_set_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
50+
struct ieee80211_bss_conf *link_conf)
51+
{
52+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
53+
struct iwl_mvm_vif_link_info *link_info =
54+
mvmvif->link[link_conf->link_id];
55+
56+
if (link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID) {
57+
link_info->fw_link_id = iwl_mvm_get_free_fw_link_id(mvm,
58+
mvmvif);
59+
if (link_info->fw_link_id >=
60+
ARRAY_SIZE(mvm->link_id_to_link_conf))
61+
return -EINVAL;
62+
63+
rcu_assign_pointer(mvm->link_id_to_link_conf[link_info->fw_link_id],
64+
link_conf);
65+
}
66+
67+
return 0;
68+
}
69+
4970
int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
5071
struct ieee80211_bss_conf *link_conf)
5172
{
@@ -55,19 +76,14 @@ int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
5576
struct iwl_link_config_cmd cmd = {};
5677
unsigned int cmd_id = WIDE_ID(MAC_CONF_GROUP, LINK_CONFIG_CMD);
5778
u8 cmd_ver = iwl_fw_lookup_cmd_ver(mvm->fw, cmd_id, 1);
79+
int ret;
5880

5981
if (WARN_ON_ONCE(!link_info))
6082
return -EINVAL;
6183

62-
if (link_info->fw_link_id == IWL_MVM_FW_LINK_ID_INVALID) {
63-
link_info->fw_link_id = iwl_mvm_get_free_fw_link_id(mvm,
64-
mvmvif);
65-
if (link_info->fw_link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf))
66-
return -EINVAL;
67-
68-
rcu_assign_pointer(mvm->link_id_to_link_conf[link_info->fw_link_id],
69-
link_conf);
70-
}
84+
ret = iwl_mvm_set_link_mapping(mvm, vif, link_conf);
85+
if (ret)
86+
return ret;
7187

7288
/* Update SF - Disable if needed. if this fails, SF might still be on
7389
* while many macs are bound, which is forbidden - so fail the binding.
@@ -248,6 +264,24 @@ int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
248264
return ret;
249265
}
250266

267+
int iwl_mvm_unset_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
268+
struct ieee80211_bss_conf *link_conf)
269+
{
270+
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
271+
struct iwl_mvm_vif_link_info *link_info =
272+
mvmvif->link[link_conf->link_id];
273+
274+
/* mac80211 thought we have the link, but it was never configured */
275+
if (WARN_ON(!link_info ||
276+
link_info->fw_link_id >=
277+
ARRAY_SIZE(mvm->link_id_to_link_conf)))
278+
return -EINVAL;
279+
280+
RCU_INIT_POINTER(mvm->link_id_to_link_conf[link_info->fw_link_id],
281+
NULL);
282+
return 0;
283+
}
284+
251285
int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
252286
struct ieee80211_bss_conf *link_conf)
253287
{
@@ -257,13 +291,10 @@ int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
257291
struct iwl_link_config_cmd cmd = {};
258292
int ret;
259293

260-
/* mac80211 thought we have the link, but it was never configured */
261-
if (WARN_ON(!link_info ||
262-
link_info->fw_link_id >= ARRAY_SIZE(mvm->link_id_to_link_conf)))
294+
ret = iwl_mvm_unset_link_mapping(mvm, vif, link_conf);
295+
if (ret)
263296
return 0;
264297

265-
RCU_INIT_POINTER(mvm->link_id_to_link_conf[link_info->fw_link_id],
266-
NULL);
267298
cmd.link_id = cpu_to_le32(link_info->fw_link_id);
268299
iwl_mvm_release_fw_link_id(mvm, link_info->fw_link_id);
269300
link_info->fw_link_id = IWL_MVM_FW_LINK_ID_INVALID;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,8 +1577,14 @@ static int iwl_mvm_mac_add_interface(struct ieee80211_hw *hw,
15771577
mvmvif->mvm = mvm;
15781578

15791579
/* the first link always points to the default one */
1580+
mvmvif->deflink.fw_link_id = IWL_MVM_FW_LINK_ID_INVALID;
1581+
mvmvif->deflink.active = 0;
15801582
mvmvif->link[0] = &mvmvif->deflink;
15811583

1584+
ret = iwl_mvm_set_link_mapping(mvm, vif, &vif->bss_conf);
1585+
if (ret)
1586+
goto out;
1587+
15821588
/*
15831589
* Not much to do here. The stack will not allow interface
15841590
* types or combinations that we didn't advertise, so we
@@ -1783,6 +1789,7 @@ static void iwl_mvm_mac_remove_interface(struct ieee80211_hw *hw,
17831789
mvm->p2p_device_vif = NULL;
17841790
}
17851791

1792+
iwl_mvm_unset_link_mapping(mvm, vif, &vif->bss_conf);
17861793
iwl_mvm_mac_ctxt_remove(mvm, vif);
17871794

17881795
RCU_INIT_POINTER(mvm->vif_id_to_mac[mvmvif->id], NULL);

drivers/net/wireless/intel/iwlwifi/mvm/mvm.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1918,11 +1918,15 @@ int iwl_mvm_binding_remove_vif(struct iwl_mvm *mvm, struct ieee80211_vif *vif);
19181918
u32 iwl_mvm_get_lmac_id(struct iwl_mvm *mvm, enum nl80211_band band);
19191919

19201920
/* Links */
1921+
int iwl_mvm_set_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1922+
struct ieee80211_bss_conf *link_conf);
19211923
int iwl_mvm_add_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
19221924
struct ieee80211_bss_conf *link_conf);
19231925
int iwl_mvm_link_changed(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
19241926
struct ieee80211_bss_conf *link_conf,
19251927
u32 changes, bool active);
1928+
int iwl_mvm_unset_link_mapping(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
1929+
struct ieee80211_bss_conf *link_conf);
19261930
int iwl_mvm_remove_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
19271931
struct ieee80211_bss_conf *link_conf);
19281932
int iwl_mvm_disable_link(struct iwl_mvm *mvm, struct ieee80211_vif *vif,

0 commit comments

Comments
 (0)