Skip to content

Commit 4263ac7

Browse files
ggreenmajmberg-intel
authored andcommitted
wifi: iwlwifi: mvm: adjust to MLO assign/unassign/switch_vif_chanctx()
Pass link_conf when it's necessary and change the code accordingly. Signed-off-by: Gregory Greenman <[email protected]> Link: https://lore.kernel.org/r/20230328104949.dc1074239c5b.I30db722af9009f1b274fa929f276fd2b78520dea@changeid Signed-off-by: Johannes Berg <[email protected]>
1 parent d6f6b0d commit 4263ac7

File tree

3 files changed

+61
-47
lines changed

3 files changed

+61
-47
lines changed

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

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4608,10 +4608,11 @@ void iwl_mvm_change_chanctx(struct ieee80211_hw *hw,
46084608
* Returns true if we're done assigning the chanctx
46094609
* (either on failure or success)
46104610
*/
4611-
bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
4612-
struct ieee80211_vif *vif,
4613-
struct ieee80211_chanctx_conf *ctx,
4614-
bool switching_chanctx, int *ret)
4611+
static bool
4612+
__iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
4613+
struct ieee80211_vif *vif,
4614+
struct ieee80211_chanctx_conf *ctx,
4615+
bool switching_chanctx, int *ret)
46154616
{
46164617
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
46174618
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
@@ -4651,12 +4652,16 @@ bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
46514652

46524653
static int __iwl_mvm_assign_vif_chanctx(struct iwl_mvm *mvm,
46534654
struct ieee80211_vif *vif,
4655+
struct ieee80211_bss_conf *link_conf,
46544656
struct ieee80211_chanctx_conf *ctx,
46554657
bool switching_chanctx)
46564658
{
46574659
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
46584660
int ret;
46594661

4662+
if (WARN_ON(!link_conf))
4663+
return -EINVAL;
4664+
46604665
if (__iwl_mvm_assign_vif_chanctx_common(mvm, vif, ctx,
46614666
switching_chanctx, &ret))
46624667
goto out;
@@ -4736,7 +4741,7 @@ static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
47364741
int ret;
47374742

47384743
mutex_lock(&mvm->mutex);
4739-
ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, ctx, false);
4744+
ret = __iwl_mvm_assign_vif_chanctx(mvm, vif, link_conf, ctx, false);
47404745
mutex_unlock(&mvm->mutex);
47414746

47424747
return ret;
@@ -4748,9 +4753,9 @@ static int iwl_mvm_assign_vif_chanctx(struct ieee80211_hw *hw,
47484753
* Returns if chanctx unassign chanctx is done
47494754
* (either on failure or success)
47504755
*/
4751-
bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
4752-
struct ieee80211_vif *vif,
4753-
bool switching_chanctx)
4756+
static bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
4757+
struct ieee80211_vif *vif,
4758+
bool switching_chanctx)
47544759
{
47554760
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
47564761

@@ -4788,6 +4793,7 @@ bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
47884793

47894794
static void __iwl_mvm_unassign_vif_chanctx(struct iwl_mvm *mvm,
47904795
struct ieee80211_vif *vif,
4796+
struct ieee80211_bss_conf *link_conf,
47914797
struct ieee80211_chanctx_conf *ctx,
47924798
bool switching_chanctx)
47934799
{
@@ -4827,7 +4833,7 @@ static void iwl_mvm_unassign_vif_chanctx(struct ieee80211_hw *hw,
48274833
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
48284834

48294835
mutex_lock(&mvm->mutex);
4830-
__iwl_mvm_unassign_vif_chanctx(mvm, vif, ctx, false);
4836+
__iwl_mvm_unassign_vif_chanctx(mvm, vif, link_conf, ctx, false);
48314837
mutex_unlock(&mvm->mutex);
48324838
}
48334839

@@ -4839,7 +4845,8 @@ iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm,
48394845
int ret;
48404846

48414847
mutex_lock(&mvm->mutex);
4842-
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true);
4848+
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4849+
vifs[0].old_ctx, true);
48434850
__iwl_mvm_remove_chanctx(mvm, vifs[0].old_ctx);
48444851

48454852
ret = __iwl_mvm_add_chanctx(mvm, vifs[0].new_ctx);
@@ -4848,8 +4855,8 @@ iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm,
48484855
goto out_reassign;
48494856
}
48504857

