History log of /freebsd-current/sys/net80211/ieee80211_node.c
Revision Date Author Comments
# 49619f73 19-Jan-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: make sure calls to (*iv_update_bss)() are locked

It turned out thare various calls into (*iv_update_bss)(), that is
direct changes to vap->iv_bss in the old days, happened without
synchronisation.

Use locking assertions to document the requirement or status quo
at some callers given ic locking will eventually have to be dealt
with.

MFC after: 3 days
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43512


# 8a5a3e3d 16-Jan-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: fix a NULL deref in ieee80211_sta_join1()

When ieee80211_sta_join1() gets an obss without ni_nt trying to lock
that will cause a NULL pointer deref. Check for the table to be
valid and deal with the obss node accordingly.

This can happen if sta_newstate() calls ieee80211_reset_bss() for
nstate == INIT and ostate != INIT. ieee80211_reset_bss() itself
calls ieee80211_node_table_reset() which calls node_reclaim()
which ends up in ieee80211_del_node_nt() which does remove the
node from the table and sets ni_table to NULL.
That node (former iv_bss) can then be returned as obss in the
(*iv_update_bss)() call in join1().

MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D43469


# c93be307 30-Nov-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: ieee80211_dump_node() check for channel to be set

Avoid panics in case ieee80211_dump_node() gets called before a
channel context is set.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 562adbe1 27-Oct-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: migrate ic_vhtcaps, ic_vht_mcsinfo, ic_flags_vht

Like for the VAP rename ic_flags_vht to ic_vht_flags for consistency to
keep "VHT" fields together and merge ic_vhtcaps and ic_vht_mcsinfo
into struct ieee80211_vht_cap ic_vht_cap.

While the structure layout changes no other functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42421


# ef48d4fa 27-Oct-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: rename iv_flags_vht to iv_vht_flags

While the flag field is internal start naming it as well as "iv_vht*"
so we keep all "VHT" fields together. This breaks with what was done
done for HT but with HE, EHT, .. coming one day seems the more logic
choice.

No functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: adrian, cc
Differential Revision: https://reviews.freebsd.org/D42419


# 3a11944b 06-Oct-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: pass __func__, __LINE__ also to ieee80211_alloc_node()

Pass caller information to ieee80211_alloc_node() so that in case
IEEE80211_DEBUG_REFCNT is compiled in we can (better) track references,
in this case the initial ieee80211_node_initref().

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 21888521 02-Oct-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: de-inline ieee80211_ref_node()

Make ieee80211_ref_node() a macro so we can pass __func__, __LINE__
in for IEEE80211_DEBUG_REFCNT as we do for other refcount related
functions. Add the appropriate IEEE80211_DPRINTF() call to the
_ieee80211_ref_node() implementation to support wlandebug(8) +node
printf style tracing.
As a plus we can now also use Dtrace fbt on the
_ieee80211_{ref,free}_node() implementations with futher logic,
gathering backtraces, etc. more flexibly.

Sponsored by: The FreeBSD Foundation
X-MFC: never


# db195a52 02-Oct-2023 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: make ieee80211_alloc_node() private

Looking through the allocation/free and reference cycle of nodes we have
a few (publicly) (almost) unused macros and functions.
Start making them private and reducing the amount of entry paths to the
same/similar functionality.
First is to make ieee80211_alloc_node() static as it is nowhere used
in the tree outside this file.

Sponsored by: The FreeBSD Foundation
X-MFC: no


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 93e49148 17-Apr-2023 Gordon Bergling <gbe@FreeBSD.org>

net80211: Remove double words in source code comments

- s/we we/we/

MFC after: 5 days


# 4a8e4d15 29-Nov-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: fix IEEE80211_DEBUG_REFCNT builds

Remove the KPI/KBI changes from ieee80211_node.h and always use the
macros to pass in __func__ and __LINE__ to the functions.
The actual implementations are prefixed by "_" rather than suffixed
by "_debug" as they no longer are "debug"-specific.

Some of the select functions were not actually using the passed in
func, line options; however they are calling other functions which
use them. Directly call the internal implementation in those cases
passing the arguments on.

Use a file-local __debrefcnt_used define to mark the arguments __unused
in cases when we compile without IEEE80211_DEBUG_REFCNT and hope the
toolchain is intelligent enough to not pass them at all in those cases.

Also _ieee80211_free_node() now has a conflict so make the previous
_ieee80211_free_node() the new __ieee80211_free_node().

Add IEEE80211_DEBUG_REFCNT to the NOTES file on amd64 to keep exercising
the option.

Sponsored by: The FreeBSD Foundation
X-MFC: never
Discussed on: freebsd-wireless
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D37529


# 9d2ba518 17-Aug-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: ieee80211_ies_expand() add extra length check

Make sure the given IE length fits into the total length left when
parsing through the information elements. In theory I would say
discard everything if there is an error but that proves hard with
the current code.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D36245


# 91b4225a 22-Mar-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: introduce (*iv_update_bss)()

Introduce (*iv_update_bss)() with a default implementation to allow
drivers to overload/intercept the time when we swap iv_bss.

This helps firmware based drivers to synchronize state with firmware.
Otherwise, for some state changes, we begin with one ni (and in
LinuxKPI lsta) and try to finish with another ni (and a new lsta
in different state) and may no longer have access to the previous state.
This also saves us from constantly checking for ni changes complicating
code.

No functional changes intended.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days
X-MFC: move (*iv_update_bss) to spare area


# 453d1a90 22-Mar-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: improve one debug logging

When forcing DEUATH in ieee80211_sta_join1() log the current state
we are coming from as well. Note this isn't always the state we
are expecting as iv_state was updated already, so contrary to the
comment we usually do not see RUN there.
Leave a comment earlier with regards to this as well.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# c3db9d4a 16-Jan-2022 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: ieee80211_dump_node() cosmetics

Printing %p does not need the 0x prefix and while here mark the
ieee80211_node_table argument unused given we do not need it in the
current incarnation of the function.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 04efa18f 26-Dec-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: add debugging information

Add more STATE / DEBUG probes and enhance the output of one in order
to track state changes triggered by "ack" (or not).
This helped to narrow down causes from drivers or the LinuxKPI 802.11
compat framework which kept us in a scan -> auth -> scan loop.

Sponsored by: The FreeBSD Foundation
MFC after: 3 days


# 09dd08f1 06-Oct-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: correct length check in ieee80211_ies_expand()

In ieee80211_ies_expand() we are looping over Elements
(also known as Information Elements or IEs).
The comment suggests that we assume well-formedness of
the IEs themselves.
Checking the buffer length being least 2 (1 byte Element ID and
1 byte Length fields) rather than just 1 before accessing ie[1]
is still good practise and can prevent and out-of-bounds read in
case the input is not behaving according to the comment.

Reported by: (coypu sdf.org)
admbugs: 857
MFC after: 3 days
Reviewed by: adrian, markj
Differential Revision: https://reviews.freebsd.org/D32340


# 2ec4c3c7 25-Sep-2021 Gordon Bergling <gbe@FreeBSD.org>

net80211(4): Fix a few common typos in source code comments

- s/annoucement/announcement/
- s/setings/settings/

MFC after: 1 week


# af7d9f8e 18-Mar-2021 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: prefix get_random_bytes() with net80211_

Both linux/random.h and net80211 have a function named
get_random_bytes(). With overlapping files included these collide.
Arguably the function could be renamed in linuxkpi but the generic
name should also not be used in net80211 so rename it there.

Sponsored-by: The FreeBSD Foundation
MFC-after: 2 weeks
Reviewed-by: philip, adrian
Differential Revision: https://reviews.freebsd.org/D29335


# 662c1305 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

net: clean up empty lines in .c and .h files


# f1481c8d 30-Jun-2020 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Migrate HT/legacy protection mode and preamble calculation to per-VAP flags

The later firmware devices (including iwn!) support multiple configuration
contexts for a lot of things, leaving it up to the firmware to decide
which channel and vap is active. This allows for things like off-channel
p2p sta/ap operation and other weird things.

However, net80211 is still focused on a "net80211 drives all" when it comes to driving
the NIC, and as part of this history a lot of these options are global and not per-VAP.
This is fine when net80211 drives things and all VAPs share a single channel - these
parameters importantly really reflect the state of the channel! - but it will increasingly
be not fine when we start supporting more weird configurations and more recent NICs.
Yeah, recent like iwn/iwm.

Anyway - so, migrate all of the HT protection, legacy protection and preamble
stuff to be per-VAP. The global flags are still there; they're now calculated
in a deferred taskqueue that mirrors the old behaviour. Firmware based drivers
which have per-VAP configuration of these parameters can now just listen to the
per-VAP options.

What do I mean by per-channel? Well, the above configuration parameters really
are about interoperation with other devices on the same channel. Eg, HT protection
mode will flip to legacy/mixed if it hears ANY BSS that supports non-HT stations or
indicates it has non-HT stations associated. So, these flags really should be
per-channel rather than per-VAP, and then for things like "do i need short preamble
or long preamble?" turn into a "do I need it for this current operating channel".
Then any VAP using it can query the channel that it's on, reflecting the real
required state.

This patch does none of the above paragraph just yet.

I'm also cheating a bit - I'm currently not using separate taskqueues for
the beacon updates and the per-VAP configuration updates. I can always further
split it later if I need to but I didn't think it was SUPER important here.

So:

* Create vap taskqueue entries for ERP/protection, HT protection and short/long
preamble;
* Migrate the HT station count, short/long slot station count, etc - into per-VAP
variables rather than global;
* Fix a bug with my WME work from a while ago which made it per-VAP - do the WME
beacon update /after/ the WME update taskqueue runs, not before;
* Any time the HT protmode configuration changes or the ERP protection mode
config changes - schedule the task, which will call the driver without the
net80211 lock held and all correctly serialised;
* Use the global flags for beacon IEs and VAP flags for probe responses and
other IE situations.

