diff mbox

[RFC] mac80211: don't transmit beacon with CSA count 0

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

Commit Message

Luca Coelho Nov. 4, 2013, 12:59 p.m. UTC
A beacon should never have a Channel Switch Announcement information
element with a count of 0, because a count of 1 means switch just
before the next beacon.  So, if a count of 0 was valid in a beacon, it
would have been transmitted in the next channel already, which is
useless.  A CSA count equal to zero is only meaningful in action
frames or probe_responses.

Fix the ieee80211_csa_is_complete() and ieee80211_update_csa()
functions accordingly.

Cc: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
---

Hi Simon (et al),

I identified this issue while playing around with CSA.  I noticed that
we are sending a CSA beaon with count == 0, which should not happen.
The last beacon visible in the current channel (ie. before the switch)
contains a CSA IE with count == 1.

I wanted to check with you if my proposed change would have any
side-effects, especially with the ath9k driver, which is the only user
of this code in the mainline at the moment.

The potential danger here is if you don't check
ieee80211_csa_is_complete() before you send the first CSA beacon out.
With the previous code, there would always be a beacon with CSA (count
== 0), but now, if the count starts with 1, there won't be any.  If
you don't check, my patch will probably introduce a WARN when the
ath9k driver tries to get the beacon without checking for CSA
completion..

Any other comments or a sanity check would also be appreciated.

--
Cheers,
Luca.


 net/mac80211/tx.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

Comments

Simon Wunderlich Nov. 4, 2013, 1:36 p.m. UTC | #1
Hey Luca,

> A beacon should never have a Channel Switch Announcement information
> element with a count of 0, because a count of 1 means switch just
> before the next beacon.  So, if a count of 0 was valid in a beacon, it
> would have been transmitted in the next channel already, which is
> useless.  A CSA count equal to zero is only meaningful in action
> frames or probe_responses.
> 
> Fix the ieee80211_csa_is_complete() and ieee80211_update_csa()
> functions accordingly.
> 
> Cc: Simon Wunderlich <sw@simonwunderlich.de>
> Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
> ---
> 
> Hi Simon (et al),
> 
> I identified this issue while playing around with CSA.  I noticed that
> we are sending a CSA beaon with count == 0, which should not happen.
> The last beacon visible in the current channel (ie. before the switch)
> contains a CSA IE with count == 1.
> 
> I wanted to check with you if my proposed change would have any
> side-effects, especially with the ath9k driver, which is the only user
> of this code in the mainline at the moment.
> 
> The potential danger here is if you don't check
> ieee80211_csa_is_complete() before you send the first CSA beacon out.
> With the previous code, there would always be a beacon with CSA (count
> == 0), but now, if the count starts with 1, there won't be any.  If
> you don't check, my patch will probably introduce a WARN when the
> ath9k driver tries to get the beacon without checking for CSA
> completion..
> 
> Any other comments or a sanity check would also be appreciated.

Thanks for checking back - I've read the part in the spec again [1], and 
appearently you are right.

With your proposed change, shouldn't we also change the behaviour if the 
userspace requests a channel switch with count = 0? I guess we should 
immediately change the channel then without waiting for beacons? I don't see 
the point in changing the beacons if we don't send them, after all. Currently, 
ath9k calls the csa_finish() after checking whether beacon sending was complete 
... so this would have to be changed.

Cheers,
    Simon


[1] IEEE 802.11-2012, 8.4.2.21 
For nonmesh STAs, the Channel Switch Count field either is set to the number of 
TBTTs until the STA sending the Channel Switch Announcement element switches 
to the new channel or is set to 0. A value of 1 indicates that the switch 
occurs immediately before the next TBTT. A value of 0 indicates that the  
switch occurs at any time after the frame containing the element is 
transmitted.
--
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. 4, 2013, 2:07 p.m. UTC | #2
On Mon, 2013-11-04 at 14:36 +0100, Simon Wunderlich wrote:
> Hey Luca,


Hey Simon,

Thanks for your quick reply. :)

> > A beacon should never have a Channel Switch Announcement information

> > element with a count of 0, because a count of 1 means switch just

> > before the next beacon.  So, if a count of 0 was valid in a beacon, it

> > would have been transmitted in the next channel already, which is

> > useless.  A CSA count equal to zero is only meaningful in action

> > frames or probe_responses.

> > 

> > Fix the ieee80211_csa_is_complete() and ieee80211_update_csa()

> > functions accordingly.

> > 

> > Cc: Simon Wunderlich <sw@simonwunderlich.de>

> > Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>

> > ---

> > 

> > Hi Simon (et al),

> > 

> > I identified this issue while playing around with CSA.  I noticed that

> > we are sending a CSA beaon with count == 0, which should not happen.

> > The last beacon visible in the current channel (ie. before the switch)

> > contains a CSA IE with count == 1.

> > 

> > I wanted to check with you if my proposed change would have any

> > side-effects, especially with the ath9k driver, which is the only user

> > of this code in the mainline at the moment.

> > 

> > The potential danger here is if you don't check

> > ieee80211_csa_is_complete() before you send the first CSA beacon out.

> > With the previous code, there would always be a beacon with CSA (count

> > == 0), but now, if the count starts with 1, there won't be any.  If

> > you don't check, my patch will probably introduce a WARN when the

> > ath9k driver tries to get the beacon without checking for CSA

> > completion..

> > 

> > Any other comments or a sanity check would also be appreciated.

> 

> Thanks for checking back - I've read the part in the spec again [1], and 

> appearently you are right.

> 

> With your proposed change, shouldn't we also change the behaviour if the 

> userspace requests a channel switch with count = 0? I guess we should 

> immediately change the channel then without waiting for beacons? I don't see 

> the point in changing the beacons if we don't send them, after all.


You're right, changing the beacons doesn't make sense in this case.
I'll change that and send v2.

Another thing is that we are missing the action frames.  The idea with
the count == 0 is that the STA's should start listening on the other
channel immediately after receiving the action frame (because the switch
will happen at any time).

If we don't send the action frame, passing context == 0 from the
userspace doesn't much make sense, because the clients won't know we're
switching.  Well, maybe it makes a bit of sense, if there are no clients
connected, but nevertheless.

count == 0 should probably be avoided, because the specs are not that
clear about it.  In case transmission on our channel needs to be stopped
immediately (eg. with DSS), we can always use the channel switch mode
(ie. no TX until the switch happens).

I'll probably start looking into the action frame implementation soon.


> Currently, 

> ath9k calls the csa_finish() after checking whether beacon sending was complete 

> ... so this would have to be changed.


Yeah, that's what I suspected from my very quick look at the ath9k code.
I'll see if I can change this easily.  I'll probably need some help with
testing, because I don't have an ath9k device. :\

--
Cheers,
Luca.
Simon Wunderlich Nov. 4, 2013, 2:31 p.m. UTC | #3
Hey Luca,

> > 
> > Thanks for checking back - I've read the part in the spec again [1], and
> > appearently you are right.
> > 
> > With your proposed change, shouldn't we also change the behaviour if the
> > userspace requests a channel switch with count = 0? I guess we should
> > immediately change the channel then without waiting for beacons? I don't
> > see the point in changing the beacons if we don't send them, after all.
> 
> You're right, changing the beacons doesn't make sense in this case.
> I'll change that and send v2.
> 
> Another thing is that we are missing the action frames.  The idea with
> the count == 0 is that the STA's should start listening on the other
> channel immediately after receiving the action frame (because the switch
> will happen at any time).
> 
> If we don't send the action frame, passing context == 0 from the
> userspace doesn't much make sense, because the clients won't know we're
> switching.  Well, maybe it makes a bit of sense, if there are no clients
> connected, but nevertheless.

Yeah, switching without actionframe and count == 0 is pretty useless.

> 
> count == 0 should probably be avoided, because the specs are not that
> clear about it.  In case transmission on our channel needs to be stopped
> immediately (eg. with DSS), we can always use the channel switch mode
> (ie. no TX until the switch happens).

Hmm, we probably need to review the IBSS part too - we adopt the channel 
switch from others here, and adopting with count = 0 works now but would 
create a warning with your change ...

> 
> I'll probably start looking into the action frame implementation soon.

I've recently added CSA action frame support for the IBSS mode, because the 
distributed beaconing may lead to slow adoption of the CSA IEs in the IBSS. 
Check ieee80211_send_action_csa() for that. I guess it would be useful to send 
at least the action frames out if we want to change "fast" (count=0).

For AP mode, I guess the right place to implement the action frames would be 
hostap? This would at least allow great flexibility with CSA, ECSA and all the 
new channel switch IEs coming now. The beacons are also generated in 
userspace, after all.

BTW, I've just checked and the WiFi Alliance requires at least 5 beacons with 
CSA-IEs to pass the 802.11h test. :)

