diff mbox

[RFC,v2,2/2] mac80211: only set CSA beacon when at least one beacon must be transmitted

Message ID 1383684854-21663-2-git-send-email-luciano.coelho@intel.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Luca Coelho Nov. 5, 2013, 8:54 p.m. UTC
With a CSA count of 0, we won't transmit any CSA beacons, because the
switch will happen before the next TBTT.  To avoid extra work and
potential confusion in the drivers, complete the CSA immediately,
instead of waiting for the driver to call ieee80211_csa_finish().

To keep things simpler, we also switch immediately when the CSA count
is 1, while in theory we should delay the switch until just before the
next TBTT.

Additionally, move the ieee80211_csa_finish() function to cfg.c,
where it makes more sense (and since we call it from cfg.c now).

Cc: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---
Simon, I think with this we won't need any changes in ath9k, right?
---
 net/mac80211/cfg.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++------
 net/mac80211/tx.c  |  9 ---------
 2 files changed, 48 insertions(+), 15 deletions(-)

Comments

Johannes Berg Nov. 6, 2013, 10:51 a.m. UTC | #1
On Tue, 2013-11-05 at 22:54 +0200, Luciano Coelho wrote:
> With a CSA count of 0, we won't transmit any CSA beacons, because the
> switch will happen before the next TBTT.  To avoid extra work and
> potential confusion in the drivers, complete the CSA immediately,
> instead of waiting for the driver to call ieee80211_csa_finish().

Does it make sense to go to the workqueue rather than do it inline?

Maybe we should just reject this? I'm a bit worried that this might
confuse drivers that expect a certain order of calls?

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luca Coelho Nov. 6, 2013, 11:28 a.m. UTC | #2
T24gV2VkLCAyMDEzLTExLTA2IGF0IDExOjUxICswMTAwLCBKb2hhbm5lcyBCZXJnIHdyb3RlOg0K
PiBPbiBUdWUsIDIwMTMtMTEtMDUgYXQgMjI6NTQgKzAyMDAsIEx1Y2lhbm8gQ29lbGhvIHdyb3Rl
Og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gY291bnQgYmVjb21lcyAxOw0KNC4gV2UgY2FsbCBk
cnZfY2hhbmdlX2NoYW5jdHgoKTsNCjUuIFNldCBuZXcgY2hhbm5lbCBiZWFjb24uDQoNCldpdGgg
dGhpcywgd2UgZ2V0IHNvbWUgdXNlbGVzcyBjaHVybiBhbmQgbmVlZCB0byBtYWtlIHN1cmUgdGhl
IGRyaXZlcnMNCmRvIHRoZSByaWdodCB0aGluZy4uLg0KDQpEbyB5b3UgaGF2ZSBhbnkgb3RoZXIg
cHJvcG9zYWw/DQoNCi0tDQpDaGVlcnMsDQpMdWNhLg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Nov. 6, 2013, 11:31 a.m. UTC | #3
On Wed, 2013-11-06 at 11:28 +0000, Coelho, Luciano wrote:

> In terms of the order of calls, the difference is that in the past we
> had this:
> 
> 1. Set CSA beacon;
> 2. When count reaches 1, the driver calls ieee80211_csa_finish();
> 3. We call drv_change_chanctx();
> 4. Set new channel beacon.
> 
> (This continues to be the case with my patch when count > 1)
> 
> With my patch, if count <= 1, we do this instead:
> 
> 1. Call drv_change_chanctx();
> 2. Set new channel beacon.
> 
> The main problem without my patch is that the driver shouldn't beacon
> with the CSA element when the count starts <= 1, so it won't have a
> chance to check if the count reached 1 to call ieee80211_csa_finish().

I think the other difference is that one calls
drv_channel_switch_beacon()? The driver might do some channel
preparations there, though I guess you can audit all the drivers (well,
one ...) :)

But that'd need some more documentation, otherwise I'd guess people
would start to rely on drv_channel_switch_beacon() and it would mostly
work - hence my question of whether it makes sense to refuse it at all
in the case of <=1.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Simon Wunderlich Nov. 6, 2013, 11:47 a.m. UTC | #4
Hey Luca,

> With a CSA count of 0, we won't transmit any CSA beacons, because the
> switch will happen before the next TBTT.  To avoid extra work and
> potential confusion in the drivers, complete the CSA immediately,
> instead of waiting for the driver to call ieee80211_csa_finish().
> 
> To keep things simpler, we also switch immediately when the CSA count
> is 1, while in theory we should delay the switch until just before the
> next TBTT.
> 
> Additionally, move the ieee80211_csa_finish() function to cfg.c,
> where it makes more sense (and since we call it from cfg.c now).
> 
> Cc: Simon Wunderlich <sw@simonwunderlich.de>
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
> ---
> Simon, I think with this we won't need any changes in ath9k, right?

