Commit Graph

47 Commits

Author SHA1 Message Date
Adrian Chadd
b94299c437 Create a new task to handle 802.11n channel width changes.
Currently, a channel width change updates the 802.11n HT info data in
net80211 but it doesn't trigger any device changes.  So the device
driver may decide that HT40 frames can be transmitted but the last
device channel set only had HT20 set.

Now, a task is scheduled so a hardware reset or change isn't done
during any active ongoing RX. It also means that it's serialised
with the other task operations (eg channel change.)

This isn't the final incantation of this work, see below.

For now, any unmodified drivers will simply receive a channel
change log entry.  A subsequent patch to ath(4) will introduce
some basic channel change handling (by resetting the NIC.)
Other NICs may need to update their rate control information.

TODO:

* There's still a small window at the present moment where the
  channel width has been updated but the task hasn't been fired.
  The final version of this should likely pass in a channel width
  field to the driver and let the driver atomically do whatever
  it needs to before changing the channel.

PR:		kern/166286
2012-03-25 03:11:57 +00:00
Adrian Chadd
e168e5f947 Only increment is_beacon_bad if we're not scanning.
Otherwise things such as off-channel probe responses and beacons are also
silently discarded and logged against this error counter.
2012-02-28 21:43:29 +00:00
Adrian Chadd
fd9a6137da Track the number of bad beacons received.
PR:		kern/165517
2012-02-28 04:05:35 +00:00
Adrian Chadd
9848863e75 .. add missing include from an incorrect merge.
Sponsored by:	Hobnob, Inc.
2011-11-08 14:34:01 +00:00
Adrian Chadd
38672d4825 Reject frames in STA mode which are not destined to the local STA address.
Some hardware (eg the AR9160 in STA mode) seems to "leak" unicast FROMDS
frames which aren't destined to itself. This angers the net80211 stack -
the existing code would fail to find an address in the node table and try
passing the frame up to each vap BSS. It would then be accepted in the
input routine and its contents would update the local crypto and sequence
number state.

If the sequence number / crypto IV replay counters from the leaked frame
were greater than the "real" state, subsequent "real" frames would be
rejected due to out of sequence / IV replay conditions.

This is also likely helpful if/when multi-STA modes are added to net80211.

Sponsored by:	Hobnob, Inc.
2011-11-08 14:28:33 +00:00
Adrian Chadd
32b0e64b56 Add 802.11h quiet time element support into net80211.
This supports both station and hostap modes:

* Station mode quiet time element support listens to quiet time
  IE's and modifies the local quiet time configuration as appropriate;
* Hostap mode both obeys the locally configured quiet time period
  and includes it in beacon frames so stations also can obey as needed.

Submitted by:	Himali Patel <himali.patel@sibridgetech.com>
Sponsored by:	Sibridge Technologies
2011-11-08 04:00:24 +00:00
Adrian Chadd
23401900d3 Fix a panic in the wifi stack when a software beacon miss occurs in the wrong state.
The ieee80211_swbmiss() callout is not called with the ic lock held, so it's
quite possible the scheduler will run the callout during a state change.

This patch:

* changes the swbmiss callout to be locked by the ic lock
* enforces the ic lock being held across the beacon vap functions
  by grabbing it inside beacon_miss() and beacon_swmiss().

This ensures that the ic lock is held (and thus the VAP state
stays constant) during beacon miss and software miss processing.
Since the callout is removed whilst the ic lock is held, it also
ensures that the ic lock can't be called during a state change
or exhibit any race conditions seen above.

Both Edgar and Joel report that this patch fixes the crash and
doesn't introduce new issues.

Reported by:	Edgar Martinez <emartinez@kbcnetworks.com>
Reported by:	Joel Dahl <joel@vnode.se>
Reported by:	emaste
2011-10-02 02:42:31 +00:00
Adrian Chadd
cd0b8f2d4a Fix some corner cases in the net80211 sequence number retransmission
handling.

The current sequence number code does a few things incorrectly:

* It didn't try eliminating duplications from HT nodes. I guess it's assumed
  that out of order / retransmission handling would be handled by the AMPDU RX
  routines. If a HT node isn't doing AMPDU RX, then retransmissions need to
  be eliminated. Since most of my debugging is based on this (as AMPDU TX
  software packet aggregation isn't yet handled), handle this corner case.

* When a sequence number of 4095 was received, any subsequent sequence number
  is going to be (by definition) less than 4095. So if the following sequence
  number (0) doesn't initially occur and the retransmit is received, it's
  incorrectly eliminated by the IEEE80211_FC1_RETRY && SEQ_LEQ() check.
  Try to handle this better.

This almost completely eliminates out of order TCP statistics showing up during
iperf testing for the 11a, 11g and non-aggregate 11n AMPDU RX case. The only
other packet loss conditions leading to this are due to baseband resets or
heavy interference.
2011-05-04 02:23:59 +00:00
Bernhard Schmidt
9d36b055fd Fix a cut&paste error while parsing htcap/htinfo elements. This one is
reponsible for not filling ni_htrates if a pre-ht information element is
present.
2011-03-13 12:21:04 +00:00
Bernhard Schmidt
893c4d6ef1 Make sure to only accept and handle action frames which are for us. In
promiscuous mode we might receive stuff which otherwise gets filtered
by hardware.
2011-02-22 19:05:42 +00:00
Bernhard Schmidt
96283082bb Add a new mgmt subtype "ACTION NO ACK" defined in 802.11n-2009, while here
clean up parts of the *_recv_mgmt() functions.
- make sure appropriate counters are bumped and debug messages are printed
- order the unhandled subtypes by value and add a few missing ones
- fix some whitespace nits
- remove duplicate code in adhoc_recv_mgmt()
- remove a useless comment, probably left in while c&p
2011-02-21 19:59:43 +00:00
Bernhard Schmidt
a7c6aabdc3 Instead of using the AMRR ratectl algo as default for drivers which have
the IEEE80211_C_RATECTL flag set, default to NONE for all drivers. Only if
a driver calls ieee80211_ratectl_init() check if the NONE algo is still
selected and try to use AMRR in that case. Drivers are still free to use
any other algo by calling ieee80211_ratectl_set() prior to the
ieee80211_ratectl_init() call.

After this change it is now safe to assume that a ratectl algo is always
available and selected, which renders the IEEE80211_C_RATECTL flag pretty
much useless. Therefore revert r211314 and 211546.

Reviewed by:	rpaulo
MFC after:	2 weeks
2010-11-06 18:17:20 +00:00
Bernhard Schmidt
ad8e331bf2 Introduce IEEE80211_C_RATECTL, drivers which use the ratectl framework
should set this capability.

MFC after:	2 weeks
2010-08-14 20:12:10 +00:00
Bernhard Schmidt
49d2c13794 Initialize ni_txrate after txparams have been setup. Some drivers
calculate various things prior to association based on ni_txrate and
rely on it being nonzero.

PR:		kern/149185
MFC after:	2 weeks
2010-08-14 09:29:42 +00:00
Tai-hwa Liang
ca765120a8 Fixing compilation bustage by adding the missing && back. 2010-06-11 01:32:42 +00:00
Rui Paulo
2bc3bd71de Some odd APs send beacons on the same TX queue as non-beacons. This breaks
802.11 duplicate detection. Upon looking at the standard, we discover
that 802.11-2007 says:
"A receiving QoS STA is also required to keep only the most recent
cache entry per<Address 2, TID, sequence-number>  triple, storing only
the most recently received fragment number for that triple. A receiving
STA may omit tuples obtained from broadcast/multicast or ATIM frames
from the cache."

To fix this, we just disable duplicate detection for multicast/broadcast
frames.

Reviewed by:	sam
MFC after:	4 weeks
Obtained from:	DragonFly
2010-06-10 20:58:34 +00:00
Rui Paulo
0917631f16 Fix a couple of bugs with 802.11n:
o Process the BAR frame on the adhoc, mesh and sta modes
o Fix the format of the ADDBA reply frame
o Fix references to the spec section numbers

Also, print the all the MCS rates in bootverbose.

Sponsored by:	iXsystems, Inc.
Obtained from:	//depot/user/rpaulo/80211n/...
2010-03-18 11:06:38 +00:00
Weongyo Jeong
7e62e45f53 fixes a broken software beacon miss handler. There is a race to check
vap->iv_bmiss_count == 0 in ieee80211_swbmiss because iv_swbmiss_task is
enqueued by taskqueue.

Reviewed by:	rpaulo
2010-03-14 01:57:32 +00:00
Rui Paulo
2b80a3409e When taking the AMPDU reorder fastpath, need_tap wasn't being
initialized. Initialize on declaration to avoid this.

Found with:	clang static analyzer
2010-02-03 10:07:43 +00:00
Rui Paulo
6f28738dc3 Call ieee80211_radiotap_rx, not ieee80211_radiotap_tx on sta_input()
PR:		143163
Submitted by:	Alexander Egorenkov <egorenar at gmail.com>
MFC after:	3 days
2010-01-25 12:23:51 +00:00
Sam Leffler
c32539d4c0 on transition to SLEEP state mark the station in power save, not awake
MFC after:	3 days
2009-09-03 16:24:21 +00:00
Sam Leffler
7634012302 Revamp 802.11 action frame handling:
o add a new facility for components to register send+recv handlers
o ieee80211_send_action and ieee80211_recv_action now use the registered
  handlers to dispatch operations
o rev ieee80211_send_action api to enable passing arbitrary data
o rev ieee80211_recv_action api to pass the 802.11 frame header as it may
  be difficult to locate
o update existing IEEE80211_ACTION_CAT_BA and IEEE80211_ACTION_CAT_HT handling
o update mwl for api rev

Reviewed by:	rpaulo
Approved by:	re (kensmith)
2009-07-05 17:59:19 +00:00
Sam Leffler
d77148fbca When associating to an AP we don't know if HT is negotiated until
we receive the AssocResp, so we can only set ni_txparms properly
at that point.  To make this possible make node_setuptxparms public
as ieee80211_node_setuptxparms.
2009-06-11 04:43:42 +00:00
Sam Leffler
2bfc8a91c9 iv_flags_ext is full, make room by moving HT-related flags to a new
iv_flags_ht word
2009-06-07 22:00:22 +00:00
Sam Leffler
c70761e6b5 o station mode channel switch support
o IEEE80211_IOC_CHANSWITCH fixups:
  - restrict to hostap vaps
  - return EOPNOTSUPP instead of EINVAL when applied to !hostap vap
    or to a vap w/o 11h enabled
  - interpret count of 0 to mean cancel the current CSA

Reviewed by:	rpaulo, avatar
2009-06-04 15:57:38 +00:00
Sam Leffler
a6c3cf3eca Fix handling of devices w/o radiotap support:
o do not attach DLT_IEEE802_11_RADIO unless both tx and rx headers are
  present; this is assumed in the capture code paths
o verify the above with asserts in ieee80211_radiotap_{rx,tx}
o add missing checks for active taps before calling ieee80211_radiotap_rx
2009-05-25 16:38:47 +00:00
Sam Leffler
5463c4a485 Overhaul monitor mode handling:
o replace DLT_IEEE802_11 support in net80211 with DLT_IEEE802_11_RADIO
  and remove explicit bpf support from wireless drivers; drivers now
  use ieee80211_radiotap_attach to setup shared data structures that
  hold the radiotap header for each packet tx/rx
o remove rx timestamp from the rx path; it was used only by the tdma support
  for debugging and was mostly useless due to it being 32-bits and mostly
  unavailable
o track DLT_IEEE80211_RADIO bpf attachments and maintain per-vap and
  per-com state when there are active taps
o track the number of monitor mode vaps
o use bpf tap and monitor mode vap state to decide when to collect radiotap
  state and dispatch frames; drivers no longer explicitly directly check
  bpf state or use bpf calls to tap frames
o handle radiotap state updates on channel change in net80211; drivers
  should not do this (unless they bypass net80211 which is almost always
  a mistake)
o update various drivers to be more consistent/correct in handling radiotap
o update ral to include TSF in radiotap'd frames
o add promisc mode callback to wi

Reviewed by:	cbzimmer, rpaulo, thompsa
2009-05-20 20:00:40 +00:00
Sam Leffler
ec4313cb78 whitespace 2009-04-26 22:44:23 +00:00
Sam Leffler
dc7bf546c8 print both fc bytes when hitting a protocol version mismatch 2009-04-26 21:50:21 +00:00
Sam Leffler
49eae5f79e add iv_recv_ctl method to allow hooking rx ctl frame handling 2009-04-26 21:46:04 +00:00
Sam Leffler
8bbd3e4119 o use shared code to handle bpf tap and mbuf cleanup
o swap conditional order to put the cheapest first
2009-04-26 21:03:29 +00:00
Rui Paulo
d4f7b23302 Remove spurious 'or'. 2009-04-23 22:08:44 +00:00
Sam Leffler
339ccfb391 Hoist 802.11 encapsulation up into net80211:
o call ieee80211_encap in ieee80211_start so frames passed down to drivers
  are already encapsulated
o remove ieee80211_encap calls in drivers
o fixup wi so it recreates the 802.3 head it requires from the 802.11
  header contents
o move fast-frame aggregation from ath to net80211 (conditional on
  IEEE80211_SUPPORT_SUPERG):
  - aggregation is now done in ieee80211_start; it is enabled when the
    packets/sec exceeds ieee80211_ffppsmin (net.wlan.ffppsmin) and frames
    are held on a staging queue according to ieee80211_ffagemax
    (net.wlan.ffagemax) to wait for a frame to combine with
  - drivers must call back to age/flush the staging queue (ath does this
    on tx done, at swba, and on rx according to the state of the tx queues
    and/or the contents of the staging queue)
  - remove fast-frame-related data structures from ath
  - add ieee80211_ff_node_init and ieee80211_ff_node_cleanup to handle
    per-node fast-frames state (we reuse 11n tx ampdu state)
o change ieee80211_encap calling convention to include an explicit vap
  so frames coming through a WDS vap are recognized w/o setting M_WDS

With these changes any device able to tx/rx 3Kbyte+ frames can use fast-frames.

Reviewed by:	thompsa, rpaulo, avatar, imp, sephe
2009-03-30 21:53:27 +00:00
Sam Leffler
0cd9c215fa shuffle code so things build w/o INVARIANTS or IEEE80211_SUPPORT_SUPERG
Prodded by:	several
2009-03-25 03:02:03 +00:00
Sam Leffler
616190d079 split Atheros SuperG support out into it's own file that's included only
with a new IEEE80211_SUPPORT_SUPERG option
2009-03-24 20:39:08 +00:00
Sam Leffler
e2126dec84 convert MALLOC/FREE to malloc/free 2008-12-18 23:00:09 +00:00
Sam Leffler
d6f57961a8 Fix checks for fast frames negotiation. ni_ath_flags holds the
capabilities reported by the ap.  These need to be cross-checked
against the local configuration in the vap.  Previously we were
only checking the ap capabilities which meant that if an ap reported
it was ff-capable but we were not setup to use them we'd try to do
ff aggregation and drop the frame.

There are a number of problems to be fixed here but applying this
fix immediately as the problem causes all traffic to stop (and has
not workaround).

Reported by:	Ashish Shukla
2008-10-30 16:22:04 +00:00
Sam Leffler
e66b0905fc o use the new association callback to notify the driver when joining a bss
in sta and adhoc modes; this should've been done forever ago as most all
  drivers use this hook to set per-station transmit parameters such as for
  tx rate control
o adjust drivers to remove explicit calls to the driver newassoc method
2008-10-27 16:46:50 +00:00
Sam Leffler
07760642a6 add/improve debug msgs 2008-10-25 23:23:41 +00:00
Dag-Erling Smørgrav
c5abbba314 Revert the removal of the MALLOC and FREE macros from the net80211 code.
Requested by:	sam
2008-10-23 19:57:13 +00:00
Dag-Erling Smørgrav
1ede983cc9 Retire the MALLOC and FREE macros. They are an abomination unto style(9).
MFC after:	3 months
2008-10-23 15:53:51 +00:00
Sam Leffler
44f7a6edcf RIFS support; needs driver callback for dynamic state change 2008-09-22 00:10:22 +00:00
Sam Leffler
8c070d69c7 MIMO power save support; still needs callbacks for notifying drivers
of dynamic state change in station mode.
2008-09-21 23:59:14 +00:00
Sam Leffler
fdabd982e7 Revamp ht ie handling:
o change ieee80211_parse_htcap and ieee80211_parse_htinfo to save only
  internal state obtained from the ie's; no dynamic state such as
  ni_chw is altered
o add ieee80211_ht_updateparams to parse ht cap+info ie's and update
  dynamic node state
o change ieee80211_ht_node_init to not take an htcap ie that is parsed;
  instead have the caller make a separate call as one caller wants to
  parse the ie while another wants to parse both cap+info ie's and
  update state so can better do this with ieee80211_ht_updateparams

These changes fix sta mode state handling where the node's channel
width was shifted to ht20/ht40 prematurely.
2008-09-21 23:44:15 +00:00
Sam Leffler
45f856e3ac Cleanup AMPDU handling:
For receive:
o explicitly tag rx frames w/ M_AMPDU instead of passing frames through
  the reorder processing according to the node having HT and the frame
  being QoS data
o relax ieee80211_ampdu_reorder asserts to allow any frame to be passed
  in, unsuitable frames are returned to the caller for normal processing;
  this permits drivers that cannot inspect the PLCP to mark all data
  frames as potential ampdu candidates with only a small penalty
o add M_AMPDU_MPDU to identify frames resubmitted from the reorder q

For transmit:
o tag aggregation candidates with M_AMPDU_MPDU
o fix the QoS ack policy set in ampdu subframes; we only support immediate
  BA streams which should be marked for "normal ack" to get implicit block
  ack behaviour; interestingly certain vendor parts BA'd frames with the
  11e BA ack policy set
o do not assign a sequence # to aggregation candidates; this must be done
  when frames are submitted for transmit (NB: this can/will be handled
  better when aggregation is pulled up to net80211)
2008-09-21 23:00:19 +00:00
Sam Leffler
0f52b1c477 make all checks if ni_chw consistent 2008-09-06 17:51:02 +00:00
Sam Leffler
b032f27c36 Multi-bss (aka vap) support for 802.11 devices.
Note this includes changes to all drivers and moves some device firmware
loading to use firmware(9) and a separate module (e.g. ral).  Also there
no longer are separate wlan_scan* modules; this functionality is now
bundled into the wlan module.

Supported by:	Hobnob and Marvell
Reviewed by:	many
Obtained from:	Atheros (some bits)
2008-04-20 20:35:46 +00:00