The primary consumer of this is ath10k. iwn could use it when sending RXON,
but we don't support IBSS or AP modes on it yet, and I'm not yet sure whether
it's required in STA mode (ie whether the firmware parses beacons to change
protection mode or whether we need to.)

Tested:

* AR9280, STA/AP
* AR9380, DWDS STA+STA/AP
* ath10k work, STA/AP
* Intel 6235, STA
* Various rtwn / run NICs, DWDS STA and STA configurations


# ea3d5fd9 13-Jun-2020 Adrian Chadd <adrian@FreeBSD.org>

[net80211] separate out node allocation and node initialisation.

This is a new, optional (for now!) method that drivers can use to separate
node allocation and node initialisation. Right now they're the same, and
drivers that need to do node allocation via firmware commands need to sleep
and thus they need to defer node allocation into an internal taskqueue.

Right now they're just separate but not deferred. Later on if I get the time
we'll start deferring the node and key related operations but that requires
making a bunch of other stuff (notably things that generate frames!) also
async/deferred.

Tested:

* RT3593, STA/DWDS mode
* AR9380, STA/AP modes
* QCA9880 (athp) - STA/AP modes


# 47bf877b 05-Jun-2020 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Fix typo.

Oops!


# 48f25cc3 05-Jun-2020 Adrian Chadd <adrian@FreeBSD.org>

[net80211] print out node A-MSDU state.

Now that the node AMSDU TX/RX flags are correctly set in ieee80211_ht.c,
we can print out the AMSDU state here.


# d20ff6e6 05-Jun-2020 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Migrate short slot time configuration into per-vap and deferred taskqueue updates.

The 11b/11g ERP and slot time update handling are two things which weren't
migrated into the per-VAP state when Sam did the initial VAP work.
That makes sense for a lot of setups where net80211 is driving radio state
and the radio only cares about the shared state.

However, as noted by a now deleted comment, the ERP and slot time updates
aren't EXACTLY correct/accurate - they only take into account the most
RECENTLY created VAP, and the state updates when one creates/destroys
VAPs isn't exactly great.

So:

* track the short slot logic per VAP;
* whenever the slot time configuration changes, just push it into a deferred
task queue update so drivers don't have to serialise it themselves;
* if a driver registers a per-VAP slot time handler then it'll just get the
per VAP one;
* .. if a driver registers a global one then the legacy behaviour is maintained -
a single slot time is calculated and pushed out.

Note that the calculated slot time is better than the existing logic - if ANY
of the VAPs require long slot then it's disabled for all VAPs rather than
whatever the last configured VAP did.

Now, this isn't entirely complete - the rest of ERP tracking around short/long
slot capable station tracking needs to be converted into per-VAP, as well
as the preamble/barker flags. Luckily those also can be done in a similar
fashion - keep per-VAP counters/flags and unify them before doing the driver
update. I'll defer that work until later.

All the existing drivers can keep doing what they're doing with the global
slot time flags as that is maintained. One driver (iwi) used the per-VAP
flags instead of the ic flags, so now that driver will work properly.

This unblocks some ath10k porting work as the firmware takes the slot time
configuration per-VAP rather than globally, and some firmware handles
STA+AP and STA+STA (on same/different channels) configurations where
the firmware will switch slot time as appropriate.

Tested:

* AR9380, STA/AP mode
* AR9880 (ath10k), STA mode


# 627bd78e 18-Dec-2018 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: fix out-of-bounds read in ieee80211_amrr(9).

ieee80211_alloc_node() does not initialize rateset tables; that's not
expected by rate control modules and will result in array access at
index -1 - where ni_essid[] array is located (zeroed at allocation, so
there are no user-visible consequences).

Just delay rate control initialization to the moment, when rateset
tables are initiaziled; nothing will use rates here anyway.

MFC after: 4 days


# 8e0cc51b 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

ieee8021_node: fix whitespace issues

Submitted by: Augustin Cavalier <waddlesplash@gmail.com>
Obtained from: Haiku (dffc3e235360cd7b71261239ee8507b7d62a1471)
MFC after: 1 week


# 58a7c4bf 10-Aug-2018 Kyle Evans <kevans@FreeBSD.org>

net80211: Drain ageq before cleaning it up.

The comment above ieee80211_ageq_cleanup specifically notes that the queue
is assumed to be empty, and in order to make it so, ieee80211_ageq_drain
must be used.

Submitted by: Augustin Cavalier <waddlesplash@gmail.com>
Obtained from: Haiku (dffc3e235360cd7b71261239ee8507b7d62a1471)
MFC after: 1 week


# f6b98645 29-Dec-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: handle VHT nodes in ieee80211_node_setuptxparms()

Select proper mode when node can do VHT.

Currently there are no drivers with VHT support in the tree,
so this should be noop.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D9806


# fe267a55 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: general adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.


# 617f8b10 19-Feb-2017 Adrian Chadd <adrian@FreeBSD.org>

[net80211] RX parameter shuffle in net80211 in preparation for 4x4 NICs and 160MHz channels.

* Migrate the rx_params stuff out from ieee80211_freebsd.h where it doesn't belong -
this isn't freebsd specific anymore.

* Don't use a hard-coded number of chains in the ioctl header; now we can shuffle
MAX_CHAINS around so it can be used in the right spot.

* Extend the signal/noisefloor levels in the mimo stats struct to userland to include
the signal and noisefloor levels for each 20MHz slice of a 160MHz channel.

* Bump the number of EVM pilots in preparation for 4x4 and 160MHz channels.

Tested:

* ath(4), STA mode
* iwn(4), STA mode
* local ath10k port, STA mode

TODO:

* 11ax chips will come with 5GHz 8x8 hardware for lots of MU-MIMO - I'll re-bump it
at that point.

Note:

* This breaks the driver and ifconfig ABI; please recompile the kernel,
ifconfig and wpa_supplicant/hostapd.


# 704cd542 31-Jan-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: cleanup ic_flags / iv_flags

Flags
- IEEE80211_F_ASCAN
- IEEE80211_F_SIBSS
- IEEE80211_F_IBSSON
are not used since r170530 (old WI compatibility ioctls removal)
and r178354 (removed from other places).

IEEE80211_F_TXPOW_FIXED was never utilized; initially added with
IEEE80211_F_TXPOW_AUTO / IEEE80211_F_TXPOW_OFF flags,
which were replaced with IEEE80211_C_TXPMGT capability check in r138568.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D9369


# 51172f62 13-Jan-2017 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Initial VHT node upgrade/downgrade support and initial IE parsing.

This is the bulk of the magic to start enabling VHT channel negotiation.
It is absolutely, positively not yet even a complete VHT wave-1 implementation.

* parse IEs in scan, assoc req/resp, probe req/resp;
* break apart the channel upgrade from the HT IE parsing - do it after the
VHT IEs are parsed;
* (dirty! sigh) add channel width decision making in ieee80211_ht.c htinfo_update_chw().
This is the main bit where negotiated channel promotion through IEs occur.
* Shoehorn in VHT node init ,teardown, rate control, etc calls like the HT
versions;
* Do VHT channel adjustment where appropriate

Tested:

* monitor mode, ath10k port
* STA mode, ath10k port - VHT20, VHT40, VHT80 modes

TODO:

* IBSS;
* hostap;
* (ignore mesh, wds for now);
* finish 11n state engine - channel width change, opmode notifications, SMPS, etc;
* VHT basic rate negotiation and acceptance criteria when scanning, associating, etc;
* VHT control/management frame handling (group managment and operating mode being
the two big ones);
* Verify TX/RX VHT rate negotiation is actually working correctly.

Whilst here, add some comments about seqno allocation and locking. To achieve
the full VHT rates I need to push seqno allocation into the drivers and
finally remove the IEEE80211_TX_LOCK() I added years ago to fix issues. :/


# 74a54be9 21-Nov-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] store references to VHT and related IEs.

This just stores pointers to the IE; it doesn't yet parse anything.

Note: it blows out the size of ieee80211_node, so this will require
ye olde kernel/modules recompile.


# 869897d2 21-Nov-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] flesh out more IBSS 11n support

* Pepper comments around which describe what state(s) we're in when faking
up 11n nodes.
* By default don't fake it up as 11n until we properly negotiate the 11n
capabilities using probe request/response frames.
* Send a probe request with our HT information, as the 802.11-2012 spec
suggests.
* Reassociate with the driver if we've been promoted.

This is done because although learning a peer via beacons can learn 11n
state, learning peers via hearing probe frames and broadcast frames
does not. Thus, sometimes you end up with an 11n peer in the peer
table and sometimes you don't.

Note that the probe request/response exchange may not actually succeed.
Ideally we'd put the peer into some blocking state until we've exchanged
probe request/reponse to learn capabilities, or we timeout and just
stay non-11n.

This is more an experiment to get 11n IBSS nodes actually discovering
each other and be able to transmit. There are other issues that creep
up which I'll attempt to address in future commits.

Tested:

* AR9380 NICs in 11n mode.

Reviewed by: avos
Differential Revision: https://reviews.freebsd.org/D8365


# 7db788c6 14-Nov-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: switch from ieee80211_iterate_nodes() to
ieee80211_iterate_nodes_vap() where possible; this should
make the code a bit cleaner.


# d2e877f0 02-Oct-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: add one-vap version of ieee80211_iterate_nodes()

- Add a counter into 'struct ieee80211_node_table' to save current number
of allocated nodes.
(allows to remove array overflow checking in ieee80211_iterate_nodes()).
- Add ieee80211_iterate_nodes_vap() function; unlike non-vap version,
it iterates on nodes for specified vap only.

