freebsd-dev/sys/net80211
Adrian Chadd 5cda6006e4 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.
2013-03-08 20:23:55 +00:00
..
_ieee80211.h Add a check for dynamic OFDM/CCK channel types. 2012-07-01 04:25:49 +00:00
ieee80211_acl.c Remove now redundant mac argument. 2011-12-17 10:32:31 +00:00
ieee80211_action.c Mesh: management mesh action frames are to be discarded 2013-02-07 21:21:40 +00:00
ieee80211_action.h
ieee80211_adhoc.c Disable this variable; the code using it is also disabled. 2013-02-18 01:37:55 +00:00
ieee80211_adhoc.h
ieee80211_ageq.c Fix memset sizeofs 2011-07-07 15:41:40 +00:00
ieee80211_ageq.h
ieee80211_alq.c Re-commit this - store the alq payload in network order. 2012-03-21 03:19:50 +00:00
ieee80211_alq.h .. revert out a local change that I hadn't yet completely finished fleshing 2012-03-18 21:54:59 +00:00
ieee80211_amrr.c sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly. 2011-01-12 19:53:50 +00:00
ieee80211_amrr.h net80211 rate control framework (net80211 ratectl). 2010-04-07 15:29:13 +00:00
ieee80211_crypto_ccmp.c - Introduce IEEE80211_KEY_NOREPLAY, a per-key flag to ignore replay 2010-07-01 20:50:12 +00:00
ieee80211_crypto_none.c
ieee80211_crypto_tkip.c - Introduce IEEE80211_KEY_NOREPLAY, a per-key flag to ignore replay 2010-07-01 20:50:12 +00:00
ieee80211_crypto_wep.c
ieee80211_crypto.c
ieee80211_crypto.h - Introduce IEEE80211_KEY_NOREPLAY, a per-key flag to ignore replay 2010-07-01 20:50:12 +00:00
ieee80211_ddb.c Update ddb to print mesh routing table. 2013-02-07 21:29:48 +00:00
ieee80211_dfs.c Add a DFS debugging mode which is useful when doing automated DFS 2012-01-31 00:03:49 +00:00
ieee80211_dfs.h Add a DFS debugging mode which is useful when doing automated DFS 2012-01-31 00:03:49 +00:00
ieee80211_freebsd.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_freebsd.h Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_hostap.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_hostap.h Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_ht.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_ht.h Migrate the net80211 TX aggregation state to be from per-AC to per-TID. 2012-04-15 20:29:39 +00:00
ieee80211_hwmp.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_input.c Substitute '#ifdef ALIGNED_POINTER' with '#ifndef __NO_STRICT_ALIGNMENT', 2013-02-12 11:24:37 +00:00
ieee80211_input.h Fix some corner cases in the net80211 sequence number retransmission 2011-05-04 02:23:59 +00:00
ieee80211_ioctl.c Add the ability to kick an existing mesh node without waiting for it 2012-01-11 17:10:27 +00:00
ieee80211_ioctl.h Update net80211 mesh struct ieee80211_meshgann_ie. 2013-02-07 21:20:28 +00:00
ieee80211_mesh.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_mesh.h HWMP: ic->raw_xmit didn't always point to correct ni. 2013-02-07 21:26:40 +00:00
ieee80211_monitor.c
ieee80211_monitor.h
ieee80211_node.c Initial cut at making IBSS support 802.11n aware. 2013-01-26 00:37:54 +00:00
ieee80211_node.h Stop a mesh STA from flooding with peer frames. 2013-02-07 21:12:55 +00:00
ieee80211_output.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_phy.c
ieee80211_phy.h
ieee80211_power.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_power.h Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_proto.c if_start() is being used here as a way of kick-starting the new queue 2012-12-22 01:17:49 +00:00
ieee80211_proto.h Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_radiotap.c Extend the radiotap code to be aware of the size of any extra vendor 2012-06-18 02:08:04 +00:00
ieee80211_radiotap.h Add in the missing radiotap definitions from the sipsolutions.net 2013-01-08 06:59:21 +00:00
ieee80211_ratectl_none.c Some device drivers calculate various timing related things based on 2010-11-13 14:59:54 +00:00
ieee80211_ratectl.c Instead of using the AMRR ratectl algo as default for drivers which have 2010-11-06 18:17:20 +00:00
ieee80211_ratectl.h The ni_rctls checks are used to verify that a ratectl algo has set up 2010-11-14 09:59:52 +00:00
ieee80211_regdomain.c Add basic HT channel setup to ieee80211_init_channels(), this will be 2012-04-03 17:48:42 +00:00
ieee80211_regdomain.h Add a new 900MHz GSM regulatory SKU for the Xagyl Communications XC900M. 2012-12-07 06:34:46 +00:00
ieee80211_rssadapt.c Remove GNU-style struct initialization. 2010-06-12 07:02:43 +00:00
ieee80211_rssadapt.h net80211 rate control framework (net80211 ratectl). 2010-04-07 15:29:13 +00:00
ieee80211_scan_sta.c Initial cut at making IBSS support 802.11n aware. 2013-01-26 00:37:54 +00:00
ieee80211_scan.c Migrate the power-save functions to be overridable VAP methods. 2012-10-02 17:45:19 +00:00
ieee80211_scan.h Add 802.11h quiet time element support into net80211. 2011-11-08 04:00:24 +00:00
ieee80211_sta.c Handle ath-specific and WME IE's in adhoc mode. 2012-12-09 22:56:29 +00:00
ieee80211_sta.h Handle ath-specific and WME IE's in adhoc mode. 2012-12-09 22:56:29 +00:00
ieee80211_superg.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_superg.h Atheros SuperG bug fixes, as part of hunting down kern/174283. 2012-12-09 19:20:28 +00:00
ieee80211_tdma.c Fix the situation where net80211 is built with IEEE80211_SUPPORT_TDMA but a module 2012-01-15 19:45:23 +00:00
ieee80211_tdma.h
ieee80211_var.h Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_wds.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211_wds.h
ieee80211_xauth.c
ieee80211.c Bring over my initial work from the net80211 TX locking branch. 2013-03-08 20:23:55 +00:00
ieee80211.h Mesh: QoS Control field bit flags fix. 2013-02-14 20:00:38 +00:00