History log of /freebsd-10.0-release/sys/net80211/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
259188 10-Dec-2013 gavin

Merge r259175 from stable/10 (head r257065 by adrian):

Fix a use-after-free node reference issue when waiting for a return
from a management frame transmission.

Approved by: re (glebius)

259187 10-Dec-2013 gavin

Merge r259174 from stable/10 (head r256294 by adrian):

Fix the "am I a net80211 vap" check for bpf listeners.

I changed it to use if_transmit a while ago but apparently with monitor
mode the if_transmit method is overridden.

This is (mostly) a workaround until a more permanent solution can be
found.

Submitted by: Patrick Kelsey <kelsey@ieee.org>
Approved by: re (glebius)

259185 10-Dec-2013 gavin

Merge r259173 from stable/10 (head r258758 by adrian):

Make sure any waiters on the scan results get notified if the scan task
decides to do nothing.

If this isn't done, then a scan request whilst a scan occurs in an
active channel set or a completed channel set will hang.

Approved by: re (glebius)

259184 10-Dec-2013 gavin

Merge r259172 from stable/10 (head r257754 by adrian):

Don't return ENOBUFS if the transmit path handles the frame but queues
it (eg in power save.)

PR: kern/183727
Approved by: re (glebius)

259065 07-Dec-2013 gjb

- Copy stable/10 (r259064) to releng/10.0 as part of the
10.0-RELEASE cycle.
- Update __FreeBSD_version [1]
- Set branch name to -RC1

[1] 10.0-CURRENT __FreeBSD_version value ended at '55', so
start releng/10.0 at '100' so the branch is started with
a value ending in zero.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


254956 27-Aug-2013 adrian

Create a new function to complete 802.11 mbuf transmission.

The aim of this function is to eventually be the completion entry point
for all 802.11 encapsulated mbufs. All the wifi drivers end up doing
what is in this function so it's an easy win to turn it into a net80211
method and abstract out this code.

Ideally the drivers will all eventually be modified to queue up completed
mbufs and call this function with all the driver locks not held.
This will allow for some much more interesting software queue handling
in the future (like net80211 based A-MSDU, fast-frames, A-MPDU aggregation
and retransmission.)

Tested:

* ath(4), iwn(4)


254900 26-Aug-2013 adrian

Migrate the ff_encap1() routine out into the normal output code.

This will eventually be used by the A-MSDU encapsulation code that
I'm writing - the sub-frame encapsulation requirement is the same.


254640 22-Aug-2013 adrian

Add in some backwards compatability hacks to make -HEAD net80211 compile
on -9.


254527 19-Aug-2013 andre

Reorder the mbuf defines to make more sense and group related flags
together.

Add M_FLAG_PRINTF for use with printf(9) %b indentifier.

Use the generic mbuf flags print names in the net80211 code and adjust
the protocol specific bits for their new positions.

Change SCTP M_PROTO mapping from 5 to 1 to fit within the 16bit field
they use internally to store some additional information.

Discussed with: trociny, glebius


254526 19-Aug-2013 andre

Migrate the net80211 protocol specific use of M_FRAG, M_FIRSTFRAG and
M_LASTFRAG flags to protocol specific flags.

Remove the now unused M_FRAG, M_FIRSTFRAG and M_LASTFRAG mbuf flags.

Discussed with: trociny, glebius, adrian


254523 19-Aug-2013 andre

Add m_clrprotoflags() to clear protocol specific mbuf flags at up and
downwards layer crossings.

Consistently use it within IP, IPv6 and ethernet protocols.

Discussed with: trociny, glebius


254506 18-Aug-2013 adrian

Don't return ENOTSUPP here - the net80211 pluggable ioctl API will treat
this as the final item in the linker set and not try others.

This stopped the fast frames IOCTLs from being called.


254500 18-Aug-2013 adrian

Return the correct status if ieee80211_ff_check() consumes the mbuf.

I broke this when converting the net80211 TX path to use if_transmit.


254315 14-Aug-2013 rpaulo

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


254261 12-Aug-2013 adrian

Blank m_nextpkt before passing it up.


254236 12-Aug-2013 adrian

When flushing packets from the powersave queue, make sure that
m_nextpkt is NULL before passing it up to the parent transmit
method.


254196 10-Aug-2013 adrian

Add in missing m_free()'s during error conditions.


254082 08-Aug-2013 adrian

Convert net80211 over to using if_transmit for the dispatch from the
upper layer(s).

This eliminates the if_snd queue from net80211. Yay!

This unfortunately has a few side effects:

* It breaks ALTQ to net80211 for now - sorry everyone, but fixing
parallelism and eliminating the if_snd queue is more important
than supporting this broken traffic scheduling model. :-)

* There's no VAP and IC flush methods just yet - I think I'll add
some NULL methods for now just as placeholders.

* It reduces throughput a little because now net80211 will drop packets
rather than buffer them if the driver doesn't do its own buffering.
This will be addressed in the future as I implement per-node software
queues.

Tested:

* ath(4) and iwn(4) in STA operation


254076 07-Aug-2013 adrian

Allow net80211 to compile on stable/9 and stable/8.


253745 28-Jul-2013 adrian

Fix compilation when debugging is disabled.


253743 28-Jul-2013 adrian

Commit the missing header change.


253727 28-Jul-2013 adrian

Refactor the VAP transmit path code into a utility function that both
the normal and the mesh transmit paths can use.

The API is a bit horrible because it both consumes the mbuf and frees
the node reference regardless of whether it succeeds or not.
It's a hold-over from how the code behaves; it'd be nice to have it
not free the node reference / mbuf if TX fails and let the caller
decide what to do.


253639 25-Jul-2013 rpaulo

Add ieee80211_add_{qos,wpa,rsn}() functions since they are needed by an
OpenBSD driver that is being ported to FreeBSD.

Reviewed by: adrian


253007 07-Jul-2013 alfred

Make kassert_printf use __printflike.

Fix associated errors/warnings while I'm here.

Requested by: avg


252847 05-Jul-2013 adrian

Add a missing unlock.


252736 05-Jul-2013 adrian

Document the current 11n rate selection shortcoming in the AMRR code.


252727 04-Jul-2013 adrian

Implement basic 802.11n awareness in the PHY and AMRR rate control code.

* Add 802.11n 2ghz and 5ghz tables, including legacy rates and up to
MCS23 rates (3x3.)

* Populate the rate code -> rate index lookup table with MCS _and_
normal rates, but _not_ the basic rate flag. Since the basic rate flag
is the same as the MCS flag, we can only use one.

* Introduce some accessor inlines that do PLCP and rate table lookup/access
and enforce that it doesn't set the basic rate bit. They're not
designed for MCS rates, so it will panic.

* Start converting drivers that use the rate table stuff to use the
accessor inlines and strip the basic flag.

* Teach AMRR about basic 11n - it's still as crap for MCS as it is
being used by iwn, so it's not a step _backwardS_.

* Convert iwn over to accept 11n MCS rates rather than 'translate' legacy
to MCS rates. It doesn't use a lookup table any longer; instead it's a
function which takes the current node (for HT parameters) and the
rate code, and returns the hardware PLCP code to use.

Tested:

* ath - it's a no-op, and it works that way
* iwn - both 11n and non-11n


252369 29-Jun-2013 rpaulo

Don't panic the kernel if we run wpa_supplicant on a hostap VAP.

Reviewed by: adrian


251766 14-Jun-2013 eadler

Fix typo (dbM -> dBm)

Submitted by: Daan@vitsch.nl
Reviewed by: adrian


251488 07-Jun-2013 adrian

Don't hold the node lock over the iterator.

The "find node" function call will increase the node reference anyway;
so there's no reason to hold the node table lock during the MLME change.

The only reason I could think of is to stop overlapping mlme ioctls
from causing issues, but this should be fixed a different way.

This fixes a whole class of LORs that creep up when nodes are being
timed out or removed by hostapd.

Tested:

* AR5416, hostap, with nodes coming and going. No LORs or stability
issues were observed.


250974 25-May-2013 adrian

Fix net80211 fragment creation.

When creating fragment frames, the header length should honour the
DATAPAD flag.

This fixes the fragments that are queued to the ath(4) driver but it
doesn't yet fix fragment transmission. That requires further changes
to the ath(4) transmit path. Well, strictly speaking, it requires
further changes to _all_ wifi driver transmit paths, but this is at least
a start.

Tested:

* AR5416, STA mode, w/ fragthreshold set to 256.


250442 10-May-2013 adrian

Fix a VAP BSS node reference in the HT code to actually take a reference
before using said node.

The "blessed" way here is to take a node reference before referencing
anything inside the node, otherwise the node can be freed between
the time the pointer is copied/dereferenced and the time the node contents
are used.

This mirrors fixes that I've done elsewhere in the net80211/driver
stack.

PR: kern/178470


249925 26-Apr-2013 glebius

Add const qualifier to the dst parameter of the ifnet if_output method.


249568 16-Apr-2013 adrian

Implement a utility function to return the current TX power cap for
the given node.

This takes into account the per-node cap, the ic cap and the
per-channel regulatory caps.

This is designed to replace references to ni_txpower in various net80211
drivers - ni_txpower doesn't necessarily reflect the actual cap for
the given node (eg if the node has the default value of 50dBm (100) and
the administrator has manually configured a lower TX power.)


248539 20-Mar-2013 adrian

Add VNET wrappers around the rest of the ieee80211 rtsock messages.

I triggered the cac/radar messages when doing testing in DFS channels.


248127 10-Mar-2013 adrian

Kill this, it's not needed at this point and (hopefully) the parent
has correctly locked the ic/vap.


248106 09-Mar-2013 adrian

Fix another compiler warning issue when invariants are disabled.


248089 09-Mar-2013 adrian

Fix non-invariant compilation.


248069 08-Mar-2013 adrian

Bring over my initial work from the net80211 TX locking branch.

This patchset implements a new TX lock, covering both the per-VAP (and
thus per-node) TX locking and the serialisation through to the underlying
physical device.

This implements the hard requirement that frames to the underlying physical
device are scheduled to the underlying device in the same order that they
are processed at the VAP layer. This includes adding extra encapsulation
state (such as sequence numbers and CCMP IV numbers.) Any order mismatch
here will result in dropped packets at the receiver.

There are multiple transmit contexts from the upper protocol layers as well
as the "raw" interface via the management and BPF transmit paths.
All of these need to be correctly serialised or bad behaviour will result
under load.

The specifics:

* add a new TX IC lock - it will eventually just be used for serialisation
to the underlying physical device but for now it's used for both the
VAP encapsulation/serialisation and the physical device dispatch.

This lock is specifically non-recursive.

* Methodize the parent transmit, vap transmit and ic_raw_xmit function
pointers; use lock assertions in the parent/vap transmit routines.

* Add a lock assertion in ieee80211_encap() - the TX lock must be held
here to guarantee sensible behaviour.

* Refactor out the packet sending code from ieee80211_start() - now
ieee80211_start() is just a loop over the ifnet queue and it dispatches
each VAP packet send through ieee80211_start_pkt().

Yes, I will likely rename ieee80211_start_pkt() to something that
better reflects its status as a VAP packet transmit path. More on
that later.

* Add locking around the management and BAR TX sending - to ensure that
encapsulation and TX are done hand-in-hand.

* Add locking in the mesh code - again, to ensure that encapsulation
and mesh transmit are done hand-in-hand.

* Add locking around the power save queue and ageq handling, when
dispatching to the parent interface.

* Add locking around the WDS handoff.

* Add a note in the mesh dispatch code that the TX path needs to be
re-thought-out - right now it's doing a direct parent device transmit
rather than going via the vap layer. It may "work", but it's likely
incorrect (as it bypasses any possible per-node power save and
aggregation handling.)

Why not a per-VAP or per-node lock?

Because in order to ensure per-VAP ordering, we'd have to hold the
VAP lock across parent->if_transmit(). There are a few problems
with this:

* There's some state being setup during each driver transmit - specifically,
the encryption encap / CCMP IV setup. That should eventually be dragged
back into the encapsulation phase but for now it lives in the driver TX path.
This should be locked.

* Two drivers (ath, iwn) re-use the node->ni_txseqs array in order to
allocate sequence numbers when doing transmit aggregation. This should
also be locked.

* Drivers may have multiple frames queued already - so when one calls
if_transmit(), it may end up dispatching multiple frames for different
VAPs/nodes, each needing a different lock when handling that particular
end destination.

So to be "correct" locking-wise, we'd end up needing to grab a VAP or
node lock inside the driver TX path when setting up crypto / AMPDU sequence
numbers, and we may already _have_ a TX lock held - mostly for the same
destination vap/node, but sometimes it'll be for others. That could lead
to LORs and thus deadlocks.

So for now, I'm sticking with an IC TX lock. It has the advantage of
papering over the above and it also has the added advantage that I can
assert that it's being held when doing a parent device transmit.
I'll look at splitting the locks out a bit more later on.

General outstanding net80211 TX path issues / TODO:

* Look into separating out the VAP serialisation and the IC handoff.
It's going to be tricky as parent->if_transmit() doesn't give me the
opportunity to split queuing from driver dispatch. See above.

* Work with monthadar to fix up the mesh transmit path so it doesn't go via
the parent interface when retransmitting frames.

* Push the encryption handling back into the driver, if it's at all
architectually sane to do so. I know it's possible - it's what mac80211
in Linux does.

* Make ieee80211_raw_xmit() queue a frame into VAP or parent queue rather
than doing a short-cut direct into the driver. There are QoS issues
here - you do want your management frames to be encapsulated and pushed
onto the stack sooner than the (large, bursty) amount of data frames
that are queued. But there has to be a saner way to do this.

* Fragments are still broken - drivers need to be upgraded to an if_transmit()
implementation and then fragmentation handling needs to be properly fixed.

Tested:

* STA - AR5416, AR9280, Intel 5300 abgn wifi
* Hostap - AR5416, AR9160, AR9280
* Mesh - some testing by monthadar@, more to come.


246930 18-Feb-2013 adrian

Disable this variable; the code using it is also disabled.


246927 18-Feb-2013 adrian

Disable this code and add a note as to why.

It wasn't currently being called anyway - but being explicit about it
can't hurt.


246861 16-Feb-2013 adrian

Fix an incorrect sizeof()

Spotted by: clang

Submitted by: dim


246807 14-Feb-2013 monthadar

Mesh: QoS Control field bit flags fix.

* The following bit flags where incroccetly defined:
o Mesh Control Present
o Mesh Power Save Level
o RSPI
This is now corrected according to Table 8.4 as per IEEE 802.11 2012;

Approved by: adrian (mentor)


246710 12-Feb-2013 glebius

Substitute '#ifdef ALIGNED_POINTER' with '#ifndef __NO_STRICT_ALIGNMENT',
since the former is defined everywhere. This cuts off some code not
necessary on non strict aligment arches.

Reviewed by: adrian
Sponsored by: Nginx, Inc.


246537 08-Feb-2013 adrian

Fix ieee80211_mesh.c compilation.

* Add the superg.h header to allow ieee80211_check_ff() to work
* Since the assert stuff creates assertions based on line numbers and there
was a conflict, just nudge things down a bit.


246520 07-Feb-2013 monthadar

Mesh: recevied GANN frames where not parsed correctly.

* Added mesh_parse_meshgate_action that parse all values to host endian;
* Add more detailed debug output;

Approved by: adrian (mentor)


246519 07-Feb-2013 monthadar

Mesh HWMP forwarding information: updating FI for transmitter.

* Added hwmp_update_transmitter function that checks if the metric
to the transmitter have improved. If old FI is invalid or metric
is larger the FI to the transmitter is updated occurdingly.
This is a recommendation from the 802.11 2012 standard, table 13-9;

Approved by: adrian (mentor)


246518 07-Feb-2013 monthadar

Mesh HWMP PERR bug fixes.

* When calling ieee80211_mesh_rt_flush_peer, the rt->rt_dest argument
should not be passed because it can get freed before invalidating
the other routes that depends on it to compare with next_hop.
Use PERR_DADDR(i) instead;

Approved by: adrian (mentor)


246517 07-Feb-2013 monthadar

Mesh bug: debug infomartion showing swapped SA and DA address.

* Fix bug for "forward frame from SA(%6D), DA(%6D)" where addresses where
swapped between SA and DA;

Approved by: adrian (mentor)


246516 07-Feb-2013 monthadar

Update ddb to print mesh routing table.

* Modified _db_show_vap and _db_show_com to print mesh routing table
if the 'm' modifier is specified;

Approved by: adrian (mentor)


246515 07-Feb-2013 monthadar

Mesh HWMP PREQ: fixed conditions for discarding elements.

Approved by: adrian (mentor)


246514 07-Feb-2013 monthadar

Mesh HWMP: don't send an intermediate PREP for proxy entries.

* The standard is unclear about what should happen in case a mesh STA (not
marked as a mesh gate) recevies a PREQ for a destination that is marked
as proxy. Solution for now is not to do intermediate reply at all, and
let the PREQ reach the mesh gate;

Approved by: adrian (mentor)


246513 07-Feb-2013 monthadar

Mesh HWMP PREQ update: proxy reply only if mesh STA is a meshgate.

* Original PREP frame is transmitted only by the target mesh STA or the
mesh STA that is the proxy target;
* Fixed so that metric value is not over written incorrectly in
hwmp_recv_preq for when replying back with a PREP;

Approved by: adrian (mentor)


246512 07-Feb-2013 monthadar

HWMP: ic->raw_xmit didn't always point to correct ni.

This is a code re-write. ic->raw_xmit need a pointer to ieee80211_node
for the destination node (da). I have reorganized the code so that
a pointer to the da node is searched for in the end & in one place.

* Make mesh_find_txnode public to be used by HWMP, renamed to
ieee80211_mesh_finx_txnode;
* changed the argument from ieee80211_node to ieee80211vap for all
hwmp_send_* functions;
* removed the 'sa' argument from hwmp_send_* functions as all HWMP frames
have the source address equal to vap->iv_myaddr;
* Modified hwmp_send_action so that if da is MULTCAST ni=vap->iv_bss
otherwise we called ieee80211_mesh_find_txnode. Also no need to hold
a reference in this functions if da is not MULTICAST as by finding the
node it became referenced in ieee80211_find_txnode;

Approved by: adrian (mentor)


246511 07-Feb-2013 monthadar

Mesh gate code to transmit to all mesh gates.

* Modified mesh_find_txnode to be able to handle proxy marked entries by
recursively calling itself to find the txnode towards the active mesh gate;
* Mesh Gate: Added a new function that transmits data frames
similar to ieee80211_start;
* Modified ieee80211_mesh_forward_to_gates so that:
+ Frames are duplicated and sent to each valid Mesh Gate;
+ Route is marked invalid before return of function, this is
because we dont know yet which Mesh Gate is we will use;

Approved by: adrian (mentor)


246510 07-Feb-2013 monthadar

Send frames to mesh gate if 11s discovery fails.

* Send frames that have no path to a known valid Mesh Gate;
* Added the function ieee80211_mesh_forward_to_gates that sends the frame
to the first found Mesh Gate in the forwarding information;
* If we try to discover again while we are discovering queue frame,
the discovery callout will send the frames either to mesh gates
or discards them silently;
* Queue frame also if we try to discover to frequently;

Approved by: adrian (mentor)


246509 07-Feb-2013 monthadar

Mark root mesh as gate when mesh gate flag set.

* Add function ieee80211_mesh_mark_gate in ieee80211_mesh.h;
* When received a proactive PREQ or RANN with corresponding mesh gate
flag set, create a new entry in the known mesh gate list;

Approved by: adrian (mentor)


246508 07-Feb-2013 monthadar

Propagate GANN frames, and store know gate info.

* Modified mesh_recv_action_meshgate to do following:
+ if mesh STA already knows the mesh gate of the recevied GANN frame
+ if mesh gate is know, check seq number according to 802.11 standard
+ if mesh gate is not know, add it to the list of known mesh gates
+ if forwarding is enabled and ttl >= 1 then propagate the GANN frame;
* Declare a new malloc type M_80211_MESH_GT_RT;
* Declare a struct to store GANN information, ieee80211_mesh_gate_route. And
add it as a TAILQ list to ieee80211_mesh_state;

Approved by: adrian (mentor)


246506 07-Feb-2013 monthadar

Mesh update: add base Mesh Gate functionality.

A Mesh Gate should transmit a Mesh Action frame containing
ieee80211_meshgann_ie as its only information element periodically
every ieee80211_mesh_gateint ms. Unless the mesh gate is also configure
as a ROOT, then these frames should not be send.
This is according to 802.11 2012 standard;

* Introduce new SYSCTL net.wlan.mesh.gateint, with 10s default;
* Add two new functions mesh_gatemode_setup and mesh_gatemode_cb. This
is similar to how HWMP setups up a callout;
* Add two new action handlers mesh_recv_action_meshgate and
mesh_send_action_meshgate;
* Added ieee80211_add_meshgate to ieee80211_mesh.h;
* Modified mesh_send_action to look similar to hwmp_send_action. This is
because we need to send out broadcast management frames.
* Introduced a new flag for mesh state IEEE80211_MESHFLAGS_ROOT. This flag
is now set by HWMP code when a mesh STA is configured as a ROOT. This
is then checked by mesh_gatemode_cb before scheduling a new callout;
* Added to new field to ieee80211_mesh_state:
+ struct callout ms_gatetimer
+ ieee80211_mesh_seq ms_gateseq;

Approved by: adrian (mentor)


246504 07-Feb-2013 monthadar

Start accepting IEEE80211_ACTION_MESH_GANN frames;

* Add IEEE80211_ACTION_MESH_GANN Action frame verification in
ieee80211_parse_action;

Approved by: adrian (mentor)


246503 07-Feb-2013 monthadar

Mesh: management mesh action frames are to be discarded
when not peered.

* Modified ieee80211_recv_action to check if neighbour is peered for
IEEE80211_ACTION_CAT_MESH frames, if not frame is discarded. This is
according to IEEE802.11 2012 standard;
* Removed duplicate checks in each hwmp_recv_* handlers because HWMP
is a subtype of mesh action;

Approved by: adrian (mentor)


246502 07-Feb-2013 monthadar

Update in ieee80211_action.c for mesh code handlers.

* Removed meshlm_send_action and hwmp_send_action. Introduced one common
for all Mesh Action frames meshaction_send_action. According to 802.11
standard Link Metric and HWMP are all under Mesh Action category;
* Did similar changes to recv_action part;
* The size of meshaction_*_action is set to 12. This is to make room for
the rest of Mesh Action category subtypes;

Approved by: adrian (mentor)


246501 07-Feb-2013 monthadar

Update net80211 mesh struct ieee80211_meshgann_ie.

* Change all field prefix from pann_ to gann_;
* Added IEEE80211_MESHGANN_BASE_SZ macro to be used in the length field
of a GANN frame according to 802.11 standard;
* Changed gann_seq field type to uint32_t;
* Added a Gate Announcement interval field according to
IEEE802.11 2012 standard;
* Added IEEE80211_MESHRT_FLAGS_GATE as flag bit to ieee80211_mesh_route;
* Added IEEE80211_MESHRT_FLAGS_GATE as flag bit to ieee80211req_mesh_route;

Approved by: adrian (mentor)


246500 07-Feb-2013 monthadar

HWMP: Accept a PERR even if path is valid.

* An HWMP PERR should be accepted even if path is valid. Because
we check if we recevied it from a neighbour that we use as a next hop;

Approved by: adrian (mentor)


246499 07-Feb-2013 monthadar

Add mesh debug for interarction between DS & MBSS.

* Add mesh debug information when frames enter or leave the MBSS;
* Set IEEE80211_MSG_OUTPUT bit to enable output;

Approved by: adrian (mentor)


246498 07-Feb-2013 monthadar

Fix mesh path flag.

* A bug occurs while in discovery mode which leaves a path marked with
both Discover and Valid flag. This happens when receiving/sending
PREQ and PREP in a particular order. Solution is to assign the Valid bit
instead of oring it;

Approved by: adrian (mentor)


246497 07-Feb-2013 monthadar

Stop a mesh STA from flooding with peer frames.

This problem happens when using ACL policy to filter mesh STA
but two nodes have different policy. Then one of them will try to
peer all the time. This can also help if for any reason one of the
peering mesh STA have problems sending/receiving peer frames.

