mirror of
https://github.com/openwrt/openwrt.git
synced 2026-11-27 19:00:39 +04:00
mac80211: let a driver count the AP Removal Timer of a link removal
An AP MLD announces the removal of an affiliated AP with the AP Removal Timer of a Reconfiguration Multi-Link element in the Beacon frames of all its links. hostapd counts the timer with a beacon update of every link at each beacon interval, and on mt7996 each such update keeps the Critical Update flag set past the DTIM Beacon. Patch 455 adds NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD, with which the driver counts the timer in the Beacon frames itself, and reports the expiry with NL80211_CMD_LINKS_REMOVED on the AP interface. The links stay until user space removes them. Patch 456 adds ieee80211_links_removed(), with which a driver reports the expiry from any context. The teardown of the interface cancels the work that sends the report. Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
1 parent
b48d951535
commit
9abf356d31
2 files changed
+236
No files matched your search
+115
@@ -0,0 +1,115 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Thu, 22 Oct 2026 20:00:00 +0200
|
||||
Subject: [PATCH] wifi: nl80211: report the expiry of an offloaded AP Removal
|
||||
Timer
|
||||
|
||||
An AP MLD announces the removal of an affiliated AP in the Beacon frames
|
||||
of all its links with a Reconfiguration Multi-Link element, whose AP
|
||||
Removal Timer counts the TBTTs to the removal (IEEE 802.11be-2024
|
||||
35.3.6.3). User space sees no TBTT, so it updates the beacons of every
|
||||
link at each beacon interval to count the timer. A device that takes
|
||||
each new template as a new critical update then keeps the Critical
|
||||
Update flag set for the whole countdown, past the DTIM Beacon frame that
|
||||
ends it (35.3.10).
|
||||
|
||||
Add an extended feature with which the driver declares that it counts
|
||||
the timer in the Beacon frames itself, and let it report the expiry with
|
||||
NL80211_CMD_LINKS_REMOVED on the AP interface. The links stay valid,
|
||||
because user space removes them after the frames that the removal needs.
|
||||
The driver can keep later beacon updates from the device until the
|
||||
expiry, since a device can take the timer of each new template as its
|
||||
new start.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
--- a/include/net/cfg80211.h
|
||||
+++ b/include/net/cfg80211.h
|
||||
@@ -11074,6 +11074,10 @@ cfg80211_6ghz_power_type(u8 control, u32
|
||||
* AP MLD removing the corresponding affiliated APs with Multi-Link
|
||||
* reconfiguration. Note that it's not valid to remove all links, in this
|
||||
* case disconnect instead.
|
||||
+ * On an AP interface, a driver with
|
||||
+ * %NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD calls it when the AP Removal
|
||||
+ * Timer of the affiliated APs of @link_mask expired. The links stay valid
|
||||
+ * until user space removes them.
|
||||
* Also note that the wdev mutex must be held.
|
||||
*/
|
||||
void cfg80211_links_removed(struct net_device *dev, u16 link_mask);
|
||||
--- a/net/wireless/nl80211.c
|
||||
+++ b/net/wireless/nl80211.c
|
||||
@@ -21969,23 +21969,32 @@ void cfg80211_links_removed(struct net_d
|
||||
struct wiphy *wiphy = wdev->wiphy;
|
||||
struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
|
||||
struct sk_buff *msg;
|
||||
+ bool ap = wdev->iftype == NL80211_IFTYPE_AP;
|
||||
struct nlattr *links;
|
||||
void *hdr;
|
||||
|
||||
lockdep_assert_wiphy(wdev->wiphy);
|
||||
trace_cfg80211_links_removed(dev, link_mask);
|
||||
|
||||
- if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
|
||||
- wdev->iftype != NL80211_IFTYPE_P2P_CLIENT))
|
||||
+ if (ap) {
|
||||
+ if (WARN_ON(!wiphy_ext_feature_isset(wiphy,
|
||||
+ NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD)))
|
||||
+ return;
|
||||
+ } else if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION &&
|
||||
+ wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) {
|
||||
return;
|
||||
+ }
|
||||
|
||||
if (WARN_ON(!wdev->valid_links || !link_mask ||
|
||||
(wdev->valid_links & link_mask) != link_mask ||
|
||||
wdev->valid_links == link_mask))
|
||||
return;
|
||||
|
||||
- cfg80211_wdev_release_link_bsses(wdev, link_mask);
|
||||
- wdev->valid_links &= ~link_mask;
|
||||
+ /* user space removes the links of an AP */
|
||||
+ if (!ap) {
|
||||
+ cfg80211_wdev_release_link_bsses(wdev, link_mask);
|
||||
+ wdev->valid_links &= ~link_mask;
|
||||
+ }
|
||||
|
||||
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
|
||||
if (!msg)
|
||||
--- a/include/uapi/linux/nl80211.h
|
||||
+++ b/include/uapi/linux/nl80211.h
|
||||
@@ -1333,6 +1333,10 @@
|
||||
* setup links due to AP MLD removing the corresponding affiliated APs with
|
||||
* Multi-Link reconfiguration. %NL80211_ATTR_MLO_LINKS is used to provide
|
||||
* information about the removed STA MLD setup links.
|
||||
+ * On an AP interface, with %NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD,
|
||||
+ * it reports that the AP Removal Timer of the affiliated APs of the links
|
||||
+ * in %NL80211_ATTR_MLO_LINKS expired; the links stay until user space
|
||||
+ * removes them.
|
||||
*
|
||||
* @NL80211_CMD_SET_TID_TO_LINK_MAPPING: Set the TID to Link Mapping for a
|
||||
* non-AP MLD station. The %NL80211_ATTR_MLO_TTLM_DLINK and
|
||||
@@ -7383,6 +7387,17 @@ enum nl80211_feature_flags {
|
||||
* service, configured with %NL80211_CMD_SET_SCS.
|
||||
* @NL80211_EXT_FEATURE_MSCS: Driver supports the mirrored stream
|
||||
* classification service, configured with %NL80211_CMD_SET_MSCS.
|
||||
+ * @NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD: The driver counts the AP
|
||||
+ * Removal Timer of an affiliated AP that a Reconfiguration Multi-Link
|
||||
+ * element in the beacon of an AP MLD link announces (IEEE 802.11be-2024,
|
||||
+ * 35.3.6.3), in the Beacon frames of every link that carries the element,
|
||||
+ * and reports its expiry with %NL80211_CMD_LINKS_REMOVED on the AP
|
||||
+ * interface. User space sets the beacons with the element once. Until
|
||||
+ * the expiry, the driver can keep later beacon updates of the links of
|
||||
+ * the AP MLD from the device, so user space sets the beacons of the links
|
||||
+ * that stay again after the event. The expiry comes before the TBTT at
|
||||
+ * which the timer reaches 0, and the removed links keep running until
|
||||
+ * user space stops them.
|
||||
*
|
||||
* @NUM_NL80211_EXT_FEATURES: number of extended features.
|
||||
* @MAX_NL80211_EXT_FEATURES: highest extended feature index.
|
||||
@@ -7472,6 +7487,7 @@ enum nl80211_ext_feature_index {
|
||||
NL80211_EXT_FEATURE_AP_ADV_TTLM,
|
||||
NL80211_EXT_FEATURE_SCS,
|
||||
NL80211_EXT_FEATURE_MSCS,
|
||||
+ NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD,
|
||||
|
||||
/* add new features before the definition below */
|
||||
NUM_NL80211_EXT_FEATURES,
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
From: Felix Fietkau <nbd@nbd.name>
|
||||
Date: Thu, 22 Oct 2026 20:00:00 +0200
|
||||
Subject: [PATCH] wifi: mac80211: let a driver report the expiry of an AP
|
||||
Removal Timer
|
||||
|
||||
A driver with NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD learns of the
|
||||
expiry from a device event, which can come in atomic context, while
|
||||
cfg80211_links_removed() needs the wiphy mutex.
|
||||
|
||||
Add ieee80211_links_removed(), which reports the links from a wiphy
|
||||
work. A link that user space removed before the work runs is left out,
|
||||
since cfg80211 no longer holds it. The driver can report links until it
|
||||
removes the interface, which comes after the stop of the interface, so
|
||||
the teardown of the interface cancels the work as well.
|
||||
|
||||
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
||||
---
|
||||
--- a/include/net/mac80211.h
|
||||
+++ b/include/net/mac80211.h
|
||||
@@ -6126,6 +6126,21 @@ void ieee80211_crit_update_done(struct i
|
||||
unsigned int link_id, u32 crit_update_id);
|
||||
|
||||
/**
|
||||
+ * ieee80211_links_removed - notify mac80211 that an AP Removal Timer expired
|
||||
+ * @vif: &struct ieee80211_vif pointer from the add_interface callback.
|
||||
+ * @links: bitmap of the link IDs of the affiliated APs whose timer expired
|
||||
+ *
|
||||
+ * A driver with %NL80211_EXT_FEATURE_AP_REMOVAL_TIMER_OFFLOAD calls this for
|
||||
+ * an AP MLD when the AP Removal Timer that the Reconfiguration Multi-Link
|
||||
+ * element of its beacon templates announces expired. mac80211 reports it with
|
||||
+ * %NL80211_CMD_LINKS_REMOVED, leaves the links running and ignores a link that
|
||||
+ * user space removed before the report.
|
||||
+ *
|
||||
+ * This function can be called from any context.
|
||||
+ */
|
||||
+void ieee80211_links_removed(struct ieee80211_vif *vif, u16 links);
|
||||
+
|
||||
+/**
|
||||
* ieee80211_proberesp_get - retrieve a Probe Response template
|
||||
* @hw: pointer obtained from ieee80211_alloc_hw().
|
||||
* @vif: &struct ieee80211_vif pointer from the add_interface callback.
|
||||
--- a/net/mac80211/ieee80211_i.h
|
||||
+++ b/net/mac80211/ieee80211_i.h
|
||||
@@ -1293,6 +1293,10 @@ struct ieee80211_sub_if_data {
|
||||
struct wiphy_work activate_links_work;
|
||||
u16 desired_active_links;
|
||||
|
||||
+ /* for ieee80211_links_removed() */
|
||||
+ struct wiphy_work links_removed_work;
|
||||
+ atomic_t links_removed;
|
||||
+
|
||||
u16 restart_active_links;
|
||||
|
||||
#ifdef CPTCFG_MAC80211_DEBUGFS
|
||||
--- a/net/mac80211/iface.c
|
||||
+++ b/net/mac80211/iface.c
|
||||
@@ -877,6 +877,8 @@ static int ieee80211_stop(struct net_dev
|
||||
guard(wiphy)(sdata->local->hw.wiphy);
|
||||
|
||||
wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->activate_links_work);
|
||||
+ wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->links_removed_work);
|
||||
+ atomic_set(&sdata->links_removed, 0);
|
||||
|
||||
/* Close the dependent MBSSID interfaces with wiphy lock as we may be
|
||||
* terminating its partner links too in case of MLD.
|
||||
@@ -921,6 +923,9 @@ static void ieee80211_teardown_sdata(str
|
||||
if (WARN_ON(!list_empty(&sdata->work.entry)))
|
||||
wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->work);
|
||||
|
||||
+ /* the driver can report links until it removes the interface */
|
||||
+ wiphy_work_cancel(sdata->local->hw.wiphy, &sdata->links_removed_work);
|
||||
+
|
||||
/* free extra data */
|
||||
ieee80211_free_keys(sdata, false);
|
||||
|
||||
@@ -1909,6 +1914,35 @@ static void ieee80211_activate_links_wor
|
||||
sdata->desired_active_links = 0;
|
||||
}
|
||||
|
||||
+static void ieee80211_links_removed_work(struct wiphy *wiphy,
|
||||
+ struct wiphy_work *work)
|
||||
+{
|
||||
+ struct ieee80211_sub_if_data *sdata =
|
||||
+ container_of(work, struct ieee80211_sub_if_data,
|
||||
+ links_removed_work);
|
||||
+ u16 links = atomic_xchg(&sdata->links_removed, 0);
|
||||
+ u16 valid_links = sdata->wdev.valid_links;
|
||||
+
|
||||
+ /* a link that user space removed meanwhile is gone already */
|
||||
+ links &= valid_links;
|
||||
+ if (!ieee80211_sdata_running(sdata) || !links || links == valid_links)
|
||||
+ return;
|
||||
+
|
||||
+ cfg80211_links_removed(sdata->dev, links);
|
||||
+}
|
||||
+
|
||||
+void ieee80211_links_removed(struct ieee80211_vif *vif, u16 links)
|
||||
+{
|
||||
+ struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
|
||||
+
|
||||
+ if (WARN_ON(vif->type != NL80211_IFTYPE_AP || !links))
|
||||
+ return;
|
||||
+
|
||||
+ atomic_or(links, &sdata->links_removed);
|
||||
+ wiphy_work_queue(sdata->local->hw.wiphy, &sdata->links_removed_work);
|
||||
+}
|
||||
+EXPORT_SYMBOL_GPL(ieee80211_links_removed);
|
||||
+
|
||||
/*
|
||||
* Helper function to initialise an interface to a specific type.
|
||||
*/
|
||||
@@ -1947,6 +1981,9 @@ static void ieee80211_setup_sdata(struct
|
||||
wiphy_work_init(&sdata->work, ieee80211_iface_work);
|
||||
wiphy_work_init(&sdata->activate_links_work,
|
||||
ieee80211_activate_links_work);
|
||||
+ wiphy_work_init(&sdata->links_removed_work,
|
||||
+ ieee80211_links_removed_work);
|
||||
+ atomic_set(&sdata->links_removed, 0);
|
||||
|
||||
switch (type) {
|
||||
case NL80211_IFTYPE_P2P_GO:
|
||||
Reference in new issue
Block a user