I think you still need to change ieee80211_ibss_process_chanswitch() which 
also calls ieee80211_ibss_csa_beacon() and drv_channel_switch_beacon().

Also, I don't think that this is sufficient for IBSS mode - changing immediately 
without sending any action frame will just split the IBSS network. Action 
frames are currently set in ieee80211_ibss_csa_beacon() as well, with this 
change we should probably move that to another position.

Even if we don't allow count <=1 from userspace as Johannes suggested, we 
still have to fix the CSA handling from other STAs in IBSS.

Cheers,
    Simon
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luca Coelho Nov. 6, 2013, 11:52 a.m. UTC | #5
T24gV2VkLCAyMDEzLTExLTA2IGF0IDEyOjMxICswMTAwLCBKb2hhbm5lcyBCZXJnIHdyb3RlOg0K
PiBPbiBXZWQsIDIwMTMtMTEtMDYgYXQgMTE6MjggKzAwMDAsIENvZWxobywgTHVjaWFubyB3cm90
ZToNCj4gDQo+ID4gSW4gdGVybXMgb2YgdGhlIG9yZGVyIG9mIGNhbGxzLCB0aGUgZGlmZmVyZW5j
ZSBpcyB0aGF0IGluIHRoZSBwYXN0IHdlDQo+ID4gaGFkIHRoaXM6DQo+ID4gDQo+ID4gMS4gU2V0
IENTQSBiZWFjb247DQo+ID4gMi4gV2hlbiBjb3VudCByZWFjaGVzIDEsIHRoZSBkcml2ZXIgY2Fs
bHMgaWVlZTgwMjExX2NzYV9maW5pc2goKTsNCj4gPiAzLiBXZSBj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Bjb3Vu
dCBzdGFydHMgYXMgemVybyBvciAxLCB0aGlzIGZ1bmN0aW9uIHdpbGwgbm90IGJlIGNhbGxlZCwN
Cj4gKyAqICAgICBzaW5jZSB0aGVyZSB3b24ndCBiZSBhbnkgdGltZSB0byBiZWFjb24gYmVmb3Jl
IHRoZSBzd2l0Y2ggYW55d2F5Lg0KDQpUaGlzIGNoYW5nZSBzaG91bGQgYmUgaW4gcGF0Y2ggMi8y
IChhY3R1YWxseSB0aGVzZSB0d28gcGF0Y2hlcyBzaG91bGQNCnByb2JhYmx5IGJlIHNxdWFzaGVk
LCBJIGp1c3Qga2VwdCB0aGVtIHNlcGFyYXRlIHNvIHRoYXQgcmV2aWV3aW5nIG15IHYyDQp3b3Vs
ZCBiZSBlYXNpZXIpLg0KDQpJIGNhbiBlbGFib3JhdGUgbW9yZSBpbiB0aGUgZG9jdW1lbnRhdGlv
biBpZiB5b3UgdGhpbmsgaXQncyBuZWNlc3NhcnkuDQoNCi0tDQpDaGVlcnMsDQpMdWNhLg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luca Coelho Nov. 6, 2013, 12:03 p.m. UTC | #6
T24gV2VkLCAyMDEzLTExLTA2IGF0IDEyOjQ3ICswMTAwLCBTaW1vbiBXdW5kZXJsaWNoIHdyb3Rl
Og0KPiBIZXkgTHVjYSwNCj4gDQo+ID4gV2l0aCBhIENTQSBjb3VudCBvZiAwLCB3ZSB3b24ndCB0
cmFuc21pdCBhbnkgQ1NBIGJlYWNvbnMsIGJlY2F1c2UgdGhlDQo+ID4gc3dpdGNoIHdpbGwgaGFw
cGVuIGJlZm9yZSB0aGUgbmV4dCBUQlRULiAgVG8gYXZvaWQgZXh0cmEgd29yayBhbmQNCj4gPiBw
b3RlbnRpYWwgY29uZnVzaW9uIGluIHRoZSBkcml2ZXJzLCBjb21wbGV0ZSB0aGUgQ1NBIGltbWVk
aWF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uICBJIHRob3VnaHQgaGUgbWVhbnQgdG8gcmVq
ZWN0IHRoZQ0KcGF0Y2guIDpQDQoNClJlamVjdGluZyBjb3VudCA8PSAxIGNvdWxkIGJlIGEgdGVt
cG9yYXJ5IHNvbHV0aW9uIHVudGlsIHdlIGltcGxlbWVudA0KdGhlIGFjdGlvbiBmcmFtZXMgcHJv
cGVybHkuICBVbmxlc3Mgd2UgZGVjaWRlIHRoYXQgdGhlIGFjdGlvbiBmcmFtZXMNCnNob3VsZCBi
ZSBoYW5kbGVkIGluIHVzZXJzcGFjZSBhcyB5b3UgcHJvcG9zZWQuDQoNCj4gd2Ugc3RpbGwgaGF2
ZSB0byBmaXggdGhlIENTQSBoYW5kbGluZyBmcm9tIG90aGVyIFNUQXMgaW4gSUJTUy4NCg0KV2hh
dCBkbyB5b3UgbWVhbj8gQmVjYXVzZSB0aGV5IGFyZSB3YWl0aW5nIGZvciBiZWFjb24gd2l0aCBj
b3VudCA9PSAwDQpiZWZvcmUgc3dpdGNoaW5nPyBJIGd1ZXNzIHRoaXMgaXMgYWxzbyB3cm9uZyBp
biBCU1MgU1RBcy4gIEknbGwgY2hlY2suDQoNCi0tDQpMdWNhLg0K
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Nov. 6, 2013, 12:06 p.m. UTC | #7
On Wed, 2013-11-06 at 11:52 +0000, Coelho, Luciano wrote:

> Right.  I actually added this to the documentation, but I accidentally
> sent it as part of patch 1/2:
> 
> > +++ b/include/net/mac80211.h
> > @@ -2676,11 +2676,13 @@ enum ieee80211_roc_type {
> >   * @channel_switch_beacon: Starts a channel switch to a new channel.
> [...]
> > + *     If the CSA count starts as zero or 1, this function will not be called,
> > + *     since there won't be any time to beacon before the switch anyway.
> 
> This change should be in patch 2/2 (actually these two patches should
> probably be squashed, I just kept them separate so that reviewing my v2
> would be easier).
> 
> I can elaborate more in the documentation if you think it's necessary.

Ah, ok, I guess that's fine.

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Johannes Berg Nov. 6, 2013, 12:06 p.m. UTC | #8
On Wed, 2013-11-06 at 12:03 +0000, Coelho, Luciano wrote:

> > Even if we don't allow count <=1 from userspace as Johannes suggested,
> 
> Ah, I had misunderstood Johannes.  I thought he meant to reject the
> patch. :P
> 
> Rejecting count <= 1 could be a temporary solution until we implement
> the action frames properly.  Unless we decide that the action frames
> should be handled in userspace as you proposed.

Well even then - the question is who would ever want to use and test
count<=1?

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Luca Coelho Nov. 6, 2013, 12:22 p.m. UTC | #9
On Wed, 2013-11-06 at 13:06 +0100, Johannes Berg wrote:
> On Wed, 2013-11-06 at 12:03 +0000, Coelho, Luciano wrote:

> 

> > > Even if we don't allow count <=1 from userspace as Johannes suggested,

> > 

> > Ah, I had misunderstood Johannes.  I thought he meant to reject the

> > patch. :P

> > 

> > Rejecting count <= 1 could be a temporary solution until we implement

> > the action frames properly.  Unless we decide that the action frames

> > should be handled in userspace as you proposed.

> 

> Well even then - the question is who would ever want to use and test

> count<=1?


I guess the reason to have this is when you must evacuate the channel
immediately, so you transmit the action frame and jump out.  If your
beacon interval is long (for whatever reason), waiting for the next TBTT
to announce the CSA may take longer than the time required to stop
transmitting.

Also, in a "stop transmitting immediately" scenario, using an action
frame with count <= 1 helps reduce data hiccups that would happen if
count > 1 and the channel switch mode is "don't transmit".

--
Luca.
Johannes Berg Nov. 6, 2013, 12:36 p.m. UTC | #10
On Wed, 2013-11-06 at 12:22 +0000, Coelho, Luciano wrote:

> > Well even then - the question is who would ever want to use and test
> > count<=1?
> 
> I guess the reason to have this is when you must evacuate the channel
> immediately, so you transmit the action frame and jump out.  If your
> beacon interval is long (for whatever reason), waiting for the next TBTT
> to announce the CSA may take longer than the time required to stop
> transmitting.

Fair point, so I guess we'd want to also test that :)

johannes

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index b0a651c..fe5de2c 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -2854,6 +2854,15 @@  cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
 	return new_beacon;
 }
 