* Modified struct ieee80211_node to include two new fields:
+ struct callout ni_mlhtimer /* link mesh backoff timer */
+ uint8_t ni_mlhcnt /* link mesh holding counter */
* Added two new sysctl (check sysctl -d for more info):
+ net.wlan.mesh.backofftimeout=5000
+ net.wlan.mesh.maxholding=2;
* When receiving a beacon and we are in IEEE80211_NODE_MESH_IDLE
check if ni_mlhcnt >= ieee80211_mesh_maxholding, if so do not do anything;
* In mesh_peer_timeout_cb when transitioning from IEEE80211_NODE_MESH_HOLDING
to IEEE80211_NODE_MESH_IDLE increment ni_mlhcnt, and eventually start
ieee80211_mesh_backofftimeout;

Approved by: adrian (mentor)


246226 02-Feb-2013 adrian

Wrap this in an #ifdef so IEEE80211_SUPPORT_SUPERG will work correctly
in a wlan.ko module.


245928 26-Jan-2013 adrian

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.


245464 15-Jan-2013 adrian

Remove the use of the ifnet send queue and if_start() in the power
save queue code.

Instead, use if_transmit() directly - and handle the cases where frame
transmission fails.

I don't necessarily like this and I think at this point the M_ENCAP check,
node freeing upon fail and the actual if_transmit() call should be done
in methods in ieee80211_freebsd.c, but I digress slightly..

This removes one of the last few uses of if_start() and the ifnet
if_snd queue. The last major offender is ieee80211_output.c, where
ieee80211_start() implements if_start() and uses the ifnet queue
directly.