4851-
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx,
4852-
true);
4858+
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4859+
vifs[0].new_ctx, true);
48534860
if (ret) {
48544861
IWL_ERR(mvm,
48554862
"failed to assign new_ctx during channel switch\n");
@@ -4871,8 +4878,8 @@ iwl_mvm_switch_vif_chanctx_swap(struct iwl_mvm *mvm,
48714878
goto out_restart;
48724879
}
48734880

4874-
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx,
4875-
true)) {
4881+
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4882+
vifs[0].old_ctx, true)) {
48764883
IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
48774884
goto out_restart;
48784885
}
@@ -4897,10 +4904,11 @@ iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm,
48974904
int ret;
48984905

48994906
mutex_lock(&mvm->mutex);
4900-
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx, true);
4907+
ops->__unassign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4908+
vifs[0].old_ctx, true);
49014909

4902-
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].new_ctx,
4903-
true);
4910+
ret = ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4911+
vifs[0].new_ctx, true);
49044912
if (ret) {
49054913
IWL_ERR(mvm,
49064914
"failed to assign new_ctx during channel switch\n");
@@ -4910,8 +4918,8 @@ iwl_mvm_switch_vif_chanctx_reassign(struct iwl_mvm *mvm,
49104918
goto out;
49114919

49124920
out_reassign:
4913-
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].old_ctx,
4914-
true)) {
4921+
if (ops->__assign_vif_chanctx(mvm, vifs[0].vif, vifs[0].link_conf,
4922+
vifs[0].old_ctx, true)) {
49154923
IWL_ERR(mvm, "failed to reassign old_ctx after failure.\n");
49164924
goto out_restart;
49174925
}

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

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -220,17 +220,23 @@ static void iwl_mvm_mld_mac_remove_interface(struct ieee80211_hw *hw,
220220
mutex_unlock(&mvm->mutex);
221221
}
222222

223-
static int __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
224-
struct ieee80211_vif *vif,
225-
struct ieee80211_chanctx_conf *ctx,
226-
bool switching_chanctx)
223+
static int
224+
__iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
225+
struct ieee80211_vif *vif,
226+
struct ieee80211_bss_conf *link_conf,
227+
struct ieee80211_chanctx_conf *ctx,
228+
bool switching_chanctx)
227229
{
228230
u16 *phy_ctxt_id = (u16 *)ctx->drv_priv;
229231
struct iwl_mvm_phy_ctxt *phy_ctxt = &mvm->phy_ctxts[*phy_ctxt_id];
230232
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
233+
unsigned int link_id = link_conf->link_id;
231234
int ret;
232235

233-
mvmvif->deflink.phy_ctxt = phy_ctxt;
236+
if (WARN_ON_ONCE(!mvmvif->link[link_id]))
237+
return -EINVAL;
238+
239+
mvmvif->link[link_id]->phy_ctxt = phy_ctxt;
234240

235241
if (switching_chanctx) {
236242
/* reactivate if we turned this off during channel switch */
@@ -239,12 +245,12 @@ static int __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
239245
}
240246

241247
/* send it first with phy context ID */
242-
ret = iwl_mvm_link_changed(mvm, vif, &vif->bss_conf, 0, false);
248+
ret = iwl_mvm_link_changed(mvm, vif, link_conf, 0, false);
243249
if (ret)
244250
goto out;
245251

246252
/* then activate */
247-
ret = iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
253+
ret = iwl_mvm_link_changed(mvm, vif, link_conf,
248254
LINK_CONTEXT_MODIFY_ACTIVE |
249255
LINK_CONTEXT_MODIFY_RATES_INFO,
250256
true);
@@ -258,19 +264,18 @@ static int __iwl_mvm_mld_assign_vif_chanctx(struct iwl_mvm *mvm,
258264
iwl_mvm_power_update_mac(mvm);
259265

260266
if (vif->type == NL80211_IFTYPE_MONITOR) {
261-
ret = iwl_mvm_mld_add_snif_sta(mvm, vif,
262-
&vif->bss_conf);
267+
ret = iwl_mvm_mld_add_snif_sta(mvm, vif, link_conf);
263268
if (ret)
264269
goto deactivate;
265270
}
266271

267272
return 0;
268273

269274
deactivate:
270-
iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
271-
LINK_CONTEXT_MODIFY_ACTIVE, false);
275+
iwl_mvm_link_changed(mvm, vif, link_conf, LINK_CONTEXT_MODIFY_ACTIVE,
276+
false);
272277
out:
273-
mvmvif->deflink.phy_ctxt = NULL;
278+
mvmvif->link[link_id]->phy_ctxt = NULL;
274279
iwl_mvm_power_update_mac(mvm);
275280
return ret;
276281
}
@@ -284,18 +289,25 @@ static int iwl_mvm_mld_assign_vif_chanctx(struct ieee80211_hw *hw,
284289
int ret;
285290

286291
mutex_lock(&mvm->mutex);
287-
ret = __iwl_mvm_mld_assign_vif_chanctx(mvm, vif, ctx, false);
292+
ret = __iwl_mvm_mld_assign_vif_chanctx(mvm, vif, link_conf, ctx, false);
288293
mutex_unlock(&mvm->mutex);
289294

290295
return ret;
291296
}
292297

