wifi: cfg80211/mac80211: pre-work for MLO CSA handling
Johannes Berg
maintainercover wifi: cfg80211/mac80211: pre-work for MLO CSA handling
Here's some pre-work/refactoring for what I'm working on with CSA handling for MLO.
Yeah the last patch doesn't really belong into that theme, but it was now really simple, so I included that anyway since I'd noticed.
johannes
Johannes Berg
maintainerPATCH 1/8 wifi: cfg80211: expose cfg80211_iter_rnr() to drivers
From: Johannes Berg <[email protected]>
In mac80211 we'll need to look at reduced neighbor report entries for channel switch purposes, so export the iteration function to make that simpler.
--- include/net/cfg80211.h | 32 ++++++++++++++++++++++++++++++++ net/wireless/scan.c | 20 +++++++------------- 2 files changed, 39 insertions(+), 13 deletions(-)
include/net/cfg80211.h +32 -0
@@ -6870,6 +6870,38 @@ cfg80211_find_vendor_ie(unsigned int oui, int oui_type,return (const void *)cfg80211_find_vendor_elem (oui, oui_type, ies, len); } +/** +* enum cfg80211_rnr_iter_ret - reduced neighbor report iteration state +* @RNR_ITER_CONTINUE: continue iterating with the next entry +* @RNR_ITER_BREAK: break iteration and return success +* @RNR_ITER_ERROR: break iteration and return error +*/ +enum cfg80211_rnr_iter_ret { +RNR_ITER_CONTINUE , +RNR_ITER_BREAK , +RNR_ITER_ERROR , +}; + +/** +* cfg80211_iter_rnr - iterate reduced neighbor report entries +* @elems: the frame elements to iterate RNR elements and then +* their entries in +* @elems_len: length of the elements +* @iter: iteration function, see also &enum cfg80211_rnr_iter_ret +* for the return value +* @iter_data: additional data passed to the iteration function +* Return: %true on success (after successfully iterating all entries +* or if the iteration function returned %RNR_ITER_BREAK), +* %false on error (iteration function returned %RNR_ITER_ERROR +* or elements were malformed.) +*/ +bool cfg80211_iter_rnr (const u8 *elems,size_t elems_len, +enum cfg80211_rnr_iter_ret + (*iter)(void *data,u8 type, +const struct ieee80211_neighbor_ap_info *info, +const u8 *tbtt_info,u8 tbtt_info_len), +void *iter_data); +/** * cfg80211_defragment_element - Defrag the given element data into a buffer *
net/wireless/scan.c +7 -13
@@ -611,19 +611,12 @@ static int cfg80211_parse_ap_info(struct cfg80211_colocated_ap *entry,return 0 ; } -enum cfg80211_rnr_iter_ret { -RNR_ITER_CONTINUE , -RNR_ITER_BREAK , -RNR_ITER_ERROR , -}; - -static bool -cfg80211_iter_rnr (const u8 *elems,size_t elems_len, -enum cfg80211_rnr_iter_ret - (*iter)(void *data,u8 type, -const struct ieee80211_neighbor_ap_info *info, -const u8 *tbtt_info,u8 tbtt_info_len), -void *iter_data) +bool cfg80211_iter_rnr (const u8 *elems,size_t elems_len, +enum cfg80211_rnr_iter_ret + (*iter)(void *data,u8 type, +const struct ieee80211_neighbor_ap_info *info, +const u8 *tbtt_info,u8 tbtt_info_len), +void *iter_data) {const struct element *rnr;const u8 *pos, *end;
@@ -675,6 +668,7 @@ cfg80211_iter_rnr(const u8 *elems, size_t elems_len,return true; } +EXPORT_SYMBOL_GPL (cfg80211_iter_rnr);struct colocated_ap_data {const struct element *ssid_elem;
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 2/8 wifi: cfg80211: allow cfg80211_defragment_element() without output
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
If we just want to determine the length of the fragmented data, we basically need the same logic, and really we want it to be _literally_ the same logic, so it cannot be out of sync in any way.
Allow calling cfg80211_defragment_element() without an output buffer, where it then just returns the required output size.
Also add this to the tests, just to exercise it, using the pre-calculated length to really do the defragmentation, which checks that this is sufficient.
--- include/net/cfg80211.h | 4 ++-- net/wireless/scan.c | 27 ++++++++++++++++++--------- net/wireless/tests/fragmentation.c | 30 +++++++++++++++++++++++++----- 3 files changed, 45 insertions(+), 16 deletions(-)
include/net/cfg80211.h +2 -2
@@ -6908,8 +6908,8 @@ bool cfg80211_iter_rnr(const u8 *elems, size_t elems_len,* @elem: the element to defragment * @ies: elements where @elem is contained * @ieslen: length of @ies -* @data: buffer to store element data -* @data_len: length of @data +* @data: buffer to store element data, or %NULL to just determine size +* @data_len: length of @data, or 0 * @frag_id: the element ID of fragments * * Return: length of @data, or -EINVAL on error
net/wireless/scan.c +18 -9
@@ -2504,16 +2504,22 @@ ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies,if (elem->id ==WLAN_EID_EXTENSION ) { copied = elem->datalen -1 ; -if (copied > data_len) -return -ENOSPC ; -memmove (data, elem->data +1 , copied); +if (data) { +if (copied > data_len) +return -ENOSPC ; + +memmove (data, elem->data +1 , copied); + } }else { copied = elem->datalen; -if (copied > data_len) -return -ENOSPC ; -memmove (data, elem->data, copied); +if (data) { +if (copied > data_len) +return -ENOSPC ; + +memmove (data, elem->data, copied); + } }/* Fragmented elements must have 255 bytes */
@@ -2532,10 +2538,13 @@ ssize_t cfg80211_defragment_element(const struct element *elem, const u8 *ies, elem_datalen = elem->datalen; -if (copied + elem_datalen > data_len) -return -ENOSPC ; +if (data) { +if (copied + elem_datalen > data_len) +return -ENOSPC ; + +memmove (data + copied, elem->data, elem_datalen); + } -memmove (data + copied, elem->data, elem_datalen); copied += elem_datalen;/* Only the last fragment may be short */
net/wireless/tests/fragmentation.c +25 -5
@@ -2,7 +2,7 @@/* * KUnit tests for element fragmentation * -* Copyright (C) 2023 Intel Corporation +* Copyright (C) 2023-2024 Intel Corporation */ #include <linux/ieee80211.h> #include <net/cfg80211.h>
@@ -27,7 +27,12 @@ static void defragment_0(struct kunit *test) ret =cfg80211_defragment_element ((void *)input, input,sizeof (input), - data,sizeof (input), +NULL ,0 , +WLAN_EID_FRAGMENT ); +KUNIT_EXPECT_EQ (test, ret,253 ); + ret =cfg80211_defragment_element ((void *)input, + input,sizeof (input), + data, ret,WLAN_EID_FRAGMENT );KUNIT_EXPECT_EQ (test, ret,253 );KUNIT_EXPECT_MEMEQ (test, data, input +3 ,253 );
@@ -63,7 +68,12 @@ static void defragment_1(struct kunit *test) ret =cfg80211_defragment_element ((void *)input, input,sizeof (input), - data,sizeof (input), +NULL ,0 , +WLAN_EID_FRAGMENT ); +KUNIT_EXPECT_EQ (test, ret,254 +7 ); + ret =cfg80211_defragment_element ((void *)input, + input,sizeof (input), + data, ret,WLAN_EID_FRAGMENT );/* this means the last fragment was not used */ KUNIT_EXPECT_EQ (test, ret,254 +7 );
@@ -106,10 +116,15 @@ static void defragment_2(struct kunit *test) ret =cfg80211_defragment_element ((void *)input, input,sizeof (input), - data,sizeof (input), +NULL ,0 ,WLAN_EID_FRAGMENT );/* this means the last fragment was not used */ KUNIT_EXPECT_EQ (test, ret,254 +255 +1 ); + ret =cfg80211_defragment_element ((void *)input, + input,sizeof (input), + data, ret, +WLAN_EID_FRAGMENT ); +KUNIT_EXPECT_EQ (test, ret,254 +255 +1 );KUNIT_EXPECT_MEMEQ (test, data, input +3 ,254 );KUNIT_EXPECT_MEMEQ (test, data +254 , input +257 +2 ,255 );KUNIT_EXPECT_MEMEQ (test, data +254 +255 , input +2 *257 +2 ,1 );
@@ -134,7 +149,12 @@ static void defragment_at_end(struct kunit *test) ret =cfg80211_defragment_element ((void *)input, input,sizeof (input), - data,sizeof (input), +NULL ,0 , +WLAN_EID_FRAGMENT ); +KUNIT_EXPECT_EQ (test, ret,254 +7 ); + ret =cfg80211_defragment_element ((void *)input, + input,sizeof (input), + data, ret,WLAN_EID_FRAGMENT );KUNIT_EXPECT_EQ (test, ret,254 +7 );KUNIT_EXPECT_MEMEQ (test, data, input +3 ,254 );
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 3/8 wifi: mac80211: pass link_id to channel switch ops
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
For CSA to work correctly in multi-link scenarios, pass the link_id to the relevant callbacks.
While at it, unify/deduplicate the tracing for them.
--- include/net/mac80211.h | 6 ++-- net/mac80211/cfg.c | 4 ++- net/mac80211/mlme.c | 4 ++- net/mac80211/trace.h | 82 ++++++++++-------------------------------- 4 files changed, 28 insertions(+), 68 deletions(-)
include/net/mac80211.h +4 -2
@@ -1763,8 +1763,9 @@ struct ieee80211_conf {* @chandef: the new channel to switch to * @count: the number of TBTT's until the channel switch event * @delay: maximum delay between the time the AP transmitted the last beacon in -* current channel and the expected time of the first beacon in the new -* channel, expressed in TU. +* current channel and the expected time of the first beacon in the new +* channel, expressed in TU. +* @link_id: the link ID of the link doing the channel switch, 0 for non-MLO */ struct ieee80211_channel_switch {u64 timestamp;
@@ -1772,6 +1773,7 @@ struct ieee80211_channel_switch {bool block_tx;struct cfg80211_chan_def chandef;u8 count; +u8 link_id;u32 delay; };
net/mac80211/cfg.c +3 -1
@@ -3897,7 +3897,9 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,struct ieee80211_sub_if_data *sdata =IEEE80211_DEV_TO_SUB_IF (dev);struct ieee80211_chan_req chanreq = { .oper = params->chandef };struct ieee80211_local *local = sdata->local; -struct ieee80211_channel_switch ch_switch; +struct ieee80211_channel_switch ch_switch = { + .link_id = params->link_id, + };struct ieee80211_chanctx_conf *conf;struct ieee80211_chanctx *chanctx;struct ieee80211_bss_conf *link_conf;
net/mac80211/mlme.c +3 -1
@@ -2021,7 +2021,9 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,struct ieee80211_chanctx *chanctx;enum nl80211_band current_band;struct ieee80211_csa_ie csa_ie; -struct ieee80211_channel_switch ch_switch; +struct ieee80211_channel_switch ch_switch = { + .link_id = link->link_id, + };struct ieee80211_bss *bss;unsigned long timeout;int res;
net/mac80211/trace.h +18 -64
124 lines not on this page · raw message
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 4/8 wifi: mac80211: pass link conf to abort_channel_switch
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Pass the link conf to the abort_channel_switch driver method so the driver can handle things correctly.
--- drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c | 13 +++++++++++-- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 3 ++- include/net/mac80211.h | 5 +++-- net/mac80211/driver-ops.h | 8 +++++--- net/mac80211/mlme.c | 2 +- 5 files changed, 22 insertions(+), 9 deletions(-)
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +11 -2
@@ -1470,7 +1470,8 @@ int iwl_mvm_post_channel_switch(struct ieee80211_hw *hw, }void iwl_mvm_abort_channel_switch (struct ieee80211_hw *hw, -struct ieee80211_vif *vif) +struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf) {struct iwl_mvm *mvm =IWL_MAC80211_GET_MVM (hw);struct iwl_mvm_vif *mvmvif =iwl_mvm_vif_from_mac80211 (vif);
@@ -5551,8 +5552,16 @@ void iwl_mvm_channel_switch_rx_beacon(struct ieee80211_hw *hw,if (chsw->count >= mvmvif->csa_count && chsw->block_tx) {if (mvmvif->csa_misbehave) { +struct ieee80211_bss_conf *link_conf; +/* Second time, give up on this AP*/ -iwl_mvm_abort_channel_switch (hw, vif); + + link_conf =wiphy_dereference (hw->wiphy, + vif->link_conf[chsw->link_id]); +if (WARN_ON (!link_conf)) +return ; + +iwl_mvm_abort_channel_switch (hw, vif, link_conf);ieee80211_chswitch_done (vif, false,0 ); mvmvif->csa_misbehave = false;return ;
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +2 -1
@@ -2709,7 +2709,8 @@ int iwl_mvm_pre_channel_switch(struct ieee80211_hw *hw,struct ieee80211_vif *vif, struct ieee80211_channel_switch *chsw);void iwl_mvm_abort_channel_switch (struct ieee80211_hw *hw, -struct ieee80211_vif *vif); +struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf);void iwl_mvm_channel_switch_rx_beacon (struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_channel_switch *chsw);
include/net/mac80211.h +3 -2
@@ -4268,7 +4268,7 @@ struct ieee80211_prep_tx_info {* after a channel switch procedure is completed, allowing the * driver to go back to a normal configuration. * @abort_channel_switch: This is an optional callback that is called -* when channel switch procedure was completed, allowing the +* when channel switch procedure was aborted, allowing the * driver to go back to a normal configuration. * @channel_switch_rx_beacon: This is an optional callback that is called * when channel switch procedure is in progress and additional beacon with
@@ -4664,7 +4664,8 @@ struct ieee80211_ops {struct ieee80211_vif *vif, struct ieee80211_bss_conf *link_conf);void (*abort_channel_switch)(struct ieee80211_hw *hw, -struct ieee80211_vif *vif); +struct ieee80211_vif *vif, +struct ieee80211_bss_conf *link_conf);void (*channel_switch_rx_beacon)(struct ieee80211_hw *hw,struct ieee80211_vif *vif,struct ieee80211_channel_switch *ch_switch);
net/mac80211/driver-ops.h +5 -3
@@ -2,7 +2,7 @@/* * Portions of this file * Copyright(c) 2016 Intel Deutschland GmbH -* Copyright (C) 2018 - 2019, 2021 - 2023 Intel Corporation +* Copyright (C) 2018-2019, 2021-2024 Intel Corporation */ #ifndef __MAC80211_DRIVER_OPS
@@ -1180,8 +1180,9 @@ drv_post_channel_switch(struct ieee80211_link_data *link) }static inline void -drv_abort_channel_switch (struct ieee80211_sub_if_data *sdata) +drv_abort_channel_switch (struct ieee80211_link_data *link) { +struct ieee80211_sub_if_data *sdata = link->sdata;struct ieee80211_local *local = sdata->local;might_sleep ();
@@ -1193,7 +1194,8 @@ drv_abort_channel_switch(struct ieee80211_sub_if_data *sdata)trace_drv_abort_channel_switch (local, sdata);if (local->ops->abort_channel_switch) - local->ops->abort_channel_switch (&local->hw, &sdata->vif); + local->ops->abort_channel_switch (&local->hw, &sdata->vif, + link->conf); } static inline void
net/mac80211/mlme.c +1 -1
@@ -2004,7 +2004,7 @@ ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link) link->csa_block_tx = false; link->conf->csa_active = false; -drv_abort_channel_switch (sdata); +drv_abort_channel_switch (link); } static void
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 5/8 wifi: mac80211: introduce a feature flag for quiet in CSA
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
When doing CSA in multi-link, there really isn't a need to stop transmissions entirely. Add a feature flag for drivers to indicate they can handle quiet in CSA (be it by parsing themselves, or by implementing drv_pre_channel_switch()), to make that possible.
Also clean up the csa_block_tx handling: it clearly cannot handle multi-link due to the way queues are stopped, move it to the sdata. Drivers should be doing it themselves for working properly during CSA in MLO anyway. Also rename it to indicate that it reflects TX was blocked at mac80211.
--- include/net/mac80211.h | 6 ++++++ net/mac80211/cfg.c | 16 +++++++++------- net/mac80211/debugfs.c | 3 ++- net/mac80211/ieee80211_i.h | 3 ++- net/mac80211/iface.c | 6 +++--- net/mac80211/mlme.c | 35 +++++++++++++++++++++-------------- 6 files changed, 43 insertions(+), 26 deletions(-)
include/net/mac80211.h +6 -0
@@ -2778,6 +2778,11 @@ struct ieee80211_txq {* @IEEE80211_HW_DISALLOW_PUNCTURING: HW requires disabling puncturing in EHT * and connecting with a lower bandwidth instead * +* @IEEE80211_HW_HANDLES_QUIET_CSA: HW/driver handles quieting for CSA, so +* no need to stop queues. This really should be set by a driver that +* implements MLO, so operation can continue on other links when one +* link is switching. +* * @NUM_IEEE80211_HW_FLAGS: number of hardware flags, used for sizing arrays */ enum ieee80211_hw_flags {
@@ -2836,6 +2841,7 @@ enum ieee80211_hw_flags {IEEE80211_HW_DETECTS_COLOR_COLLISION ,IEEE80211_HW_MLO_MCAST_MULTI_LINK_TX ,IEEE80211_HW_DISALLOW_PUNCTURING , +IEEE80211_HW_HANDLES_QUIET_CSA ,/* keep last, obviously */ NUM_IEEE80211_HW_FLAGS
net/mac80211/cfg.c +9 -7
@@ -1580,10 +1580,10 @@ static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev,/* abort any running channel switch or color change */ link_conf->csa_active = false; link_conf->color_change_active = false; -if (link->csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - link->csa_block_tx = false; + sdata->csa_blocked_tx = false; }ieee80211_free_next_beacon (link);
@@ -3615,7 +3615,7 @@ void ieee80211_channel_switch_disconnect(struct ieee80211_vif *vif, bool block_tstruct ieee80211_if_managed *ifmgd = &sdata->u.mgd;struct ieee80211_local *local = sdata->local; - sdata->deflink.csa_block_tx = block_tx; + sdata->csa_blocked_tx = block_tx;sdata_info (sdata,"channel switch failed, disconnecting\n" );wiphy_work_queue (local->hw.wiphy, &ifmgd->csa_connection_drop_work); }
@@ -3701,10 +3701,10 @@ static int __ieee80211_csa_finalize(struct ieee80211_link_data *link_data)ieee80211_link_info_change_notify (sdata, link_data, changed); -if (link_data->csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - link_data->csa_block_tx = false; + sdata->csa_blocked_tx = false; } err =drv_post_channel_switch (link_data);
@@ -3980,12 +3980,14 @@ __ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev, } link_data->csa_chanreq = chanreq; - link_data->csa_block_tx = params->block_tx; link_conf->csa_active = true; -if (link_data->csa_block_tx) +if (params->block_tx && + !ieee80211_hw_check (&local->hw,HANDLES_QUIET_CSA )) {ieee80211_stop_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); + sdata->csa_blocked_tx = true; + } cfg80211_ch_switch_started_notify(sdata->dev, &link_data->csa_chanreq.oper, 0,
net/mac80211/debugfs.c +2 -1
@@ -4,7 +4,7 @@* * Copyright 2007 Johannes Berg <[email protected]> * Copyright 2013-2014 Intel Mobile Communications GmbH -* Copyright (C) 2018 - 2019, 2021-2023 Intel Corporation +* Copyright (C) 2018 - 2019, 2021-2024 Intel Corporation */ #include <linux/debugfs.h>
@@ -498,6 +498,7 @@ static const char *hw_flag_names[] = {FLAG (DETECTS_COLOR_COLLISION ),FLAG (MLO_MCAST_MULTI_LINK_TX ),FLAG (DISALLOW_PUNCTURING ), +FLAG (HANDLES_QUIET_CSA ), #undef FLAG };
net/mac80211/ieee80211_i.h +2 -1
@@ -1034,7 +1034,6 @@ struct ieee80211_link_data {struct ieee80211_key __rcu *default_beacon_key;struct wiphy_work csa_finalize_work; -bool csa_block_tx;bool operating_11g_mode;
@@ -1093,6 +1092,8 @@ struct ieee80211_sub_if_data {unsigned long state; +bool csa_blocked_tx; +char name[IFNAMSIZ ];struct ieee80211_fragment_cache frags;
net/mac80211/iface.c +3 -3
@@ -8,7 +8,7 @@* Copyright 2008, Johannes Berg <[email protected]> * Copyright 2013-2014 Intel Mobile Communications GmbH * Copyright (c) 2016 Intel Deutschland GmbH -* Copyright (C) 2018-2023 Intel Corporation +* Copyright (C) 2018-2024 Intel Corporation */ #include <linux/slab.h> #include <linux/kernel.h>
@@ -544,10 +544,10 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do sdata->vif.bss_conf.csa_active = false;if (sdata->vif.type ==NL80211_IFTYPE_STATION ) sdata->deflink.u.mgd.csa_waiting_bcn = false; -if (sdata->deflink.csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->deflink.csa_block_tx = false; + sdata->csa_blocked_tx = false; }wiphy_work_cancel (local->hw.wiphy, &sdata->deflink.csa_finalize_work);
net/mac80211/mlme.c +21 -14
@@ -1926,10 +1926,10 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link)WARN_ON (!link->conf->csa_active); -if (link->csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - link->csa_block_tx = false; + sdata->csa_blocked_tx = false; } link->conf->csa_active = false;
@@ -1997,11 +1997,12 @@ ieee80211_sta_abort_chanswitch(struct ieee80211_link_data *link)ieee80211_link_unreserve_chanctx (link); -if (link->csa_block_tx) +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); + sdata->csa_blocked_tx = false; + } - link->csa_block_tx = false; link->conf->csa_active = false;drv_abort_channel_switch (link);
@@ -2145,13 +2146,15 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, link->conf->csa_active = true; link->csa_chanreq = csa_ie.chanreq; - link->csa_block_tx = csa_ie.mode; link->u.mgd.csa_ignored_same_chan = false; link->u.mgd.beacon_crc_valid = false; -if (link->csa_block_tx) +if (csa_ie.mode && + !ieee80211_hw_check (&local->hw,HANDLES_QUIET_CSA )) {ieee80211_stop_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); + sdata->csa_blocked_tx = true; + } cfg80211_ch_switch_started_notify(sdata->dev, &csa_ie.chanreq.oper, link->link_id, csa_ie.count,
@@ -2179,7 +2182,8 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,* reset when the disconnection worker runs. */ link->conf->csa_active = true; - link->csa_block_tx = csa_ie.mode; + sdata->csa_blocked_tx = + csa_ie.mode && !ieee80211_hw_check (&local->hw,HANDLES_QUIET_CSA );wiphy_work_queue (sdata->local->hw.wiphy, &ifmgd->csa_connection_drop_work);
@@ -3233,10 +3237,10 @@ static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, sdata->vif.bss_conf.csa_active = false; sdata->deflink.u.mgd.csa_waiting_bcn = false; sdata->deflink.u.mgd.csa_ignored_same_chan = false; -if (sdata->deflink.csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->deflink.csa_block_tx = false; + sdata->csa_blocked_tx = false; }/* existing TX TSPEC sessions no longer exist */
@@ -3549,9 +3553,12 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)if (!ifmgd->associated)return ; -/* in MLO assume we have a link where we can TX the frame */ - tx =ieee80211_vif_is_mld (&sdata->vif) || - !sdata->deflink.csa_block_tx; +/* +* MLO drivers should have HANDLES_QUIET_CSA, so that csa_blocked_tx +* is always false; if they don't then this may try to transmit the +* frame but queues will be stopped. +*/ + tx = !sdata->csa_blocked_tx;if (!ifmgd->driver_disconnect) {unsigned int link_id;
@@ -3584,10 +3591,10 @@ static void __ieee80211_disconnect(struct ieee80211_sub_if_data *sdata)/* the other links will be destroyed */ sdata->vif.bss_conf.csa_active = false; sdata->deflink.u.mgd.csa_waiting_bcn = false; -if (sdata->deflink.csa_block_tx) { +if (sdata->csa_blocked_tx) {ieee80211_wake_vif_queues (local, sdata,IEEE80211_QUEUE_STOP_REASON_CSA ); - sdata->deflink.csa_block_tx = false; + sdata->csa_blocked_tx = false; } ieee80211_report_disconnect(sdata, frame_buf, sizeof(frame_buf), tx,
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 6/8 wifi: mac80211: mlme: unify CSA handling
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Unify all the CSA handling, including handling of a beacon after the CSA, into ieee80211_sta_process_chanswitch().
The CRC of the beacon will change due to changes in the CSA/ECSA elements, so there's really no need to have the 'beacon after CSA' handling before the CRC processing or to change the beacon_crc_valid value here.
--- net/mac80211/mlme.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-)
net/mac80211/mlme.c +22 -16
@@ -1934,11 +1934,6 @@ static void ieee80211_chswitch_post_beacon(struct ieee80211_link_data *link) link->conf->csa_active = false; link->u.mgd.csa_waiting_bcn = false; -/* -* If the CSA IE is still present on the beacon after the switch, -* we need to consider it as a new CSA (possibly to self). -*/ - link->u.mgd.beacon_crc_valid = false; ret =drv_post_channel_switch (link);if (ret) {
@@ -2053,18 +2048,32 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link,if (res <0 ) goto drop_connection; -if (beacon && link->conf->csa_active && - !link->u.mgd.csa_waiting_bcn) { -if (res) +if (link->conf->csa_active) { +/* already processing - disregard action frames */ +if (!beacon) +return ; + +if (link->u.mgd.csa_waiting_bcn) { +ieee80211_chswitch_post_beacon (link); +/* +* If the CSA IE is still present in the beacon after +* the switch, we need to consider it as a new CSA +* (possibly to self) - this happens by not returning +* here so we'll get to the check below. +*/ + }else if (res) {ieee80211_sta_abort_chanswitch (link); -else +return ; + }else {drv_channel_switch_rx_beacon (sdata, &ch_switch); -return ; - }else if (link->conf->csa_active || res) { -/* disregard subsequent announcements if already processing */ -return ; +return ; + } } +/* nothing to do at all - no active CSA nor a new one */ +if (res) +return ; +if (link->conf->chanreq.oper.chan->band != csa_ie.chanreq.oper.chan->band) { sdata_info(sdata,
@@ -6293,9 +6302,6 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_link_data *link, } } -if (link->u.mgd.csa_waiting_bcn) -ieee80211_chswitch_post_beacon (link); -/* * Update beacon timing and dtim count on every beacon appearance. This * will allow the driver to use the most updated values. Do it before
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 7/8 wifi: mac80211: remove TDLS peers only on affected link
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
If a link does CSA, or if it changes SMPS mode, we need to drop the TDLS peers, but we really should drop them only on the affected link. Fix that.
--- net/mac80211/cfg.c | 2 +- net/mac80211/ieee80211_i.h | 2 +- net/mac80211/mlme.c | 7 ++++--- net/mac80211/tdls.c | 6 +++++- 4 files changed, 11 insertions(+), 6 deletions(-)
net/mac80211/cfg.c +1 -1
@@ -3208,7 +3208,7 @@ int __ieee80211_request_smps_mgd(struct ieee80211_sub_if_data *sdata,if (err) link->u.mgd.req_smps = old_req;else if (smps_mode !=IEEE80211_SMPS_OFF && tdls_peer_found) -ieee80211_teardown_tdls_peers (sdata); +ieee80211_teardown_tdls_peers (link);return err; }
net/mac80211/ieee80211_i.h +1 -1
@@ -2611,7 +2611,7 @@ int ieee80211_tdls_channel_switch(struct wiphy *wiphy, struct net_device *dev,void ieee80211_tdls_cancel_channel_switch (struct wiphy *wiphy,struct net_device *dev,const u8 *addr); -void ieee80211_teardown_tdls_peers (struct ieee80211_sub_if_data *sdata); +void ieee80211_teardown_tdls_peers (struct ieee80211_link_data *link);void ieee80211_tdls_handle_disconnect (struct ieee80211_sub_if_data *sdata,const u8 *peer,u16 reason);void
net/mac80211/mlme.c +4 -3
@@ -2115,12 +2115,13 @@ ieee80211_sta_process_chanswitch(struct ieee80211_link_data *link, }/* -* Drop all TDLS peers - either we disconnect or move to a different -* channel from this point on. There's no telling what our peer will do. +* Drop all TDLS peers on the affected link - either we disconnect or +* move to a different channel from this point on. There's no telling +* what our peer will do. * The TDLS WIDER_BW scenario is also problematic, as peers might now * have an incompatible wider chandef. */ -ieee80211_teardown_tdls_peers (sdata); +ieee80211_teardown_tdls_peers (link); conf =rcu_dereference_protected (link->conf->chanctx_conf,lockdep_is_held (&local->hw.wiphy->mtx));
net/mac80211/tdls.c +5 -1
@@ -2028,8 +2028,9 @@ ieee80211_process_tdls_channel_switch(struct ieee80211_sub_if_data *sdata, } } -void ieee80211_teardown_tdls_peers (struct ieee80211_sub_if_data *sdata) +void ieee80211_teardown_tdls_peers (struct ieee80211_link_data *link) { +struct ieee80211_sub_if_data *sdata = link->sdata;struct sta_info *sta;u16 reason =WLAN_REASON_TDLS_TEARDOWN_UNSPECIFIED ;
@@ -2039,6 +2040,9 @@ void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata) !test_sta_flag(sta, WLAN_STA_AUTHORIZED))continue ; +if (sta->deflink.link_id != link->link_id) +continue ; +ieee80211_tdls_oper_request (&sdata->vif, sta->sta.addr,NL80211_TDLS_TEARDOWN , reason,GFP_ATOMIC );
Signature · 1 line
2.43.2
Johannes Berg
maintainerPATCH 8/8 wifi: mac80211: remove TDLS peers on link deactivation
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
If a link is deactivated, we really cannot sustain any TDLS connections on that link any more. With the API now changed, fix this issue and remove TDLS connections.
--- net/mac80211/link.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/mac80211/link.c +1 -1
@@ -356,7 +356,7 @@ static int _ieee80211_set_active_links(struct ieee80211_sub_if_data *sdata, link =sdata_dereference (sdata->link[link_id], sdata); -/* FIXME: kill TDLS connections on the link */ +ieee80211_teardown_tdls_peers (link);ieee80211_link_release_channel (link); }
Signature · 1 line
2.43.2