(There's a couple of gotchas here, where the if_start pointer is
compared to ieee80211_start(), but that's a later problem.)


245156 08-Jan-2013 adrian

Add in the missing radiotap definitions from the sipsolutions.net
radiotap "upstream" source.


245098 06-Jan-2013 adrian

Handle ps-poll data frame if_transmit() failure.

If the data frame transmission failures, it may have a node reference
that needs cleaning up.

If the frame is marked as M_ENCAP then it should treat recvif as a node
reference and clear it.

Now - since the mbuf has been freed by calling if_transmit() (even on
failure), the mbuf has to be treated as invalid. Hence why the ifp is
used.


245097 06-Jan-2013 adrian

Handle HWMP if_transmit() failure gracefully.

If if_transmit() fails, the node ref may need freeing.

This is based on the same logic used by the ageq, which the mesh code
(re) uses for frames which need to be staged before transmitting.
It also does the same thing - if M_ENCAP is set on the mbuf, it treats
the recvif pointer as a node reference and derefs it.


244577 22-Dec-2012 adrian

if_start() is being used here as a way of kick-starting the new queue
processing. For if_transmit() style hardware drivers (which none publicly
exist yet, for wireless) they will need to still implement if_start()
but only to re-start the TX queue.


244576 22-Dec-2012 adrian

Remove a use of if_start() - instead, use if_transmit() to dispatch the
frame.


244078 10-Dec-2012 adrian

Adjust the channel to correctly setup the HT flags when transitioning
an IBSS VAP to RUN.

An 11n IBSS was beaconing HTINFO/HTCAP IE's that didn't have any HT
information setup (like the HT TX/RX MCS bitmask.)

Tested:

* AR9280, IBSS - both a statically setup channel and a scanned channel

PR: kern/172955


244062 10-Dec-2012 adrian

Update the aggressive mode logic to also enable aggressive mode
parameters in IBSSes.

IBSS was just being plainly ignored here even though aggressive mode
was 'on'.

This still doesn't fix the "why are the WME parameters reset upon
interface down/up" issue.

PR: kern/165969


244061 10-Dec-2012 adrian

Undo the previous adhoc commit - doing the WME IE handling here
is totally wrong.

If we parse the WME IE here, we'll be constantly updating the WME
configuration from each WME enabled IBSS node we see.

There's a separate issue where the WME configuration is blanked out
when the interface is brought up; the WME parameters aren't "sticky."

Also, ieee80211_init_neighbor() parses the ath IE, so doing it here
isn't required.

Sorry about the noise.

PR: kern/165969


244060 09-Dec-2012 adrian

Handle ath-specific and WME IE's in adhoc mode.

The Adhoc support wasn't parsing and handling the ath specific and WME
IEs, thus the atheros vendor support and WME TXOP parameters aren't being
copied from the peer.

It copies the WME parameters from whichever adhoc node it decides to
associate to, rather than just having them be statically configured
per adhoc node. This may or may not be exactly "right", but it's certainly
going to be more convienent for people - they just have to ensure their
adhoc nodes are setup with correct WME parameters.

Since WME parameters aren't per-node but are configured on hardware TX
queues, if some nodes support WME and some don't - or perhaps, have
different WME parameters - things will get quite quirky.

So ensure that you configure your adhoc nodes with the same WME
parameters.

Secondly - the Atheros Vendor IE is parsed and operated on per-node, so
this should work out ok between nodes that do and don't do Atheros
extensions. Once you see a becaon from that node and you setup the
association state, it _should_ parse things correctly.

TODO:

* I do need to ensure that both adhoc setup paths are correctly updating
the IE stuff. Ie, if the adhoc node is created by a data frame instead
of a beacon frame, it'll come up with no WME/ath IE config. The next
beacon frame that it receives from that node will update the state.
I just need to sit down and better understand how that's suppose to
work in IBSS mode.

Tested:

* AR5416 <-> AR9280 - fast frames and the WME configuration both popped
up. (This is with a local HAL patch that enables the fast frames
capability on the AR5416 chipsets.)

PR: kern/165969


244051 09-Dec-2012 adrian

Atheros SuperG bug fixes, as part of hunting down kern/174283.

The stageqdepth (global, over all staging queues) was being kept
incorrectly. It was being incremented whenever things were added,
but only decremented during a flush. During active fast frames activity
it wasn't being decremented, resulting in it always having a non-zero
value during normal fast-frames operation.

It was only used when checking if the aging queue should be checked;
we may as well just defer to each of those staging queue counters (which
look correct, thankfully.)

Whilst I'm here, add locking assertions in the staging queue add/remove
functions. The current crash shows that the staging queue has one frame,
but only has a tail pointer set (the head pointer being set to NULL.)
I'd like to grab a few more crashes where these locking assertions are
in place so I can narrow down the issue between "somehow locking is
messed up and things are racy" and "the stage queue head/tail pointer
manipulation logic is subtly wrong."

Tested:

* AR5416 STA, AR5413 AP; with FastFrames enabled in the AR5416 HAL.

PR: kern/174283


244044 09-Dec-2012 adrian

Don't panic if the stageq here is empty; just fall through with NULL
pointers and leave the stage queue flush routine to just do nothing
(since both head and tail here will be NULL.)

This should quieten the "stageq empty" panic where the stageq itself
is empty, but it won't fix the second KASSERT() here "staging queue empty"
as that's likely a different underlying problem.

PR: kern/174283


244025 08-Dec-2012 adrian

Fix a use-after-free bug in the Atheros fast-frames support.

Tested:

* AR5212 AP, AR5413 STA, iperf TCP STA->AP, destroyed and/or shutdown
the STA vap during active iperf TCP traffic.

PR: kern/174273
MFC after: 1 week


243974 07-Dec-2012 adrian

Add a new 900MHz GSM regulatory SKU for the Xagyl Communications XC900M.

The XC900M acts as a Ubiquiti XR9 (and I _think_ SR9) by default;
it uses the same 900MHz<->2.4GHz downconverter mapping.

However it has an alternative frequency mapping which squeezes in a couple
more half/quarter rate channels. Since the default HAL doesn't support
fractional tuning (sub-1MHz) in 2.4GHz mode on the AR5413/AR5414, they
implement it using a jumper.

Datasheet: http://www.xagyl.com/download/XC900M_Datasheet.pdf

Thankyou to Xagyl Communications for the XC900M NICs and Edgar Martinez
for organising the donation.

Tested:

* XC900M <-> XC900M
* Ubiquiti XR9 <-> XC900M

TODO:

* Test against SR9 and GZ901 if possible (the IEEE channel<->frequency
mapping may not match up, thanks to the slightly different channels
involved)


243882 05-Dec-2012 glebius

Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags within sys.

Exceptions:

- sys/contrib not touched
- sys/mbuf.h edited manually


243532 26-Nov-2012 adrian

Add a primitive to check if a lock is not owned.


242205 28-Oct-2012 adrian

Add some further BAR TX debugging; it was useful when figuring out
when BAR TX was actually failing.


242155 26-Oct-2012 adrian

Oops, missed in my last commit.


242154 26-Oct-2012 adrian

Allow net80211 to be built on -9 and -8.

There are some people who use the -HEAD net80211 and wireless drivers
on earlier FreeBSD versions in order to get the updated 802.11n support.
The previous if_clone API changes broke this.


242149 26-Oct-2012 adrian

Fix up some initial issues with creation and deletion of hotplugged
net80211 devices and vaps.

* vnet sets vnet0 during kldload and device probe/attach, but not for
the hotplug event. Thus, plugging in a NIC causes things to panic.
So, add a CURVNET_SET(vnet0) for now during the attach phase, until
the hotplug code is taught to set CURVNET_SET(vnet0).

* there's also no implied detach vnet context - so teach the detach
path about ifp->if_vnet.

* When creating/deleting vaps, also set the vnet context appropriately.
These can be done at any time.

Now, the problems!

* ieee80211.c is supposed to be OS-portable code, with no OS-specific stuff
like vnet. That should be fixed.

* When the device hotplug code gets taught about CURVNET_SET(vnet0), the
device vnet set can go away; but the VAP vnet set still needs to be there.

* .. and there still is the question about potentially adding an implied
CURVNET_SET(ifp->if_vnet) on if_free(), since any/all devices may end up
being detached by a hotplug event in today's world. That's going to be
a topic of a subsequent commit.


241610 16-Oct-2012 glebius

Make the "struct if_clone" opaque to users of the cloning API. Users
now use function calls:

if_clone_simple()
if_clone_advanced()

to initialize a cloner, instead of macros that initialize if_clone
structure.

Discussed with: brooks, bz, 1 year ago


241394 10-Oct-2012 kevlo

Revert previous commit...

Pointyhat to: kevlo (myself)


241370 09-Oct-2012 kevlo

Prefer NULL over 0 for pointers


241138 02-Oct-2012 adrian

Migrate the power-save functions to be overridable VAP methods.

This turns ieee80211_node_pwrsave(), ieee80211_sta_pwrsave() and
ieee80211_recv_pspoll() into methods.

The intent is to let drivers override these and tie into the power save
management pathway.

For ath(4), this is the beginning of forcing a node software queue to
stop and start as needed, as well as supporting "leaking" single frames
from the software queue to the hardware.

Right now, ieee80211_recv_pspoll() will attempt to transmit a single frame
to the hardware (whether it be a data frame on the power-save queue or
a NULL data frame) but the driver may have hardware/software queued frames
queued up. This initial work is an attempt at providing the hooks required
to implement correct behaviour.

Allowing ieee80211_node_pwrsave() to be overridden allows the ath(4)
driver to pause and unpause the entire software queue for a given node.
It doesn't make sense to transmit anything whilst the node is asleep.

Please note that there are other corner cases to correctly handle -
specifically, setting the MORE data bit correctly on frames to a station,
as well as keeping the TIM updated. Those particular issues can be
addressed later.


240574 16-Sep-2012 adrian

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.


240521 14-Sep-2012 eadler

s/ is is / is /g
s/ a a / a /g

Approved by: cperciva
MFC after: 3 days


239319 16-Aug-2012 adrian

Fix an incorrect comparison.

PR: kern/170098


239312 15-Aug-2012 adrian

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


239142 08-Aug-2012 adrian

Fix an incorrect comment.


238942 31-Jul-2012 monthadar

Fixed some debug output in hwmp_recv_prep.


238940 31-Jul-2012 monthadar

Fix a PREQ comparison error in 11s HWMP.

* Earlier we compared two not equal metrics, one was what we recevied
in the 'new PREQ' while the other was what we already have saved which
was 'old PREQ' + link metric for the last hop;
* Fixed by adding 'new PREQ' + link metric for the last hop in a
temporary variable;


238939 31-Jul-2012 monthadar

Fix bugs in net80211s found with wtap simulator.

For description of the test scripts refer to projects/net80211_testsuite/wtap.

* Test 007 showed a bug in intermediate PREP for a proxy entry. Resolved;
* Test 002 showed a bug in the Addressing Mode flag for a PREQ. Resolved;


237871 01-Jul-2012 adrian

Add a check for dynamic OFDM/CCK channel types.


237561 25-Jun-2012 monthadar

Mesh mode, potential garbage in QoS subfield.

* qos[1] subfield is never assigned a value before this statement.
qos[1] can potentially be OR:ed with garbage. Make it an assignment instead;
* Remove brackets around if statement;

Approved by: adrian


237214 18-Jun-2012 adrian

Extend the radiotap code to be aware of the size of any extra vendor
bitmaps that may occur.

The way this works is:

* the beginning of the radiotap frame has a 32 bit "radiotap" namespace
bitmap;
* if the vendor bitmap bit is set, then the next bitmap will be interpreted
as a vendor bitmap;
* this can keep going on and on (ie, more vendor and radiotap namespace
bitmaps can be added) until the last bitmap with no "more bitmaps" set.

Now, the radiotap code gets its grubby fingers into the supplied
radiotap rx/tx buffer and replaces the channel configuration
for each frame. I don't know why it's not up to the drivers themselves
to do this, but I digress. So, if a vendor bitmap (or two, etc) exists,
the offset calculations will be all completely wrong.

This particular patch introduces ieee80211_radiotap_attachv(), which
includes the number of vendor bitmaps (well, any other bitmaps, vendor
or otherwise) between the end of the bitmap/header and the start of the
actual radiotap field entries. This makes the radiotap calculations
"right", so it correctly calculates where to overwrite the channel
configuration.

The long term fix is to go through and make each driver update the channel
configuration, as some of the fields are already being updated.

That, however, is a longer term fix that will need each driver fixed.

I leave that as an exercise to someone in the future.


235801 22-May-2012 adrian

Fix some corner cases in the ieee80211_send_bar() handling.

* If the first call succeeded but failed to transmit, a timer would
reschedule it via bar_timeout(). Unfortunately bar_timeout() didn't
check the return value from the ieee80211_send_bar() reattempt and
if that failed (eg the driver ic_raw_xmit() failed), it would never
re-arm the timer.

* If BARPEND is cleared (which ieee80211_send_bar() will do if it can't
TX), then re-arming the timer isn't enough - once bar_timeout() occurs,
it'll see BARPEND is 0 and not run through the rest of the routine.
So when rearming the timer, also set that flag.

* If the TX wasn't occuring, bar_tx_complete() wouldn't be called and the
driver callback wouldn't be called either. So the driver had no idea
that the BAR TX attempt had failed. In the ath(4) case, TX would stay
paused.

(There's no callback to indicate that BAR TX had failed or not;
only a "BAR TX was attempted". That's a separate, later problem.)

So call the driver callback (ic_bar_response()) before the ADDBA session
is torn down, so it has a chance of being notified that things didn't
quite go to plan.

I've verified that yes, this does suspend traffic for ath(4), retry BAR
TX even if the driver is failing ic_raw_xmit(), and then eventually giving
up and sending a DELBA. I'll address the "out of ath_buf" issue in ath(4)
in a subsequent commit - this commit just fixes the edge case where any
driver is (way) out of internal buffers/descriptors and fails frame TX.

PR: kern/168170
Reviewed by: bschmidt
MFC after: 1 month


234896 01-May-2012 monthadar

Update HWMP Proactive code and mesh route flags.

* Modified hwmp_recv_preq:
o cleaned up code, removed rootmac variable because preq->origaddr
is the root when we recevie a Proactive PREQ;
o Modified so that a PREP in response of a Proactive PREQ is unicast,
a PREP is ALWAYS unicast;
* Modified hwmp_recv_prep:
o Before we mark a route to be valid we should remove the discovery
flag and then mark it valid in such a way we wont lose the isgate flag;

Approved by: adrian


234894 01-May-2012 monthadar

PREQ discovery update.

* Added a new discovery flag IEEE80211_MESHRT_FLAGS_DISCOVER;
* Modified ieee80211_ioctl.h to include IEEE80211_MESHRT_FLAGS_DISCOVER;
* Added hwmp_rediscover_cb, which will be called by a timeout to do
rediscovery if we have not reach max number of preq discovery;
* Modified hwmp_discover to setup a callout for path rediscovery;
* Added to ieee80211req_mesh_route to have a back pointer to ieee80211vap
for the discovery callout context;
* Modified mesh_rt_add_locked arguemnt from ieee80211_mesh_state to
ieee80211vap, this because we have to initialize the above back pointer;

Approved by: adrian


234892 01-May-2012 monthadar

Net80211s update: Mesh Gate Announcement and removal of Portal Announcement.

* Renamed IEEE80211_ELEMID_MESHPANN to IEEE80211_ELEMID_MESHGANN according to
amendment;
* Added IEEE80211_IOC_MESH_GATE that controls whether Mesh Gate Announcement
is activated or not;
* Renamed all flags from Portal to Gate in HWMP frames;
* Removed IEEE80211_ACTION_MESHPANN enum cause its part of the Mesh Action
category now as per amendment;
* Renamed IEEE80211_MESHFLAGS_PORTAL to IEEE80211_MESHFLAGS_GATE in
ieee80211_mesh_state flags;
* Modified ieee80211_hwmp.c/ieee80211_mesh.c to use new GATE flags;

Approved by: adrian


234891 01-May-2012 monthadar

RANN update

* Introduced a new HWMP sysctl, Root Confirmation Interval;
* Added hr_lastrootconf to hwmp_route, is for ratecheck for a specific ROOT;
* We missed reading RANN.interval subfield from a RANN frame before;
* Updated hwmp_recv_rann according to amendment, see comments;

Approved by: adrian


234890 01-May-2012 monthadar

PERR update to be called from mesh code.

* Added mpp_senderror for Mesh Path Selection protocol;
* Added hwmp_senderror that will send an HWMP PERR according to the
supplied reason code;
* Call mpp_senderror when deleting a route with correct reason code
for whether the route is marked proxy or not;
* Call mpp_senderror when trying to forward an individually addressed
frame and there is no forwarding information;

Approved by: adrian


234889 01-May-2012 monthadar

* Modified PERR acceptance criteria according to amendment;
* Modified how PERR is handled and propagated according to amendment;

Approved by: adrian


234888 01-May-2012 monthadar

Updated PREQ propagation code;

* When receiving a Proactive PREQ dont return after processing it but propagate;
* When we propagate we should not enforce ratechecking;
* Added checking for multiple pred ID detection;
* Storing proxy orig address when PREQ is not for us;

Approved by: adrian


234887 01-May-2012 monthadar

* PREQ acceptance criteria updated to check for proxy condition as in amendment;

Approved by: adrian


234886 01-May-2012 monthadar

* Proactive PREQ (original transmission) must also set
IEEE80211_MESHPREQ_TFLAGS_USN flag in target_flag field;

Approved by: adrian


234885 01-May-2012 monthadar

* Fixed hwmp_discover code to populate a PREQ packet correctly;
* Removed IEEE80211_MESHPREQ_TFLAGS_RF which is no longer part of the
amendment spec;

Approved by: adrian


234884 01-May-2012 monthadar

* Fixed PREQ flag field Adressing mode subfiled according to amendment specs;

Approved by: adria


234883 01-May-2012 monthadar

* Added a mesh max PREQ retires sysctl that governous how many times
we try to discover an address;
* Added a mesh net travelse time across an MBSS, which is used to enforce
discovery rate check;

Approved by: adrian


234882 01-May-2012 monthadar

Change how we enforce PREQ minimum interval.

* Moved hs_lastpreq to be hr_lastpreq cause this rate check should be per
target mesh STA according to amendment (NB: not applicable for PERR);
* Modified hwmp_send_preq to use two extra arguments for last sent PREQ and
minimum PREQ interval;
* hwmp_send_preq is called with last two arguments equal to NULL when sending
Proactive PREQs cause the call back task enforces the rate check;

Approved by: adrian


234881 01-May-2012 monthadar

PREP update

* Added assertion in mesh_rt_update;
* Fixed some prep propagation that where multicast, ALL PREPS ARE UNICAST;
* Fixed PREP acceptance criteria;
* Fixed some PREP debug messages;
* HWMP intermediate reply (PREP) should only be sent if we have newer
forwarding infomration (FI) about target;
* Fixed PREP propagation condition and PREP w/ AE handling;
* Ignore PREPs that have unknown originator.
* Removed old code inside PREP that was for proactive path building
to root mesh;

Other errors include:
* use seq number of target and not orig mesh STA;
* Metric is what we have stored in our FI;
* Error in amendment, Hop count is not 0 but equals FI hopcount for target;

Approved by: adrian


234880 01-May-2012 monthadar

* MeshForwarding update mesh_recv_indiv_data_to_fwrd to silently discard
unknown meshDA instead of panic, which is allowed per amendment spec;

Approved by: adrian


234879 01-May-2012 monthadar

Added route lifetime update for destination and source mesh along a mesh path;

* In mesh_recv_indiv_data_to_fwd update route entry for both meshDA and meshSA;
* In mesh_recv_indiv_data_to_me update route entry for meshSA;
* in ieee80211_mesh_rt_update put code so that a proxy entry that is gated
by us (number of hops == 0) is never invalidated;
* Fixed so that we always call ieee80211_mesh_rt_update with lifetime in ms;

Approved by: adrian


234878 01-May-2012 monthadar

Mesh forwarding with proxy support.

* Modified HWMP PREP/PREQ to contain a proxy entry and also changed PREP
frame processing according to amendment as following:
o Fixed PREP to always update/create if acceptance criteria is meet;
o PREQ processing to reply if request is for a proxy entry that is
proxied by us;
o Removed hwmp_discover call from PREQ, because sending a PREP will
build the forward path, and by receving and accepting a PREQ we
have already built the reverse path (non-proactive code);
* Disabled code for pro-active in PREP for now (will make a separate patch for
pro-active HWMP routing later)
* Added proxy information for a Mesh route, mesh gate to use and proxy seqno;
* Modified ieee80211_encap according to amendment;
* Introduced Mesh control address extension enum and removed unused struct,
also rename some structure element names.
* Modified mesh_input and added mesh_recv_* that should verify and process mesh
data frames according to 9.32 Mesh forwarding framework in amendment;
* Modified mesh_decap accordingly to changes done in mesh control AE struct;

Approved by: adrian


234877 01-May-2012 monthadar

Implemented so that Mesh forwarding information lifetime is dynamic.

* Introduced ieee80211_mesh_rt_update that updates a route with the
maximum(lifetime left, new lifetime);
* Modified ieee80211_mesh_route struct by adding a lock that will be used
by both ieee80211_mesh_rt_update and precursor code (added in future commit);
* Modified in ieee80211_hwmp.c HWMP code to use new ieee80211_mesh_rt_update;
* Modified mesh_rt_flush_invalid to use new ieee80211_mesh_rt_update;
* mesh_rt_flush also checks that lifetime == 0, this gives route discovery
a change to complete;
* Modified mesh_recv_mgmt case IEEE80211_FC0_SUBTYPE_BEACON:
when ever we received a beacon from a neighbor we update route lifetime;

Approved by: adrian


234876 01-May-2012 monthadar

Fixed some MPM reason codes and max number of neighbors check

* Added IEEE80211_MESH_MAX_NEIGHBORS and it is set to 15, same as before;
* Modified mesh_parse_meshpeering_action to verify MPM frame and send
correct reason code for when a frame is rejected according to standard spec;
* Modified mesh_recv_action_meshpeering_* according to the standard spec;
* Modified mesh_peer_timeout_cb to always send CLOSE frame when in CONFIRMRCV
state according to the standard spec;

Approved by: adrian


234875 01-May-2012 monthadar

Modified structure and code that handles Mesh peering management.

* Old struct ieee80211_meshpeer_ie had wrong peer_proto field size;
* Added IEEE80211_MPM_* size macros;
* Created an enum for the Mesh Peering Protocol Identifier field according
to the standard spec and removed old defines;
* Abbreviated Handshake Protocol is not used by the standard anymore;
* Modified mesh_verify_meshpeer to use IEEE80211_MPM_* macros for verification;
* Modified mesh_parse_meshpeering_action to parse complete frame, also to parse
it according to the standard spec;
* Modified ieee80211_add_meshpeer to construct correct MPM frames according to
the standard spec;

Approved by: adrian


234874 01-May-2012 monthadar

Added Self-protected action category (including MPM).

* Added new action category IEEE80211_ACTION_CAT_SELF_PROT which is used by 11s
for Mesh Peering Management;
* Updated Self protected enum Action codes to start from 1 instead of 0
according to the standard spec;
* Removed old and wrong action categories IEEE80211_ACTION_CAT_MESHPEERING;
* Modified ieee80211_mesh.c and ieee80211_action.c to use the new action
category code;
* Added earlier verification code in ieee80211_input;

Approved by: adrian


234324 15-Apr-2012 adrian

Migrate the net80211 TX aggregation state to be from per-AC to per-TID.

TODO:

* Test mwl(4) more thoroughly!

Reviewed by: bschmidt (for iwn)


234018 08-Apr-2012 adrian

Add some statistics to track BAR TX.


233845 03-Apr-2012 bschmidt

Add basic HT channel setup to ieee80211_init_channels(), this will be
used by at least ral(4).

Reviewed by: ray


233531 27-Mar-2012 adrian

Correct the ordering of tid/crypto ic_name.

Because the code lacks all the GNU extensions to printf() format stuff,
the compiler doesn't helpfully tell us that I messed up in a previous
commit.

Pointy hat to: adrian, who likely only cares about this because he's the
only one who bothers flipping on net80211 debugging.


233452 25-Mar-2012 adrian

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


233255 21-Mar-2012 adrian

Re-commit this - store the alq payload in network order.


233133 18-Mar-2012 adrian

.. revert out a local change that I hadn't yet completely finished fleshing
out and testing.

sorry!


233129 18-Mar-2012 adrian

Add a missing endian conversion.


233050 16-Mar-2012 adrian

Pull in a dependency on ALQ if it's compiled with IEEE80211_ALQ.


232705 09-Mar-2012 adrian

Add missing \n's.

This showed up when testing the wtap module, as it attaches with
no radiotap tx/rx configuration.


232625 06-Mar-2012 adrian

Modify HWMP to be able to allocate memory for PREQ/PREP/PERR for all scenarios.

* Added verify_mesh_*_len functions that verify the length
according to the amendment spec and return number of destination addresses
for allocation of appropriate struct size in memory;
* Modified hwmp_recv_action_meshpath to allocate HWMP ie instead of
storing them on the stack and store all available field according the flags;
* Modify hwmp_add_mesh* to work with all cases of HWMP according to amendment.
* Modify hwmp_send_* to calculate correct len of bytes for the HWMP ie.
* Added new M_80211_MESH_* malloc defines.
* Added macros with magic numbers for HWMP ie sizes according to amendment.
* Added the external address to all HWMP ie structs.

Submitted by: monthadar@gmail.com


232530 05-Mar-2012 adrian

Oops - used the wrong field.

Noticed by: nwhitehorn


232526 04-Mar-2012 adrian

Add the thread id to the net80211 alq records.

This will (hopefully) aid in debugging concurrency related issues.


232525 04-Mar-2012 adrian

Fix style(9) issues.


232484 04-Mar-2012 glebius

Fix build w/o 'options IEEE80211_SUPPORT_MESH'.


232480 04-Mar-2012 adrian

* Introduce new flag for QoS control field;
* Change in mesh_input to validate that QoS is set and Mesh Control field
is present, also both bytes of the QoS are read;
* Moved defragmentation in mesh_input before we try to forward packet as
inferred from amendment spec, because Mesh Control field only present in first
fragment;
* Changed in ieee80211_encap to set QoS subtype and Mesh Control field present,
only first fragment have Mesh Control field present bit equal to 1;

Submitted by: monthadar@gmail.com


232479 04-Mar-2012 adrian

* Added IEEE80211_ACTION_CAT_MESH in ieee80211.h as specified amendment spec;
* Moved old categories as specified by D4.0 to be action fields of MESH category
as specified in amendment spec;
* Modified functions to use MESH category and its action fields:
+ ieee80211_send_action_register
+ ieee80211_send_action
+ ieee80211_recv_action_register
+ieee80211_recv_action;
* Modified ieee80211_hwmp_init and hwmp_send_action so they uses correct
action fields as specified in amendment spec;
* Modified ieee80211_parse_action so that it verifies MESH frames.
* Change Mesh Link Metric to use one information element as amendment spec.
Draft 4.0 defined two different information elements for request and response.

Submitted by: monthadar@gmail.com


232373 02-Mar-2012 adrian

Attempt to catch scan cancellations at exactly the wrong time from occuring.

The scan code unlocks the comlock and calls into the driver. It then
assumes the state hasn't changed from underneath it.

Although I haven't seen this particular condition trigger, I'd like to
be informed if I or anyone else sees it.

What I'm thinking may occur:

* A cancellation comes in during the scan_end call;
* the cancel flag is set;
* but it's never checked, so scandone isn't updated;
* .. and the interface stays in the STA power save mode.

It's a subtle race, if it even exists.

PR: kern/163318


232270 28-Feb-2012 adrian

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.


232269 28-Feb-2012 adrian

Print out the bogus beacon interval.


232244 28-Feb-2012 adrian

Track the number of bad beacons received.

PR: kern/165517


232097 24-Feb-2012 adrian

Hold IF_LOCK when manipulating the interface flags.

It doesn't _really_ help all that much, I'll commit something to
sys/net/if.c at some point explaining why, but the lock should be held
when checking/manipulating/branching because of said lock.


232096 24-Feb-2012 adrian

Although it's documented that the vap newstate call can drop the
comlock, I'd like to find and analyse these cases to see if they
really are valid.

So, throw in a lock here and wait for the (hopefully!) inevitable
complaints.


232095 24-Feb-2012 adrian

Add a radiotap vendor header definition.


231939 20-Feb-2012 ray

Remove redundant forward declaration of struct ieee80211com.

Approved by: bschmidt


231576 13-Feb-2012 adrian

Correct the 802.11s mesh configuration structure and related tidbits.

* Change the mesh IE size to be IEEE80211_MESH_CONF_SZ rather than the
size of the structure;
* conf_cap is now a uint8_t rather than a uint16_t (uint16_t in D3.0,
uint8_t in the amendment spec);
* Update mesh config capability bits - earlier bits were from draft X,
current is amendment spec;
* Update the following to be an enum rather than #define and added
a VENDOR entry too from the amendment spec;
IEEE80211_MESHCONF_PATH_*
IEEE80211_MESHCONF_METRIC_*
IEEE80211_MESHCONF_CC_*
IEEE80211_MESHCONF_SYNC_*
IEEE80211_MESHCONF_AUTH_*
* Kept IEEE80211_MESHCONF_FORM_* and IEEE80211_MESHCONF_CAP_* as
defines because they are defined in a way that we need to mask in/out
information;
* In IEEE80211_MESHCONF_CAP_* IEEE80211_MESHCONF_CAP_TBTTA is removed
and 0x80 is made reserved as defined in the amendment spec.

Submitted by: monthadar@gmail.com
Reviewed by: rpaulo


231187 08-Feb-2012 adrian

Update the 802.11s IE numbers to represent the latest 802.11 amendment standard.

Submitted by: monthadar@gmail.com
Reviewed by: rpaulo


231058 06-Feb-2012 adrian

Update the mesh reason codes to match the latest 802.11s specification.

Submitted by: <monthadar@gmail.com>
Reviewed by: rpaulo


230926 03-Feb-2012 rpaulo

Whitespace removal.


230793 31-Jan-2012 adrian

Add a DFS debugging mode which is useful when doing automated DFS
compliance testing.

In order to allow for radar pattern matching to occur, the DFS CAC/NOL
handling needs to be made configurable. This commit introduces a new
sysctl, "net.wlan.dfs_debug", which controls which DFS debug mode
net80211 is in.

* 0 = default, CSA/NOL handling as per normal.
* 1 = announce a CSA, but don't add the channel to the non-occupy list
(NOL.)
* 2 = disable both CSA and NOL - only print that a radar event occured.

This code is not compiled/enabled by default as it breaks regulatory
handling. A user must enable IEEE80211_DFS_DEBUG in their kernel
configuration file for this option to become available.

Obtained from: Atheros


230752 29-Jan-2012 adrian

Missing code for receiving MESH PREP that should be part of r230409.

Submitted by: <monthadar@gmail.com>


230447 22-Jan-2012 adrian

Mark the taskqueue as the _net80211_ taskqueue.

This makes it much easier to determine whether an event occurs in the
net80211 taskqueue (which was called "ath0 taskq") or the ath driver
taskqueue (which is also called "ath0 taskq".)


230409 21-Jan-2012 adrian

Fix the hwmp code to handle nodes in a "line" topology.

For example, this particular topology didn't work correctly from all
nodes:

[A] - [B] - [C] - [D]

Submitted by: Monthadar Al Jaberi <monthadar@gmail.com>
Reviewed by: bschmidt, adrian


230408 21-Jan-2012 adrian

Change the hwmp debugging to use %6D rather than ether_sprintf().

This allows for multiple MAC addresses to be printed on the same
debugging line. ether_sprintf() uses a static char buffer and
thus isn't very useful here.

Submitted by: Monthadar Al Jaberi <monthadar@gmail.com>


230153 15-Jan-2012 adrian

Fix the situation where net80211 is built with IEEE80211_SUPPORT_TDMA but a module
is used.

Although the module _builds_, it fails to load because of a missing symbol from
ieee80211_tdma.c.

Specifics:

* Always build ieee80211_tdma.c in the module;
* only compile in the code if IEEE80211_SUPPORT_TDMA is defined.


229968 11-Jan-2012 adrian

Add the ability to kick an existing mesh node without waiting for it
to time out.

Submitted by: Monthadar Al Jaberi <monthadar@gmail.com>


229952 11-Jan-2012 adrian

Add the MCS radiotype entry.


229948 10-Jan-2012 adrian

Add in the vendor extension bit in the radiotap header.


229795 07-Jan-2012 bz

Correct comment for the IPv6 case to say "traffic class" not "TOS"
as pointed out back in 2009.

MFC after: 3 days


229284 02-Jan-2012 bschmidt

MCS32 equals 32, not 8*ic_txstream.


228622 17-Dec-2011 bschmidt

Remove now redundant mac argument.

Discussed with: adrian@


228621 17-Dec-2011 bschmidt

Fix some net80211 enum nits:
- ic_vap_create() uses an ieee80211_opmode argument
- ieee80211_rate2media() takes an ieee80211_phymode argument
- ieee80211_plcp2rate() takes an ieee80211_phytype argument
- cast to enum ieee80211_protmode and ieee80211_roamingmode to silence
compiler warnings

Submitted by: arundel@


228514 15-Dec-2011 adrian

Modify the ACL code slightly to support a few nifty things:

* Call it before sending probe responses, so the ACL code has the
chance to reject sending them.

* Pass the whole frame to the ACL code now, rather than just the
destination MAC - that way the ACL module can look at the frame
contents to determine what the response should be.

This is part of some uncommitted work to support band steering.

Sponsored by: Hobnob, Inc.


227339 08-Nov-2011 adrian

.. add missing include from an incorrect merge.

Sponsored by: Hobnob, Inc.


227338 08-Nov-2011 adrian

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.


227331 08-Nov-2011 adrian

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


227309 07-Nov-2011 ed

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


227293 07-Nov-2011 ed

Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.

This means that their use is restricted to a single C file.


226885 28-Oct-2011 adrian

Include the tid when printing out crypto replay errors.

I found this useful when trying to debug the AR9160 STA RX filter issue -
I'd get crypto reply errors but it wasn't entirely clear which TID it
was for.


226296 12-Oct-2011 adrian

Fix an unused variable warning/error when invariants isn't enabled.

Reported by: bz


225913 02-Oct-2011 adrian

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


225139 24-Aug-2011 adrian

This patch fixes beacon frame sequence number generation. The code
didn't set a sequence number; it didn't show up earlier because the
hardware most people use for hostap (ie, AR5212 series stuff) sets the
sequence numbers up in hardware. Later hardware (AR5416, etc) which
can do 11n and aggregation require sequence numbers to be generated in
software.

Submitted by: paradyse@gmail.com
Approved by: re (kib)


225013 19-Aug-2011 adrian

Correctly handle BAR TX failures.

On a TX failure, ic_raw_xmit will still call ieee80211_node_free().
There's no need to call it here.

Submitted by: moonlightakkiy@yahoo.ca
Approved by: re (kib)


224907 16-Aug-2011 adrian

Fix BAR frame TX completion - successful transmission is indicated
by a status of 0.

Approved by: re (kib)


224717 08-Aug-2011 bschmidt

When setting a fixed channel on adapters with 11n support the scan
channel list ends up with 2 entries, the HT and the legacy channel.
The scan itself is currently always done at legacy rates so we end
up receiving scan results for legacy networks on the HT channel and
erroneously assigning the BSS to the 11n channel. As the channel's
capabilities are used to setup the adapter we might end up with
non-working settings and/or firmware crashes.

Fix this by ensuring that scan results received on a HT channel
are only assigned to that channel if the htcap IE is available,
else use the legacy channel equivalent.

Tested by: Pawel Worach, Raoul Megelas, Maciej Milewski,
Andrei <az at azsupport dot com>
Approved by: re (kib)


224222 20-Jul-2011 adrian

Fix brokenness introduced by my last commit.

Approved by: re (implicit)


224220 19-Jul-2011 adrian

This sets the BSS channel for each VAP for the given interface.
It's only relevant in STA mode.

The CSA forces a channel switch for the interface, but doesn't update
the VAP channel.

Approved by: re (bz)


223842 07-Jul-2011 kevlo

Fix memset sizeofs

Reviewed by: bschmidt


223583 27-Jun-2011 adrian

Print out a big warning if DFS can't find a channel to use.
This way people debugging DFS won't be surprised when their
AP stops talking.


223331 20-Jun-2011 adrian

Add a callback for ADDBA response timeouts.

TX for the given TID needs to be paused during ADDBA requests (and unpaused
once the session is established.) Since net80211 currently doesn't implement
software aggregation, if this pause/unpause is done in the driver (as it
is in my development branch) then it will need to be unpaused both on
ADDBA response and on ADDBA timeout.

This callback allows the driver to unpause TX for the relevant TID.

Reviewed by: bschmidt


223145 16-Jun-2011 kevlo

Change i_len in ieee80211req to be unsigned and fix other signed/unsigned
issues.

Reviewed by: bschmidt
Obtained from: NetBSD


222683 04-Jun-2011 bschmidt

Certain adapters have HT40 support on some but not all channels. The
Intel 4965 devices for example have HT40 on 2GHz completely disabled
but it is still supported for 5GHz. To handle that in sta mode we
need to check if we can "upgrade" to a HT40 channel after the
association, if that is not possible but we are still announcing
support to the remote side we are left with a very flabby connection.

Reviewed by: adrian


222682 04-Jun-2011 bschmidt

Data frames sent over the mgmt path might be part of a TX aggr session
too. In that case don't fiddle with the seqno as drivers are supposed
to handle that.

Currently only the powersave feature does sent QoS-null-data frames
before and after a background scan which must be handled correctly. Due
to this being quite rare we don't fiddle around with starting of aggr
sessions.


222162 21-May-2011 bschmidt

Fix typo, it is MPDU not MDPU.


221782 11-May-2011 adrian

Fix up the net80211 alq logging - this commit makes it usable.

* revert a local path change that shouldn't have made it to the commit
* fix some indenting/wrapping

* Fix the ale data copy - i should be copying into the ale data pointer,
not over the ale entry itself.


221781 11-May-2011 adrian

net80211 alq bugfixes:

* Track number of logged operations
* call alq_post() so things are logged
* network order things


221418 04-May-2011 adrian

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.


221022 25-Apr-2011 bz

We need in.h for both INET and INET6, as according to RFC 3493 it
defines struct in6_addr, which is needed by ip6_hdr used in here.

Reviewed by: gnn
Sponsored by: The FreeBSD Foundation
Sponsored by: iXsystems
MFC after: 5 days


220935 22-Apr-2011 adrian

Revert r220907 and r220915.

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


220908 21-Apr-2011 adrian

Implement very basic ALQ logging for net80211.

This is destined to be a lightweight and optional set of ALQ
probes for debugging events which are just impossible to debug
with printf/log (eg packet TX/RX handling; AMPDU handling.)

The probes and operations themselves will appear in subsequent
commits.


220907 21-Apr-2011 adrian

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.


220446 08-Apr-2011 adrian

Re-add the pad[2] I deleted by accident.


220445 08-Apr-2011 adrian

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.


219961 24-Mar-2011 adrian

Fix a WME corner case found by the FreeBSD 802.11n testing crew.

The symptom: sometimes 11n (and non-11n) throughput is great.
Sometimes it isn't. Much teeth gnashing occured, and much kernel
bisecting happened, until someone figured out it was the order
of which things were rebooted, not the kernel versions.
(Which was great news to me, it meant that I hadn't broken if_ath.)

What we found was that sometimes the WME parameters for the best-effort
queue had a burst window ("txop") in which the station would be allowed
to TX as many packets as it could fit inside that particular burst
window. This improved throughput.

After initially thinking it was a bug - the WME parameters for the
best-effort queue -should- have a txop of 0, Bernard and I discovered
"aggressive mode" in net80211 - where the WME BE queue parameters
are changed if there's not a lot of high priority traffic going on.
The WME parameters announced in the association response and beacon
frames just "change" based on what the current traffic levels are.
So in fact yes, the STA was acutally supposed to be doing this higher
throughput stuff as it's just meant to be configuring things based on
the WME parameters - but it wasn't.

What was eventually happening was this:

* at startup, the wme qosinfo count field would be 0;
* it'd be parsed in ieee80211_parse_wmeparams();
* and it would be bumped (to say 10);
* .. and the WME queue parameters would be correctly parsed and set.

But then, when you restarted the assocation (eg hostap goes away and
comes back with the same qosinfo count field of 10, or if you
destroy the sta VIF and re-create it), the WME qosinfo count field -
which is associated not to the VIF, but to the main interface -
wouldn't be cleared, so the queue default parameters would be used
(which include no burst setting for the BE queue) and would remain
that way until the hostap qosinfo count field changed, or the STA
was actually rebooted.

This fix simply cleares the wme capability field (which has the count
field) to 0, forcing it to be reset by the next received beacon.

Thanks go to Milu for finding it and helping me track down what was
going on, and Bernard Schmidt for working through the net80211 and
WME specific magic.


219606 13-Mar-2011 bschmidt

Constantly use MHz instead of Mhz.

Pointed out by: N.J. Mann <njm at njm.me.uk>


219604 13-Mar-2011 bschmidt

When injecting frames a temporary node is faked, during this several
uses of ic_curchan occur. Due to the nature of a scan, switching
channels constantly and all this happening without any kind of locks
held, it might happen that ic_curchan points to nowhere leading to
panics. Fix this by not allowing frame injections while in SCAN state.

Tested by: Paul B. Mahol <onemda at gmail.com>


219603 13-Mar-2011 bschmidt

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.


219602 13-Mar-2011 bschmidt

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.


219601 13-Mar-2011 bschmidt

Fix rmax calculation during BSS selection.

If multiple networks are available the max bandwidth is one
condition used for selecting the "best" BSS. To achieve that
we should consider all parameters which affect the max RX rate.
This includes 20/40MHz, SGI and the of course the MCS set.

If the TX MCS parameters are available we should use those,
because an AP announcing support for receiving frames at 450Mbps
might only be able to transmit at 150Mbps (1T3R). I haven't seen
devices with support for transmitting at higher rates then
receiving, so prefering TX over RX information should be safe.

While here, remove the hardcoded assumption that MCS15 is the max
possible MCS rate, use MCS31 instead which really is the highest
rate (according to the 802.11n std). Also, fix a mismatch of an
40MHz/SGI check.


219600 13-Mar-2011 bschmidt

Fill hc_mcsset completely.

Contrary to the rateset information in legacy frames the MCS Set
field also contains TX capability information in cases where the
number of available TX and RX spartial streams differ. Because a
rateset doesn't contain that information we have to pull the
those directly from the hardware capabilities.


219599 13-Mar-2011 bschmidt

While determining the maxrate for ieee80211_media_setup() honor
the device capabilities.


219598 13-Mar-2011 bschmidt

Change the way HT capatibilities are announced.

Get rid of the assumption that every device is capable of 40MHz,
SGI and 2 spartial streams. Instead of printing, in the worst case,
8 times 76 MCS rates, print logically connect ranges and the
support RX/TX streams.

A device without 40MHz and SGI support looks like:
ath0: 2T2R
ath0: 11na MCS 20Mhz
ath0: MCS 0-7: 6.5Mbps - 65Mbps
ath0: MCS 8-15: 13Mbps - 130Mbps
ath0: 11ng MCS 20Mhz
ath0: MCS 0-7: 6.5Mbps - 65Mbps
ath0: MCS 8-15: 13Mbps - 130Mbps


219596 13-Mar-2011 bschmidt

First step on removing the harcoded RX/TX stream and MCS0-15 assumptions.

Initialize ic_rxstream/ic_txstream with 2, for compatibility reasons.
Introduce 4 new HTC flags, which are used in addition to ic_rxstream
and ic_txstream to compute the hc_mcsset content and also for initializing
ni_htrates. The number of spatial streams is enough to determine support
for MCS0-31 but not for MCS32-76 as well as some TX parameters in the
hc_mcsset field.


219456 10-Mar-2011 bschmidt

Complete the MCS rate table based on the final 802.11n std. While here
adjust the IEEE80211_HTRATE_MAXSIZE constant, only MCS0 - 76 are valid
the other bits in the mcsset IE (77 - 127) are either reserved or used
for TX parameters.


218965 23-Feb-2011 brucec

Fix typos - remove duplicate "is".

PR: docs/154934
Submitted by: Eitan Adler <lists at eitanadler.com>
MFC after: 3 days


218958 22-Feb-2011 bschmidt

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.


218928 21-Feb-2011 bschmidt

It is IEEE80211_SUPPORT_XXX not IEEE80211_XXX_SUPPORT.


218927 21-Feb-2011 bschmidt

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


218916 21-Feb-2011 adrian

Default to the lowest negotiated rate for mgmt/multicast traffic in 11n mode

The current code transmits management and multicast frames at MCS 0.
What it should do is check whether the negotiated basic set is zero (and
the MCS set is not) before making this decision.

For now, simply default to the lowest negotiated rate, rather than
MCS 0. This fixes the behaviour with at least the DLINK DIR-825, which
ACKs but silently ignores block-ack (BA) response frames.


218092 30-Jan-2011 bschmidt

Instead of always returning 0 to a scan request, indicate if there is
one running already.

MFC after: 1 month


218091 30-Jan-2011 bschmidt

Change return code semantics of start_scan_locked(). Instead of reporting
if a scan is running, report if a scan has been started. The return value
itself is not (yet) used anywhere in the tree and it is also not exported
to userspace.

MFC after: 1 month


218085 30-Jan-2011 bschmidt

Honor the IEEE80211_SCAN_BGSCAN flag, which makes it possible to actually
request a background scan using IEEE80211_IOC_SCAN_BGSCAN.

MFC after: 1 month


217590 19-Jan-2011 bschmidt

Jump to the next element and not to an arbitrary point. frm[1] contains
the element's data length, frm[2] is the first byte of the element's data.

Submitted by: Monthadar Al Jaberi <monthadar at gmail.com>
MFC after: 1 week


217554 18-Jan-2011 mdf

Specify a CTLTYPE_FOO so that a future sysctl(8) change does not need
to rely on the format string. For SYSCTL_PROC instances that I
noticed a discrepancy between the CTLTYPE and the format specifier,
fix the CTLTYPE.


217511 17-Jan-2011 bschmidt

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


217322 12-Jan-2011 mdf

sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.

Commit the net* piece.


215699 22-Nov-2010 bschmidt

The meshid element is memcpy()'ed into se_meshid if included in either
beacon or probe-response frames. Fix the condition by checking for the
the array's content instead of the always existing array itself.

Reviewed by: rpaulo, stefanf
MFC after: 3 days


215289 14-Nov-2010 bschmidt

The ni_rctls checks are used to verify that a ratectl algo has set up
its internal data. This has been used to bypass missing calls in drivers
which do not use the ratectl framework correctly. Issue is, not all algos
use that variable, or even have internal data, therefore valid calls are
not done. Fix this by removing the checks, all driver issues should be
resolved.

MFC after: 1 week


215244 13-Nov-2010 bschmidt

Some device drivers calculate various timing related things based on
the currently selected rate. The calculations of course need a valid
rate. To make that possible before any call to node_rate() is done,
initialize ni_txrate on none_node_init() calls.

MFC after: 1 week


214894 06-Nov-2010 bschmidt

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


214069 19-Oct-2010 bschmidt

Fix an undefined behaviour if the desired ratectl algo is not available.
This can happen if the algos are built as modules but are not loaded. If
the selected ratectl algo is not available, try to load it (The load
module functions does nothing currently). Add a dummy ratectl algo which
always selects the first available rate. Use that one if the desired algo
is not available.

MFC after: 1 week


213321 01-Oct-2010 adrian

Fix background roaming to actually work in AUTO roaming mode.

IEEE80211_F_BGSCAN is a vap flag, not a channel flag. So although bgscan
occured, sta_roam_check() would never be called.


211546 21-Aug-2010 bschmidt

Wrap remaining ieee80211_ratectl_node_init() calls missed in r211314.

MFC after: 1 week


211314 14-Aug-2010 bschmidt

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

MFC after: 2 weeks


211295 14-Aug-2010 bschmidt

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


209636 01-Jul-2010 bschmidt

- Introduce IEEE80211_KEY_NOREPLAY, a per-key flag to ignore replay
violations.
- Use SIOCGIFMEDIA to determine VAP's opmode, cache it and set
IEEE80211_KEY_NOREPLAY for AHDEMO and IBSS.

Approved by: rpaulo (mentor)


209092 12-Jun-2010 ed

Remove GNU-style struct initialization.

Spotted by: clang
Approved by: rpaulo


209022 11-Jun-2010 avatar

Fixing compilation bustage by adding the missing && back.


209016 10-Jun-2010 rpaulo

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


209013 10-Jun-2010 rpaulo

Add missing braces.

Submitted by: sam
MFC after: 3 days


208699 01-Jun-2010 rpaulo

Fix resource leaks in ieee80211_ioctl_setchanlist() in case of error.

Found with: Coverity Prevent(tm)
CID: 4115
MFC after: 3 days


208697 01-Jun-2010 rpaulo

Compare the address of the array, not the array.

Found with: Coverity Prevent(tm)
CID: 3690
MFC after: 3 days


208696 01-Jun-2010 rpaulo

Don't reference null pointer in hwmp_recv_preq().

Found with: Coverity Prevent(tm)
CID: 3912
MFC after: 3 days


208693 01-Jun-2010 rpaulo

Properly initialize stack variable sr in setmlme_assoc_adhoc().

Found with: Coverity Prevent(tm)
CID 4365
MFC after: 3 days


207554 03-May-2010 sobomax

Add new tunable 'net.link.ifqmaxlen' to set default send interface
queue length. The default value for this parameter is 50, which is
quite low for many of today's uses and the only way to modify this
parameter right now is to edit if_var.h file. Also add read-only
sysctl with the same name, so that it's possible to retrieve the
current value.

MFC after: 1 month


207370 29-Apr-2010 rpaulo

Decrement rxa_pad due to the addition of rxa_private.


207327 28-Apr-2010 rpaulo

Add a private field to struct ieee80211_rx_ampdu do hold driver specific
data.

Sponsored by: iXsystems, inc


207326 28-Apr-2010 rpaulo

Add ic_rxstream and ic_txstream. These variables hold the number of RX
streams and the number of TX streams respectively.

Obtained from: //depot/user/rpaulo/80211n/...
Sponsored by: iXsystems, inc.


207323 28-Apr-2010 rpaulo

When in the RUN -> AUTH -> RUN FSM transition happens, we'll call the
ratectl_node_init() functions and since ni_rtctls was already
malloc'ed() we will panic. Fix this by using the already malloc'ed
pointer.

Found by: bschmidt
Reviewed by: bschmidt


207322 28-Apr-2010 rpaulo

Fix typo. No functional change.

Obtained from: DragonFlyBSD


206617 14-Apr-2010 rpaulo

Make this code a little more portable by wrapping the mtx calls into
macros.

MFC after: 1 week


206457 10-Apr-2010 bschmidt

Add WPA-None support:
* WPA-None requires ap_scan=2:
The major difference between ap_scan=1 (default) and 2 is, that no
IEEE80211_IOC_SCAN* ioctls/functions are called, though, there is a
dependency on those. For example the call to wpa_driver_bsd_scan()
sets the interface UP, this never happens, therefore the interface
must be marked up in wpa_driver_bsd_associate(). IEEE80211_IOC_SSID
also is not called, which means that the SSID has not been set prior
to the IEEE80211_MLME_ASSOC call.
* WPA-None has no support for sequence number updates, it doesn't make
sense to check for replay violations..
* I had some crashes right after the switch to RUN state, issue is
that sc->sc_lastrs was not yet defined.

Approved by: rpaulo (mentor)
MFC after: 3 weeks


206419 09-Apr-2010 rpaulo

Use M_NOWAIT instead of M_WAITOK to avoid race conditions.

MFC after: 1 month


206415 09-Apr-2010 rpaulo

Swap IEEE80211_RATECTL_TX_SUCCESS/IEEE80211_RATECTL_TX_FAILURE.

Submitted by: PseudoCylon Furukoshi <moonlightakkiy at yahoo.ca>
MFC after: 1 month


206398 08-Apr-2010 rpaulo

Prevent foot-shooting in ieee80211_ratectl_node_deinit().

MFC after: 1 month


206367 07-Apr-2010 rpaulo

Fix build.

Pointy hat: me
MFC after: 1 month


206358 07-Apr-2010 rpaulo

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


205986 31-Mar-2010 rpaulo

Constify vap argument of ieee80211_{note,discard}* functions.

MFC after: 1 week


205791 28-Mar-2010 rpaulo

Add a comment explaining the previous commit.

Submitted by: sam
> Description of fields to fill in above: 76 columns --|
> PR: If a GNATS PR is affected by the change.
> Submitted by: If someone else sent in the change.
> Reviewed by: If someone else reviewed your modification.
> Approved by: If you needed approval for this commit.
> Obtained from: If the change is from a third party.
> MFC after: N [day[s]|week[s]|month[s]]. Request a reminder email.
> Security: Vulnerability reference (one per line) or description.
> Empty fields above will be automatically removed.

M ieee80211_hostap.c


205516 23-Mar-2010 rpaulo

When receiving a management frame, pass the mbuf to bpf before calling
iv_recv_mgmt(). iv_recv_mgmt() will generate management frame responses
and pass them to bpf before the management frame that triggered the
response.

PR: 144323
Submitted by: Alexander Egorenkov <egorenar at gmail.com>
MFC after: 2 weeks
Sponsored by: iXsystems, inc.


205513 23-Mar-2010 rpaulo

Add a new field for extended HT capabilities.

Submitted by: Alexander Egorenkov <egorenar at gmail.com>
MFC after: 2 weeks
Sponsored by: iXsystems, inc.


205281 18-Mar-2010 rpaulo

Unbreak build by removing a code bit that is only related to other code
in my branch.


205277 18-Mar-2010 rpaulo

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/...


205140 14-Mar-2010 weongyo

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


203673 08-Feb-2010 bschmidt

Ensure that tkip_mixing_phase1() is called after a rekeying event when
useing plain s/w crypto.

Approved by: rpaulo (mentor)
Reviewed by: sam


203556 06-Feb-2010 rpaulo

Revert unwanted changes in revision 203422.

Spotted by: sam


203423 03-Feb-2010 rpaulo

Avoid a null pointer deref when parsing the meshid.

Found with: clang static analyzer


203422 03-Feb-2010 rpaulo

When taking the AMPDU reorder fastpath, need_tap wasn't being
initialized. Initialize on declaration to avoid this.

Found with: clang static analyzer


202967 25-Jan-2010 rpaulo

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


202935 24-Jan-2010 syrinx

While flushing the multicast filter of an interface, do not zero the relevant
ifmultiaddr structures' reference to the parent interface, unless the parent
interface is really detaching. While here, program only link layer multicast
filters to a wlan's hardware parent interface.

PR: kern/142391, kern/142392
Reviewed by: sam, rpaolo, bms
MFC after: 1 week


202612 19-Jan-2010 thompsa

Use the iflladdr_event event to keep the mac address on the vap in sync with
the parent wirless interface. If the user passed in a mac address or it was
autogenerated then flag this to avoid trashing it on update.

This will fix wlan+lagg in a post vap world.


202295 14-Jan-2010 rpaulo

Fix bugs introduced in previous commit: off-by-one in add_meshconf() and
big-endian bug on verify_meshconf()


202178 12-Jan-2010 rpaulo

Update mesh code to to D4.0.


201793 08-Jan-2010 trasz

Fix #ifdefs so that GCC 4.4 doesn't complain about it.

Reviewed by: rpaulo


201758 07-Jan-2010 mbr

Remove extraneous semicolons, no functional changes.

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


200242 08-Dec-2009 rpaulo

Fix typo in comment

Submitted by: Paul B Mahol <onemda at gmail.com>


199187 11-Nov-2009 antoine

Remove trailing ";" in struct ieee80211_beacon_offsets declaration

Found by: phk's FlexeLint in September
Reviewed by: rpaulo@
MFC after: 1 month


199186 11-Nov-2009 antoine

Fix off by one in ieee80211_send_action_register

Found by: phk's FlexeLint in September
Reviewed by: rpaulo@
MFC after: 1 month


199076 09-Nov-2009 rpaulo

The isr_intval in ieee80211req_scan_result structure should be 16 bit.
This makes ifconfig list scan display the correct beacon interval
(previously it would int overflow). As a side effect, this makes the
ieee80211req_scan_result word aligned.

Submitted by: Paul B Mahol <onemda at gmail.com>


198988 06-Nov-2009 jhb

Take a step towards removing if_watchdog/if_timer. Don't explicitly set
if_watchdog/if_timer to NULL/0 when initializing an ifnet. if_alloc()
sets those members to NULL/0 already.


198581 29-Oct-2009 rpaulo

Update the route's sequence number upon receiving a RANN.

MFC after: 3 days


198384 23-Oct-2009 rpaulo

The draft spec doesn't say beacon frames need to have a wildcard BSSID,
so remove the mesh code necessary for that.

MFC after: 2 days


198369 22-Oct-2009 rpaulo

Initialize rann_flags properly.

MFC after: 2 days


198346 21-Oct-2009 rpaulo

Don't call the newstate callback as that's dangerous. Rely no ENETRESET
to DTRT.

MFC after: 3 days


198260 19-Oct-2009 rpaulo

Fix a bug in composing PERR frames introduced by latest draft update.

MFC after: 3 days


198242 19-Oct-2009 rpaulo

Implement the missing support for updating the mesh conf number of
neighbors via ieee80211_beacon_notify().

MFC after: 3 days


198230 19-Oct-2009 rpaulo

HWMP fixes, namely:
* fix the processing of RANN frames
* the originator and target addresses were swapped and while it worked
fine, it was not spec compliant.

MFC after: 3 days


198027 13-Oct-2009 rpaulo

Properly initialize the mesh conf capabilities byte.

MFC after: 2 days


197977 12-Oct-2009 rpaulo

Fix a wrong initialization that snuck in the latest commit.

MFC after: 3 days


197975 12-Oct-2009 rpaulo

Another 3.03 draft bit that I missed in the previous 802.11s stack
update. The Mesh Configuration IE has changed quite a bit. Refactor the
code to handle this change.

MFC after: 3 days


197413 22-Sep-2009 rpaulo

Update 802.11s mesh support to draft 3.03. This includes a revised frame
format for peering and changes to the PERR frames.
Note that this is incompatible with the previous code.

Reviewed by: sam
MFC after: 1 week


196970 08-Sep-2009 phk

Revert previous commit and add myself to the list of people who should
know better than to commit with a cat in the area.


196969 08-Sep-2009 phk

Add necessary include.


196785 03-Sep-2009 sam

correct timeout for doing NOL processing; need a ticks-relative value

Obtained from: Marvell
MFC after: 3 days


196783 03-Sep-2009 sam

on transition to SLEEP state mark the station in power save, not awake

MFC after: 3 days


196316 17-Aug-2009 rpaulo

Fix a typo in ifdef mesh support. This would make mesh unworkable if
TDMA support was compiled out.

Approved by: re (kib)


196159 12-Aug-2009 sam

Drain link state event changes posted during vap destroy. This is a
band-aid for the general problem that if_link_state_change can be
called between if_detach and if_free leaving a task queued that has
been free'd.

Spotted by: thompsa
Reviewed by: rwatson
Approved by: re (rwatson)


196019 01-Aug-2009 rwatson

Merge the remainder of kern_vimage.c and vimage.h into vnet.c and
vnet.h, we now use jails (rather than vimages) as the abstraction
for virtualization management, and what remained was specific to
virtual network stacks. Minor cleanups are done in the process,
and comments updated to reflect these changes.

Reviewed by: bz
Approved by: re (vimage blanket)


196005 31-Jul-2009 sam

fix misplaced #endif that caused tdma handling to be merged with ESS handling
(causing tdma scanning to break)

Approved by: re (kib)


196004 31-Jul-2009 sam

Filter setting IFF_PROMISC on tdma vaps; we don't want the underyling device
to be in promiscuous mode as we have a h/w bssid.

Approved by: re (kib)


195908 27-Jul-2009 rpaulo

Mesh fixes, namely:
* don't clobber proxy entries
* HWMP seq number processing, including discard of old frames
* flush routing table entries based on nexthop
* print route flags in ifconfig
* more debugging messages and comments

Proxy changes submitted by sam.

Approved by: re (kib)


195849 24-Jul-2009 sam

revert OACTIVE part of r195845; instead fix the comment so it does not refer
to the old hack removed in r193312

Approved by: re (implicit)


195847 24-Jul-2009 sam

correct handling of IFF_PROMISC; this should not be pushed to the parent
device except for monitor and ahdemo mode vaps

Reviewed by: rpaulo
Approved by: re (kensmith)


195846 24-Jul-2009 sam

monitor mode vaps are meant to be read-only so they can operate on any
frequency w/o regulatory issues, do this by hooking if_transmit and
if_output with routines that discard all transmits

Reviewed by: thompsa, cbzimmer (intent)
Approved by: re (kensmith)


195845 24-Jul-2009 sam

o kill old code no longer needed after r193312
o count output packets+errors for frames sent through ieee80211_output

Approved by: re (kensmith)


195813 21-Jul-2009 sam

store mesh timers as ticks and sysctls for changing the defaults

Reviewed by: rpaulo
Approved by: re (kib)


195812 21-Jul-2009 sam

Correct handling of keys that already have a hardware/device key index:
this was broken in r183248 when the check of wk_keyix was replaced by
a check of IEEE80211_KEY_DEVKEY (because the flag was clobbered). Define
IEEE80211_KEY_DEVICE to specify flags that are owned by net80211/driver
and use this to preserve IEEE80211_KEY_DEVKEY so we don't ask the driver
for another key index when we already have one.

Testing by: Daniel Thiele, Wes Morgan
Reviewed by: rpaulo
Approved by: re (kib)


195784 20-Jul-2009 rpaulo

More mesh bits, namely:
* bridge support (sam)
* handling of errors (sam)
* deletion of inactive routing entries
* more debug msgs (sam)
* fixed some inconsistencies with the spec.
* decap is now specific to mesh (sam)
* print mesh seq. no. on ifconfig list mesh
* small perf. improvements

Reviewed by: sam
Approved by: re (kib)


195757 18-Jul-2009 sam

Move code that does payload realigment to a new routine, ieee80211_realign,
so it can be reused. While here rewrite the logic to always use a single mbuf.

Reviewed by: rpaulo
Approved by: re (kib)


195699 14-Jul-2009 rwatson

Build on Jeff Roberson's linker-set based dynamic per-CPU allocator
(DPCPU), as suggested by Peter Wemm, and implement a new per-virtual
network stack memory allocator. Modify vnet to use the allocator
instead of monolithic global container structures (vinet, ...). This
change solves many binary compatibility problems associated with
VIMAGE, and restores ELF symbols for virtualized global variables.

Each virtualized global variable exists as a "reference copy", and also
once per virtual network stack. Virtualized global variables are
tagged at compile-time, placing the in a special linker set, which is
loaded into a contiguous region of kernel memory. Virtualized global
variables in the base kernel are linked as normal, but those in modules
are copied and relocated to a reserved portion of the kernel's vnet
region with the help of a the kernel linker.

Virtualized global variables exist in per-vnet memory set up when the
network stack instance is created, and are initialized statically from
the reference copy. Run-time access occurs via an accessor macro, which
converts from the current vnet and requested symbol to a per-vnet
address. When "options VIMAGE" is not compiled into the kernel, normal
global ELF symbols will be used instead and indirection is avoided.

This change restores static initialization for network stack global
variables, restores support for non-global symbols and types, eliminates
the need for many subsystem constructors, eliminates large per-subsystem
structures that caused many binary compatibility issues both for
monitoring applications (netstat) and kernel modules, removes the
per-function INIT_VNET_*() macros throughout the stack, eliminates the
need for vnet_symmap ksym(2) munging, and eliminates duplicate
definitions of virtualized globals under VIMAGE_GLOBALS.

Bump __FreeBSD_version and update UPDATING.

Portions submitted by: bz
Reviewed by: bz, zec
Discussed with: gnn, jamie, jeff, jhb, julian, sam
Suggested by: peter
Approved by: re (kensmith)


195661 13-Jul-2009 rpaulo

Fix inline function declaration and prototype.

Approved by: re (kensmith)


195618 11-Jul-2009 rpaulo

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


195561 10-Jul-2009 sam

mark struct ieee80211req_maclist packed so sizeof works as intended on arm;
fixes "list mac"

Approved by: re (kensmith)


195527 10-Jul-2009 sam

correctly set the tailq ptr when removing the last item in the q

Approved by: re (kensmith)


195379 05-Jul-2009 sam

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)


195377 05-Jul-2009 sam

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)


194760 23-Jun-2009 rwatson

Modify most routines returning 'struct ifaddr *' to return references
rather than pointers, requiring callers to properly dispose of those
references. The following routines now return references:

ifaddr_byindex
ifa_ifwithaddr
ifa_ifwithbroadaddr
ifa_ifwithdstaddr
ifa_ifwithnet
ifaof_ifpforaddr
ifa_ifwithroute
ifa_ifwithroute_fib
rt_getifa
rt_getifa_fib
IFP_TO_IA
ip_rtaddr
in6_ifawithifp
in6ifa_ifpforlinklocal
in6ifa_ifpwithaddr
in6_ifadd
carp_iamatch6
ip6_getdstifaddr

Remove unused macro which didn't have required referencing:

IFP_TO_IA6

This closes many small races in which changes to interface
or address lists while an ifaddr was in use could lead to use of freed
memory (etc). In a few cases, add missing if_addr_list locking
required to safely acquire references.

Because of a lack of deep copying support, we accept a race in which
an in6_ifaddr pointed to by mbuf tags and extracted with
ip6_getdstifaddr() doesn't hold a reference while in transmit. Once
we have mbuf tag deep copy support, this can be fixed.

Reviewed by: bz
Obtained from: Apple, Inc. (portions)
MFC after: 6 weeks (portions)


194739 23-Jun-2009 bz

After cleaning up rt_tables from vnet.h and cleaning up opt_route.h
a lot of files no longer need route.h either. Garbage collect them.
While here remove now unneeded vnet.h #includes as well.


194461 18-Jun-2009 rpaulo

ieee80211_dwds_mcast(): check the correct mbuf ptr after encap.


194136 13-Jun-2009 sam

Rev IEEE80211_IOC_STA_INFO abi: ni_flags grew from 16 bits to 32
bits but isi_state did not follow; expand it to 32 bits and pad to
maintain alignment. Note this is an incompatible change that
requires rebuilding of user applications.

Submitted by: rpaulo, cbzimmer, avatar


194022 11-Jun-2009 sam

make implicit pad visible


194021 11-Jun-2009 sam

use negotiated short gi to calculate the tx rate; using the htcaps
does not take into account local state (e.g. manual disable of sgi)


193966 11-Jun-2009 sam

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.


193844 09-Jun-2009 sam

protect callouts with the com lock

Prodded by: jhb


193843 09-Jun-2009 sam

add missing calls to ieee80211_dfs_attach/detach


193840 09-Jun-2009 sam

Correct ieee80211_gettid:
o don't increment extracted tid, this was a vestige of IEEE80211_NONQOS_TID
being defined as 0 (w/ real tid's +1)
o handle 4-address frames (add IEEE80211_IS_DSTODS to check if an 802.11
header is DSTODS)

Submitted by: cbzimmer
Reviewed by: avatar


193761 08-Jun-2009 sam

purge dead code


193760 08-Jun-2009 sam

fix big-endian machines


193744 08-Jun-2009 bz

After r193232 rt_tables in vnet.h are no longer indirectly dependent on
the ROUTETABLES kernel option thus there is no need to include opt_route.h
anymore in all consumers of vnet.h and no longer depend on it for module
builds.

Remove the hidden include in flowtable.h as well and leave the two
explicit #includes in ip_input.c and ip_output.c.


193675 08-Jun-2009 sam

do not strip M_MORE_DATA on packets coming through ieee80211_start;
frames coming out of the ps q may have this set and removing it
causes the 802.11 header to not indicate more frames follow which can
result in the sta going to sleep and missing them


193666 07-Jun-2009 sam

prefer callout_schedule


193665 07-Jun-2009 sam

use c99-style initializers


193658 07-Jun-2009 sam

teach ieee80211_classify about ipv6 packets

Reviewed by: bz, rrs


193657 07-Jun-2009 sam

add iv_flags_ht and ic_flags_ht


193655 07-Jun-2009 sam

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


193554 06-Jun-2009 sam

o add bits for STBC and Greenfield
o fix some comments


193549 05-Jun-2009 sam

reserve node flag bits for a-msdu tx/rx


193548 05-Jun-2009 sam

reserve ioc's for Greenfield and STBC


193543 05-Jun-2009 sam

correct status code returned for ht capability mismatch on assoc/reassoc


193542 05-Jun-2009 sam

o correct/add action frame categories
o add IEEE80211_STATUS_MISSING_HT_CAPS, added in 11n D3.0 spec


193541 05-Jun-2009 sam

add tid param to ieee80211_notify_replay_failure to get the correct rsc


193504 05-Jun-2009 rwatson

Fix spelling of MAC check for 8.x version of MAC Framework, not noticed due
to a lack of an opt_mac.h include, which I won't add for now as options MAC
will soon move to opt_global.h.

Spotted by: pjd


193439 04-Jun-2009 sam

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


193414 03-Jun-2009 sam

When a channel switch is done to a channel with different operating
characteristics force the stations to re-associate so protocol state
is re-initialized. Note that for 11h/DFS this is irrelevant as channel
changes are never cross-band.

Reviewed by: ctlaw


193413 03-Jun-2009 sam

After a channel switch mark associated stations so they will immediately
be probed as inactive; this more quickly weeds out stations that don't
follow to the new channel.


193366 03-Jun-2009 weongyo

calls callout_drain(9) to un-schedule a scan timer to prevent a page
fault in softclock.

Submitted by: sam
Reviewed by: jhb, sam (original version), thompsa


193348 02-Jun-2009 sam

remove another vestige of the null if_softc on detach hack


193347 02-Jun-2009 sam

fix typo


193340 02-Jun-2009 sam

partially fix mode setting; this no longer returns an error but still
needs to handle the case where the vap is up+running

Noticed by: "Paul B. Mahol" <onemda@gmail.com>


193337 02-Jun-2009 sam

move if_detach to the top of ieee80211_ifdetach to close various races

Reviewed by: jhb


193312 02-Jun-2009 sam

Remove hack used to deal with ifnet teardown now that if_detach and the
bridge do a better job.
o move ether_ifdetach to the top of ieee80211_detach
o do not clear if_softc at the top of ieee80211_detach; we no longer need
this because we are safeguarded against calls coming back through if_ioctl
o simplify the bpf tracker now that we don't null if_softc

This also fixes an issue where having a bpf consumer active when a vap
is destroyed would cause a crash because bpf referenced free'd memory.

Reviewed by: imp


193292 02-Jun-2009 sam

Fix monitor mode vaps to work as intended:
o track # bpf taps on monitor mode vaps instead of # monitor mode vaps
o spam monitor mode taps on tx/rx
o fix ieee80211_radiotap_rx_all to dispatch frames only if the vap is up
o while here print radiotap (and superg) state in show com


193288 02-Jun-2009 sam

don't dispatch frames to vap's not running


193287 02-Jun-2009 sam

count packets


193239 01-Jun-2009 sam

pad data structures to enable integration of future features w/o abi breakage


193115 30-May-2009 sam

distribute sysctl decls so global variables can be made static


193114 30-May-2009 sam

o assert TDMA_MAXSLOTS is 2 so noone tries to blindly increase it
o add safety belt in vdetach for failed state block allocation
o fix dynamic change to tdma config; ERESTART may not result in
kicking the state machine so we need to explicitly mark the
beacon for update

Sponsored by:


193072 29-May-2009 sam

add ieee80211_isratevalid


192765 25-May-2009 sam

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


192764 25-May-2009 sam

do internal bpf tracking only for radiotap DLT's


192473 20-May-2009 sam

Prepare to distribute sysctl code to reduce global definitions:
o expose net.wlan sysctl node
o expose ieee80211_sysctl_msecs_ticks

Reviewed by: rpaulo, thompsa


192468 20-May-2009 sam

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


192328 18-May-2009 sam

add block ack frame id


192108 14-May-2009 sam

add missing type for SYSCTL_PROC items; w/o a type you can view the value
but not change it


192107 14-May-2009 sam

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


191955 10-May-2009 thompsa

Cancel the scan when going to INIT state. Should do this for other states here
too as once the protocol newstate handler runs the scan has always ended.


191816 05-May-2009 zec

Change the curvnet variable from a global const struct vnet *,
previously always pointing to the default vnet context, to a
dynamically changing thread-local one. The currvnet context
should be set on entry to networking code via CURVNET_SET() macros,
and reverted to previous state via CURVNET_RESTORE(). Recursions
on curvnet are permitted, though strongly discuouraged.

This change should have no functional impact on nooptions VIMAGE
kernel builds, where CURVNET_* macros expand to whitespace.

The curthread->td_vnet (aka curvnet) variable's purpose is to be an
indicator of the vnet context in which the current network-related
operation takes place, in case we cannot deduce the current vnet
context from any other source, such as by looking at mbuf's
m->m_pkthdr.rcvif->if_vnet, sockets's so->so_vnet etc. Moreover, so
far curvnet has turned out to be an invaluable consistency checking
aid: it helps to catch cases when sockets, ifnets or any other
vnet-aware structures may have leaked from one vnet to another.

The exact placement of the CURVNET_SET() / CURVNET_RESTORE() macros
was a result of an empirical iterative process, whith an aim to
reduce recursions on CURVNET_SET() to a minimum, while still reducing
the scope of CURVNET_SET() to networking only operations - the
alternative would be calling CURVNET_SET() on each system call entry.
In general, curvnet has to be set in three typicall cases: when
processing socket-related requests from userspace or from within the
kernel; when processing inbound traffic flowing from device drivers
to upper layers of the networking stack, and when executing
timer-driven networking functions.

This change also introduces a DDB subcommand to show the list of all
vnet instances.

Approved by: julian (mentor)


191768 03-May-2009 thompsa

Relax the condition for printing the lost state transition message. The new
state will be set before the EXT_STATEWAIT flag is cleared and its ok to
transition again at that point.


191757 02-May-2009 sam

don't say "ac WME_AC_BE"; remove "ac"


191756 02-May-2009 sam

promote ieee80211_seq typedef


191755 02-May-2009 sam

o dump tx/rx seq#'s for qos tid's
o improve check for when to dump rx ampdu state


191754 02-May-2009 sam

whitespace


191753 02-May-2009 sam

make superg/fast-frames state dynamically-allocated (and indirect off
the com structure instead of embedded); this reduces the overhead when
not configured and reduces visibility of the contents


191746 02-May-2009 thompsa

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


191732 01-May-2009 sam

revert wip


191571 27-Apr-2009 sam

Store the tx seq# of an 802.11 frame in the mbuf pkthdr; this will be
used for s/w retransmit schemes that want to access this information
w/o the overhead of decoding the raw frame. Note this also allows
drivers to record this information w/o writing the frame when the seq#
is obtained through an out-of-band mechanism (e.g. when a h/w assigned
seq# is reported in a descriptor on tx done notification).

Reviewed by: sephe, avatar


191555 26-Apr-2009 sam

add IEEE80211_FEXT_4ADDR to indicate ieee80211_encap should do 4-address
encapsulation when relaying frames; this reduces the cost of the test and
enables use for situations other than "sta vap + dwds"


191554 26-Apr-2009 sam

don't depend on includes to get definitions of struct ieee80211_tx_ampdu
and ieee80211_rx_ampdu; these should've been part of r191552


191553 26-Apr-2009 sam

hoist ampdu tx aggregation setup from ieee80211_encap to ieee80211_start
where it was meant all along (the code was in encap because ampdu was
implemented pre vaps)


191552 26-Apr-2009 sam

allow drivers to hook ampdu rx start/stop


191551 26-Apr-2009 sam

improvements:
o formatting
o more rx ampdu state
o tdma state
o show ifnet names
o show auth policy name


191550 26-Apr-2009 sam

stash the node pointer in the mbuf before doing ff aggregration so this
is done in only one place


191549 26-Apr-2009 sam

whitespace


191547 26-Apr-2009 sam

print both fc bytes when hitting a protocol version mismatch


191546 26-Apr-2009 sam

add iv_recv_ctl method to allow hooking rx ctl frame handling


191545 26-Apr-2009 sam

don't fragment ampdu aggregates


191544 26-Apr-2009 sam

uniformly mark mbufs that pass through the tx path with M_MCAST; drivers
can now use this flag instead of inspecting the contents


191542 26-Apr-2009 sam

o add missing 802.3 bpf tap
o add 802.11 bpf tap to output path now that it's removed from ieee80211_encap


191541 26-Apr-2009 sam

add missing DLT_IEEE802_11 tap


191540 26-Apr-2009 sam

add missing part of r191537 that should have read: hoist DLT_IEEE802_11
bpf tap from ieee80211_encap up to ieee80211_start


191538 26-Apr-2009 sam

fix comment


191537 26-Apr-2009 sam

add missing DLT_IEEE802_11 bpf tap in ieee80211_start


191536 26-Apr-2009 sam

fixup ieee80211_output handling:
o correct bpf handling, send 'em to the right tap
o do accouting
o mark mbufs holding multicast frames


191534 26-Apr-2009 sam

o use shared code to handle bpf tap and mbuf cleanup
o swap conditional order to put the cheapest first


191532 26-Apr-2009 sam

correct bssid reporting for wds vaps


191444 23-Apr-2009 rpaulo

Remove spurious 'or'.


191148 16-Apr-2009 kmacy

Change if_output to take a struct route as its fourth argument in order
to allow passing a cached struct llentry * down to L2

Reviewed by: rwatson


191018 13-Apr-2009 sam

setup turboA/G fixed rate parameters too; this is needed, in particular,
for turboG operation


191017 13-Apr-2009 sam

correct debug printf


191016 13-Apr-2009 sam

check correct address for a bssid mtch


191015 13-Apr-2009 sam

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


190850 08-Apr-2009 sam

o add a capability for drivers that require 802.3 encapsulation of
frames passed down through the transmit path
o mark ndis requiring 802.3 encap'd frames

Reviewed by: "Paul B. Mahol" <onemda@gmail.com>, thompsa


190678 03-Apr-2009 sam

fix whitespace


190672 03-Apr-2009 sam

o update dwds mcast handling after hoisting ieee80211_encap: frames need
to be encapsulated before dispatching to the driver
o eliminate M_WDS now that we call ieee80211_encap directly and can supply
the wds vap to indicate a 4-address frame should be created


190579 30-Mar-2009 sam

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


190578 30-Mar-2009 rpaulo

Fix typo in comment.


190577 30-Mar-2009 rpaulo

MFP mesh11s:
Add mesh debugging bit replacing the now deprecated RADKEYS.


190532 29-Mar-2009 sam

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


190530 29-Mar-2009 sam

toggling fast-frames requires clocking the state machine


190526 29-Mar-2009 sam

Eliminate ic_myaddr so changing the mac address of a device works correctly:
o remove ic_myaddr from ieee80211com
o change ieee80211_ifattach to take the mac address of the physical device
and use that to setup the lladdr.
o replace all references to ic_myaddr in drivers by IF_LLADDR
o related cleanups (e.g. kill dead code)

PR: kern/133178
Reviewed by: thompsa, rpaulo


190455 26-Mar-2009 sam

o move tdma+superg protocol defs out of public view
o add #ifdef _KERNEL to superg+tdma include files so they can be used
by user code to get the protocol defs


190451 26-Mar-2009 sam

Fix enough bits so that fast frames work again:
o include ath ie in beacon frames
o fix probe response check for including ath ie
o add ieee80211_add_athcap shorthand for ap-side ie additions


190450 26-Mar-2009 sam

dynamic turbo mode is only implemented in sta mode; don't enable it
for other operating modes based on the capability


190449 26-Mar-2009 sam

need to adjust htinfo offset when csa is inserted


190448 26-Mar-2009 sam

adjust tdma ie offset when beacon frame contents changes


190402 25-Mar-2009 sam

shuffle code so things build w/o INVARIANTS or IEEE80211_SUPPORT_SUPERG

Prodded by: several


190394 24-Mar-2009 sam

hide linker set stuff from user space


190391 24-Mar-2009 sam

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


190384 24-Mar-2009 sam

add linker sets for get/set ioctl handlers so optional net80211
code is isolated


190381 24-Mar-2009 sam

use IEEE80211_SUPPORT_TDMA option to control whether code is
configured; this allows us to remove an #ifdef


190094 19-Mar-2009 rpaulo

Remove leftover comment because we now use a flag to check for associd.

Discussed with: sam


190093 19-Mar-2009 rpaulo

Fix typo in comment.


189987 18-Mar-2009 rpaulo

Use plural in a comment. No functional change.


189981 18-Mar-2009 sam

rate limit printfs for invalid tdma ie contents; probably want this to
be less than 1/sec


189980 18-Mar-2009 sam

Minor cleanups of tdma protocol handling:
o break out version-related code to simplify rev'ing the protocol
o add parameter validation macros so checks that appear multiple places
are consistent (and easy to change)
o add protocol version check when looking for a scan candidate
o improve scan debug output format
o rewrite beacon update handling to calculate a bitmask of changed values
and pass that down through the driver callback so drivers can optimize work
o do slot bounds check before use when parsing received beacons


189377 04-Mar-2009 sam

add the desired channel to the scan list if not already present and
compatible with other scan controls


189170 28-Feb-2009 ed

Add memmove() to the kernel, making the kernel compile with Clang.

When copying big structures, LLVM generates calls to memmove(), because
it may not be able to figure out whether structures overlap. This caused
linker errors to occur. memmove() is now implemented using bcopy().
Ideally it would be the other way around, but that can be solved in the
future. On ARM we don't do add anything, because it already has
memmove().

Discussed on: arch@
Reviewed by: rdivacky


189106 27-Feb-2009 bz

For all files including net/vnet.h directly include opt_route.h and
net/route.h.

Remove the hidden include of opt_route.h and net/route.h from net/vnet.h.

We need to make sure that both opt_route.h and net/route.h are included
before net/vnet.h because of the way MRT figures out the number of FIBs
from the kernel option. If we do not, we end up with the default number
of 1 when including net/vnet.h and array sizes are wrong.

This does not change the list of files which depend on opt_route.h
but we can identify them now more easily.


188925 22-Feb-2009 sam

change tdma slave behaviour: if the channel is locked don't do bmiss handling
(so no scanning/roaming)

Reviewed by: Chris Anderson


188924 22-Feb-2009 sam

display min/max dwell times in msecs in debug msgs


188869 20-Feb-2009 sam

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


188864 20-Feb-2009 sam

o reset aggressive mode flag; it was being left set after marking an
interface down
o only allow the first vap to initialize shared wme parameters


188863 20-Feb-2009 sam

misc cleanup of wme parameter setting


188821 19-Feb-2009 sam

use 1/2 and 1/4 rate phy types to simplify txtime calculation


188782 19-Feb-2009 sam

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.


188781 19-Feb-2009 sam

o looseen abi dependencies on IEEE80211_MODE_MAX by accepting smaller
parameters for IEEE80211_IOC_ROAM and IEEE80211_IOC_TXPARAMS; this
lets us add more modes and still have old apps work
o consolidate loops to remote assumptions about mode ordering


188780 19-Feb-2009 sam

use c99 initializers


188779 19-Feb-2009 sam

o consolidate loops to eliminate assumptions about ordering of modes
o replace 0x80 by IEEE80211_RATE_MCS


188778 19-Feb-2009 sam

Change country ie construction to simplify forthcoming changes:
o use c99 initializer for skipflags
o calculate band flags instead of statically listing them in the table


188777 19-Feb-2009 sam

use c99 initializer


188776 19-Feb-2009 sam

simplify setting up the roaming parameters; writing default parameters only
for active modes hasn't turned out to be useful so just define a const table
and copy it in place


188775 19-Feb-2009 sam

check ptr against NULL


188774 19-Feb-2009 sam

instead of special casing lookups for the 11na/g legacy rate set, just
install the rates once when creating the com structure


188772 19-Feb-2009 sam

add phy types for 1/2 and 1/4-rate modes


188556 13-Feb-2009 sam

remove ic_stats; it was intended to accumulate stats from vaps as they
were reaped but was never used and is inaccessible


188554 13-Feb-2009 sam

strip M_FRAG & co mbufs coming down from ip_output, these flags are
re-used within net80211 to mark 802.11 frags so allowing them to
leak through to the driver caused packets to be dropped in ath


188541 12-Feb-2009 sam

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


188533 12-Feb-2009 thompsa

Add a ieee80211_waitfor_parent() function that will wait for all deferred
parent interface tasks to complete. This had been added to the ioctl path but
it is also need elsewhere like detach so its safe to teardown.

Reported by: Hans Petter Selasky
Submitted by: sam


188494 11-Feb-2009 sam

improve key index map reclaim debug msg


188493 11-Feb-2009 sam

oops, fix octal escape sequence


188489 11-Feb-2009 sam

remove bogus reference reclaim on the slave-side bss node on beacon miss


188488 11-Feb-2009 sam

fix mis-numbering of IEEE80211_MSG_BITS


188467 11-Feb-2009 sam

when operating as a slave, clear neighbor entries and the peer bss node
on beacon miss

while here, remove a stray pointless write of iv_bmiss_count


188466 11-Feb-2009 sam

clean neighbor entries on beacon miss


188427 10-Feb-2009 sam

correctly fixup iv_des_chan after installing a new channel table; if the
previous channel is now invalid we must set it to IEEE80211_CHAN_ANYC


188380 09-Feb-2009 weongyo

mark M_LASTFRAG at the last fragment.

Reviewed by: sam
MFC after: 3 weeks


188182 05-Feb-2009 sam

o change _db_show_key to always dump the contents instead of checking
IEEE80211_KEY_DEVKEY
o fix channel power printing (they are signed values)
o add show statab to dump a node table and automatically dump the sta
table of a com structure with /s


188170 05-Feb-2009 sam

o add IEEE80211_KEY_BITS for %b printing of wk_flags
o replace hand-rolled code to print wk_flags
o add display of ni_ucastkey in show sta
o fix \n in _db_show_key


188106 03-Feb-2009 sam

When crafting a media setting w/ an auto (non-fixed) rate mask out the
turbo option in addition to the mode bits; otherwise if the current
channel is a turbo mode channel we'll form an invalid media setting
and the ifmedia_set operation in vap_attach will panic.

While here use C99-style initialization for an array indexed by mode;
this makes it consistent w/ other usage and avoids breakage if we
should ever change the set of modes.


187991 01-Feb-2009 sam

when promoting an 11b channel to 11g do not accept a ``pure G'' (OFDM only)
channel, only accept a real 11g channel; this fixes a problem where we were
wrongly promoting 11b to a Dynamic Turbo G channel which broke scanning on
channel 6


187899 29-Jan-2009 sam

setup default fixed rates for static turbo and 11n;
the 11n rates are pure guess


187898 29-Jan-2009 sam

set ni_txparms for static turbo mode


187897 29-Jan-2009 sam

setup default rate set for static turbo mode


187835 28-Jan-2009 sam

add an assert to verify the number of channels returned by ic_getradiocaps
correlates with the size of the channel array passed down

might want to promote this to be always present to catch for driver errors


187834 28-Jan-2009 sam

change null_getradiocaps to return the actual count of channels instead
of the true number; otherwise the caller may use the count to do things
with the data it should not (e.g. sort the channel table)


187803 27-Jan-2009 sam

Extend channel definition with:
o max antenna gain
o driver private opaque data

Note this grows the size of a channel to 16 bytes; which makes the
default channel table 4Kbytes (up from 3Kbytes).


187802 27-Jan-2009 sam

fix comment


187801 27-Jan-2009 sam

Remove assumptions about the max # channels in ioctl's:
o change ioctl's that pass channel lists in/out to handle variable-size
arrays instead of a fixed (compile-time) value; we do this in a way
that maintains binary compatibility
o change ifconfig so all channel list data structures are now allocated
to hold MAXCHAN entries (1536); this, for example, allows the kernel
to return > IEEE80211_CHAN_MAX entries for calls like IEEE80211_IOC_DEVCAPS


187800 27-Jan-2009 sam

change ic_getradiocaps driver callback to include the max # channels
so callers know the size of the array passed down


187799 27-Jan-2009 sam

o add country codes from Atheros regulatory; these are not listed in
the ISO tables, mark them accordingly
o add sku's for handling 900MHz cards
o add opaque struct defs and change []'s to *'s so this file can be
included w/o requiring all of net80211 to be pulled in
o make CTRY_DEBUG and CTRY_DEFAULT public


187797 27-Jan-2009 sam

o make %b msg bit defines public (to user apps too)
o rename IEEE80211_C_CRYPTO_BITS to IEEE80211_CRYPTO_BITS


187796 27-Jan-2009 sam

fill in ieee channel #'s and max tx power for drivers that work exclusively
with frequencies; this mimics how ieee80211_setregdomain works


187795 27-Jan-2009 sam

add new state bit to indicate when interference is observed on the channel


187794 27-Jan-2009 sam

change IEEE80211_IS_CHAN_OFDM and IEEE80211_IS_CHAN_CCK to return true
for 11g (dynamic CCK/OFDM)


187793 27-Jan-2009 sam

define IEEE80211_CHAN_108A and IEEE80211_CHAN_108G in terms of their
non-turbo names to make the relationship more clear


187678 25-Jan-2009 thompsa

If the parent up/down task was queued then sync with it before returning from
the vap ioctl. This means that the parent interface should hopefully be up
before we return to userland, it does not depend on the parent init succeeding,
just that it was run.

This fixes wpa_supplicant with ndis and USB where the parent interfaces can be
slow to init.


187635 23-Jan-2009 sam

fix regulatory state check for all vaps' being down; it must be done
before calling the ic_setregdomain callback


187634 23-Jan-2009 sam

add defines for driver-private bits to eliminate use of constants


187060 11-Jan-2009 sam

add missing return that broke WPA1+2 support

Submitted by: "Jared Go" <jared@hobnob.com>


186904 08-Jan-2009 sam

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


186870 07-Jan-2009 sam

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


186659 31-Dec-2008 sam

mark discovered neighbors QoS capable if they advertise wme


186658 31-Dec-2008 sam

follow prevailing style


186302 18-Dec-2008 sam

convert MALLOC/FREE to malloc/free


186151 16-Dec-2008 sam

fix comment

Submitted by: Daan Vreeken


186144 15-Dec-2008 sam

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


186143 15-Dec-2008 sam

remove extraneous ';'


186107 15-Dec-2008 sam

Fix definition of IEEE80211_CHAN_MAX; it was defined as 255 but
really was meant to be 256. Adjust usage accordingly and replace
bogus usage of this value in checking IEEE channel #'s.

NB: this causes an ABI change; ifconfig must be recompiled


186099 15-Dec-2008 sam

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


185571 02-Dec-2008 bz

Rather than using hidden includes (with cicular dependencies),
directly include only the header files needed. This reduces the
unneeded spamming of various headers into lots of files.

For now, this leaves us with very few modules including vnet.h
and thus needing to depend on opt_route.h.

Reviewed by: brooks, gnn, des, zec, imp
Sponsored by: The FreeBSD Foundation


185197 23-Nov-2008 sam

correct sorting


185164 22-Nov-2008 kmacy

convert calls to IFQ_HANDOFF to if_transmit


184480 30-Oct-2008 sam

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


184345 27-Oct-2008 sam

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


184303 26-Oct-2008 sam

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


184302 26-Oct-2008 sam

Fix joining an 11b BSS: scanning is normally done using 11g channels
(unless explicitly locked to mode 11b) so when we join the bss the
channel attached to the scan cache entry may need to be demoted.

o demote to 11b if the ap is advertising 11b rates
o skip the ap if it's 11b but we're locked to 11g (could consider this
advisory but for now treat it as mandatory)
o handle an odd edge case, if there is a fixed transmit rate for 11g
then the rate check against the 11b ap will fail, try to demote to
11b and retry the rate check

Reviewed by: sephe, thompsa


184288 26-Oct-2008 sam

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).


184287 26-Oct-2008 sam

move decl up before first use


184286 26-Oct-2008 sam

introduce M_ENCAP flag to mark packets encapsulated w/ an 802.11 header


184285 26-Oct-2008 sam

fix comment that belonged w/ previous commit


184284 26-Oct-2008 sam

change ieee80211_send_probereq to supply raw xmit parameters so it can
control how frames are handled by the driver


184283 26-Oct-2008 sam

change ieee80211_send_nulldata to send a QoS Null Data frame to a
QoS-enabled station; this makes inactivity handling follow the spec
as previously it would probe inactive stations w/ a Null Data (no QoS)
data frame


184282 26-Oct-2008 sam

o change ieee80211_mgmt_output to take a raw xmit parameters block so
the net80211 layer has complete control over the handling of mgt frames
(in particular, the ac, tx rate, and retry count); this also allows us
to purge the M_LINK0 flag that was attached to mbufs to mark them as
needing encryption for shared key auth
o change ieee80211_send_setup to take a tid parameter so it can be used
to setup QoS frames


184281 26-Oct-2008 sam

fix old merge botch that causes gaps in the tx seq# space for QoS frames


184280 26-Oct-2008 sam

Sync BAR frame handling with out of tree work:
o correct BAR frame construction for AMPDU
o retransmit BAR frames until ACK'd or timeout (use tunables to
control behaviour, default is very aggressive)
o defer seq# update until BAR frame is ACK'd
o add BAR response handling callback for driver to interpose and
push new state to device or push pending aggregates

While here also:
o add backpointer to node in the per-tid tx aggregation data structure
o move ampdu tx state setup/teardown work to separate functions


184279 25-Oct-2008 sam

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


184278 25-Oct-2008 sam

honor IEEE80211_CLONE_NOBEACONS for type of vap, not just a sta mode vap


184277 25-Oct-2008 sam

improve inactivity handling debug support


184276 25-Oct-2008 sam

use a private mgt frame recv handler for ahdemo mode instead of an inline
test in the adhoc mode rx path so classes derived from ahdemo mode can
override the default behaviour


184275 25-Oct-2008 sam

expand captured ie's before calling match_bss so they can potentially
be used in the process


184274 25-Oct-2008 sam

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


184273 25-Oct-2008 sam

o add support for ifconfig wlanX mode foo
o yank useless code for setting fixed rate through media opts: this
mechanism didn't scale to HT rates and couldn't handle multiple bands;
fixed tx rates are set with the IEEE80211_IOC_TXPARAMS ioctl


184272 25-Oct-2008 sam

add debug msgs


184271 25-Oct-2008 sam

fix associd check for adhoc mode

Reviewed by: jhay


184270 25-Oct-2008 sam

ignore IEEE80211_ELEMID_PWRCNSTR when parsing beacon/probe response frames
to avoid counting it as an unknown elemid (we often beacon this so it shows
up as a "false positive")


184269 25-Oct-2008 sam

add 1/2 and 1/4 channel flags to IEEE80211_CHAN_ALL so that operations
like ieee80211_find_channel are more useful


184268 25-Oct-2008 sam

add/improve debug msgs


184210 23-Oct-2008 des

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

Requested by: sam


184205 23-Oct-2008 des

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

MFC after: 3 months


183550 02-Oct-2008 zec

Step 1.5 of importing the network stack virtualization infrastructure
from the vimage project, as per plan established at devsummit 08/08:
http://wiki.freebsd.org/Image/Notes200808DevSummit

Introduce INIT_VNET_*() initializer macros, VNET_FOREACH() iterator
macros, and CURVNET_SET() context setting macros, all currently
resolving to NOPs.

Prepare for virtualization of selected SYSCTL objects by introducing a
family of SYSCTL_V_*() macros, currently resolving to their global
counterparts, i.e. SYSCTL_V_INT() == SYSCTL_INT().

Move selected #defines from sys/sys/vimage.h to newly introduced header
files specific to virtualized subsystems (sys/net/vnet.h,
sys/netinet/vinet.h etc.).

All the changes are verified to have zero functional impact at this
point in time by doing MD5 comparision between pre- and post-change
object files(*).

(*) netipsec/keysock.c did not validate depending on compile time options.

Implemented by: julian, bz, brooks, zec
Reviewed by: julian, bz, brooks, kris, rwatson, ...
Approved by: julian (mentor)
Obtained from: //depot/projects/vimage-commit2/...
X-MFC after: never
Sponsored by: NLnet Foundation, The FreeBSD Foundation


183421 27-Sep-2008 sam

guard against adhoc_pick_channel returning a NULL channel; this can
happen after a scan cache flush (e.g. in response to ifconfig wlan bssid -)


183364 25-Sep-2008 sam

must do a deep copy of mcast packets as they can be modified after dispatch

Submitted by: "Jared Go" <jared@hobnob.com>


183355 25-Sep-2008 thompsa

Use db_printsym to lookup and print the function pointers.


183259 22-Sep-2008 sam

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


183258 22-Sep-2008 sam

cleanup after merge


183257 22-Sep-2008 sam

Fix handling of shortgi: use the local configuration (and implicitly
device capabilities) to decide whether to use short gi. Drivers
inspect ni_flags to decide whether to send a frame w/ short sgi.


183256 22-Sep-2008 sam

RIFS support; needs driver callback for dynamic state change


183255 22-Sep-2008 sam

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


183254 21-Sep-2008 sam

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.


183253 21-Sep-2008 sam

don't propagate ht bss occupancy changes to legacy vaps;
they won't have an htinfo ie to update


183252 21-Sep-2008 sam

o widen ni_flags as it's going to be full shortly
o shuffle members to minimize holes


183251 21-Sep-2008 sam

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.


183250 21-Sep-2008 sam

change ieee80211_ampdu_stop to take an explicit reason code


183249 21-Sep-2008 sam

simplify debug msg


183248 21-Sep-2008 sam

Crypto api changes:
o don't use the key index to identify when the driver has been
asked to allocate a key slot, use an explicit flag; allows
drivers to force s/w fallback for entries in the global table
o change callback api to allocate driver resources for a crypto key:
- de-const the key parameter so drivers can muck with the flags
- on callback failure don't automatically try to setup s/w crypto;
instead the driver must now mark the key entry for s/w crypto and
the caller will re-attach the cipher module

NB: api change permits drivers more control over fallback to s/w
crypto (e.g. based on a limited number of h/w key slots)


183247 21-Sep-2008 sam

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)