293-
static void __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
294-
struct ieee80211_vif *vif,
295-
struct ieee80211_chanctx_conf *ctx,
296-
bool switching_chanctx)
298+
static void
299+
__iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
300+
struct ieee80211_vif *vif,
301+
struct ieee80211_bss_conf *link_conf,
302+
struct ieee80211_chanctx_conf *ctx,
303+
bool switching_chanctx)
297304
{
298305
struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
306+
unsigned int link_id = link_conf->link_id;
307+
308+
/* shouldn't happen, but verify link_id is valid before accessing */
309+
if (WARN_ON_ONCE(!mvmvif->link[link_id]))
310+
return;
299311

300312
if (vif->type == NL80211_IFTYPE_AP && switching_chanctx) {
301313
mvmvif->csa_countdown = false;
@@ -312,12 +324,12 @@ static void __iwl_mvm_mld_unassign_vif_chanctx(struct iwl_mvm *mvm,
312324
if (vif->type == NL80211_IFTYPE_MONITOR)
313325
iwl_mvm_mld_rm_snif_sta(mvm, vif);
314326

315-
iwl_mvm_link_changed(mvm, vif, &vif->bss_conf,
327+
iwl_mvm_link_changed(mvm, vif, link_conf,
316328
LINK_CONTEXT_MODIFY_ACTIVE, false);
317329

318330
if (switching_chanctx)
319331
return;
320-
mvmvif->deflink.phy_ctxt = NULL;
332+
mvmvif->link[link_id]->phy_ctxt = NULL;
321333
iwl_mvm_power_update_mac(mvm);
322334
}
323335

@@ -329,7 +341,7 @@ static void iwl_mvm_mld_unassign_vif_chanctx(struct ieee80211_hw *hw,
329341
struct iwl_mvm *mvm = IWL_MAC80211_GET_MVM(hw);
330342

331343
mutex_lock(&mvm->mutex);
332-
__iwl_mvm_mld_unassign_vif_chanctx(mvm, vif, ctx, false);
344+
__iwl_mvm_mld_unassign_vif_chanctx(mvm, vif, link_conf, ctx, false);
333345
mutex_unlock(&mvm->mutex);
334346
}
335347

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2365,10 +2365,12 @@ int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw,
23652365
struct iwl_mvm_switch_vif_chanctx_ops {
23662366
int (*__assign_vif_chanctx)(struct iwl_mvm *mvm,
23672367
struct ieee80211_vif *vif,
2368+
struct ieee80211_bss_conf *link_conf,
23682369
struct ieee80211_chanctx_conf *ctx,
23692370
bool switching_chanctx);
23702371
void (*__unassign_vif_chanctx)(struct iwl_mvm *mvm,
23712372
struct ieee80211_vif *vif,
2373+
struct ieee80211_bss_conf *link_conf,
23722374
struct ieee80211_chanctx_conf *ctx,
23732375
bool switching_chanctx);
23742376
};
@@ -2380,14 +2382,6 @@ iwl_mvm_switch_vif_chanctx_common(struct ieee80211_hw *hw,
23802382
enum ieee80211_chanctx_switch_mode mode,
23812383
struct iwl_mvm_switch_vif_chanctx_ops *ops);
23822384

2383-
bool __iwl_mvm_assign_vif_chanctx_common(struct iwl_mvm *mvm,
2384-
struct ieee80211_vif *vif,
2385-
struct ieee80211_chanctx_conf *ctx,
2386-
bool switching_chanctx, int *ret);
2387-
bool __iwl_mvm_unassign_vif_chanctx_common(struct iwl_mvm *mvm,
2388-
struct ieee80211_vif *vif,
2389-
bool switching_chanctx);
2390-
23912385
/* Channel info utils */
23922386
static inline bool iwl_mvm_has_ultra_hb_channel(struct iwl_mvm *mvm)
23932387
{

0 commit comments

Comments
 (0)