> 
> > Currently,
> > ath9k calls the csa_finish() after checking whether beacon sending was
> > complete ... so this would have to be changed.
> 
> Yeah, that's what I suspected from my very quick look at the ath9k code.
> I'll see if I can change this easily.  I'll probably need some help with
> testing, because I don't have an ath9k device. :\

No problem, I can test here, just tell me what to test. :)

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. 5, 2013, 8:28 a.m. UTC | #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XJzLA0KTHVjYS4NCg0K
--
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. 5, 2013, 10:06 a.m. UTC | #5
On Tue, 2013-11-05 at 10:27 +0200, Luciano Coelho wrote:
> On Mon, 2013-11-04 at 15:31 +0100, Simon Wunderlich wrote:

> > > > Thanks for checking back - I've read the part in the spec again [1], and

> > > > appearently you are right.

> > > > 

> > > > With your proposed change, shouldn't we also change the behaviour if the

> > > > userspace requests a channel switch with count = 0? I guess we should

> > > > immediately change the channel then without waiting for beacons? I don't

> > > > see the point in changing the beacons if we don't send them, after all.

> > > 

> > > You're right, changing the beacons doesn't make sense in this case.

> > > I'll change that and send v2.

> > > 

> > > Another thing is that we are missing the action frames.  The idea with

> > > the count == 0 is that the STA's should start listening on the other

> > > channel immediately after receiving the action frame (because the switch

> > > will happen at any time).

> > > 

> > > If we don't send the action frame, passing context == 0 from the

> > > userspace doesn't much make sense, because the clients won't know we're

> > > switching.  Well, maybe it makes a bit of sense, if there are no clients

> > > connected, but nevertheless.

> > 

> > Yeah, switching without actionframe and count == 0 is pretty useless.

> 

> Actually, if the userspace requests count == 1, we won't have any

> beacons either, because 1 means "just before the next TBTT".  So for

> count == 1 (coming from the userspace) we shouldn't configure the

> beacon, since we won't send it.  We need the action frame for this case

> too.


Hmmm... Now there's something that is a bit unclear to me in the specs:

"For nonmesh STAs, the Channel Switch Count field either is set to the
number of TBTTs until the STA sending the Channel Switch Announcement
element switches to the new channel or is set to 0."

There's nothing specifying exactly when, relative to the beacon, the
switch actually happens.  Just before? Just after? Is the beacon that
matches that TBTT transmitted in the current or in the next channel?

For a value of 1, it's pretty clear:

"A value of 1 indicates that the switch occurs immediately before the
next TBTT."

I don't think we're doing that now.  At least in the ath9k case, you
switch the channel immediately after the beacon with count == 1, by
calling ieee80211_csa_finish().  The correct would be just before the
next beacon is sent.

A value of 0 is also unclear, because it doesn't refer to any TBTTs at
all.  So if you read it literally, the following would mean that it
could at *any* time in the future:

"A value of 0 indicates that the switch occurs at any time after the
frame containing the element is transmitted."

Am I missing something? What do you think?

--
Cheers,
Luca.
Simon Wunderlich Nov. 5, 2013, 1:36 p.m. UTC | #6
> On Mon, 2013-11-04 at 15:31 +0100, Simon Wunderlich wrote:
> > > > Thanks for checking back - I've read the part in the spec again [1],
> > > > and appearently you are right.
> > > > 
> > > > With your proposed change, shouldn't we also change the behaviour if
> > > > the userspace requests a channel switch with count = 0? I guess we
> > > > should immediately change the channel then without waiting for
> > > > beacons? I don't see the point in changing the beacons if we don't
> > > > send them, after all.
> > > 
> > > You're right, changing the beacons doesn't make sense in this case.
> > > I'll change that and send v2.
> > > 
> > > Another thing is that we are missing the action frames.  The idea with
> > > the count == 0 is that the STA's should start listening on the other
> > > channel immediately after receiving the action frame (because the
> > > switch will happen at any time).
> > > 
> > > If we don't send the action frame, passing context == 0 from the
> > > userspace doesn't much make sense, because the clients won't know we're
> > > switching.  Well, maybe it makes a bit of sense, if there are no
> > > clients connected, but nevertheless.
> > 
> > Yeah, switching without actionframe and count == 0 is pretty useless.
> 
> Actually, if the userspace requests count == 1, we won't have any
> beacons either, because 1 means "just before the next TBTT".  So for
> count == 1 (coming from the userspace) we shouldn't configure the
> beacon, since we won't send it.  We need the action frame for this case
> too.
> 