183246 21-Sep-2008 sam

Always update ic_lastnonht so we track overlapping legacy bss
properly; was doing this only on a change in the protection mode
so the advertised protection mode in the beacon would oscillate.

Submitted by: Chris Zimmermann


183245 21-Sep-2008 sam

Cleanup starting seq# for tx ampdu:
o use txa_start to form the addba request and purge txa_seqstart
o fill txa_start before calling ic_addba_request to permit drivers
to override when they handle seq# generation (e.g. mwl)


183243 21-Sep-2008 sam

o fix spelling of EOSP
o correct SMPS values


183210 20-Sep-2008 thompsa

Fix clone destruction, can't use the simple api because that does not remove
the ifnet from cloner's list. Expose if_clone_destroyif api to do this.

Submitted by: sam


182834 06-Sep-2008 sam

make all checks if ni_chw consistent


182833 06-Sep-2008 sam

use c99 syntax for initializers; this silences
warnings with picky compiler settings


182832 06-Sep-2008 sam

only return the negotiated ampdu density for sta mode


182831 06-Sep-2008 sam

o kill IEEE80211_NODE_PSUPDATE; it was never used
o kill IEEE80211_NODE_CHWUPDATE; it's use was pointless and it was defined
wrong (overlap w/ existing flags)


182830 06-Sep-2008 sam