In addition to the above:
- Remove ieee80211_iterate_nt(); it is not used by drivers / net80211
outside ieee80211_iterate_nodes() function + cannot be separated due
to structural changes in code.

Since size of 'struct ieee80211_node_table' (part of ieee80211com,
which is a part of driver's softc) is changed all wireless drivers /
kernel need to be recompiled.

Tested with wpi(4), STA mode.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D7996


# 172b009a 21-Sep-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] don't add IBSS node table entries for neighbors from other SSIDs.

The adhoc probe/beacon input path was creating nodes for all SSIDs.
This wasn't a problem when the NICs were configured to only process
frames for the current BSSID, but that didn't allow IBSS merges.
Once avos and I flipped on "beacons from all BSSIDs" to allow for
correct IBSS merging, we found this interesting behaviour.

This adds a check against the current SSID.

* If there's no VAP SSID, allow anything
* If there's a VAP SSID, check if the incoming frame has a suitable
SSID and if so, allow it.

This prevents nodes being created for other SSIDs in probe and beacon
frames - ie, beacons overlapping IBSSes with different SSIDs, and
probe requests from arbitrary devices.

Tested:

* AR9380, IBSS mode, both local and other IBSSes.

Reviewed by: avos
Differential Revision: https://reviews.freebsd.org/D7959


# 03475bd0 19-Jun-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] remove node scan lock / generation number + fix few LORs

Drop scan generation number and node table scan lock - the only place
where ni_scangen is checked is in ieee80211_timeout_stations() (and it
is used to prevent duplicate checking of the same node); node scan lock
protects only this variable + node table scan generation number.

This will fix (at least) next LOR (hostap mode):

lock order reversal:
1st 0xc175f84c urtwm0_scan_loc (urtwm0_scan_loc) @ /usr/src/sys/modules/wlan/../../net80211/ieee80211_node.c:2019
2nd 0xc175e018 urtwm0_com_lock (urtwm0_com_lock) @ /usr/src/sys/modules/wlan/../../net80211/ieee80211_node.c:2693
stack backtrace:
#0 0xa070d1c5 at witness_debugger+0x75
#1 0xa070d0f6 at witness_checkorder+0xd46
#2 0xa0694cce at __mtx_lock_flags+0x9e
#3 0xb03ad9ef at ieee80211_node_leave+0x12f
#4 0xb03afd13 at ieee80211_timeout_stations+0x483
#5 0xb03aa1c2 at ieee80211_node_timeout+0x42
#6 0xa06c6fa1 at softclock_call_cc+0x1e1
#7 0xa06c7518 at softclock+0xc8
#8 0xa06789ae at intr_event_execute_handlers+0x8e
#9 0xa0678fa0 at ithread_loop+0x90
#10 0xa0675fbe at fork_exit+0x7e
#11 0xa08af910 at fork_trampoline+0x8

In addition to the above:

* switch to ieee80211_iterate_nodes();
* do not assert that node table lock is held, while calling node_age();
that's not really needed (there are no resources, which can be protected
by this lock) + this fixes LOR/deadlock between ieee80211_timeout_stations()
and ieee80211_set_tim() (easy to reproduce in HOSTAP mode while
sending something to an STA with enabled power management).

Tested:

* (avos) urtwn0, hostap mode
* (adrian) AR9380, STA mode
* (adrian) AR9380, AR9331, AR9580, hostap mode

Notes:

* This changes the net80211 internals, so you have to recompile all of it
and the wifi drivers.

Submitted by: avos
Approved by: re (delphij)
Differential Revision: https://reviews.freebsd.org/D6833


# 601a2543 12-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: drop some unused variables / local macros

Most of them left after some commits (r178354, r191544, r287197 etc.);
some were never used.

Found by: Clang Static Analyzer


# a4641f4e 03-May-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/net*: minor spelling fixes.

No functional change.


# c89e0d15 09-Apr-2016 Bjoern A. Zeeb <bz@FreeBSD.org>

Try to unbreak the build: the 'vap' variable is only used if ieee80211
debugging compile is on.


# 2b8b8ae8 08-Apr-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] print out the channel type (eg a, b, g, n) when creating
an IBSS network.


# adad5b45 08-Apr-2016 Adrian Chadd <adrian@FreeBSD.org>

[net8021] Pull out the ibss check code into a public function.

The ath(4) driver now sees beacons and management frames for different
BSSIDs in IBSS mode, which is a problem when you're in a very busy
IBSS environment.

So, expose this function so drivers can use it to check if the current
RX node is actually for a BSS we need to pay attention to or not.

PR: kern/208644
Sponsored by: Eva Automation. Inc.


# 1c7b0c84 05-Apr-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Initial A-MSDU support for testing / evaluation

A-MSDU is another 11n aggregation mechanism where multiple ethernet
frames get LLC encapsulated (so they have a length field), padded,
and put in a single MPDU (802.11 MAC frame.) This means it gets sent
out as a single frame, with a single seqno, it's acked as one frame, etc.

It turns out that, hah, atheros fast frames is almost but not quite
like this, so I'm reusing all of the current superg/fast-frames stuff
in order to actually transmit A-MSDU. Yes, this means that A-MSDU
frames are also only aggregated two at a time, so it's not necessarily
a huge win, but it's better than nothing.

This doesn't do anything by default - the driver needs to say it does
A-MSDU as well as set the AMSDU software TX capability so this code path
gets exercised.

For now, the only driver that enables this is urtwn. I'll enable it
for rsu at some point soon.
Tested:

* Add an amsdu encap path to aggregate two frames, same as the
fast-frames path.

* Always do the superg init/teardown and node init/teardown stuff,
regardless of whether the nodes are doing fast-frames (the ATH
capability stuff.) That way we can reuse it for amsdu.

* Don't do AMSDU for multicast/broadcast and EAPOL frames.

* If we're doing A-MPDU, then don't bother doing FF/A-MSDU.
We can likely do both together, but I don't want to change
behaviour.

* Teach the fast frames approx txtime logic to support the 11n
rates. But, since we don't currently have a full "current rate"
support, assume it's HT20, long-gi, etc. That way we overshoot
on the TX time estimation, so we're always inside the requirements.
(And we only aggregate two frames for now, so we're not really
going to exceed that.)

* Drop the maximum FF age default down to 2ms, otherwise we end up
with some very annoyingly large latencies.

TODO:

* We only aggregate two ethernet frames, so I'm not checking the max
A-MSDU size. But when it comes time to support >2 frames, we should
obey that.

Tested:

* urtwn(4)


# b8e29e06 29-Mar-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] migrate the time_* macros to ieee80211_* namespace.

It turns out that these will clash very annoyingly with the linux
macros in the linuxkpi layer, so let the wookie^Wlinux win.

The only user that I can find is ath(4), so fix it there too.


# ffadb4ac 23-Feb-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: fix TIM cleanup.

Remove duplicate 'ni->ni_associd = 0' assignment from
ieee80211_node_leave(), since it breaks iv_set_tim() in
ic->ic_node_cleanup() (associd is cleared right after this call).

Tested with RTL8188EU (HOSTAP mode) and
WUSB54GC (STA mode, with powersaving enabled).

Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D5398


# b9b53389 25-May-2015 Adrian Chadd <adrian@FreeBSD.org>

Convert malloc/free back to #define's, as part of OS portability work.

DragonflyBSD uses the FreeBSD wireless stack and drivers. Their malloc()
API is named differently, so they don't have userland/kernel symbol
clashes like we do (think libuinet.)

So, to make it easier for them and to port to other BSDs/other operating
systems, start hiding the malloc specific bits behind defines in
ieee80211_freebsd.h.

DragonflyBSD can now put these portability defines in their local
ieee80211_dragonflybsd.h.

This should be a great big no-op for everyone running wifi.

TODO:

* kill M_WAITOK - some platforms just don't want you to use it
* .. and/or handle it returning NULL rather than waiting forever.
* MALLOC_DEFINE() ?
* Migrate the well-known malloc names (eg M_TEMP) to net80211
namespace defines.


# c8f5794e 25-May-2015 Gleb Smirnoff <glebius@FreeBSD.org>

Use name from ieee80211com instead of parent ifnet, in debugging printfs.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# fd90e2ed 22-May-2015 Jung-uk Kim <jkim@FreeBSD.org>

CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten
years for head. However, it is continuously misused as the mpsafe argument
for callout_init(9). Deprecate the flag and clean up callout_init() calls
to make them more consistent.

Differential Revision: https://reviews.freebsd.org/D2613
Reviewed by: jhb
MFC after: 2 weeks


# eca3b4fc 03-May-2015 Adrian Chadd <adrian@FreeBSD.org>

Add node_clear_keyixmap() and use it in the ieee80211_free_node() / node_reclaim().

PR: kern/199672
Submitted by: Andriy Voskoboinyk <s3erios@gmail.com>


# 8a055831 03-May-2015 Adrian Chadd <adrian@FreeBSD.org>

Remove old iv_bss entry from the node table

This may happen on RUN -> SCAN -> RUN -> SCAN state transition:

1. RUN -> SCAN: in ieee80211_sta_join1(): iv_bss will be moved to obss,
refcnt will be reduced by 2 (default minimum).

Now, if old iv_bss have some extra references (for example, from
unacknowledged probe responses), it will not be freed and will stay
in the node table.

2. SCAN -> RUN.

3. If old iv_bss will not be deleted by the time when the next RUN -> SCAN
state transition occurs, then sta_leave() will reduce it's reference
counter once more. As a result, two last users will free it -> this will
lead to kernel panic.

In this patch old iv_bss entry is explicitly removed from the node table in
ieee80211_sta_join1() (as a result, it will not be processed by sta_leave()).

PR: kern/199676
Differential Revision: Andriy Voskoboinyk <s3erios@gmail.com>


# 76039bc8 26-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# a3e08d6f 13-Aug-2013 Rui Paulo <rpaulo@FreeBSD.org>