Hmm, right, we will decrement the counter before sending it out ...

> > For AP mode, I guess the right place to implement the action frames would
> > be hostap? This would at least allow great flexibility with CSA, ECSA
> > and all the new channel switch IEs coming now. The beacons are also
> > generated in userspace, after all.
> 
> What new channel channel switch IEs?

Right now we also have extendended channel switch announcements (ECSA), and 
secondary channel offset, and there are more to come with 802.11ac I think. I 
have not studied it yet (and I don't have access to 802.11 drafts), but have a 
look at that:

https://mentor.ieee.org/802.11/dcn/13/11-13-0105-00-00ac-lb190-proposed-
resolution-on-cid-7367-and-7368.docx&ei=T_N4UuHWGcmt4ATQj4DwBg&usg=AFQjCNE5E-
bpqRGQM7-QwG0L4TiU3OOLig&bvm=bv.55980276,d.bGE&cad=rja

(not only the .doc format is ugly)

> 
> You're right that it might make sense to implement the action frames in
> hostap.  But OTOH, the action frame is quite simple and mac80211 should
> have all the information needed to send it out.
> 
> > BTW, I've just checked and the WiFi Alliance requires at least 5 beacons
> > with CSA-IEs to pass the 802.11h test. :)
> 
> Do you mean that the tests only check when count starts as > 5?
> 

It checks if the last beacon hast a CSA IE in the beacon, and also if there 
are 4 beacons before that including a CSA IE. It does not check for the count 
though, but that's implicitly given ...

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
Simon Wunderlich Nov. 5, 2013, 2 p.m. UTC | #7
> On Tue, 2013-11-05 at 10:27 +0200, Luciano Coelho wrote:
> > On Mon, 2013-11-04 at 15:31 +0100, Simon Wunderlich wrote:
> > > > > Thanks for checking back - I've read the part in the spec again
> > > > > [1], and appearently you are right.
> > > > > 
> > > > > With your proposed change, shouldn't we also change the behaviour
> > > > > if the userspace requests a channel switch with count = 0? I guess
> > > > > we should immediately change the channel then without waiting for
> > > > > beacons? I don't see the point in changing the beacons if we don't
> > > > > send them, after all.
> > > > 
> > > > You're right, changing the beacons doesn't make sense in this case.
> > > > I'll change that and send v2.
> > > > 
> > > > Another thing is that we are missing the action frames.  The idea
> > > > with the count == 0 is that the STA's should start listening on the
> > > > other channel immediately after receiving the action frame (because
> > > > the switch will happen at any time).
> > > > 
> > > > If we don't send the action frame, passing context == 0 from the
> > > > userspace doesn't much make sense, because the clients won't know
> > > > we're switching.  Well, maybe it makes a bit of sense, if there are
> > > > no clients connected, but nevertheless.
> > > 
> > > Yeah, switching without actionframe and count == 0 is pretty useless.
> > 
> > Actually, if the userspace requests count == 1, we won't have any
> > beacons either, because 1 means "just before the next TBTT".  So for
> > count == 1 (coming from the userspace) we shouldn't configure the
> > beacon, since we won't send it.  We need the action frame for this case
> > too.
> 
> Hmmm... Now there's something that is a bit unclear to me in the specs:
> 
> "For nonmesh STAs, the Channel Switch Count field either is set to the
> number of TBTTs until the STA sending the Channel Switch Announcement
> element switches to the new channel or is set to 0."
> 
> There's nothing specifying exactly when, relative to the beacon, the
> switch actually happens.  Just before? Just after? Is the beacon that
> matches that TBTT transmitted in the current or in the next channel?
> 
> For a value of 1, it's pretty clear:
> 
> "A value of 1 indicates that the switch occurs immediately before the
> next TBTT."

If it says for 1 "just before the next TBTT", then this would mean the next 
beacon is on the next channel. I'd interpret then that for count=0, the 
channel switch happens as soon as possible, and may happen any time before the 
next TBTT.
> 
> I don't think we're doing that now.  At least in the ath9k case, you
> switch the channel immediately after the beacon with count == 1, by
> calling ieee80211_csa_finish().  The correct would be just before the
> next beacon is sent.

Hm, I think you are right, although I'm not sure how easy that would be 
implementation-wise.

BTW, for that case I think we also have to fix the client side, which is 
currently switching immediately for count = 1 and not waiting for the next 
TBTT. (see end of ieee80211_sta_process_chanswitch(), the rest appears correct 
though).