put back placeholder comment


182829 06-Sep-2008 sam

o validate the ba policy in addba response
o leave a check for the max ba window disabled; we accept out of range
values and just truncate them but may want to act differently in the future


182828 06-Sep-2008 sam

add IEEE80211_NODE_HT_ALL to collect up all the HT-related node flags


182827 06-Sep-2008 sam

don't do ampdu reordering of fragments; they should never happen


182826 06-Sep-2008 sam

moreve the aggregation q; it's not being used and
there's a better way to do this


182822 06-Sep-2008 sam

o show key indices w/o adjustment
o display all key flags symbolically


182821 06-Sep-2008 sam

purge ni_reqcw; not used and never will be


182820 06-Sep-2008 sam

o fix BAR definitions
o add 11e reason codes


182819 06-Sep-2008 sam

fix age calculations (yet again); entries in the q have values
relative to the head

MFC after: 3 days


182742 03-Sep-2008 brooks

Replace a line matching /^ $/ with one matching /^$/.

Obtained from: //depot/projects/vimage-commit2/...


182674 02-Sep-2008 weongyo

free ifp allocated at ieee80211_vap_setup.

Reviewed by: sam, thompsa


182437 29-Aug-2008 avatar

Fixing INVARIANTS build by adding 'z' format prefix for size_t typed
variable.