+void ieee80211_csa_finish(struct ieee80211_vif *vif)
+{
+	struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
+
+	ieee80211_queue_work(&sdata->local->hw,
+			     &sdata->csa_finalize_work);
+}
+EXPORT_SYMBOL(ieee80211_csa_finish);
+
 void ieee80211_csa_finalize_work(struct work_struct *work)
 {
 	struct ieee80211_sub_if_data *sdata =
@@ -2912,7 +2921,7 @@  static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 	struct ieee80211_local *local = sdata->local;
 	struct ieee80211_chanctx_conf *chanctx_conf;
 	struct ieee80211_chanctx *chanctx;
-	int err, num_chanctx;
+	int err, num_chanctx, changed = 0;
 
 	if (!list_empty(&local->roc_list) || local->scanning)
 		return -EBUSY;
@@ -2951,19 +2960,42 @@  static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 
 	switch (sdata->vif.type) {
 	case NL80211_IFTYPE_AP:
-		sdata->csa_counter_offset_beacon =
-			params->counter_offset_beacon;
-		sdata->csa_counter_offset_presp = params->counter_offset_presp;
 		sdata->u.ap.next_beacon =
 			cfg80211_beacon_dup(&params->beacon_after);
 		if (!sdata->u.ap.next_beacon)
 			return -ENOMEM;
 
+		/*
+		 * With a count of 0, we don't have to wait for any
+		 * TBTT before switching, so complete the CSA
+		 * immediately.  In theory, with a count == 1 we
+		 * should delay the switch until just before the next
+		 * TBTT, but that would complicate things so we switch
+		 * immediately too.  If we would delay the switch
+		 * until the next TBTT, we would have to set the probe
+		 * response here.
+		 *
+		 * TODO: A channel switch with count <= 1 without
+		 * sending a CSA action frame is kind of useless,
+		 * because the clients won't know we're changing
+		 * channels.  The action frame must be implemented
+		 * either here or in the userspace.
+		 */
+		if (params->count <= 1) {
+			ieee80211_csa_finish(&sdata->vif);
+			break;
+		}
+
+		sdata->csa_counter_offset_beacon =
+			params->counter_offset_beacon;
+		sdata->csa_counter_offset_presp = params->counter_offset_presp;
 		err = ieee80211_assign_beacon(sdata, &params->beacon_csa);
 		if (err < 0) {
 			kfree(sdata->u.ap.next_beacon);
 			return err;
 		}
+		changed |= err;
+
 		break;
 	case NL80211_IFTYPE_ADHOC:
 		if (!sdata->vif.bss_conf.ibss_joined)
@@ -2991,9 +3023,17 @@  static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 		    params->chandef.chan->band)
 			return -EINVAL;
 
+		/* see comments and TODO in the NL80211_IFTYPE_AP block */
+		if (params->count <= 1) {
+			ieee80211_csa_finish(&sdata->vif);
+			break;
+		}
+
 		err = ieee80211_ibss_csa_beacon(sdata, params);
 		if (err < 0)
 			return err;
+		changed |= err;
+
 		break;
 	default:
 		return -EOPNOTSUPP;
@@ -3009,8 +3049,10 @@  static int ieee80211_channel_switch(struct wiphy *wiphy, struct net_device *dev,
 	local->csa_chandef = params->chandef;
 	sdata->vif.csa_active = true;
 
-	ieee80211_bss_info_change_notify(sdata, err);
-	drv_channel_switch_beacon(sdata, &params->chandef);
+	ieee80211_bss_info_change_notify(sdata, changed);
+
+	if (params->count > 1)
+		drv_channel_switch_beacon(sdata, &params->chandef);
 
 	return 0;
 }
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 1e0d40f..ac4b79f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2343,15 +2343,6 @@  static int ieee80211_beacon_add_tim(struct ieee80211_sub_if_data *sdata,
 	return 0;
 }
 
-void ieee80211_csa_finish(struct ieee80211_vif *vif)
-{
-	struct ieee80211_sub_if_data *sdata = vif_to_sdata(vif);
-
-	ieee80211_queue_work(&sdata->local->hw,
-			     &sdata->csa_finalize_work);
-}
-EXPORT_SYMBOL(ieee80211_csa_finish);
-
 static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
 				 struct beacon_data *beacon)
 {