Replace the homegrown implementation of nitems() with calls to nitems()
(param.h).

Operating systems that don't have nitems() can easily define it on their own
net80211 OS-specific header file.

Discussed with: adrian


# d71a1f7a 25-Jan-2013 Adrian Chadd <adrian@FreeBSD.org>

Initial cut at making IBSS support 802.11n aware.

* Add HTINFO field decoding to ieee80211_ies_expand() - it's likely not
100% correct as it's not looking at the draft 11n HTINFO location,
but I don't think anyone will care.

* When doing an IBSS join make sure the 11n channel configuration
is used - otherwise the 11a/11bg channel will be used
and there won't be any chance for an upgrade to 11n.

* When creating an IBSS network, ensure the channel is updated to an
11n channel so other 11n nodes can see it and speak to it with MCS
rates.

* Add a bit of code that's disabled for now which handles the HT
field updating. This won't work out very well with lots of adhoc
nodes as we'd end up ping-ponging between the HT configuration for
each node. Instead, we should likely only pay attention to the
"master" node we initially associated against and then ensure we
propagate that information forward in our subsequent beacons. However,
due to the nature of IBSS (ie, there's no specific "master" node in
the specification) it's unclear which node we should lift the HT
parameters from.

So for now this assumes the HT parameters are squirreled away in the
initial beacon/probe response.

So there's some trickiness here.

With ap/sta pairing, the probe response just populates a legacy node
and the association request/response is what is used for negotiation
11n-ness (and upgrading things as needed.)

With ibss networks, the pairing is done with probe request/response,
with discovery being done by creating nodes when new beacons in the
IBSS / BSSID are heard. There's no assoc request/response frames going on.

So the trick here has been to figure out where to upgrade things.
I don't like how I just taught ieee80211_sta_join() to "speak" HT -
I'd rather there be an upgrade path when an IBSS node joins and there
are HT parameters present. Once I've done that, I'll kill this
HT special casing that's going on in ieee80211_sta_join().

Tested:

* AR9280, AR5416, AR5212 - basic iperf and ping interoperability tests
whilst in a non-encrypted adhoc network.

TODO:

* Fix up the HT upgrade path for IBSS nodes rather than adding code
in ieee80211_sta_join(), then remove my code from there.

* When associating, there's a concept of a "master" node in the IBSS
which is the node you first joined the network through. It's possible
the correct thing to do is to listen to HT updates and configure WME
parameters from that node. However, once that node goes away, which
node(s) should be listened to for configuration changes?

For things like HT channel width, it's likely going to be ok to
just associate as HT40 and then use the per-neighbor rate control
and HTINFO/HTCAP fields to figure out which rates and configuration
to speak. Ie, for a 20MHz 11n node, just speak 20MHz rates to
it. It shouldn't "change", like what goes on in AP/STA configurations.


# 7b5a3435 16-Sep-2012 Adrian Chadd <adrian@FreeBSD.org>

Fix a crash bug introduced in the iterate node work recently done.

When resuming, the first VAP is checked for max_aid; however if there
is no VAP, this results in a NULL pointer dereference and kernel
panic.


# b6afbb79 15-Aug-2012 Adrian Chadd <adrian@FreeBSD.org>

Fix an incorrect comparison.

PR: kern/170098


# 7d684b4b 15-Aug-2012 Adrian Chadd <adrian@FreeBSD.org>

Don't call the node iteration function inside the node table / node
iterate lock.

This causes LORs and deadlocks as some code paths will have the com lock
held when calling ieee80211_iterate_nodes().

Here, the comlock isn't held during the node table and node iteration
locks; and the callback isn't called with any (extra) lock held.

PR: kern/170098
Submitted by: moonlightakkiy@yahoo.ca
MFC after: 4 weeks


# b94299c4 24-Mar-2012 Adrian Chadd <adrian@FreeBSD.org>

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


# 88e428c6 21-Apr-2011 Adrian Chadd <adrian@FreeBSD.org>

Revert r220907 and r220915.

Changing the size of struct ieee80211_mimo_info changes
the STA info data, breaking ifconfig in general.


# bc4e0fe6 20-Apr-2011 Adrian Chadd <adrian@FreeBSD.org>

Change the MIMO userland export ABI to include flags, number of radio chains,
extended EVM statistics and EXT channel data.

ifconfig still displays 3 chains worth of ctl noise/rssi.


# 864ab114 08-Apr-2011 Adrian Chadd <adrian@FreeBSD.org>

Add initial support for MIMO statistics to net80211.

This introduces struct ieee80211_rx_stats - which stores the various kinds
of RX statistics which a MIMO and non-MIMO 802.11 device can export.

It also fleshes out the mimo export to userland (node_getmimoinfo()).

It assumes that MIMO radios (for now) export both ctl and ext channels.
Non-11n MIMO radios are possible (and I believe Atheros made at least
one), so if that chipset support is added, extra flags to the
struct ieee80211_rx_stats can be added to extend this support.

Two new input functions have been added - ieee80211_input_mimo() and
ieee80211_input_mimo_all() - which MIMO-aware devices can call with
MIMO specific statistics.

802.11 devices calling the non-MIMO input functions will still function.


# 597029bf 12-Mar-2011 Bernhard Schmidt <bschmidt@FreeBSD.org>

Honor device capabilities while initializing ni_htrates.

Instead of hardcoding MCS0-15 generate the table dynamically, also
restrict the MCS rates to our own capabilities while parsing a htcap
element.


# bd56e71b 17-Jan-2011 Bernhard Schmidt <bschmidt@FreeBSD.org>

Pull ieee80211_ratectl_node_init() calls from drivers into net80211.
This fixes hostap mode for at least ral(4) and run(4), because there is
no sufficient call into drivers which could be used initialize the node
related ratectl variables.

MFC after: 3 days


# a7c6aabd 06-Nov-2010 Bernhard Schmidt <bschmidt@FreeBSD.org>

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


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 87d87e1d 21-Aug-2010 Bernhard Schmidt <bschmidt@FreeBSD.org>

Wrap remaining ieee80211_ratectl_node_init() calls missed in r211314.

MFC after: 1 week


# ad8e331b 14-Aug-2010 Bernhard Schmidt <bschmidt@FreeBSD.org>

Introduce IEEE80211_C_RATECTL, drivers which use the ratectl framework
should set this capability.

MFC after: 2 weeks


# 49d2c137 14-Aug-2010 Bernhard Schmidt <bschmidt@FreeBSD.org>

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


# 82878b11 11-May-2010 Rui Paulo <rpaulo@FreeBSD.org>

MFC r206367, r206358, r206370, r206371, r206372, r206398, r206415,
r206416, r206417, r206418, r206418:

net80211 ratectl framework.


# 48e1bda0 28-Apr-2010 Rui Paulo <rpaulo@FreeBSD.org>

Fix typo. No functional change.

Obtained from: DragonFlyBSD


# b6108616 07-Apr-2010 Rui Paulo <rpaulo@FreeBSD.org>

net80211 rate control framework (net80211 ratectl).

This framework allows drivers to abstract the rate control algorithm and
just feed the framework with the usable parameters. The rate control
framework will now deal with passing the parameters to the selected
algorithm. Right now we have AMRR (the default) and RSSADAPT but there's
no way to select one with ifconfig, yet.
The objective is to have more rate control algorithms in the net80211
stack so all drivers[0] can use it. Ideally, we'll have the well-known
sample rate control algorithm in the net80211 at some point so all
drivers can use it (not just ath).

[0] all drivers that do rate control in software, that is.

Reviewed by: bschmidt, thompsa, weyongo
MFC after: 1 months


# 7733cf8f 11-Feb-2010 Matt Jacob <mjacob@FreeBSD.org>

MFC a number of changes from head for ISP (203478,203463,203444,202418,201758,
201408,201325,200089,198822,197373,197372,197214,196162). Since one of those
changes was a semicolon cleanup from somebody else, this touches a lot more.


# c2ede4b3 07-Jan-2010 Martin Blapp <mbr@FreeBSD.org>

Remove extraneous semicolons, no functional changes.

Submitted by: Marc Balmer <marc@msys.ch>
MFC after: 1 week


# 59aa14a9 11-Jul-2009 Rui Paulo <rpaulo@FreeBSD.org>

Implementation of the upcoming Wireless Mesh standard, 802.11s, on the
net80211 wireless stack. This work is based on the March 2009 D3.0 draft
standard. This standard is expected to become final next year.
This includes two main net80211 modules, ieee80211_mesh.c
which deals with peer link management, link metric calculation,
routing table control and mesh configuration and ieee80211_hwmp.c
which deals with the actually routing process on the mesh network.
HWMP is the mandatory routing protocol on by the mesh standard, but
others, such as RA-OLSR, can be implemented.

Authentication and encryption are not implemented.

There are several scripts under tools/tools/net80211/scripts that can be
used to test different mesh network topologies and they also teach you
how to setup a mesh vap (for the impatient: ifconfig wlan0 create
wlandev ... wlanmode mesh).

A new build option is available: IEEE80211_SUPPORT_MESH and it's enabled
by default on GENERIC kernels for i386, amd64, sparc64 and pc98.

Drivers that support mesh networks right now are: ath, ral and mwl.

More information at: http://wiki.freebsd.org/WifiMesh

Please note that this work is experimental. Also, please note that
bridging a mesh vap with another network interface is not yet supported.

Many thanks to the FreeBSD Foundation for sponsoring this project and to
Sam Leffler for his support.
Also, I would like to thank Gateworks Corporation for sending me a
Cambria board which was used during the development of this project.

Reviewed by: sam
Approved by: re (kensmith)
Obtained from: projects/mesh11s


# 5b16c28c 05-Jul-2009 Sam Leffler <sam@FreeBSD.org>