Reminded by: tinderbox


182434 29-Aug-2008 sam

Fix mic calculation when final data is entirely in a trailing mbuf;
it's unclear if this can happen on freebsd but does appear on netbsd.
Identified by Matthias Drochner who came up with an initial change
that we then revised together.

Reviewed by: thompsa, sephe, avatar
MFC after: 2 weeks


182144 25-Aug-2008 julian

This instance of ifnet got forgotten.


181455 09-Aug-2008 imp

Verify that the WPA flags set are actually compatible with the
driver's set of valid flags. Otherwise, wpa_supplicant wouldn't
report an error for old wi cards that can't do WPA.

Reviewed by: sam@


181347 06-Aug-2008 sam

add WPS oui

Submitted by: "Chuck Tuffli" <chuck@tuffli.net>
MFC after: 3 days


181197 02-Aug-2008 sam

add missing lock for htinfo update

Submitted by: Chris Zimmermann


181196 02-Aug-2008 sam

correct decap of of AppleTalk and IPX frames; don't strip the SNAP
header as they have one natively

Submitted by: Chris Zimmermann


181194 02-Aug-2008 sam

add a sysctl to deliver a radar event for testing


181193 02-Aug-2008 sam

schedule the correct timer when receiving a radar event during CAC


180837 27-Jul-2008 sam

don't deauth a station because it sends a ps-poll w/ a bogus aid in it;
turns out some devices do this and since we otherwise validate the station
is associated and don't use the aid for anything being lenient here allows
them to function

Submitted by: Chris Zimmermann
MFC after: 2 weeks


180351 07-Jul-2008 sam

reorder RSN/WPA2 ie in beacon and probe response frames to comply
with IEEE802.11-2007 spec

Submitted by: Chris Zimmermann


180309 05-Jul-2008 sam

correct construction of delba action frame; don't shift+mask the initiator
argument

Submitted by: Marvell


179643 07-Jun-2008 sam

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


179642 07-Jun-2008 sam

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


179641 07-Jun-2008 sam

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.


179640 07-Jun-2008 sam

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


179396 28-May-2008 sam

Add ieee80211_crypto_reload_keys to push all keys known
to net80211 back into the device; intended for use on resume
by devices that lose the contents of their h/w key table.


179395 28-May-2008 sam

Add a mac address to the key definition as otherwise we lose the
address specified in the ioctl and for drivers that need the address
to locate a key (e.g. for delete).

Note this changes net80211-private api's but not the driver callback;
may want to change that in the future.

Reviewed by: sephe, thompsa


179394 28-May-2008 sam

Split s/w crypt/mic attributes to allow future hackery; this change
should be a noop.


179393 28-May-2008 sam

missing piece of last commit; add RESUME flag bit definition


179391 28-May-2008 sam

Add ieee80211_suspend_all and ieee80211_resume_all for
brute force suspend/resume handling of vaps.


179390 28-May-2008 sam

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


179389 28-May-2008 sam

Simplify some contorted logic that wrongly left ISCAN_DISCARD set
in certain cases causing the current ap to be lost from the scan cache.

Obtained from: Atheros (original bug)


179388 28-May-2008 sam

Revise lock name handling:
o construct a name for the com lock as done for other locks
o pass the device name to IEEE80211_LOCK_INIT so the mtx name
is constructed as foo_com_lock
o introduce *_LOCK_OBJ macro's to hide the lock contents and
minimize redundant code


179220 22-May-2008 sam

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


179217 22-May-2008 sam

ignore sw beacon miss while scanning, just reset the beacon count and timer

Reviewed by: thompsa


179216 22-May-2008 sam

no need to stop the sw beacon miss timer; it's not used with adhoc or wds


178959 12-May-2008 sam

declare ieee80211_phymode_name with an array size


178958 12-May-2008 sam

Update PLCP<->rate mapping support:
o correct mapping of CCK rates to PLCP; was using nonstandard Ralink
values which just happened to also be used by Zydas (so went unnoticed)
o change ieee80211_plcp2rate api to take a phy type instead of a flag
that indicates ofdm/!ofdm
o update drivers to match (restore per-driver code to map rate->PLCP)

Reviewed by: sephe, weongyo, thompsa


178957 12-May-2008 sam

Minor cleanup of vap create work:
o add IEEE80211_C_STA capability to indicate sta mode is supported
(was previously assumed) and mark drivers as capable
o add ieee80211_opcap array to map an opmode to the equivalent capability bit
o move IEEE80211_C_OPMODE definition to where capabilities are defined so it's
clear it should be kept in sync (on future additions)
o check device capabilities in clone create before trying to create a vap;
this makes driver checks unneeded
o make error codes return on failed clone request unique
o temporarily add console printfs on clone request failures to aid in
debugging; these will move under DIAGNOSTIC or similar before release


178956 11-May-2008 sam

we have a DFS capability now so enable check


178955 11-May-2008 sam

use c99-style initialization for ieee80211_phymode_name


178954 11-May-2008 sam

add DFS capability bit and use it to auto-enable DFS support


178953 11-May-2008 sam

use the current left edge of the BA window when forming ADDBA request
so an existing session is re-established with the correct seq#


178952 11-May-2008 sam

add PLCP service bit definitions


178951 11-May-2008 sam

move inline keyword to silence compiler complaints


178712 01-May-2008 sam

fix build w/ IEEE80211_DEBUG_REFCNT enabled


178703 01-May-2008 sam

re-enable WME by default; after a full day of testing on iwi I see no
issues and the only way we'll identify them is for people to use it


178694 30-Apr-2008 sam

disable default enabling of WME until we resolve driver regressions


178521 25-Apr-2008 sam

hookup the parent device's if_input and if_output to stub routines
to catch unintended use (one might argue about if_output but it's
behaviour is ill-defined without vap context)

Noticed by: Paul B. Mahol


178354 20-Apr-2008 sam

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)


176653 29-Feb-2008 sam

Fix adhoc mode to scan all available channels for a bss to join
while still restricting auto-channel select to only those channels
permitted by regulatory constraints (sorta, we're still missing the
checks to honor radar and noadhoc status on channels). This somehow
got lost in the initial merge of the revised scanning code.

Reviewed by: jhay
MFC after: 2 weeks


175939 03-Feb-2008 sephe

- Correctly handle ALTQ in ieee80211_deliver_data()
- Add comment from sam that ALTQ probably does not work well with WME

PR: kern/119548
Approved by: sam (mentor)


175880 02-Feb-2008 sam

add opaque pointer to tx ampdu state for drivers

MFC after: 3 days


175877 01-Feb-2008 sam

o correct typo that broke check when handling addba response
o add a comment about the ht rates being for 20MHz channels w/ long GI;
needs a separate fix after more thought

MFC after: 3 days


174568 13-Dec-2007 sam

update channel flag defs to match _ieee80211.h so cpp doesn't complain
about redefinitions

MFC after: 1 week


174388 07-Dec-2007 kmacy

Add padding for anticipated functionality
- vimage
- TOE
- multiq
- host rtentry caching

Rename spare used by 80211 to if_llsoftc

Reviewed by: rwatson, gnn
MFC after: 1 day


173956 26-Nov-2007 sam

Be more careful handling off-channel frames: if the driver (wrongly)
sends frames up the stack after changing the current channel then
the lookup by ieee channel number may fail leaving a null ptr in
se_chan; if this happens fallback to the channel recorded when the
frame is processed (curchan). Since the frame doesn't contribute
to scan results for the sta this is acceptable.

Reviewed by: thompsa
MFC after: 3 days


173867 23-Nov-2007 sam

correct WMM packet classification:
o use TID_TO_WME_AC on vlan tag priority
o ignore ECN bits in DSCP when mapping IP TOS and use TID_TO_WME_AC

MFC after: 3 days


173866 23-Nov-2007 sam

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

MFC after: 3 days


173865 23-Nov-2007 sam

correct sta mode setup: adopt ap's ampdu density and max ampdu size
instead of using local settings

MFC after: 3 days


173864 23-Nov-2007 sam

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

MFC after: 3 days


173863 23-Nov-2007 sam

correct TID_TO_WME_AC handling of BE

MFC after: 3 days


173862 23-Nov-2007 sam

use the DSPARMS ie to find the home channel for off-channel frames

Reviewed by: thompsa
MFC after: 1 week


173861 23-Nov-2007 sam

add ieee80211_find_channel_byieee to lookup a channel by ieee channel #

Reviewed by: thompsa
MFC after: 1 week


173860 23-Nov-2007 sam

update default wme parameters to latest WiFi test plans

Reviewed by: Allan Lim
MFC after: 3 days


173618 14-Nov-2007 sam

correct MIMO power save action frame format;
this one really is from the D2.04 spec

MFC after: 3 days


173462 08-Nov-2007 sam

correct termination check doing amsdu de-aggregation

MFC after: 3 days


173368 05-Nov-2007 sam

Correct handling of off-channel frames:
o do not override the home channel recorded for the sta when the frame is
received off-channel; this fixes a problem where we might think the sta
was operating on the channel the frame was received on causing association
requests to be ignored/rejected (likely cause of kern/99036)
o don't include rssi of off-channel frames in the avg rssi used to select
a bss; this gives us a better estimate of the signal we will see for the
station when on-channel

PR: kern/99036
Found by: Yubin Gong
Reviewed by: sephe
MFC after: 1 week


173273 02-Nov-2007 sam

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

MFC after: 1 week


173272 02-Nov-2007 sam

correct channel flags returned by IEEE80211_IOC_STA_INFO; we need
to return all 32-bits to identify stations operating with HT

MFC after: 1 week


173271 02-Nov-2007 sam

don't try to re-associate after a parameter change, too many ap's
don't do this right; instead go to the scan cache so we pass through
auth state (if the cache is warm we can do this w/o an actual scan)

MFC after: 1 week


172931 24-Oct-2007 sam

silence complaint about not loading the wlan_scan_monitor module;
it does not exist and is not needed as monitor mode operation has
always required setting the current channel

Reviewed by: thompsa
MFC after: 1 week


172233 18-Sep-2007 sam

invalidate ic_prevchan when constructing a new channel list

Approved by: re (blanket wireless)


172232 18-Sep-2007 sam

honor IEEE80211_C_TXFRAG; drivers should never get fragmented packets
unless they indicate they're able to handle them

Approved by: re (blanket wireless)


172231 18-Sep-2007 sam

tag mgmt and null data frames w/ a WME priority so drivers can assume
only data frames require classification

Approved by: re (blanket wireless)


172230 18-Sep-2007 sam

mgmt subtype 13 is action

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


172229 18-Sep-2007 sam

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


172228 18-Sep-2007 sam

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


172227 18-Sep-2007 sam

skip IEEE80211_MODE_AUTO in announcing supported rates in ieee80211_announce;
there won't be any

Approved by: re (blanket wireless)


172226 18-Sep-2007 sam

o add IEEE80211_RATE_MCS to use instead of naked constant (for marking MCS)
o correct ieee80211_rate2media handling of MCS
o correct rate HT announcements for 11n devices

Approved by: re (blanket wireless)


172225 18-Sep-2007 sam

o move IEEE80211_NONQOS_TID into a public location
o add IEEE80211_TID_SIZE and replace all the nake constants

Approved by: re (blanket wireless)


172223 18-Sep-2007 sam

remove IFM_IEEE80211_HT40PLUS and IFM_IEEE80211_HT40MINUS; they
never got used so nuke 'em before we branch

Approved by: re (blanket wireless)


172211 17-Sep-2007 sam

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)


172204 17-Sep-2007 sam

correct netband skip check in constructing a country ie

Approved by: re (blanket net80211)


172063 06-Sep-2007 sam

oops, add missing bit from last change

Approved by: re (blanket wireless)


172062 06-Sep-2007 sam

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)


172058 05-Sep-2007 sam

o add 802.11 state machine states for DFS and client-side power save
o fixup drivers to ignore new states

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


172056 05-Sep-2007 sam

Update channel definition:
o add ic_extieee to hold the HT40 extension channel number
o add ic_state to track dynamic channel state for DFS
o add flags to mark regulatory channel requirements
o add state defs for DFS/radar support

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


172055 05-Sep-2007 sam

Miscellaneous fixups to 802.11 defs:
o update 11n definitions to D2.0 spec
o add IEEE80211_CAPINFO_SPECTRUM_MGMT for DFS support
o add CSA ie definition for DFS support
o purge some unused definitions
o correct 802.11 reason and status codes
o correct reason code returned when a sta tries to associate to an
ap operating with WPA/RSN but without a WPA/RSN ie

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


172054 05-Sep-2007 sam

o add M_WEP mbuf flag so drivers can mark frames that are decrypted by the
device and have had the crypto bits stripped from the 802.11 header
o strip mbuf flags in the rx path before passing up the stack

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


171985 26-Aug-2007 sephe

Off-by-one bug in country ie construction, which will make HOSTAP send out
malformatted beacons.

Reviewed by: sam
Approved by: re (bmah), sam (mentor)


171984 26-Aug-2007 sephe

Fix following nits:
- Per ieee80211com sysctl ctx leakage on detach
- getmgtframe incorrectly adjusts mbuf.m_data

Reviewed by: sam
Approved by: re (bmah), sam (mentor)


171950 24-Aug-2007 sam

drop frames marked for encryption when no key is available

Reviewed by: avatar
Approved by: re (kensmith)
Obtained from: madwifi


171519 20-Jul-2007 sephe

In add_channel(), search 11g channels if mode is AUTO and corresponding
11b channel is not found, e.g. Atheros 5211.

Reported by: matteo
Problem outlined by: thompsa
Reviewed by: sam, thompsa
Approved by: re (kensmith), sam (mentor)
Tested by: matteo (an early version)


171409 12-Jul-2007 sam

revert handling of ssid and bssid to be manadatory instead of advisory

Prodded by: Kevin Gerry
Reviewed by: thompsa, sephe
Approved by: re (kensmith)


171127 01-Jul-2007 thompsa

Move the XCHANNEL radiotap definition to a free slot. NetBSD defined some
additional values causing a conflict.

Submitted by: sam
Approved by: re (kensmith)


171125 30-Jun-2007 thompsa

Fix scanning issues since the new net80211 code went in
- provide dummy routines for ic_scan_curchan and ic_scan_mindwell, we do not support those operations.
- add ieee80211_scan_done() to tell the scanning module that all channels have been scanned.
- pass IEEE80211_S_SCAN state off to net80211 so it can initiate scanning
- fix overflow in the rates array
- scale the rate value passed back from the firmware scan to the units that net80211 uses.

Submitted by: Token
Reviewed by: sam, avatar
Approved by: re (kensmith)


171124 30-Jun-2007 thompsa

Change the channel number in the scan results struct to be a pointer to the
operating channel and use this in the scan cache rather than directly using
ic_curchan. Some firmware cards can only do a full scan and so ic_curchan does
not have the correct value.

Also add IEEE80211_CHAN2IEEE to directly dereference ic_ieee from the channel
to be used in the fast path.

Reviewed by: sam, sephe
Approved by: re (kensmith)


171022 25-Jun-2007 sam

Correct msecs_to_ticks macro. This fixes problems when hz is not the
default 1000 setting.

Reviewed by: thompsa, rpaulo
Approved by: re (bmah)


170817 16-Jun-2007 sam

Correct state machine handling of AUTH -> AUTH transitions that pass
through wpa_supplcant. If a sta is deauth'd (e.g. due to inactivity)
with roaming mode set to manual then a subsequent MLME assoc request
will be incorrectly handled and the station will never reauthenticate.
To fix this interpret a reason code of zero as sufficient to send an
auth request frame.


170573 11-Jun-2007 imp

Prefer __packed to __attribute__((__packed__)).

OK'd by sam@ months ago...


170530 11-Jun-2007 sam

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.


170360 06-Jun-2007 sam

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

Reviewed by: onoe


169281 05-May-2007 sephe

- Nuke unnecessary header.
- Make wlan_amrr depend on wlan, so that it can find various symbols in
wlan module if wlan is not compiled into kernel.

Approved by: sam (mentor)
Tested by: kevlo


167468 11-Mar-2007 sam

change ic_modecaps to a bit vector and use setbit, et. al.


167443 11-Mar-2007 sam