> 
> A value of 0 is also unclear, because it doesn't refer to any TBTTs at
> all.  So if you read it literally, the following would mean that it
> could at *any* time in the future:
> 
> "A value of 0 indicates that the switch occurs at any time after the
> frame containing the element is transmitted."
> 
> Am I missing something? What do you think?

As said above, I'd interpret it as the change should happen as soon as 
possible. If count = 1 means the change will happen "immediately before the 
next TBTT", I would guess 0 would mean even before that, or at least not after 
the "before the next TBTT".

I agree that the spec is not perfectly clear about that, but I currently don't 
see any other reasonable interpretation here ...

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. 5, 2013, 2:25 p.m. UTC | #8
T24gVHVlLCAyMDEzLTExLTA1IGF0IDE0OjM2ICswMTAwLCBTaW1vbiBXdW5kZXJsaWNoIHdyb3Rl
Og0KPiA+IE9uIE1vbiwgMjAxMy0xMS0wNCBhdCAxNTozMSArMDEwMCwgU2ltb24gV3VuZ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uc2UgdG8gaW1wbGVtZW50IHRoZSBhY3Rpb24gZnJhbWVzIGluDQo+ID4gaG9z
dGFwLiAgQnV0IE9UT0gsIHRoZSBhY3Rpb24gZnJhbWUgaXMgcXVpdGUgc2ltcGxlIGFuZCBtYWM4
MDIxMSBzaG91bGQNCj4gPiBoYXZlIGFsbCB0aGUgaW5mb3JtYXRpb24gbmVlZGVkIHRvIHNlbmQg
aXQgb3V0Lg0KPiA+IA0KPiA+ID4gQlRXLCBJJ3ZlIGp1c3QgY2hlY2tlZCBhbmQgdGhlIFdpRmkg
QWxsaWFuY2UgcmVxdWlyZXMgYXQgbGVhc3QgNSBiZWFjb25zDQo+ID4gPiB3aXRoIENTQS1JRXMg
dG8gcGFzcyB0aGUgODAyLjExaCB0ZXN0LiA6KQ0KPiA+IA0KPiA+IERvIHlvdSBtZWFuIHRoYXQg
dGhlIHRlc3RzIG9ubHkgY2hlY2sgd2hlbiBjb3VudCBzdGFydHMgYXMgPiA1Pw0KPiA+IA0KPiAN
Cj4gSXQgY2hlY2tzIGlmIHRoZSBsYXN0IGJlYWNvbiBoYXN0IGEgQ1NBIElFIGluIHRoZSBiZWFj
b24sIGFuZCBhbHNvIGlmIHRoZXJlIA0KPiBhcmUgNCBiZWFjb25zIGJlZm9yZSB0aGF0IGluY2x1
ZGluZyBhIENTQSBJRS4gSXQgZG9lcyBub3QgY2hlY2sgZm9yIHRoZSBjb3VudCANCj4gdGhvdWdo
LCBidXQgdGhhdCdzIGltcGxpY2l0bHkgZ2l2ZW4gLi4uDQoNCk9rYXksIHNvIHdlIGp1c3QgbmVl
ZCB0byByZW1lbWJlciB0byB1c2UgY291bnQgPj0gNiB3aGVuIHRlc3RpbmcuIDspDQoNCi0tDQpM
dWNhLg0K
--
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. 5, 2013, 2:35 p.m. UTC | #9
On Tue, 2013-11-05 at 15:00 +0100, Simon Wunderlich wrote:
> > On Tue, 2013-11-05 at 10:27 +0200, Luciano Coelho wrote:

> > > On Mon, 2013-11-04 at 15:31 +0100, Simon Wunderlich wrote:

> > > > > > Thanks for checking back - I've read the part in the spec again

> > > > > > [1], and appearently you are right.

> > > > > > 

> > > > > > With your proposed change, shouldn't we also change the behaviour

> > > > > > if the userspace requests a channel switch with count = 0? I guess

> > > > > > we should immediately change the channel then without waiting for

> > > > > > beacons? I don't see the point in changing the beacons if we don't

> > > > > > send them, after all.

> > > > > 

> > > > > You're right, changing the beacons doesn't make sense in this case.

> > > > > I'll change that and send v2.

> > > > > 

> > > > > Another thing is that we are missing the action frames.  The idea

> > > > > with the count == 0 is that the STA's should start listening on the

> > > > > other channel immediately after receiving the action frame (because

> > > > > the switch will happen at any time).

> > > > > 

> > > > > If we don't send the action frame, passing context == 0 from the