Add ieee80211_ageq; a facility for staging packets that require
long-term work before they can be serviced. Packets are tagged and
assigned an age (in seconds) at the point they are added to the
queue. If a packet is not retrieved before it's age expires it is
reclaimed. Tagging can take two forms: a reference to an ieee80211_node
(as happens in the tx path) or an opaque token in cases where there
is no reference or the node structure is not stable (i.e. it's going
to be destroyed).

o add ic_stageq to replace the per-node wds staging queue used for
dynamic wds
o add ieee80211_mac_hash for building ageq tokens; this computes a
32-bit hash from an 802.11 mac address (copied from the bridge)
o while here fix a stray ';' noticed in IEEE80211_PSQ_INIT

Reviewed by: rpaulo
Approved by: re (kensmith)


# d77148fb 10-Jun-2009 Sam Leffler <sam@FreeBSD.org>

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.


# 2bfc8a91 07-Jun-2009 Sam Leffler <sam@FreeBSD.org>

iv_flags_ext is full, make room by moving HT-related flags to a new
iv_flags_ht word


# 5463c4a4 20-May-2009 Sam Leffler <sam@FreeBSD.org>

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


# 70ca3d6a 14-May-2009 Sam Leffler <sam@FreeBSD.org>

correct handling of ctl frames: the sender's address is always i_addr2 for
frames we should expect to process (old code was trying to handle frames
we should never see--like ACK)

Reviewed by: thompsa, cbzimmer


# 5efea30f 02-May-2009 Andrew Thompson <thompsa@FreeBSD.org>

Create a taskqueue for each wireless interface which provides a serialised
sleepable context for net80211 driver callbacks. This removes the need for USB
and firmware based drivers to roll their own code to defer the chip programming
for state changes, scan requests, channel changes and mcast/promisc updates.
When a driver callback completes the hardware state is now guaranteed to have
been updated and is in sync with net80211 layer.

This nukes around 1300 lines of code from the wireless device drivers making
them more readable and less race prone.

The net80211 layer has been updated as follows
- all state/channel changes are serialised on the taskqueue.
- ieee80211_new_state() always queues and can now be called from any context
- scanning runs from a single taskq function and executes to completion. driver
callbacks are synchronous so the channel, phy mode and rx filters are
guaranteed to be set in hardware before probe request frames are
transmitted.

Help and contributions from Sam Leffler.

Reviewed by: sam


# c5262b82 13-Apr-2009 Sam Leffler <sam@FreeBSD.org>

fix txparms setup for 108G sta's: ieee80211_iserp_rateset does not
identify a station operating in turbo-boost mode because it has a
pure ofdm rate set; add an explicit check for the channel type
instead of depending on IEEE80211_NODE_ERP being set


# 339ccfb3 30-Mar-2009 Sam Leffler <sam@FreeBSD.org>

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


# 26d39e2c 29-Mar-2009 Sam Leffler <sam@FreeBSD.org>

o add ic_rt to track the rate table for the current channel; this enables
calculation of packet transmit times to do things like check txop limits
o remove equivalent driver code and convert to use net80211 state


# 616190d0 24-Mar-2009 Sam Leffler <sam@FreeBSD.org>

split Atheros SuperG support out into it's own file that's included only
with a new IEEE80211_SUPPORT_SUPERG option


# aa68c24f 20-Feb-2009 Sam Leffler <sam@FreeBSD.org>

mark nodes created by way of neighbor discovery need to be marked as ERP
so they get the correct tx parameters setup by node_settxparms


# 6a76ae21 18-Feb-2009 Sam Leffler <sam@FreeBSD.org>

Add modes for 1/2 and 1/4-width channels so we have separate roaming
and xmit parameters. This makes it possible to use tdma on fractional
channels.
o add IEEE80211_MODE_HALF and IEEE80211_MODE_QUARTER; note these are
band-agnostic (may need revisiting)
o setup all default rates in ic_sup_rates instead of doing it only
for active modes; we need these to calculate the default tx parameters
which are not recalculated after a regulatory update (can't just
recalculate after installing a new channel list because we might
clobber user settings)
o remove special case code in ieee80211_get_suprates; this is now
a candidate for an inline or removal
o add various entries for new modes (roaming+tx params, wme, rate
mapping, scan set setup, country ie construction, tdma, basic rates)

Note these modes are intentionally not visible through if_media.


# 47a7b0fa 12-Feb-2009 Sam Leffler <sam@FreeBSD.org>

o replace ieee80211_node_reclaim by individual operations to release the
references to iv_bss and the sta table; this is equivalent and causes
direct reclaim of the old bss node when any references in packets inflight
are reclaimed (previously the old node would sit in the bss table until
the inactivity processing reclaimed it)
o remove ieee80211_node_reclaim now that it's only use is gone

Reviewed by: avatar, cbzimmer


# 73bac36f 11-Feb-2009 Sam Leffler <sam@FreeBSD.org>

improve key index map reclaim debug msg


# f76cde95 29-Jan-2009 Sam Leffler <sam@FreeBSD.org>

set ni_txparms for static turbo mode


# 10ad9a77 08-Jan-2009 Sam Leffler <sam@FreeBSD.org>

TDMA support for long distance point-to-point links using ath devices:
o add net80211 support for a tdma vap that is built on top of the
existing adhoc-demo support
o add tdma scheduling of frame transmission to the ath driver; it's
conceivable other devices might be capable of this too in which case
they can make use of the 802.11 protocol additions etc.
o add minor bits to user tools that need to know: ifconfig to setup and
configure, new statistics in athstats, and new debug mask bits

While the architecture can support >2 slots in a TDMA BSS the current
design is intended (and tested) for only 2 slots.

Sponsored by: Intel


# 6ca74c40 07-Jan-2009 Sam Leffler <sam@FreeBSD.org>

only mark an infrastructure node to require an associd for xmit; fixes adhoc
mode sta's that join an existing ibss


# 9094ffdf 31-Dec-2008 Sam Leffler <sam@FreeBSD.org>

mark discovered neighbors QoS capable if they advertise wme


# e2126dec 18-Dec-2008 Sam Leffler <sam@FreeBSD.org>

convert MALLOC/FREE to malloc/free


# ca92652a 15-Dec-2008 Sam Leffler <sam@FreeBSD.org>

Fix ucastkey teardown for drivers that plumb clear keys or similar
(e.g. ath): we must check the key index and not whether the key
points at a cipher other than "undef". This looks like it's been
broken for a while. Might be worth adding an explicit clear cipher
at some point though this would require changes to the usage of
IEEE80211_KEY_UNDEFINED.

PR: 125906


# 1b999d64 14-Dec-2008 Sam Leffler <sam@FreeBSD.org>

Replace adhoc checks in ieee80211_start with a per-node flag that
indicates if an association id is required before outbound traffic
is permitted. This cleans up the previous change that broke mcast
traffic "to the stack" in ap mode as a side effect.

Reviewed by: sephe, thompsa, weongyo


# 5d44f8c0 26-Oct-2008 Sam Leffler <sam@FreeBSD.org>

o re-enable a lock assert
o while here reformat a comment to sync w/ other repot's


# 63092fce 25-Oct-2008 Sam Leffler <sam@FreeBSD.org>

New ap-side power save implementation; the main change is to allow drivers
to queue frames previously encapsulated on a separate high priority list
that is dispatched before the unencapsulated frames (to preserve order).


# dfcd1f4d 25-Oct-2008 Sam Leffler <sam@FreeBSD.org>

set erp flag and tx parameter state when joining a bss; this allows
drivers to use ni_txparms


# be1054ed 25-Oct-2008 Sam Leffler <sam@FreeBSD.org>

improve inactivity handling debug support


# 10959256 25-Oct-2008 Sam Leffler <sam@FreeBSD.org>

change ieee80211_sta_join to take an explicit channel instead of
using the value in the scan parameters; this will be used to fix
issues with 11b operation


# c5abbba3 23-Oct-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Revert the removal of the MALLOC and FREE macros from the net80211 code.

Requested by: sam


# 1ede983c 23-Oct-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Retire the MALLOC and FREE macros. They are an abomination unto style(9).

MFC after: 3 months


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# b9b5f07d 21-Sep-2008 Sam Leffler <sam@FreeBSD.org>

cleanup bss node setup; syncs w/ p4 state that's been in use for months


# 44f7a6ed 21-Sep-2008 Sam Leffler <sam@FreeBSD.org>

RIFS support; needs driver callback for dynamic state change


# 8c070d69 21-Sep-2008 Sam Leffler <sam@FreeBSD.org>

MIMO power save support; still needs callbacks for notifying drivers
of dynamic state change in station mode.


# 01a03542 21-Sep-2008 Sam Leffler <sam@FreeBSD.org>

Add current transmit parameters for fixed rate handling so drivers
don't duplicate this. These are setup according to the role of the
node--the bss node for ap and adhoc modes need to use parameters
that are the least common denomimator of all nodes in the bss;
otherwise we are setting up params for a station joining a bss and
we select those according to the capabilities of the station.

This stuff needs more work as we do extra work due to having setup
in common code paths shared by nodes using both roles.


# 0f52b1c4 06-Sep-2008 Sam Leffler <sam@FreeBSD.org>

make all checks if ni_chw consistent


# 38c208f8 07-Jun-2008 Sam Leffler <sam@FreeBSD.org>

Change the calling convention for ic_node_alloc to deal with
some longstanding issues:
o pass the vap since it's now the "coin of the realm" and required
to do things like set initial tx parameters in private node
state for use prior to association
o pass the mac address as cards that maintain outboard station
tables require this to create an entry (e.g. in ibss mode)
o remove the node table reference, we only have one node table
and it's unlikely this will change so this is not needed to
find the com structure


# 2dc4d8dc 07-Jun-2008 Sam Leffler <sam@FreeBSD.org>