Update to reflect correct usage:
o leave IEEE80211_RADIOTAP_HDRLEN for portability to other systems but
correct comment about radiotap headers being padded to 64-bytes
(hasn't been true for many years)
o remove reference to IEEE80211_RADIOTAP_FCS; it was never used, instead
the flags are marked with IEEE80211_RADIOTAP_F_FCS to indicate whether
or not FCS is present

Might be better to just remove IEEE80211_RADIOTAP_HDRLEN so drivers
don't bogusly pad.

MFC after: 2 weeks


167442 11-Mar-2007 sam

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


167441 11-Mar-2007 sam

expose IEEE80211_DISCARD, IEEE80211_DISCARD_IE, and IEEE80211_DISCARD_MAC
so they can be used within net80211 but outside ieee80211_input.c

MFC after: 2 weeks


167440 11-Mar-2007 sam

improve debug msg for ie's that are too short

MFC after: 2 weeks


167439 11-Mar-2007 sam

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


167438 11-Mar-2007 sam

split check for rate set mismatch on assoc req away from check
for pure 11g mode so we can give meaningful diagnostic msgs

MFC after: 2 weeks


167436 11-Mar-2007 sam

disallow re-associate with a slot time mismatch

Obtained from: Atheros
MFC after: 2 weeks


167435 11-Mar-2007 sam

move __inline before type to appease gcc 4.x

Obtained from: netbsd


167433 11-Mar-2007 sam

white space diff reduction


167432 11-Mar-2007 sam

add IEEE80211_KEY_UNDEFINED and use it instead of local defs

Obtained from: netbsd


167431 11-Mar-2007 sam

discard deauth+disassoc frames that are not destined for us; these
can be received when the interface is in promisc mode

Reviewed by: sephe
Obtained from: netbsd


167430 11-Mar-2007 sam

change ieee80211_mhz2ieee to use the PSB mapping when the frequency
falls in the proper place, not when we're handed a 1/2 or 1/4-rate channel

MFC after: 2 weeks


167284 07-Mar-2007 sam

When dispatching frames saved on the power save queue to a
station exiting power save mode prepend them to the driver's
send q instead of appending them. This insures the packets
are not misordered wrt any packets already q'd for the station.

This corrects a problem noticed when using a VoIP phone talking
to an ath card in ap mode; the misordered packets caused noise.

Submitted by: "J.R. Oldroyd" <jr@opal.com>
MFC after: 2 weeks


167283 07-Mar-2007 sam

add ieee80211_opmode_name array for mapping the opmode to a string
for printing diagnostic msgs

MFC after: 2 weeks


167282 07-Mar-2007 sam

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


167245 05-Mar-2007 sam

correct inital bounds check on returning scan results; this does not
paper over catching an error as the case was already handled, albeit
in a somewhat surprising way (the caller received zero'd data)

Submitted by: sephe
MFC after: 2 weeks


167242 05-Mar-2007 sam

correct conversions between TU and ms/ticks; these are not used
by any code in the tree[1] and are close enough for common values
that this change is a noop

[1] ath uses one macro to calculate a value that is not used
Submitted by: sephe
MFC after: 1 week


166481 04-Feb-2007 sam

clear/reclaim challenge text when switching auth mode and operating as an ap

Obtained from: Atheros


166409 02-Feb-2007 sam

add IEEE80211_IS_CHAN_PASSIVE

MFC after: 1 week


166012 15-Jan-2007 sam

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


165911 09-Jan-2007 sam

reduce user-visible namespace to just what is needed

MFC after: 2 weeks


165904 09-Jan-2007 sam

bandaid to unbreak build (user code includes this file)


165894 08-Jan-2007 sam

Fix potential node refcnt leak. If mbufs are q'd on ic_mgtq when
the state machine clocks to INIT, node references are not reclaimed.
Add a new routine ieee80211_drain_ifq that does this and use it
instead of IF_DRAIN.

Submitted by: Sepherosa Ziehau
Obtained from: DragonFly
MFC after: 1 month


165887 08-Jan-2007 sam

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


165825 06-Jan-2007 mjacob

Fix compile error.


165822 06-Jan-2007 kmacy

fix declaration / definition mismatch with ieee80211_chan2ieee


165574 28-Dec-2006 sam

o unbreak rate set defaulting
o mark 11g mode support on finding 11g or pure 11g (OFDM-only)
channels; was requiring pure 11g which caused some contortions
in drivers that manually setup their channel lists


165569 27-Dec-2006 sam

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


164809 01-Dec-2006 imp

Fix packing on the country band descriptor. No real change since this
is unused.

Reviewed by: sam


164805 01-Dec-2006 sam

back out use of LLC_SNAPFRAMELEN now that sizeof(struct llc) isn't
padded on arm


164782 01-Dec-2006 sam

sizeof(struct llc) includes padding on arm; use LLC_SNAPFRAMELEN for now

Submitted by: jhay
MFC after: 2 weeks


164645 26-Nov-2006 sam

Default the rate sets for 802.11 operating modes so drivers aren't
required to. Note this only happens when drivers don't set them
up before calling ieee80211_ifattach so this change is backwards
compatible.

MFC after: 1 month


164634 26-Nov-2006 sam

add rate control debug msg bit

MFC after: 1 month


164633 26-Nov-2006 sam

device-independent implementation of AMRR tx rate control algorithm

Obtained from: openbsd (w/ mods)
MFC after: 1 month


164033 06-Nov-2006 rwatson

Sweep kernel replacing suser(9) calls with priv(9) calls, assigning
specific privilege names to a broad range of privileges. These may
require some future tweaking.

Sponsored by: nCircle Network Security, Inc.
Obtained from: TrustedBSD Project
Discussed on: arch@
Reviewed (at least in part) by: mlaier, jmg, pjd, bde, ceri,
Alex Lyashkov <umka at sevcity dot net>,
Skip Ford <skip dot ford at verizon dot net>,
Antoine Brodin <antoine dot brodin at laposte dot net>


162659 26-Sep-2006 ru

Now that we have COMPAT_FREEBSD6 officially, use it from opt_compat.h.


162375 17-Sep-2006 andre

Move ethernet VLAN tags from mtags to its own mbuf packet header field
m_pkthdr.ether_vlan. The presence of the M_VLANTAG flag on the mbuf
signifies the presence and validity of its content.

Drivers that support hardware VLAN tag stripping fill in the received
VLAN tag (containing both vlan and priority information) into the
ether_vtag mbuf packet header field:

m->m_pkthdr.ether_vtag = vlan_id; /* ntohs()? */
m->m_flags |= M_VLANTAG;

to mark the packet m with the specified VLAN tag.

On output the driver should check the mbuf for the M_VLANTAG flag to
see if a VLAN tag is present and valid:

if (m->m_flags & M_VLANTAG) {
... = m->m_pkthdr.ether_vtag; /* htons()? */
... pass tag to hardware ...
}

VLAN tags are stored in host byte order. Byte swapping may be necessary.

(Note: This driver conversion was mechanic and did not add or remove any
byte swapping in the drivers.)

Remove zone_mtag_vlan UMA zone and MTAG_VLAN definition. No more tag
memory allocation have to be done.

Reviewed by: thompsa, yar
Sponsored by: TCP/IP Optimization Fundraise 2005


161146 10-Aug-2006 sam

More statistics fixups:
o change rssi to be signed in ieee80211_nodestats
o add noise floor in ieee80211_nodestats (use an implicit hole to
preserve layout); return it as zero until we can update the api's
so the driver can provide noise floor data
o add a bandaid so IEEE80211_IOC_STA_STATS works for sta mode; when
all nodes are in the station table this will no longer be needed
o fix braino in IEEE80211_IOC_STA_INFO implementation; was supposed
to take a mac address and return info for that sta or all stations
if ff:ff:ff:ff:ff was supplied--but somehow this didn't get implemented;
implement the intended semantics and leave a compat shim at the old
ioctl number for the previous api

Reviewed by: mlaier
MFC after: 3 weeks


161145 10-Aug-2006 sam

minor fixups:
o add some missing stats to the global stat structure
o move accounting work for data frame rx into ieee80211_deliver_data
o add per-sta stats for rx ucast/mcast frames
o set rcvif in ieee80211_deliver_data so callers don't need to

MFC after: 2 weeks


161144 10-Aug-2006 sam

add per-sta ucast/mcast stats

MFC after: 1 week


160690 26-Jul-2006 sam

add support for 802.11 packet injection via bpf

Together with: Andrea Bittau <a.bittau@cs.ucl.ac.uk>
Reviewed by: arch@
MFC after: 1 month


160686 26-Jul-2006 sam

add IEEE80211_IOC_BMISSTHRESHOLD for managing the beacon miss
threshold

Submitted by: Henrik Brix Andersen <henrik@brixandersen.dk>
MFC after: 2 weeks


160685 26-Jul-2006 sam

o move min/max beacon interval and dtim period to public location
o add min/max beacon miss threshold settings
o delete IEEE80211_SWBMISS_THRESHOLD, it was never used

MFC after: 2 weeks


160413 16-Jul-2006 sam

correct ie length check; need to include fixed part of ie

MFC after: 2 weeks


160407 16-Jul-2006 sam

power save mode state changes should not require clocking the 802.11
state machine; use the reset method instead

MFC after: 2 weeks


160405 16-Jul-2006 sam

tighten invariant on loops used to parse ie's; this ensures we never
touch data outside the packet (previously we might touch 1 byte); it
also has the happy side effect of working around broken orinoco/agere
firmware that sends malformed association response frames

Help by: Vladimir Egorin


159915 24-Jun-2006 sam

remove duplicate ifname in debug msg

MFC after: 1 week


159590 13-Jun-2006 jhb

Use kern_kldload() and kern_kldunload() to load and unload modules when
we intend for the user to be able to unload them later via kldunload(2)
instead of calling linker_load_module() and then directly adjusting the
ref count on the linker file structure. This makes the resulting
consumer code simpler and cleaner and better hides the linker internals
making it possible to sanely lock the linker.


159180 02-Jun-2006 csjp

Fix the following bpf(4) race condition which can result in a panic:

(1) bpf peer attaches to interface netif0
(2) Packet is received by netif0
(3) ifp->if_bpf pointer is checked and handed off to bpf
(4) bpf peer detaches from netif0 resulting in ifp->if_bpf being
initialized to NULL.
(5) ifp->if_bpf is dereferenced by bpf machinery
(6) Kaboom

This race condition likely explains the various different kernel panics
reported around sending SIGINT to tcpdump or dhclient processes. But really
this race can result in kernel panics anywhere you have frequent bpf attach
and detach operations with high packet per second load.

Summary of changes:

- Remove the bpf interface's "driverp" member
- When we attach bpf interfaces, we now set the ifp->if_bpf member to the
bpf interface structure. Once this is done, ifp->if_bpf should never be
NULL. [1]
- Introduce bpf_peers_present function, an inline operation which will do
a lockless read bpf peer list associated with the interface. It should
be noted that the bpf code will pickup the bpf_interface lock before adding
or removing bpf peers. This should serialize the access to the bpf descriptor
list, removing the race.
- Expose the bpf_if structure in bpf.h so that the bpf_peers_present function
can use it. This also removes the struct bpf_if; hack that was there.
- Adjust all consumers of the raw if_bpf structure to use bpf_peers_present

Now what happens is:

(1) Packet is received by netif0
(2) Check to see if bpf descriptor list is empty
(3) Pickup the bpf interface lock
(4) Hand packet off to process

From the attach/detach side:

(1) Pickup the bpf interface lock
(2) Add/remove from bpf descriptor list

Now that we are storing the bpf interface structure with the ifnet, there is
is no need to walk the bpf interface list to locate the correct bpf interface.
We now simply look up the interface, and initialize the pointer. This has a
nice side effect of changing a bpf interface attach operation from O(N) (where
N is the number of bpf interfaces), to O(1).

[1] From now on, we can no longer check ifp->if_bpf to tell us whether or
not we have any bpf peers that might be interested in receiving packets.

In collaboration with: sam@
MFC after: 1 month


159139 01-Jun-2006 dds

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.


158121 28-Apr-2006 sam

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


158044 26-Apr-2006 sam

back out public safety-specific channel number mapping; we can't do
it until we know it should be applied as otherwise we can map 11a
channels into the 2.4G range and choose the wrong item from the
chanenl array


157172 27-Mar-2006 sam

implement set(IEEE80211_IOC_STA_STATS) for hostapd; for
now just make it clear station statistics (could read
a stat block and assign to caller can do partial changes)

Reviewed by: avatar (previous version)
MFC after: 1 week


156758 15-Mar-2006 sam

when doing s/w crypto make sure work is done w/ a writable mbuf chain;
this corrects problems with drivers that rely on the host to do
crypto (iwi, ipw, ral, ural, wi (hostap), awi)

Hard work by: luigi, mlaier
Reviewed by: luigi, mlaier
MFC after: 1 week


156524 10-Mar-2006 sam

fix switching between agressive and non-agressive wmm modes

Obtained from: atheros
MFC after: 3 days


156367 07-Mar-2006 sam

use m_dup instead of m_copypacket when doing internal bridging
in case packets are modified (e.g. encrypted)

MFC after: 1 week


156359 06-Mar-2006 sam

deliver an l2uf frame on sta join to prime the bridge

Obtained from: madwifi
MFC after: 1 week


156358 06-Mar-2006 sam

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


155999 25-Feb-2006 sam

consolidate calculation of capabilities ie

Reviewed by: avatar
MFC after: 2 weeks


155885 21-Feb-2006 sam

honor user-specified key index for global key slots

Submitted by: Joe Love
Reviewed by: avatar
MFC after: 1 week


155862 20-Feb-2006 sam

treat setting the optional ie to a zero-length datum to mean "delete
the ie"; this helps drivers that (wrongly) check ic_opt_ie against NULL
when making decisions

Reviewed by: luigi, avatar
MFC after: 3 days


155688 14-Feb-2006 sam

o make driver override of net80211 parameter state consistent
with methods: instead of honoring non-zero values expect drivers
to write their own values on return from ieee80211_ifattach
o add a define for the default h/w bmiss count

MFC after: 2 weeks


155460 08-Feb-2006 sam

set the mgt frame tx timer before dispatching the frame to the
driver; this closes a race where a response could be processed
before the timer was started and cause a RUN->SCAN state change
when operating in station mode

Reviewed by: avatar, dyoung
MFC after: 1 week


154736 23-Jan-2006 sam

s/w beacon miss facility; need to add knobs to fiddle with the settings

MFC after: 2 weeks


154734 23-Jan-2006 sam

switch beacon miss threshold from a time to the number of beacon
frames; the time value was implicitly based on the beacon interval
but never being updated so wrong when the negotiated beacon interval
was not 100 TU


154732 23-Jan-2006 sam

bounds check each ie's length when parsing

Obtained from: madwifi
MFC after: 1 week


154541 18-Jan-2006 sam

Rev ioctl to get scan results:
o lock the list walk
o malloc a results buffer instead of copying out one result at a time
using an on-stack buffer
o fix definition of ieee80211req_scan_result so size of variable-length
information elements is large enough to hold all possible ie's
(still only return wpa+wme, at some point may return all)
o make rssi+noise data signed; they should've been so all along
o add a bit more padding for future additions while we're here
o define a new ioctl for new api and add compat code for old ioctl
under COMPAT_FREEBSD6 (temporarily enabled local to the file)

Reviewed by: Scott Long
MFC after: 2 weeks


154532 18-Jan-2006 sam

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


154505 18-Jan-2006 cperciva

Correct a buffer overflow when scanning for 802.11 wireless networks.

Security: FreeBSD-SA-06:05.80211


154139 09-Jan-2006 sam

add flag to tag frames w/ a known bad FCS

Obtained from: netbsd
MFC after: 1 week


153974 02-Jan-2006 sam

enable "aggressive mode" only when operating in ap or station mode; in
particular this fixes use of wme in adhoc demo mode, it wasn't possible
to set the txop limit because the aggressive mode logic would override

Reviewed by: apatti
MFC after: 2 weeks


153973 02-Jan-2006 sam

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

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


153863 30-Dec-2005 sam

correct checking for turbo channels: rev 1.24 fixed static turbo channels
but broke handling of the turboG channel; since we aren't ready to revamp
the channel list just check for turboA channels for now so channel 6 is
considered in auto mode

Noticed by: gibbs


153849 29-Dec-2005 sam

correct (reversed) ms<->tu macros

Reviewed by: apatti, kcyu


153512 18-Dec-2005 glebius

- Fix VLAN_INPUT_TAG() macro, so that it doesn't touch mtag in
case if memory allocation failed.
- Remove fourth argument from VLAN_INPUT_TAG(), that was used
incorrectly in almost all drivers. Indicate failure with
mbuf value of NULL.

In collaboration with: yongari, ru, sam


153421 14-Dec-2005 sam

make packet bursting configurable (default to on if device is capable)


153404 14-Dec-2005 sam

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.


153403 14-Dec-2005 sam

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

Obtained from: madwifi


153402 14-Dec-2005 sam

allow setting the bssid in any mode

Obtained from: netbsd


153353 12-Dec-2005 sam

disallow module unload when there are dynamic references

MFC after: 1 week


153352 12-Dec-2005 sam

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

MFC after: 2 weeks


153351 12-Dec-2005 sam

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


153350 12-Dec-2005 sam

o correct auto mode logic for avoiding turbo channels
o correct assumption that a static turbo channel is also
usable in 11a; the opposite is true

MFC after: 1 week


153349 12-Dec-2005 sam

Add ieee80211_beacon_miss for processing sta mode beacon miss events
in the 802.11 layer: we send a directed probe request frame to the
current ap bmiss_max times (w/o answer) before scanning for a new ap.

MFC after: 2 weeks


153347 12-Dec-2005 sam

add some useful definitions that'll be used soon


153346 12-Dec-2005 sam

add fixed rate for sending multicast frames

Obtained from: atheros
MFC after: 1 week


153345 12-Dec-2005 sam

change malloc when setting an optional ie to use M_NOWAIT

MFC after: 3 days


153344 12-Dec-2005 sam

correct parameter check when retrieving the current channel list

MFC after: 3 days


153139 05-Dec-2005 sam

correct handling of dtim for periods > 1

Obtained from: madwifi


153073 04-Dec-2005 sam

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


152968 30-Nov-2005 sam

fix dynamic changes in short slottime for 11g sta mode: set the
slot time based on the rcvd capabilities, not the existing ones

Obtained from: atheros
MFC after: 1 week


152450 15-Nov-2005 sam

Update ieee80211_mhz2ieee to understand public safety bands and spectrum
that can potentially be mapped to negative ieee #'s.

NB: before operation on the latter can be supported we need to cleanup
various code that assumes ieee channel #'s are >= 0


152315 11-Nov-2005 ru

- Store pointer to the link-level address right in "struct ifnet"
rather than in ifindex_table[]; all (except one) accesses are
through ifp anyway. IF_LLADDR() works faster, and all (except
one) ifaddr_byindex() users were converted to use ifp->if_addr.

- Stop storing a (pointer to) Ethernet address in "struct arpcom",
and drop the IFP2ENADDR() macro; all users have been converted
to use IF_LLADDR() instead.


151967 02-Nov-2005 andre

Retire MT_HEADER mbuf type and change its users to use MT_DATA.

Having an additional MT_HEADER mbuf type is superfluous and redundant
as nothing depends on it. It only adds a layer of confusion. The
distinction between header mbuf's and data mbuf's is solely done
through the m->m_flags M_PKTHDR flag.

Non-native code is not changed in this commit. For compatibility
MT_HEADER is mapped to MT_DATA.

Sponsored by: TCP/IP Optimization Fundraise 2005


149620 30-Aug-2005 avatar

Properly set ic_curchan before calling back to device driver to do channel
switching(ifconfig devX channel Y). This fix should make channel changing
works again in monitor mode.

Submitted by: sam
X-MFC-With: other ic_curchan changes


149031 13-Aug-2005 sam

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


149028 13-Aug-2005 sam

Extend acl support to pass ioctl requests through and use this to
add support for getting the current policy setting and collecting
the list of mac addresses in the acl table.

Submitted by: Michal Mertl (original version)
MFC after: 2 weeks


148941 10-Aug-2005 sam

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


148936 10-Aug-2005 sam

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


148887 09-Aug-2005 rwatson

Propagate rename of IFF_OACTIVE and IFF_RUNNING to IFF_DRV_OACTIVE and
IFF_DRV_RUNNING, as well as the move from ifnet.if_flags to
ifnet.if_drv_flags. Device drivers are now responsible for
synchronizing access to these flags, as they are in if_drv_flags. This
helps prevent races between the network stack and device driver in
maintaining the interface flags field.

Many __FreeBSD__ and __FreeBSD_version checks maintained and continued;
some less so.

Reviewed by: pjd, bz
MFC after: 7 days


148863 08-Aug-2005 sam

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


148845 08-Aug-2005 sam

use ieee80211_iterate_nodes to retrieve station data; the previous
code walked the list w/o locking

MFC after: 1 week


148843 08-Aug-2005 sam

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


148778 06-Aug-2005 sam

fix debug msg typo

MFC after: 3 days


148777 06-Aug-2005 sam

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


148582 31-Jul-2005 sam

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


148433 27-Jul-2005 sam

when bridging internally bypass the bss node as traffic to it
must follow the normal input path

Submitted by: Michal Mertl
MFC after: 5 days


148432 27-Jul-2005 sam

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


148323 23-Jul-2005 sam

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


148320 22-Jul-2005 sam

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


148315 22-Jul-2005 sam

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


148314 22-Jul-2005 sam

split 802.11 frame xmit setup code into ieee80211_send_setup

MFC after: 3 days


148307 22-Jul-2005 sam

simplify ic_newassoc callback

MFC after: 3 days


148306 22-Jul-2005 sam

simplify ieee80211_ibss_merge api

MFC after: 3 days


148305 22-Jul-2005 sam

add stats we know we'll need soon and some spare fields for future expansion

MFC after: 3 days


148304 22-Jul-2005 sam

simplify tim callback api

MFC after: 3 days


148303 22-Jul-2005 sam

don't include 802.3 header in min frame length calculation as it may
not be present for a frag; fixes problem with small (fragmented) frames
being dropped

Obtained from: Atheros
MFC after: 3 days


148302 22-Jul-2005 sam

simplify ieee80211_node_authorize and ieee80211_node_unauthorize api's

MFC after: 3 days


148301 22-Jul-2005 sam

simplifiy ieee80211_send_nulldata api

MFC after: 3 days


148299 22-Jul-2005 sam

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

MFC after: 3 days


148298 22-Jul-2005 sam

reject association requests with a wpa/rsn ie when wpa/rsn is not
configured on the ap; previously we either ignored the ie or (possibly)
failed an assertion

Obtained from: Atheros
MFC after: 3 days


148296 22-Jul-2005 sam

missed one in last commit; add device name to discard msgs


148295 22-Jul-2005 sam

include device name in discard msgs


148294 22-Jul-2005 sam

add diag msgs for frames discarded because the direction field is wrong


148293 22-Jul-2005 sam

split data frame delivery out to a new function ieee80211_deliver_data


148292 22-Jul-2005 sam

o add IEEE80211_IOC_FRAGTHRESHOLD for getting+setting the
tx fragmentation threshold
o fix bounds checking on IEEE80211_IOC_RTSTHRESHOLD

MFC after: 3 days


148291 22-Jul-2005 sam

o add IEEE80211_FRAG_DEFAULT
o move default settings for RTS and frag thresholds to ieee80211_var.h


148290 22-Jul-2005 sam

diff reduction against p4: define IEEE80211_FIXED_RATE_NONE and use
it instead of -1


148289 22-Jul-2005 sam

add flags missed in last merge


148288 22-Jul-2005 sam

Diff reduction against p4:
o add ic_flags_ext for eventual extention of ic_flags
o define/reserve flag+capabilities bits for superg,
bg scan, and roaming support
o refactor debug msg macros

MFC after: 3 days


148278 22-Jul-2005 sam

send a response when an auth request is denied due to an acl;
might be better to silently ignore the frame but this way we
give stations a chance of figuring out what's wrong


148277 22-Jul-2005 sam

remove excess whitespace


148276 22-Jul-2005 sam

use IF_HANDOFF when bridging frames internally so if_start gets
called; fixes communication between associated sta's

MFC after: 3 days


147892 11-Jul-2005 sam

Handle encrypt of arbitarily fragmented mbuf chains: previously
we bailed if we couldn't collect the 16-bytes of data required
for an aes block cipher in 2 mbufs; now we deal with it. While
here make space accounting signed so a sanity check does the
right thing for malformed mbuf chains.

Approved by: re (scottl)


147891 11-Jul-2005 sam

nuke assert that duplicates real check

Reviewed by: avatar
Approved by: re (scottl)


147870 09-Jul-2005 sam

Change default key allocation method to do the right thing for
legacy parts (i.e. those that have 4 global key slots). We
blindly assign unicast keys to key slot 0. Devices that need
alternate allocation logic must override this method.

Reviewed by: avatar
Approved by: re (scottl)


147846 08-Jul-2005 sam

correct check for high priority wme traffic

Noticed by: Ralf Assmann
Reviewed by: apatti
Approved by: re (scottl)


147836 08-Jul-2005 sam

fix another instance of the MORE_DATA bit handling for frames on the
power save queue (missed in previous commit)

Submitted by: Bruno Randolf
Approved by: re (scottl)


147794 06-Jul-2005 sam

add "pureg" mode for ap operation: reject association requests from
11b-only stations when operating in 11g

Reviewed by: avatar
Approved by: re (scottl)


147789 06-Jul-2005 sam

Fix handling of data frames queued for a station in power save mode:
don't mark the MORE_DATA bit when taking it off the ps queue, there's
no 802.11 header then; we must wait to do this at encap time so
mark the mbuf instead.

Reviewed by: avatar
Approved by: re (scottl)
Obtained from: Atheros


147788 06-Jul-2005 sam

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)


147787 06-Jul-2005 avatar

Only update the scan entry state based on newly received frames.
This fixes duplicative BSS entries(memory leaks as well) listed in
"ifconfig dev list scan" when a station fails to associate with an AP.

Reviewed by: sam
Approved by: re (scottl)


147779 05-Jul-2005 sam

remove auto-add of IEEE80211_KEY_GROUP; all the apps that need to
set it have been fixed

Reviewed by: avatar
Approved by: re (scottl)


147775 05-Jul-2005 sam

o when setting a wpa key, hold a ref on the bss node;
fixes a ref cnt leak
o make unicast key handling on delete identical to set
o change legacy wep key api to reset the 802.11 state
machine for backwards compatibility

Reviewed by: avatar
Approved by: re (scottl)


147765 04-Jul-2005 sam

when operating in ap mode, explicitly drop associated/authenticated
stations when transitioning to INIT state (e.g. as a result of
changing state at the 802.11 level)

Approved by: re (scottl)


147349 13-Jun-2005 sam

revert 1.53; it breaks ibss merge

Noticed by: Bruno Randolf
Approved by: re (dwhite)


147273 10-Jun-2005 sam

don't look at the wme ie in a beacon unless we negotiated use


147256 10-Jun-2005 brooks

Stop embedding struct ifnet at the top of driver softcs. Instead the
struct ifnet or the layer 2 common structure it was embedded in have
been replaced with a struct ifnet pointer to be filled by a call to the
new function, if_alloc(). The layer 2 common structure is also allocated
via if_alloc() based on the interface type. It is hung off the new
struct ifnet member, if_l2com.

This change removes the size of these structures from the kernel ABI and
will allow us to better manage them as interfaces come and go.

Other changes of note:
- Struct arpcom is no longer referenced in normal interface code.
Instead the Ethernet address is accessed via the IFP2ENADDR() macro.
To enforce this ac_enaddr has been renamed to _ac_enaddr.
- The second argument to ether_ifattach is now always the mac address
from driver private storage rather than sometimes being ac_enaddr.

Reviewed by: sobomax, sam


147254 10-Jun-2005 sam

validate the bssid for non-data frames too when operating in
adhoc/ahdemo/hostap modes


147252 10-Jun-2005 sam

o fix wpa w/ wme: don't strip the QoS header on recv as tkip requires
it; instead pass the space occupied by the header down into the
crypto modules (except in the demic case which needs it only when
doing int in s/w)
o while here fix defrag to strip the header from 2nd and later frames
o teach decap code how to handle 4-address frames


147223 10-Jun-2005 sam

mark stations authorized during recv processing instead of doing it
as a side effect of sending an auth success frame; sending mgmt
frames should not have side effects


147221 10-Jun-2005 sam

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


147220 10-Jun-2005 sam

accept diassoc frame in ASSOC state


147215 10-Jun-2005 sam

pull some debug msgs up so they're seen more often


147214 10-Jun-2005 sam

kick the state machine when we receive failure notice from an ap (when
operating in sta mode); this speeds up the state machine, previously
we were acting on a timeout


147213 10-Jun-2005 sam

discard open auth requests in adhoc mode


147212 10-Jun-2005 sam

reject open auth requests when shared key auth is configured

Obtained from: Atheros


147211 10-Jun-2005 sam

add ieee80211_send_error to encapsulate an idiom


147210 10-Jun-2005 sam

o always check if ic_set_tim is !NULL before using it
o add missing call to clear tim after flushing ps q


147209 10-Jun-2005 sam

mark state for protection only when operating in 11g


147208 10-Jun-2005 sam

don't reject station based on the PRIVACY bit in the capabilities;
the 802.11 spec says not to

Obtained from: Atheros


147207 10-Jun-2005 sam

correct checks for rate set compatibility


147206 10-Jun-2005 sam

record tstamp from beacons received in station mode when associated;
this is needed by drivers that want to resync their timers based on
the tsf of the last recv'd beacon frame


147152 09-Jun-2005 sam

o collect dtim period+count from beacons in station mode so drivers
can better program beacon timers
o leave placeholder in com structure for future ap/adhoc mode tim support

Reviewed by: avatar


147118 07-Jun-2005 sam

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.


147116 07-Jun-2005 sam

Don't clock the state machine in various cases when roaming is set
to manual; this helps keep wpa_supplicant in sync.


147066 07-Jun-2005 sam

WPA/802.11i interoperability fixes:
o only include capabilities word in the WPA ie when non-zero and
not preauth
o always include the capabilities in the RSN ie

Obtained from: Atheros


147045 06-Jun-2005 sam

add force flag to enmic/demic crypto api for use in xmit fragmentation
and h/w mic verification

Reviewed by: avatar


144960 12-Apr-2005 sam

Revise crypto api lightly to improve group key handling:
o don't pre-assign key index to the global key table entries so device
has a chance to decide what to use
o make ieee80211_crypto_newkey take the desired flags as an argument
instead of wacking the key structure directly; this eliminates a
bunch of code warts
o add a new flag IEEE80211_KEY_GROUP to indicate a key is a WPA Group
key so devices don't need to guess (temporarily add this flag in the
ioctl code until we can get wpa_supplicant+hostapd updated)
o shuffle IEEE80211_KEY_* bits to move flags used internally to the high
nibble of the flags word