> > > > > userspace doesn't much make sense, because the clients won't know

> > > > > we're switching.  Well, maybe it makes a bit of sense, if there are

> > > > > no clients connected, but nevertheless.

> > > > 

> > > > Yeah, switching without actionframe and count == 0 is pretty useless.

> > > 

> > > Actually, if the userspace requests count == 1, we won't have any

> > > beacons either, because 1 means "just before the next TBTT".  So for

> > > count == 1 (coming from the userspace) we shouldn't configure the

> > > beacon, since we won't send it.  We need the action frame for this case

> > > too.

> > 

> > Hmmm... Now there's something that is a bit unclear to me in the specs:

> > 

> > "For nonmesh STAs, the Channel Switch Count field either is set to the

> > number of TBTTs until the STA sending the Channel Switch Announcement

> > element switches to the new channel or is set to 0."

> > 

> > There's nothing specifying exactly when, relative to the beacon, the

> > switch actually happens.  Just before? Just after? Is the beacon that

> > matches that TBTT transmitted in the current or in the next channel?

> > 

> > For a value of 1, it's pretty clear:

> > 

> > "A value of 1 indicates that the switch occurs immediately before the

> > next TBTT."

> 

> If it says for 1 "just before the next TBTT", then this would mean the next 

> beacon is on the next channel. I'd interpret then that for count=0, the 

> channel switch happens as soon as possible, and may happen any time before the 

> next TBTT.


It says "just before the next TBTT" for value == 1, not for values >
1. ;)

But yeah, my interpretation is the same as yours.  We can extrapolate
this to when value > 1 as well.

 
> > I don't think we're doing that now.  At least in the ath9k case, you

> > switch the channel immediately after the beacon with count == 1, by

> > calling ieee80211_csa_finish().  The correct would be just before the

> > next beacon is sent.

> 

> Hm, I think you are right, although I'm not sure how easy that would be 

> implementation-wise.


Yes, I guess this would be pretty hard to do if we have beacon
offload...


> BTW, for that case I think we also have to fix the client side, which is 

> currently switching immediately for count = 1 and not waiting for the next 

> TBTT. (see end of ieee80211_sta_process_chanswitch(), the rest appears correct 

> though).


Yes, I have seen that too.  The problem is that this "immediately
before" is not well specified either.  It depends on many things, like
how long it takes the hardware to physically switch to the next channel
and start beaconing.  I guess  the only problem would be a hick up in
the connection, if the AP switches at a different time than the STA
does...


> > A value of 0 is also unclear, because it doesn't refer to any TBTTs at

> > all.  So if you read it literally, the following would mean that it

> > could at *any* time in the future:

> > 

> > "A value of 0 indicates that the switch occurs at any time after the

> > frame containing the element is transmitted."

> > 

> > Am I missing something? What do you think?

> 

> As said above, I'd interpret it as the change should happen as soon as 

> possible. If count = 1 means the change will happen "immediately before the 

> next TBTT", I would guess 0 would mean even before that, or at least not after 

> the "before the next TBTT".

> 

> I agree that the spec is not perfectly clear about that, but I currently don't 

> see any other reasonable interpretation here ...


Yes, I agree with your interpretations too.  I was just being too
literal. ;) In any case, we can only hope everyone interprets it in the
same way...

--
Cheers,
Luca.
diff mbox

Patch

diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
index 9993fcb..1e0d40f 100644
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -2376,8 +2376,12 @@  static void ieee80211_update_csa(struct ieee80211_sub_if_data *sdata,
 	if (WARN_ON(counter_offset_beacon >= beacon_data_len))
 		return;
 
-	/* warn if the driver did not check for/react to csa completeness */
-	if (WARN_ON(beacon_data[counter_offset_beacon] == 0))
+	/* Warn if the driver did not check for/react to csa
+	 * completeness.  A beacon with CSA counter set to 0 should
+	 * never occur, because a counter of 1 means switch just
+	 * before the next beacon.
+	 */
+	if (WARN_ON(beacon_data[counter_offset_beacon] == 1))
 		return;
 
 	beacon_data[counter_offset_beacon]--;
@@ -2434,7 +2438,7 @@  bool ieee80211_csa_is_complete(struct ieee80211_vif *vif)
 	if (WARN_ON(counter_beacon > beacon_data_len))
 		goto out;
 
-	if (beacon_data[counter_beacon] == 0)
+	if (beacon_data[counter_beacon] == 1)
 		ret = true;
  out:
 	rcu_read_unlock();