Split ieee80211_notify_erp into locked and unlocked variants
and use the locked version to handle the hostap input path
case where the com lock is not already held.

Noticed by: Jared Go


# 37e9743a 07-Jun-2008 Sam Leffler <sam@FreeBSD.org>

Fix node cleanup issues when the last reference is held by
the driver (e.g. in the tx q); ni_vap may not be valid, we
must carefully check before using it.


# 13f91245 07-Jun-2008 Sam Leffler <sam@FreeBSD.org>

correct code returned in AsssocResp; the previous code is spec'd for use
only in deauth+disassoc frames

Submitted by: Chris Zimmermann
MFC after: 1 month


# 34c9a6c7 28-May-2008 Sam Leffler <sam@FreeBSD.org>

Don't override the txpower cap installed by ieee80211_alloc_node;
we use ic_txpowlimit (for now) to initialize all new sta entries.


# a2cfa5b7 22-May-2008 Sam Leffler <sam@FreeBSD.org>

special-case broadcast probe request in ieee80211_find_rxnode; we need
to spam all vaps and this won't happen if the frame comes from a station
that is associated to an ap vap (and so has an entry in the table)

Noticed by: Jared Go
Reviewed by: thompsa


# 92172ed8 01-May-2008 Sam Leffler <sam@FreeBSD.org>

fix build w/ IEEE80211_DEBUG_REFCNT enabled


# b032f27c 20-Apr-2008 Sam Leffler <sam@FreeBSD.org>

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)


# ce8977df 22-Nov-2007 Sam Leffler <sam@FreeBSD.org>

o correct re-association indicator dispatched in node join event
o remove misleading "reassociation" msg on sta join

MFC after: 3 days


# cb42c5bb 22-Nov-2007 Sam Leffler <sam@FreeBSD.org>

parse htcap ie early so ampdu density and max rx size are available
for constructing the AssocReq frame

MFC after: 3 days


# 1b6167d2 01-Nov-2007 Sam Leffler <sam@FreeBSD.org>

sync 11n support with vap code base; many changes based on interop
testing with all major vendors

MFC after: 1 week


# 5698ab1a 18-Sep-2007 Sam Leffler <sam@FreeBSD.org>

Close longstanding race dropping inactive stations; grab a reference
to the node before starting the work, otherwise the node may go
away before a reference is made in ieee80211_send_mgmt.

Approved by: re (blanket wireless)
Obtained from: Atheros


# e5ac9e91 18-Sep-2007 Sam Leffler <sam@FreeBSD.org>

Safeguard count of stations in power save; don't touch it unless we're
operating in a mode where it should be maintained.

Approved by: re (blanket wireless)
MFC after: 2 weeks


# b105a069 17-Sep-2007 Sam Leffler <sam@FreeBSD.org>

Update beacon handling to sync w/ vap code base:
o add driver callback to handle notification of beacon changes;
this is required for devices that manage beacon frames themselves
(devices must override the default handler which does nothing)
o move beacon update-related flags from ieee80211com to the beacon
offsets storage (or handle however a driver wants)
o expand beacon offsets structure with members needed for 11h/dfs
and appie's
o change calling convention for ieee80211_beacon_alloc and
ieee80211_beacon_update
o add overlapping bss support for 11g; requires driver to pass
beacon frames from overlapping bss up to net80211 which is not
presently done by any driver
o move HT beacon contents update to a routine in the HT code area

Reviewed by: avatar, thompsa, sephe
Approved by: re (blanket wireless)


# 7595008b 05-Sep-2007 Sam Leffler <sam@FreeBSD.org>

oops, add missing bit from last change

Approved by: re (blanket wireless)


# c066143c 05-Sep-2007 Sam Leffler <sam@FreeBSD.org>

Fixup sta inactivity handling:
o reset ni_inact when ni_inact_reload is changed so we're
assured a valid setting
o never let ni_inact go negative
o add a knob to disable hostap sta idle handling (e.g. so it can be done
by a user application)
o remove bogus reload on associate

Reviewed by: avatar
Approved by: re (blanket wireless)


# 68e8e04e 10-Jun-2007 Sam Leffler <sam@FreeBSD.org>

Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing

Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested

This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.


# ae8b7333 05-Jun-2007 Sam Leffler <sam@FreeBSD.org>

copyright updates:
o update to include 2007
o switch back to a 2-clause bsd-only license

Reviewed by: onoe


# 70e28b9a 11-Mar-2007 Sam Leffler <sam@FreeBSD.org>

change ieee80211_fix_rate to take a rate set instead of using
ni_rates; this lets us re-use the code to check 11n HT rates

MFC after: 2 weeks


# 801df4a5 11-Mar-2007 Sam Leffler <sam@FreeBSD.org>

keep tx/rx seq #'s for non-QoS traffic separate from QoS; stations
aren't supposed mix traffic but if they did frames might be mis-handled

Obtained from: Atheros
MFC after: 2 weeks


# fe49f061 06-Mar-2007 Sam Leffler <sam@FreeBSD.org>

when starting up an ibss master use a random address for
the bssid; this is required for wifi alliance compliance

Obtained from: Atheros
MFC after: 2 weeks


# ca4ac7ae 14-Jan-2007 Sam Leffler <sam@FreeBSD.org>

Add initial support for 900MHz cards like the Ubiquiti SR9:
o add channel flag to enable freq <-> ieee channel # mapping (can
go away in the future when ieee number is precomputed)
o add mapping between 900mhz freq's and channel #'s that gives a
unique channel # for each half/quarter/full width channel
o remove assumptions that half/quarter rate channels on happen in 11a
o remove assumptions that all 11g channels are full width
o ensure ic_curchan is reset on mode change so changing the channel
list (e.g. on countrycode change) doesn't leave curchan set to an
invalid channel

There is still an issue with switching rate sets; to be fixed separately.

MFC after: 1 month


# 79edaebf 08-Jan-2007 Sam Leffler <sam@FreeBSD.org>

Correct several issues with rate set negotiation:
o add IEEE80211_F_JOIN flag to ieee80211_fix_rate to indicate a station
is joining a BSS; this is used to control whether or not we over-write
the basic rate bit in the calculated rate set
o fix ieee80211_fix_rate to honor IEEE80211_F_DODEL when IEEE80211_F_DONEGO
is not specified (e.g. when joining an ibss network)
o on sta join always delete unusable rates from the negotiated rate set,
this was being done only ibss networks but is also needed for 11g bss
with mixed stations
o on sta join delete unusable rates from the bss node's rate set, not the
scan table entry's rate set
o when calculating a rate set for new neighbors in an ibss caculate a
negotiated rate set so drivers are not presented with rates they should
not use

Submitted by: Sepherosa Ziehau (w/ modifications)
Obtained from: DragonFly
MFC after: 1 month


# 41b3c790 27-Dec-2006 Sam Leffler <sam@FreeBSD.org>

First cut at half/quarter-rate 11a channel support (e.g. for use
in the Public Safety Band):
o add channel flags to identify half/quarter-rate operation
o add rate sets (need to check spec on 4Mb/s in 1/4 rate)
o add if_media definitions for new rates
o split net80211 channel setup out into ieee80211_chan_init
o fixup ieee80211_mhz2ieee and ieee80211_ieee2mhz to understand half/quarter
rate channels: note we temporarily use a nonstandard/hack numbering that
avoids overlap with 2.4G channels because we don't (yet) have enough
state to identify and/or map overlapping channel sets
o fixup ieee80211_ifmedia_init so it can be called post attach and will
recalculate the channel list and associated state; this enables changing
channel-related state like the regulatory domain after attach (will be
needed for 802.11d support too)
o add ieee80211_get_suprates to return a reference to the supported rate
set for a given channel
o add 3, 4.5, and 27 MB/s tx rates to rate <-> media conversion routines
o const-poison channel arg to ieee80211_chan2mode


# 132142c5 01-Jun-2006 Diomidis Spinellis <dds@FreeBSD.org>

Move conditional preprocessing out from the IEEE80211_DPRINTF macro
invocation. Per C99 6.10.3 paragraph 11 preprocessing directives
appearing as macro arguments yield undefined behavior.


# ee25b8df 28-Apr-2006 Sam Leffler <sam@FreeBSD.org>

Ensure outbound data packets in hostap mode are delivered only to
stations that are associated by making ieee80211_find_txnode return
NULL when a unicast frame is to be delivered to an unassociated
station. This will be handled differently in the future but for
now putting the check here allows all drivers to immediately do
the right thing.

Reviewed by: avatar
MFC after: 1 week


# 097131ff 06-Mar-2006 Sam Leffler <sam@FreeBSD.org>

when scanning channels marked passive defer probe request until
802.11 traffic is seen; fixes problems with ap's hiding their ssid

Obtained from: atheros
MFC after: 1 week


# a1a50502 18-Jan-2006 Sam Leffler <sam@FreeBSD.org>

bump the scan generation number before iterating so we're guaranteed
to have a value that's not been used before; this fixes the problem
where the first traversal of the scan list did nothing because the
entries were initialized with the current generation number (a
separate issue)

MFC after: 1 week


# 0912bac9 02-Jan-2006 Sam Leffler <sam@FreeBSD.org>

update erp information element in the beacon frame to reflect
changes in the bss

Reviewed by: avatar
Obtained from: atheros
MFC after: 2 weeks


# 8e292e8e 13-Dec-2005 Sam Leffler <sam@FreeBSD.org>

When creating neighbor entries for an ahdemo bss apply the local
settings. In particular this allows us to use QoS frames in a
bss and in turn enables disabling ack's.


# 50d8b493 13-Dec-2005 Sam Leffler <sam@FreeBSD.org>

when creating an ahdemo bss use any requested bssid; otherwise use zero

Obtained from: madwifi


# 1fd2349d 12-Dec-2005 Sam Leffler <sam@FreeBSD.org>