Reviewed by: Tai-hwa Liang


144618 04-Apr-2005 sam

remove extern from function decls


144616 04-Apr-2005 sam

change ieee80211_input to return the frame type or -1


144302 29-Mar-2005 sam

pass re-association events up using a new message type


144137 26-Mar-2005 sam

when WPA is enabled discard association requests w/o a WPA ie

Submitted by: Divy Le Ray


144136 26-Mar-2005 sam

don't include wme ie in probe request frames; it was meant for probe response
frames--move it there

Noticed by: Ghislain Mary
Submitted by: Michael Wong


143716 16-Mar-2005 sam

correct comparison for null ptr

Noticed by: Coverity Prevent analysis tool


143715 16-Mar-2005 sam

avoid potential array index by -1

Noticed by: Coverity Prevent analysis tool


143714 16-Mar-2005 sam

eliminate use after free in debug code

Noticed by: Coverity Prevent analysis tool


143713 16-Mar-2005 sam

kill dead code

Noticed by: Coverity Prevent analysis tool


143300 08-Mar-2005 sam

honor any desired bssid when creating an ibss

Prodded by: David Young
Obtained from: netbsd


143110 03-Mar-2005 wpaul

Recently, it was reported to me that you could provoke a double fault
panic with the NDISulator if you did "ifconfig ndis0 10.0.0.1/24,"
whereas "ifconfig ndis0 10.0.0.1/24 up" worked fine. The double fault
was caused by the ifconfig thread running out of kernel stack space.
(This was partly due to the NDIsulator using a couple of big buffers on
the stack, but even after fixing that the double fault persisted.)

It turns out that ndis_init() is called in both cases, but in the first
case the code path passes through ieee80211_ioctl(), and it turns out
ieee80211_ioctl() consumes a whopping 2400 bytes of stack space.
Apparently, gcc -O2 causes the ieee80211_ioctl_get80211() routine to
be inlined into ieee80211_ioctl(), and for some reason which I do not
fully understand, this causes ieee80211_ioctl() to consume an extra 2K
of stack space.

To prevent this overly agressive optimization, ieee80211_ioctl_get80211()
is now declared with __attribute__ ((noinline)). With this change,
ieee80211_ioctl() now only reserves about 200 bytes of stack instead of 2400.


142283 23-Feb-2005 sam

mark timestamp for pending fragments

Noticed by: Jeffrey D. Chung


141660 10-Feb-2005 sam

rev 1.19 fixed wpa supplicant but broke wpa authenticator; when operating
as an authenticator need to always check for the unicast key in the node
(as was the case before)

Submitted by: Divy Le Ray


141658 10-Feb-2005 sam

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


141210 03-Feb-2005 sam

correct check for unicast key being setup; wpa_supplicant in particular
uses only the global key state so looking in the per-node key slot is wrong

Submitted by: Tai-hwa Liang


140915 27-Jan-2005 sam

supply a default ic_reset method for drivers; the ioctl code expect this
method to always be setup

Submitted by: Tai-hwa Liang


140766 24-Jan-2005 sam

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


140764 24-Jan-2005 sam

clear IEEE80211_F_WMEUPDATE when building the initial beacon frame so we
don't do an update on the first beacon


140763 24-Jan-2005 sam

noop change so RUN->RUN transition isn't considered invalid
(it happens on ibss merge)


140762 24-Jan-2005 sam

add macros to convert between txop's and usecs


140754 24-Jan-2005 sam

o clarify that beacon interval settings are in TU's, not ms
o add macros to convert between TU's and ms


140753 24-Jan-2005 sam

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


140636 22-Jan-2005 sam

handle potential stale values of bssid in neighbor nodes that
can occur after an ibss merge

Submitted by: David Young


140634 22-Jan-2005 sam

when ssid suppression is enabled don't respond to probe requests
unless our ssid is specified


140633 22-Jan-2005 sam

be consistent in naming inactivity timers;
net.wlan.X.inact -> net.wlan.X.inact_run


140630 22-Jan-2005 sam

o replace out-of-line copy of FCS w/ a flag that indicates the
frame includes FCS (requires applications to be updated, but since
we weren't doing the out-of-line FCS stuff anyway app changes
were needed already)
o add a flag to indicate padding exists between the 802.11 header and
the payload (e.g. for Atheros cards)
o diff reducation against netbsd

MFC after: 1 week


140499 20-Jan-2005 sam

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


140498 20-Jan-2005 sam

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


140497 20-Jan-2005 sam

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


140455 18-Jan-2005 sam

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


140454 18-Jan-2005 sam

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

Submitted by: Tai-hwa Liang


140453 18-Jan-2005 sam

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


140448 18-Jan-2005 sam

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.


140445 18-Jan-2005 sam

correct logic that caused beacon frames received in ibss mode to be
discarded when not scanning


140444 18-Jan-2005 sam

move beacon/probe response counting down to after we've decided whether or
not we're going to process the frame; this makes the counters reflect frames
actually processes instead of received (discarded frames were already counted)


140441 18-Jan-2005 sam

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

Noticed by: Tai-hwa Liang


140440 18-Jan-2005 sam

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


139543 01-Jan-2005 sam

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).


139531 31-Dec-2004 sam

remove netbsd rcsid lines; they are way out of date and we appear to be
diverging too much to make tracking these files worthwhile


139530 31-Dec-2004 sam

bump copyright for 2005


139528 31-Dec-2004 sam

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


139527 31-Dec-2004 sam

Relearn how WPA keying is supposed to work and fix WPA+WME while
we're at it:
o WPA/802.11i has a unicast key and a group key; in station mode
everything is sent with the unicast key--we were consulting the
destination mac address and incorrectly using the group key
o (perpetuate fallback use of the default tx key to maintain
compatibility with the way wpa_supplicant works)
o correct EAPOL encryption logic to check unicast key instead
of assuming other state implies this
o move QoS encapsulation up to before enmic work so TKIP has the
information required to calculate the pseudo-header
o do not do QoS-encapsulation of EAPOL frames as some ap's do the
wrong thing with such frames (may need to revisit this if ap's
start dropping non-QoS frames from stations assoc'd with QoS)
o move ieee80211_mbuf_adjust closer to its caller


139526 31-Dec-2004 sam

disable default use of wme until we can sort out interoperability issues;
users that want it can explicitly enable it


139525 31-Dec-2004 sam

s/inline/__inline/


139524 31-Dec-2004 sam

compare pointers against NULL


139523 31-Dec-2004 sam

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


139522 31-Dec-2004 sam

do 11g erp station management in turboG mode too


139521 31-Dec-2004 sam

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


139520 31-Dec-2004 sam

include phy mode in scan debug msg


139519 31-Dec-2004 sam

accept IEEE80211_KEYIX_NONE for a default tx key


139517 31-Dec-2004 sam

don't return prematurely from processing a beacon or probe response frame
when associated; this corrects a problem where doing a scan while associated
caused the associated ap to sometimes not be included in the scan set


139516 31-Dec-2004 sam

change ieee80211_parse_wmeparams to return a unique value when the ie
is invalid so we can distinguish this from needing a parameter update;
fixes dynamic update of wme parameters


139515 31-Dec-2004 sam

remove stray \n from debug msg


139514 31-Dec-2004 sam

clear wep bit in 802.11 header after crypto decap so packet
capture doesn't see it


139512 31-Dec-2004 sam

o add net.wlan.X.driver_caps mib variable for setting the driver capabilities
flags for testing
o debug msg consistency fixups


139511 31-Dec-2004 sam

correct pseudo-mic header calculation for QoS frames


139510 31-Dec-2004 sam

whitespace/debug msg fixups


139509 31-Dec-2004 sam

add ieee80211_hdrspace and ieee80211_anyhdrspace to calculate the space
for an ieee80211 header taking into account padding requirements


139508 31-Dec-2004 sam

correct header length calculations on tx path for QoS-encapsulated frames
when IEEE80211_F_DATAPAD is set (e.g. ath); must use ieee80211_hdrspace
instead of ieee80211_hdrsize


139506 31-Dec-2004 sam

const'ify ivp reference


139504 31-Dec-2004 sam

add/fixup debug msgs


139503 31-Dec-2004 sam

s/inline/__inline/


139502 31-Dec-2004 sam

expose ieee80211_phymode_name for use in debug msgs


138817 13-Dec-2004 sam

correct module dependency


138816 13-Dec-2004 sam

correct module dependency


138777 13-Dec-2004 sam

cover up the landmine until there's a proper solution


138720 12-Dec-2004 sam

do not clear the global key cache when reaching the INIT state


138711 12-Dec-2004 sam

remove module dependency on rc4; it's not needed any more


138663 10-Dec-2004 sam

fix wep key seting: ENETRESET is the code to return to signal the driver
should push software state to the hardware (was ERESTART which caused the
system call to be retried)

Submitted by: Tor Egge


138609 08-Dec-2004 sam

fixup printf arguments for 64-bit machines


138568 08-Dec-2004 sam

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.


132712 27-Jul-2004 rwatson

Add a new network interface flag, IFF_NEEDSGIANT, which will allow
device drivers to declare that the ifp->if_start() method implemented
by the driver requires Giant in order to operate correctly.

Add a 'struct task' to 'struct ifnet' that can be used to execute a
deferred ifp->if_start() in the event that if_start needs to be called
in a Giant-free environment. To do this, introduce if_start(), a
wrapper function for ifp->if_start(). If the interface can run MPSAFE,
it directly dispatches into the interface start routine. If it can't
run MPSAFE, we're running with debug.mpsafenet != 0, and Giant isn't
currently held, the task is queued to execute in a swi holding Giant
via if_start_deferred().

Modify if_handoff() to use if_start() instead of direct dispatch.
Modify 802.11 to use if_start() instead of direct dispatch.

This is intended to provide increased compatibility for non-MPSAFE
network device drivers in the presence of Giant-free operation via
asynchronous dispatch. However, this commit does not mark any network
interfaces as IFF_NEEDSGIANT.


130416 13-Jun-2004 mlaier

Link ALTQ to the build and break with ABI for struct ifnet. Please recompile
your (network) modules as well as any userland that might make sense of
sizeof(struct ifnet).
This does not change the queueing yet. These changes will follow in a
seperate commit. Same with the driver changes, which need case by case
evaluation.

__FreeBSD_version bump will follow.

Tested-by: (i386)LINT


129876 30-May-2004 phk

Add some missing <sys/module.h> includes which are masked by the
one on death-row in <sys/kernel.h>


128966 05-May-2004 andre

Link state change notification of ethernet media to the routing socket.

o The ieee80211_media_status() function updates the ifi_link_state field
and calls rt_ifmsg() to notify listeners on the routing socket.

Approved by: sam


127917 05-Apr-2004 sam

Resolve the issue of whether frames have FCS or not. Frame data does not
include FCS; if you want to provide it you can put it in the header.

Submitted by: David Young


127916 05-Apr-2004 sam

eliminate nested include by making MALLOC_DECLARE conditional on the
inclusion of <sys/malloc.h>

Submitted by: bde


127903 05-Apr-2004 sam

add definitions for WME, WPA (and WPA2), and miscellaneous other stuff
that's coming soon

Obtained from: madwifi


127877 05-Apr-2004 sam

export the malloc type M_80211_NODE for drivers that override the node
allocation routines


127876 05-Apr-2004 sam

make malloc tag for ieee80211_node more recognizable


127774 02-Apr-2004 sam

Change handling of probe response frames. Previously we always dropped the
refcnt on the node but left it in the node table. This allows the node table
to hold the results of scanned ap's but for ibss scans left nodes w/o any
driver-private state setup and/or a bad refcnt (when the nodes were timed
out they were prematurely discarded). Now we treat nodes identified for ap
scanning as before but force nodes discovered when scanning for ibss neighbors
to have complete/proper state and hold the refcnt on the node. Any other
nodes created because of these frames are discarded directly (need to optimize
this case to eliminate various work that's immediately discarded).


127772 02-Apr-2004 sam

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)


127771 02-Apr-2004 sam

always free node reference when processing a probe request frame; was
conditionally doing an unref if operating in adhoc mode which turns
out to be wrong


127770 02-Apr-2004 sam

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


127769 02-Apr-2004 sam

track node allocation failure stats in ieee80211_alloc_node instead
of each caller

Obtained from: madwifi


127768 02-Apr-2004 sam

replace explicit malloc/free with MALLOC/FREE for portability

Obtained from: madwifi


127767 02-Apr-2004 sam

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

Obtained from: madwifi


127766 02-Apr-2004 sam

diff reduction against madwifi


127765 02-Apr-2004 sam

when processing beacon/probe response frames capture "is probe" in a
variable to improve code legibility since we're going to use it more
in forthcoming mods

Obtained from: madwifi


127764 02-Apr-2004 sam

add a case of IEEE80211_ELEMID_IBSSPARMS so the statistic on unknown
elements is more meaningful (will add more with WPA merge)

Obtained from: madwifi


127763 02-Apr-2004 sam

when doing internal bridging free the node instead of just dropping the
reference for consistency (explicit refcounting is discouraged)

Obtained from: madwifi


127762 02-Apr-2004 sam

when receiving a frame w/ a bad version number don't unref the node; the
driver is responsible for that

Obtained from: madwifi


127761 02-Apr-2004 sam

insure basic rate bit is set in derived rate set; this
works around a protocol/firmware problem with some versions found
in hermes/prism cards


127760 02-Apr-2004 sam

diff reduction against madwifi/p4


127648 30-Mar-2004 sam

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


127646 30-Mar-2004 sam

Only call if_init when doing SIOCSIFADDR if the interface is not marked
up (IFF_UP). This eliminates extraneous AP scanning.

Reviewed by: imp


127087 16-Mar-2004 mux

Add explicit dependency on "ether", since we use ether_ifattach().


124706 19-Jan-2004 onoe

Change WI_RID_SCAN_RES compatibility interface to return the result after
active scan is completed just as WI_RID_READ_APS.
This fixes wicontrol -L for ath(4) and awi(4) to have results even if
the driver cannot associate any APs.


124543 15-Jan-2004 onoe

Add support for FH phy, which will be used by awi driver.
Also some if_media constants to indicate operational mode are changed
to bitmasks to reduce diffs from NetBSD.


124457 13-Jan-2004 sam

Handle SIOCSIFMTU ioctl directly so we can apply 802.11-specific bounds.
Note that the min is actually constrained to IF_MINMTU by the if layer.


123926 28-Dec-2003 sam

Sync with netbsd:

o #ifdef _KERNEL the fallback definition for DLT_IEEE802_11_RADIO
o fix many comments
o rename antenna stuff and fix units/reference signal
o change IEEE80211_RADIOTAP_DBM_TX_POWER from unsigned 16-bit value
to a signed 8-bit value
o change IEEE80211_RADIOTAP_FLAGS from 16 bits to 8 bits to simplify
padding requirements
o drop IEEE80211_RADIOTAP_TIME
o change IEEE80211_RADIOTAP_ANTENNA from 16 bits to 8 bits
o drop IEEE80211_RADIOTAP_PAD
o add channel flag definitions for outside the kernel so radiotap
doesn't depend on stuff in ieee80211*.h

Obtained from: NetBSD


122600 13-Nov-2003 sam

o insure the current channel is in a good state before starting an AP scan
o reject scan requests for a device that isn't marked up

This fixes a problem where requesting a scan before marking the device
up would cause a panic because the current channel was set to "any" (0xffff).


122374 09-Nov-2003 sam

fix typo that broke AP scanning by BSSID

Submitted by: Len Widra


122090 05-Nov-2003 green

Fix a reversed suser(9) in SIOCG80211:IEEE80211_IOC_WEPKEY which prevents
root from reading the wireless card's WEP keys, but allows non-root.


121816 31-Oct-2003 brooks

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)


121181 17-Oct-2003 sam

fix station mode breakage (repeat after me: "test every change, no
matter how small...")


121180 17-Oct-2003 sam

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


121179 17-Oct-2003 sam

fixup debug msgs


121178 17-Oct-2003 sam

include FH/DS parameters element in probe response frames


121176 17-Oct-2003 sam

correct comment


121174 17-Oct-2003 sam

o add capability to indicate if device receives all management frames
o use recv mgmt capability to decide if outbound frames should be
discarded if no node table entry is present


121172 17-Oct-2003 sam

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


120483 26-Sep-2003 sam

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.


120482 26-Sep-2003 sam

Correct rate set negotiation when operating as a station: if the
AP has basic rates that we do not support then ignore them instead
of marking the rate set in error.

This fixes an 11b station associating with an 11g/b AP.


120481 26-Sep-2003 sam

allocate node table entries with a specific malloc type


120480 26-Sep-2003 sam

correct spelling of IEEE80211_IOC_RTSTHRESHOLD


120104 15-Sep-2003 sam

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.


120099 15-Sep-2003 sam

Change input handling to not expect drivers to filter short frames.
In particular, let drivers send up control frames so we can dispatch
them to bpf in monitor mode.

This is the first (small) step to adding more functionality such as
power save mode.


120098 15-Sep-2003 sam

add definitions for various control frames and a minimum-sized frame that
we use to define IEEE80211_MIN_LEN; the minimal length for frames drivers
may pass up into the 802.11 layer


120070 14-Sep-2003 sam

Honor the short preamble capability/state flag when calculating the
capabilities for outbound management frames. But beware of sending
this when operating on 5GHz channels; some 11a AP's reject association
requests if this bit is set in the capabilities listed.

Obtained from: MADWIFI (with modifications)


120067 14-Sep-2003 sam

short preamble capability is not just for 11g; mark IEEE80211_F_SHPREAMBLE
regardless of the operating mode

Obtained from: MADWIFI


119782 05-Sep-2003 sam

Experimental bpf capture format for 802.11 devices. The link layer
type belongs in net/bpf.h but we keep it here for the moment.

P:
Submittep by:
Obtained from: David Young <dyoung@pobox.com>


119627 01-Sep-2003 sam

o correct logic that checks frame size to decide if a cluaster is needed
o add an assertion to check the max possible packet size

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


119150 19-Aug-2003 sam

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)


118887 13-Aug-2003 sam

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>


118886 13-Aug-2003 sam

Use IEEE80211_RATE_MAXSIZE instead of IEEE80211_RATE_SIZE to validate the
rate set element id from an AP. This allows stations to associate with
AP's that violate the 802.11 spec by sending >8 rates. This corrects a
recent regression; older code did likewise.


117817 21-Jul-2003 sam

add monitor mode


117811 20-Jul-2003 sam

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


117041 29-Jun-2003 sam

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


117040 29-Jun-2003 sam

use proper length to copy data for WI_RID_DESIRED_SSID (was smashing
ic_des_chan that immediately follows)


117039 29-Jun-2003 sam

add safeguard against (bogus) null channel parameter


116904 27-Jun-2003 sam

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


116899 27-Jun-2003 sam

fix typo

Submitted by: "Norman Diamond \(ITS\)" <n_diamond@its.jp>


116895 26-Jun-2003 sam

add comment


116830 25-Jun-2003 sam

fix tcpdump -y IEEE802_11; NBPFILTER was a holdover from netbsd compatibility


116742 23-Jun-2003 sam

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...