mac80211 remain-on-channel unification
Subsystems (2)
Johannes Berg
maintainercover mac80211 remain-on-channel unification
We found major bugs with the mac80211 ROC code in particular in the offloaded case.
As a result, I've decided to get rid of the pseudo- generic "off-channel work" code since it's not used any more except for remain-on-channel and instead have written new ROC support that is more unified between SW and HW implementations, in particular wrt. merging etc.
This is also going to be the long-term trend: with multi-channel getting closer, we don't want to have to deal with this in mac80211 as much any more as it's all timing sensitive.
johannes
Johannes Berg
maintainerPATCH 1/3 mac80211: do remain-on-channel while idle
From: Johannes Berg <[email protected]>
The IDLE handling in HW off-channel is broken right now since we turn off IDLE only when the off-channel period already started. Therefore, all drivers that use it today (only iwlwifi!) must support off-channel while idle, so playing with idle isn't needed at all.
Off-channel in general, since it's no longer used for authentication/association, shouldn't affect PS, so also remove that logic.
Also document a small caveat for reporting TX status from off-channel frames in HW remain-on-channel.
--- include/net/mac80211.h | 8 +++++++- net/mac80211/cfg.c | 7 +++---- net/mac80211/iface.c | 17 +++++++---------- net/mac80211/mlme.c | 6 ------ net/mac80211/offchannel.c | 4 ---- 5 files changed, 17 insertions(+), 25 deletions(-)
include/net/mac80211.h +7 -1
@@ -2178,7 +2178,13 @@ enum ieee80211_rate_control_changed {* offload. Frames to transmit on the off-channel channel are transmitted * normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the * duration (which will always be non-zero) expires, the driver must call -* ieee80211_remain_on_channel_expired(). This callback may sleep. +* ieee80211_remain_on_channel_expired(). +* The driver must not call ieee80211_remain_on_channel_expired() before +* the TX status for a frame that was sent off-channel, otherwise the TX +* status is reported to userspace in an invalid way. +* Note that this callback may be called while the device is in IDLE and +* must be accepted in this case. +* This callback may sleep. * @cancel_remain_on_channel: Requests that an ongoing off-channel period is * aborted before it expires. This callback may sleep. *
net/mac80211/cfg.c +3 -4
@@ -2187,8 +2187,6 @@ static int ieee80211_cancel_remain_on_ch local->hw_roc_cookie =0 ; local->hw_roc_channel =NULL ; -ieee80211_recalc_idle (local); -return 0 ; }
@@ -2248,7 +2246,7 @@ static int ieee80211_mgmt_tx(struct wiphstruct ieee80211_work *wk;const struct ieee80211_mgmt *mgmt = (void *)buf;u32 flags; -bool is_offchan = false; +bool is_offchan = false, in_hw_roc = false;if (dont_wait_for_ack) flags =IEEE80211_TX_CTL_NO_ACK ;
@@ -2268,6 +2266,7 @@ static int ieee80211_mgmt_tx(struct wiphif (chan == local->hw_roc_channel) {/* TODO: check channel type? */ is_offchan = false; + in_hw_roc = true; flags |=IEEE80211_TX_CTL_TX_OFFCHAN ; }
@@ -2368,7 +2367,7 @@ static int ieee80211_mgmt_tx(struct wiph* wait is involved, we might otherwise not be on * the right channel for long enough! */ -if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) { +if (!is_offchan && !wait && (in_hw_roc || !sdata->vif.bss_conf.idle)) {ieee80211_tx_skb (sdata, skb);return 0 ; }
net/mac80211/iface.c +7 -10
@@ -1442,7 +1442,7 @@ u32 __ieee80211_recalc_idle(struct ieee8 {struct ieee80211_sub_if_data *sdata;int count =0 ; -bool working = false, scanning = false, hw_roc = false; +bool working = false, scanning = false;struct ieee80211_work *wk;unsigned int led_trig_start =0 , led_trig_stop =0 ;
@@ -1479,9 +1479,11 @@ u32 __ieee80211_recalc_idle(struct ieee8 count++; } -list_for_each_entry (wk, &local->work_list, list) { - working = true; - wk->sdata->vif.bss_conf.idle = false; +if (!local->ops->remain_on_channel) { +list_for_each_entry (wk, &local->work_list, list) { + working = true; + wk->sdata->vif.bss_conf.idle = false; + } } if (local->scan_sdata &&
@@ -1490,9 +1492,6 @@ u32 __ieee80211_recalc_idle(struct ieee8 local->scan_sdata->vif.bss_conf.idle = false; } -if (local->hw_roc_channel) - hw_roc = true; -list_for_each_entry (sdata, &local->interfaces, list) {if (sdata->vif.type ==NL80211_IFTYPE_MONITOR || sdata->vif.type ==NL80211_IFTYPE_AP_VLAN )
@@ -1504,7 +1503,7 @@ u32 __ieee80211_recalc_idle(struct ieee8ieee80211_bss_info_change_notify (sdata,BSS_CHANGED_IDLE ); } -if (working || scanning || hw_roc) +if (working || scanning) led_trig_start |=IEEE80211_TPT_LEDTRIG_FL_WORK ;else led_trig_stop |=IEEE80211_TPT_LEDTRIG_FL_WORK ;
@@ -1516,8 +1515,6 @@ u32 __ieee80211_recalc_idle(struct ieee8ieee80211_mod_tpt_led_trig (local, led_trig_start, led_trig_stop); -if (hw_roc) -return ieee80211_idle_off (local,"hw remain-on-channel" );if (working)return ieee80211_idle_off (local,"working" );if (scanning)
net/mac80211/offchannel.c +0 -4
@@ -207,8 +207,6 @@ static void ieee80211_hw_roc_start(struc GFP_KERNEL); } -ieee80211_recalc_idle (local); -mutex_unlock (&local->mtx); }
@@ -244,8 +242,6 @@ static void ieee80211_hw_roc_done(struct local->hw_roc_channel =NULL ; local->hw_roc_cookie =0 ; -ieee80211_recalc_idle (local); -mutex_unlock (&local->mtx); }
net/mac80211/mlme.c +0 -6
@@ -930,11 +930,6 @@ void ieee80211_recalc_ps(struct ieee8021return ; } -if (!list_empty (&local->work_list)) { - local->ps_sdata =NULL ; - goto change; - } -list_for_each_entry (sdata, &local->interfaces, list) {if (!ieee80211_sdata_running (sdata))continue ;
@@ -1007,7 +1002,6 @@ void ieee80211_recalc_ps(struct ieee8021 local->ps_sdata =NULL ; } - change:ieee80211_change_ps (local); }
Johannes Berg
maintainerPATCH 2/3 cfg80211: validate remain-on-channel time better
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
The remain-on-channel time validation shouldn't depend on the value of HZ, as it does now with the check against jiffies, since then you might use a value that works on one system but not on another. Fix it by checking against a minimum that's fixed.
Also add validation of the wait duration for a management frame TX since this also translates into remain-on-channel internally.
--- include/linux/nl80211.h | 2 ++ net/wireless/nl80211.c | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-)
include/linux/nl80211.h +2 -0
@@ -1522,6 +1522,8 @@ enum nl80211_attrs {#define NL80211_MAX_NR_CIPHER_SUITES 5#define NL80211_MAX_NR_AKM_SUITES 2 +#define NL80211_MIN_REMAIN_ON_CHANNEL_TIME 10 +/** * enum nl80211_iftype - (virtual) interface types *
net/wireless/nl80211.c +16 -7
@@ -5545,18 +5545,18 @@ static int nl80211_remain_on_channel(str duration =nla_get_u32 (info->attrs[NL80211_ATTR_DURATION ]); +if (!rdev->ops->remain_on_channel || + !(rdev->wiphy.flags &WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL )) +return -EOPNOTSUPP ; +/* -* We should be on that channel for at least one jiffie, -* and more than 5 seconds seems excessive. +* We should be on that channel for at least a minimum amount of +* time (10ms) but no longer than the driver supports. */ -if (!duration || !msecs_to_jiffies (duration) || +if (duration <NL80211_MIN_REMAIN_ON_CHANNEL_TIME || duration > rdev->wiphy.max_remain_on_channel_duration)return -EINVAL ; -if (!rdev->ops->remain_on_channel || - !(rdev->wiphy.flags &WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL )) -return -EOPNOTSUPP ; -if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE ] && !nl80211_valid_channel_type (info, &channel_type))return -EINVAL ;
@@ -5827,6 +5827,15 @@ static int nl80211_tx_mgmt(struct sk_bufif (!(rdev->wiphy.flags &WIPHY_FLAG_OFFCHAN_TX ))return -EINVAL ; wait =nla_get_u32 (info->attrs[NL80211_ATTR_DURATION ]); + +/* +* We should wait on the channel for at least a minimum amount +* of time (10ms) but no longer than the driver supports. +*/ +if (wait <NL80211_MIN_REMAIN_ON_CHANNEL_TIME || + wait > rdev->wiphy.max_remain_on_channel_duration) +return -EINVAL ; + }if (info->attrs[NL80211_ATTR_WIPHY_CHANNEL_TYPE ]) {
Johannes Berg
maintainerPATCH 3/3 mac80211: unify SW/offload remain-on-channel
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Redesign all the off-channel code, getting rid of the generic off-channel work concept, replacing it with a simple remain-on-channel list.
This fixes a number of small issues with the ROC implementation:
* offloaded remain-on-channel couldn't be queued, now we can queue it as well, if needed
* in iwlwifi (the only user) offloaded ROC is mutually exclusive with scanning, use the new queue to handle that case -- I expect that it will later depend on a HW flag
The bigger issue though is that there's a bad bug in the current implementation: if we get a mgmt TX request while HW roc is active, and this new request has a wait time, we actually schedule a software ROC instead since we can't guarantee the existing offloaded ROC will still be that long. To fix this, the queuing mechanism was needed.
The queuing mechanism for offloaded ROC isn't yet optimal, ideally we should add API to have the HW extend the ROC if needed. We could add that later but for now use a software implementation.
Overall, this unifies the behaviour between the offloaded and software-implemented case as much as possible.
---
v2: fix locking & use ieee80211_queue_delayed_work (Eliad)
include/net/mac80211.h | 3 net/mac80211/Makefile | 1 net/mac80211/cfg.c | 472 ++++++++++++++++++++++++--------------------- net/mac80211/ieee80211_i.h | 89 ++------ net/mac80211/iface.c | 23 -- net/mac80211/main.c | 10 net/mac80211/offchannel.c | 284 ++++++++++++++++++++++----- net/mac80211/scan.c | 4 net/mac80211/status.c | 28 -- net/mac80211/work.c | 370 ----------------------------------- 10 files changed, 532 insertions(+), 752 deletions(-)
net/mac80211/Makefile +0 -1
@@ -9,7 +9,6 @@ mac80211-y := \ scan.o offchannel.o \ ht.o agg-tx.o agg-rx.o \ ibss.o \ - work.o \ iface.o \ rate.o \ michael.o \
net/mac80211/ieee80211_i.h +24 -65
131 lines not on this page · raw message
net/mac80211/iface.c +4 -19
@@ -528,10 +528,7 @@ static void ieee80211_do_stop(struct iee*/ netif_tx_stop_all_queues (sdata->dev); -/* -* Purge work for this interface. -*/ -ieee80211_work_purge (sdata); +ieee80211_roc_purge (sdata);/* * Remove all stations associated with this interface.
@@ -637,18 +634,6 @@ static void ieee80211_do_stop(struct ieeieee80211_configure_filter (local);break ;default : -mutex_lock (&local->mtx); -if (local->hw_roc_dev == sdata->dev && - local->hw_roc_channel) { -/* ignore return value since this is racy */ -drv_cancel_remain_on_channel (local); -ieee80211_queue_work (&local->hw, &local->hw_roc_done); - } -mutex_unlock (&local->mtx); - -flush_work (&local->hw_roc_start); -flush_work (&local->hw_roc_done); -flush_work (&sdata->work);/* * When we get here, the interface is marked down.
@@ -1455,8 +1440,8 @@ u32 __ieee80211_recalc_idle(struct ieee8struct ieee80211_sub_if_data *sdata;int count =0 ;bool working = false, scanning = false; -struct ieee80211_work *wk;unsigned int led_trig_start =0 , led_trig_stop =0 ; +struct ieee80211_roc_work *roc;#ifdef CONFIG_PROVE_LOCKING WARN_ON(debug_locks && !lockdep_rtnl_is_held() &&
@@ -1492,9 +1477,9 @@ u32 __ieee80211_recalc_idle(struct ieee8 }if (!local->ops->remain_on_channel) { -list_for_each_entry (wk, &local->work_list, list) { +list_for_each_entry (roc, &local->roc_list, list) { working = true; - wk->sdata->vif.bss_conf.idle = false; + roc->sdata->vif.bss_conf.idle = false; } }
net/mac80211/main.c +1 -9
@@ -625,8 +625,6 @@ struct ieee80211_hw *ieee80211_alloc_hw(INIT_DELAYED_WORK (&local->scan_work, ieee80211_scan_work); -ieee80211_work_init (local); -INIT_WORK (&local->restart_work, ieee80211_restart_work);INIT_WORK (&local->reconfig_filter, ieee80211_reconfig_filter);
@@ -669,7 +667,7 @@ struct ieee80211_hw *ieee80211_alloc_hw(ieee80211_led_names (local); -ieee80211_hw_roc_setup (local); +ieee80211_roc_setup (local);return &local->hw; }
@@ -1009,12 +1007,6 @@ void ieee80211_unregister_hw(struct ieeertnl_unlock (); -/* -* Now all work items will be gone, but the -* timer might still be armed, so delete it -*/ -del_timer_sync (&local->work_timer); -cancel_work_sync (&local->restart_work);cancel_work_sync (&local->reconfig_filter);
net/mac80211/scan.c +2 -2
@@ -324,7 +324,7 @@ static void __ieee80211_scan_completed(sieee80211_mlme_notify_scan_completed (local);ieee80211_ibss_notify_scan_completed (local);ieee80211_mesh_notify_scan_completed (local); -ieee80211_queue_work (&local->hw, &local->work_work); +ieee80211_start_next_roc (local); }void ieee80211_scan_completed (struct ieee80211_hw *hw,bool aborted)
@@ -377,7 +377,7 @@ static int ieee80211_start_sw_scan(strucstatic bool ieee80211_can_scan (struct ieee80211_local *local,struct ieee80211_sub_if_data *sdata) { -if (!list_empty (&local->work_list)) +if (!list_empty (&local->roc_list))return false; if (sdata->vif.type == NL80211_IFTYPE_STATION &&
net/mac80211/status.c +4 -24
@@ -520,36 +520,16 @@ void ieee80211_tx_status(struct ieee8021if (info->flags &IEEE80211_TX_INTFL_NL80211_FRAME_TX ) {u64 cookie = (unsigned long )skb; + acked = info->flags &IEEE80211_TX_STAT_ACK ;if (ieee80211_is_nullfunc (hdr->frame_control) || -ieee80211_is_qos_nullfunc (hdr->frame_control)) { - acked = info->flags &IEEE80211_TX_STAT_ACK ; - +ieee80211_is_qos_nullfunc (hdr->frame_control))cfg80211_probe_status (skb->dev, hdr->addr1, cookie, acked,GFP_ATOMIC ); - }else { -struct ieee80211_work *wk; - -rcu_read_lock (); -list_for_each_entry_rcu (wk, &local->work_list, list) { -if (wk->type !=IEEE80211_WORK_OFFCHANNEL_TX ) -continue ; -if (wk->offchan_tx.frame != skb) -continue ; - wk->offchan_tx.status = true; -break ; - } -rcu_read_unlock (); -if (local->hw_roc_skb_for_status == skb) { - cookie = local->hw_roc_cookie ^2 ; - local->hw_roc_skb_for_status =NULL ; - } - +else cfg80211_mgmt_tx_status ( skb->dev, cookie, skb->data, skb->len, - !!(info->flags &IEEE80211_TX_STAT_ACK ), -GFP_ATOMIC ); - } + acked,GFP_ATOMIC ); }if (unlikely (info->ack_frame_id)) {
net/mac80211/work.c deleted +0 -370
370 lines not on this page · raw message
net/mac80211/cfg.c +257 -215
568 lines not on this page · raw message
net/mac80211/offchannel.c +240 -44
336 lines not on this page · raw message
include/net/mac80211.h +0 -3
@@ -2184,9 +2184,6 @@ enum ieee80211_rate_control_changed {* normally except for the %IEEE80211_TX_CTL_TX_OFFCHAN flag. When the * duration (which will always be non-zero) expires, the driver must call * ieee80211_remain_on_channel_expired(). -* The driver must not call ieee80211_remain_on_channel_expired() before -* the TX status for a frame that was sent off-channel, otherwise the TX -* status is reported to userspace in an invalid way. * Note that this callback may be called while the device is in IDLE and * must be accepted in this case. * This callback may sleep.