propagate current bss state on sta join so, in particular, authmode
is set properly in the new bss node

MFC after: 2 weeks


# 1b49e120 12-Dec-2005 Sam Leffler <sam@FreeBSD.org>

Bandaid ieee80211_set_chan to handle a channel parameter of "any";
this can happen under certain conditions when scanning. This logic
will eventually go away with the new scanning code.

While here de-inline the routine.

MFC after: 1 week


# be425a0f 03-Dec-2005 Sam Leffler <sam@FreeBSD.org>

Adhoc mode fixups:
o plug memory leak in adhoc mode: on rx the sender may be the
current master so simply checking against ic_bss is not enough
to identify if the packet comes from an unknown sender; must
also check the mac address
o split neighbor node creation into two routines and fillin state
of nodes faked up on xmit when a beacon or probe response frame
is later received; this ensures important state like the rate set
and advertised capabilities are correct

Obtained from: netbsd
MFC after: 1 week


# 5ff80921 13-Aug-2005 Sam Leffler <sam@FreeBSD.org>

revert 1.64: we cannot use the channel characteristics to decide when to
do 11g erp sta accounting because b/g channels show up as false positives
when operating in 11b.

Noticed by: Michal Mertl


# efefac40 10-Aug-2005 Sam Leffler <sam@FreeBSD.org>

Don't use ic_curmode to decide when to do 11g station accounting,
use the station channel properties. Fixes assert failure/bogus
operation when an ap is operating in 11a and has associated stations
then switches to 11g.

Noticed by: Michal Mertl
Reviewed by: avatar
MFC after: 2 weeks


# b5c99415 10-Aug-2005 Sam Leffler <sam@FreeBSD.org>

Clarify/fix handling of the current channel:
o add ic_curchan and use it uniformly for specifying the current
channel instead of overloading ic->ic_bss->ni_chan (or in some
drivers ic_ibss_chan)
o add ieee80211_scanparams structure to encapsulate scanning-related
state captured for rx frames
o move rx beacon+probe response frame handling into separate routines
o change beacon+probe response handling to treat the scan table
more like a scan cache--look for an existing entry before adding
a new one; this combined with ic_curchan use corrects handling of
stations that were previously found at a different channel
o move adhoc neighbor discovery by beacon+probe response frames to
a new ieee80211_add_neighbor routine

Reviewed by: avatar
Tested by: avatar, Michal Mertl
MFC after: 2 weeks


# c1225b52 08-Aug-2005 Sam Leffler <sam@FreeBSD.org>

Split crypto tx+rx key indices and add a key index -> node mapping table:

Crypto changes:
o change driver/net80211 key_alloc api to return tx+rx key indices; a
driver can leave the rx key index set to IEEE80211_KEYIX_NONE or set
it to be the same as the tx key index (the former disables use of
the key index in building the keyix->node mapping table and is the
default setup for naive drivers by null_key_alloc)
o add cs_max_keyid to crypto state to specify the max h/w key index a
driver will return; this is used to allocate the key index mapping
table and to bounds check table loookups
o while here introduce ieee80211_keyix (finally) for the type of a h/w
key index
o change crypto notifiers for rx failures to pass the rx key index up
as appropriate (michael failure, replay, etc.)

Node table changes:
o optionally allocate a h/w key index to node mapping table for the
station table using the max key index setting supplied by drivers
(note the scan table does not get a map)
o defer node table allocation to lateattach so the driver has a chance
to set the max key id to size the key index map
o while here also defer the aid bitmap allocation
o add new ieee80211_find_rxnode_withkey api to find a sta/node entry
on frame receive with an optional h/w key index to use in checking
mapping table; also updates the map if it does a hash lookup and the
found node has a rx key index set in the unicast key; note this work
is separated from the old ieee80211_find_rxnode call so drivers do
not need to be aware of the new mechanism
o move some node table manipulation under the node table lock to close
a race on node delete
o add ieee80211_node_delucastkey to do the dirty work of deleting
unicast key state for a node (deletes any key and handles key map
references)

Ath driver:
o nuke private sc_keyixmap mechansim in favor of net80211 support
o update key alloc api

These changes close several race conditions for the ath driver operating
in ap mode. Other drivers should see no change. Station mode operation
for ath no longer uses the key index map but performance tests show no
noticeable change and this will be fixed when the scan table is eliminated
with the new scanning support.

Tested by: Michal Mertl, avatar, others
Reviewed by: avatar, others
MFC after: 2 weeks


# d365f9c7 07-Aug-2005 Sam Leffler <sam@FreeBSD.org>

Cleanup beacon/listen interval handling:
o separate configured beacon interval from listen interval; this
avoids potential use of one value for the other (e.g. setting
powersavesleep to 0 clobbers the beacon interval used in hostap
or ibss mode)
o bounds check the beacon interval received in probe response and
beacon frames and drop frames with bogus settings; not clear
if we should instead clamp the value as any alteration would
result in mismatched sta+ap configuration and probably be more
confusing (don't want to log to the console but perhaps ok with
rate limiting)
o while here up max beacon interval to reflect WiFi standard

Noticed by: Martin <nakal@nurfuerspam.de>
MFC after: 1 week


# 97c973ad 05-Aug-2005 Sam Leffler <sam@FreeBSD.org>

Fix handling of frames sent prior to a station being authorized
when operating in ap mode. Previously we allocated a node from the
station table, sent the frame (using the node), then released the
reference that "held the frame in the table". But while the frame
was in flight the node might be reclaimed which could lead to
problems. The solution is to add an ieee80211_tmp_node routine
that crafts a node that does exist in a table and so isn't ever
reclaimed; it exists only so long as the associated frame is in flight.

MFC after: 5 days


# 19ad2dd7 31-Jul-2005 Sam Leffler <sam@FreeBSD.org>

close a race between reclaiming a node when a station is inactive
and sending the null data frame used to probe inactive stations

MFC after: 5 days


# 936f15d2 26-Jul-2005 Sam Leffler <sam@FreeBSD.org>

bandaid ni_fails handling so ap's with association failures are
reconsidered after a bit; a proper fix involves more changes to
the scanning infrastructure

Reviewed by: avatar, David Young
MFC after: 5 days


# 44b666cd 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

the AREF flag is only meaningful in ap mode; adhoc neighbors now
are timed out of the sta/neighbor table


# f66d97f6 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

o move inactivity-related debug msgs under IEEE80211_MSG_INACT
o probe inactive neighbors in adhoc mode (they don't have an
association id so previously were being timed out)

MFC after: 3 days


# af8418dc 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

split xmit of probe request frame out into a separate routine that
takes explicit parameters; this will be needed when scanning is
decoupled from the state machine to do bg scanning

MFC after: 3 days


# e9962332 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplify ic_newassoc callback

MFC after: 3 days


# 641b4d0b 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplify ieee80211_ibss_merge api

MFC after: 3 days


# edfa57d0 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplify tim callback api

MFC after: 3 days


# e4918ecd 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days


# f62121ce 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplifiy ieee80211_send_nulldata api

MFC after: 3 days


# 7d77cd53 22-Jul-2005 Sam Leffler <sam@FreeBSD.org>

simplify rate set api's by removing ic parameter (implicit in node reference)

MFC after: 3 days


# ebdda46c 05-Jul-2005 Sam Leffler <sam@FreeBSD.org>

Fix race condition in handling node reference counts for authenticating
stations in ap mode. Track when a node's first auth frame is
received and use this to decide whether or not to bump the refcnt.
This insures we only ever bump the refcnt once.

Reviewed by: avatar
Approved by: re (scottl)


# 7268fa64 09-Jun-2005 Sam Leffler <sam@FreeBSD.org>

move AID implementation defines from the protocol definitions to
where they are used


# f02a0bd2 07-Jun-2005 Sam Leffler <sam@FreeBSD.org>

Change the MLME ASSOCIATE ioctl to accept either a ssid, a bssid,
or a bssid+ssid. This is needed for later versions of wpa_supplicant
and for forthcoming addons to wpa_supplicant.

Note this is an api change and applications must be rebuilt.


# 6edf09a6 16-Mar-2005 Sam Leffler <sam@FreeBSD.org>

avoid potential array index by -1

Noticed by: Coverity Prevent analysis tool


# 48b0a5be 08-Mar-2005 Sam Leffler <sam@FreeBSD.org>

honor any desired bssid when creating an ibss

Prodded by: David Young
Obtained from: netbsd


# f9cd9174 10-Feb-2005 Sam Leffler <sam@FreeBSD.org>

propagate state kept in the bss node when re-creating the node
on state transitions; this is a stopgap measure, need to rethink
how we do management of this state

Identified by: Divy Le Ray


# 49a15236 24-Jan-2005 Sam Leffler <sam@FreeBSD.org>

update node reference count debug msgs to include the node address
since the mac address may not be sufficient to uniquely identify a node


# acc4f7f5 24-Jan-2005 Sam Leffler <sam@FreeBSD.org>

statically allocate the station/neighbor node table; the deferred
allocation scheme introduced a race condition during device state
transitions


# 44acc00d 19-Jan-2005 Sam Leffler <sam@FreeBSD.org>

when a station is timed out for inactivity, remove it from the table
so it isn't considered again


# ce647032 19-Jan-2005 Sam Leffler <sam@FreeBSD.org>

explicitly avoid timing out ourself due to inactivity; it
can easily happen if the bss is quiet


# 90d0d036 19-Jan-2005 Sam Leffler <sam@FreeBSD.org>

fix refcnt leak in adhoc mode: entries in the neighbor table
created due to rx'd frames had an extra reference


# a84679cd 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

remove debug msg from ieee80211_iterate_nodes; it makes logs very noisy
as onoe rate control invokes this once a second


# 29d368a7 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

avoid possible null pointer deref when refcnt debugging is enabled; the
node may be orphaned

Submitted by: Tai-hwa Liang


# 96acc1b6 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

Explicitly ignore ibss merge requests when the node is ic_bss. This can
happen on the first management frame received from a neighbor; we assume
any merge candidate will send more frames and those should be processed
with a suitable table entry.

Stepped on by: Tai-hwa Liang


# 3fcfbbfa 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

Simplify the logic for checking the scan candidates at the end of a scan.
Hold a lock on the table instead of futzing with reference counts which
was potentially dangerous except drivers were quiescent while we did this
so the table contents never changed. Disable the hack logic for removing
scan candidates with multiple association failures; it's never done the
right thing and will be fixed correctly with background scanning goes in.


# c75ac469 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

when scanning is interrupted reset state so table entries go in the station
table and not the scan table

Noticed by: Tai-hwa Liang


# 98ff6263 18-Jan-2005 Sam Leffler <sam@FreeBSD.org>

do fixed rate check when considering if a scan candidate is suitable so when
it's time to join the bss we can't get an error


# ef92bcdc 01-Jan-2005 Sam Leffler <sam@FreeBSD.org>

Correct scan candidate selection logic for dual-band devices: prefer
candidate on 5Ghz channel to candidate on 2Ghz channel only when the
rssi are comparable (wasn't considering rssi).


# 1f1d7810 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

bump copyright for 2005


# 2045f699 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

fixup inactivity timers:
o ic_inact_auth is a bad name, it's the inactivity threshold
for being associated but not authorized; use it that way
o reset ni_inact when switching inactivity thresholds to
minimize the race against the timer (don't want to lock
for this stuff)
o change the inactivity probe threshold from a one-shot to
cover a range: when below this threshold but not expired
send a probe each inactivity interval; should probably
guard against the interval being turned way down as this
could cause us to spam the net with probes


# 736b3dc3 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

compare pointers against NULL


# b8fcf546 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

make ap mode sta association debug msg as informative as sta mode


# 624a1bdb 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

do 11g erp station management in turboG mode too


# 3d073929 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

check if the node/station table is already present before creating one; this
can happen on an ibss merge


# 3ea67c54 31-Dec-2004 Sam Leffler <sam@FreeBSD.org>

include phy mode in scan debug msg


# 8a1b9b6a 08-Dec-2004 Sam Leffler <sam@FreeBSD.org>

Update 802.11 support; too much new functionality to fully describe
here but it includes completed 802.11g, WPA, 802.11i, 802.1x, WME/WMM,
AP-side power-save, crypto plugin framework, authenticator plugin framework,
and access control plugin frameowrk.


# 32346d60 04-Apr-2004 Sam Leffler <sam@FreeBSD.org>

make malloc tag for ieee80211_node more recognizable


# 750d6d0c 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

fix adhoc/ibss operation for drivers that require host support (e.g. ath):

o remove IEEE80211_C_RCVMGT capability
o on transmit craft new nodes as needed using new ieee80211_find_txnode routine
o add ieee80211_find_txnode routine to lookup a node by mac address and
if not present create one when operating in ibss/ahdemo mode; new nodes
are dup'd from bss and the driver is told to treat the node as if a new
association has been created so driver-private state (e.g. rate control
handling) is setup

Obtained from: netbsd (basic idea)


# 694dca64 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

o change ieee80211_dup_bss to inherit explicit data from ic_bss instead of
blindy copying the node contents; this turns out to be a bad idea as we
add more state in the node for things like WPA
o track node allocation failures in ieee80211_dup_bss instead of the callers

Obtained from: madwifi


# c64bfa0f 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

track node allocation failure stats in ieee80211_alloc_node instead
of each caller

Obtained from: madwifi


# 410ca74b 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

replace explicit malloc/free with MALLOC/FREE for portability

Obtained from: madwifi


# b4c5a90f 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

extract node matching logic into new ieee80211_match_bss routine for use
in background/incremental scanning

Obtained from: madwifi


# 849b8980 02-Apr-2004 Sam Leffler <sam@FreeBSD.org>

diff reduction against madwifi


# 2e79ca97 30-Mar-2004 Sam Leffler <sam@FreeBSD.org>

o add support for controlling the power of transmitted frames
o add support for controlling the 11g protection mechanism used
to protect OFDM frames in a mixed 11b/g network

Reviewed by: imp


# bca1062b 09-Nov-2003 Sam Leffler <sam@FreeBSD.org>

fix typo that broke AP scanning by BSSID

Submitted by: Len Widra


# 9bf40ede 31-Oct-2003 Brooks Davis <brooks@FreeBSD.org>

Replace the if_name and if_unit members of struct ifnet with new members
if_xname, if_dname, and if_dunit. if_xname is the name of the interface
and if_dname/unit are the driver name and instance.

This change paves the way for interface renaming and enhanced pseudo
device creation and configuration symantics.

Approved By: re (in principle)
Reviewed By: njl, imp
Tested On: i386, amd64, sparc64
Obtained From: NetBSD (if_xname)


# 1be50176 17-Oct-2003 Sam Leffler <sam@FreeBSD.org>

add statistics for all failures and/or abnormal events; still need
to add per-node statistics


# 1e343b38 17-Oct-2003 Sam Leffler <sam@FreeBSD.org>

parameterize locking to improve portability and possible
change to different locking strategies


# 303ebc3c 26-Sep-2003 Sam Leffler <sam@FreeBSD.org>

Try yet again to deal with timing out nodes. We cannot hold the
node lock while sending a management frame as this will potentially
result in a LOR with a driver lock. This doesn't happen for the
Atheros driver but does for the wi driver. Use a generation number
to help process each node once when scanning the node table and
drop the node lock if we need to timeout a node and send a frame.


# 37c150c4 26-Sep-2003 Sam Leffler <sam@FreeBSD.org>

allocate node table entries with a specific malloc type


# d1e61976 15-Sep-2003 Sam Leffler <sam@FreeBSD.org>

Generalize the per-node RSSI data so drivers can do more interesting
things than record a single value.

o add a per-node method for returning the "current RSSI" for a node
o create a default method that returns ni_rssi which is the rssi for
the last received frame
o use the per-node "get rssi" method to return data for the RID's
submitted by wicontrol, et. al.

Loosely based on work by Tom Marshall <tommy@home.tig-grr.com> for MADWIFI.


# 0a915fad 19-Aug-2003 Sam Leffler <sam@FreeBSD.org>

MFp4 changes to fix locking issues and correct reference
count handling of station entries in hostap mode:

Input path:

o driver is now expected to find the node associated with the
sender of a received frame; use ic_bss if none is located
o driver passes the (referenced) node into ieee80211_input for
use within the wlan module and is responsible for cleaning up
on return
o the antenna state is no longer passed up with each frame; this
is now considered driver-private state and drivers are responsible
for keeping it in the driver-private part of a node

Output path:

Revamp output path for management frames to eliminate redundant
locking that causes problems and to correct reference counting
bogosity that occurs when stations are timed out due to inactivity
(in AP mode). On output the refcnt'd node is stashed in the pkthdr's
recvif field (yech) and retrieved by the driver. This eliminates
an unref/ref scenario and related node table unlock/lock due to the
driver looking up the node. This is particularly important when
stations are timed out as this causes a lock order reversal that
can result in a deadlock. As a byproduct we also reduce the overhead
for sending management frames (minimal). Additional fallout from
this is a change to ieee80211_encap to return a refcn't node for
tieing to the outbound frame. Node refcnts are not reclaimed until
after a frame is completely processed (e.g. in the tx interrupt
handler). This is especially important for timed out stations as
this deref will be the final one causing the node entry to be
reclaimed.

Additional semi-related changes:
o replace m_copym use with m_copypacket (optimization)
o add assert to verify ic_bss is never free'd during normal operation
o add comments explaining calling conventions by drivers for frames
going in each direction
o remove extraneous code that "cannot be executed" (e.g. because
pointers may never be null)


# 2692bb26 13-Aug-2003 Sam Leffler <sam@FreeBSD.org>

Delay creating ic_bss until after the super-class has a chance
to override the method pointers for manipulating nodes; this fixes
a problem where the ic_bss node was not being created properly
for the ath driver causing the driver to scribble on random memory.

Noticed by: David Young <dyoung@pobox.com>


# a11c9a5c 20-Jul-2003 Sam Leffler <sam@FreeBSD.org>

o change ieee80211_new_state handling to use a proper method that drivers
override in their sub-class; this eliminates the hack of interpreting the
EINPROGRESS return value to mean "don't do any of the normal work"
o correct active scanning so the first channel is only scanned once and so
per-channel passive mode is properly honored
o expose 802.11 FSM state names so every driver doesn't keep a private copy
o eliminate node parameter to ieee80211_begin_scan; it was not being used


# 58f40303 29-Jun-2003 Sam Leffler <sam@FreeBSD.org>

insure ic_bss always has a "valid" channel; avoids problems where users could
query the state of a card and find a null channel since allocating the node
left ni_chan zero


# 7535e66a 26-Jun-2003 Sam Leffler <sam@FreeBSD.org>

revise copyright notices per discussion with Atsushi Onoe <onoe@sm.sony.co.jp>


# 1a1e1d21 23-Jun-2003 Sam Leffler <sam@FreeBSD.org>

new 802.11 layer:

o code reorg (relative to old netbsd-derived code) for future growth
o drivers now specify available channels and rates and 802.11 layer handles
almost all ifmedia actions
o multi-mode support for 11a/b/g devices
o 11g protocol additions (incomplete)
o new element id additions (for other than 11g)
o node/station table redone for proper locking and to eliminate driver
incestuousness
o split device flags and capabilities to reduce confusion and provide room
for expansion
o incomplete power management infrastructure (need to revisit)
o incomplete hooks for software retry
o more...