Commit Graph

1128 Commits

Author SHA1 Message Date
Adrian Chadd
ad3e6dcd37 Break out the TX descriptor link field into HAL methods.
The DMA FIFO chips (AR93xx and later) differ slightly to th elegacy
chips:

* The RX DMA descriptors don't have a ds_link field;
* The TX DMA descriptors have a ds_link field however at a different
  offset.

This is a reimplementation based on what the reference driver and ath9k
does.

A subsequent commit will enable it in the TX and beacon paths.

Obtained from:	Linux ath9k, Qualcomm Atheros
2012-07-19 02:25:14 +00:00
Adrian Chadd
c7f5bb7a4f Handle RX Keymiss events.
The AR9003 series NICs implement a separate RX error to signal that a
Keycache miss occured.  The earlier NICs would not set the key index
valid bit.

I'll dig into the difference between "no key index bit set" and "keycache
miss".
2012-07-15 20:51:41 +00:00
Adrian Chadd
29edf89eaa Log the number of handled decsriptors and valid descriptors when
hitting RXEOL.
2012-07-15 20:48:21 +00:00
Adrian Chadd
7e3fc039f6 Fix build breakage when one isn't building with IEEE80211_SUPPORT_SUPERG.
Noticed by:	mav
2012-07-14 12:15:20 +00:00
Adrian Chadd
2e7620b6d2 Merge in some other features from the legacy RX path:
* wrap the RX proc calls in the RX refcount;
* call the DFS checking, fast frames staging and TX rescheduling if
  required.

TODO:

* figure out if I can just make "do TX rescheduling" mean "schedule
  TX taskqueue" ?
2012-07-14 07:56:47 +00:00
Adrian Chadd
9a5a667da4 Make sure that 'rs' is pointing to the correct RX status. 2012-07-14 05:53:03 +00:00
Adrian Chadd
b5b60f35b7 Ensure that error is set.
Noticed by:	rui
2012-07-14 05:51:54 +00:00
Adrian Chadd
0b59717b4b Change the RX EDMA path to first complete the FIFO, then re-populate it
with fresh descriptors, before handling the frames.

Wrap it all in the RX locks.

Since the FIFO is very shallow (16 for HP, 128 for LP) it needs to be
drained and replenished very quickly.  Ideally, I'll eventually move this
RX FIFO drain/fill into the interrupt handler, only deferring the actual
frame completion.
2012-07-14 02:52:48 +00:00
Adrian Chadd
8d467c41b0 Don't free the descriptor allocation/map if it doesn't exist.
I missed this in my previous commit.
2012-07-14 02:47:16 +00:00
Adrian Chadd
2fe91baa92 Create an RX queue lock.
Ideally these locks would go away and there'd be a single driver lock,
like what iwn(4) does.  I'll worry about that later.
2012-07-14 02:22:17 +00:00
Adrian Chadd
39abbd9bd2 Fix EDMA RX to actually work without panicing the machine.
I was setting up the RX EDMA buffer to be 4096 bytes rather than the
RX data buffer portion.  The hardware was likely getting very confused
and DMAing descriptor portions into places it shouldn't, leading to
memory corruption and occasional panics.

Whilst here, don't bother allocating descriptors for the RX EDMA case.
We don't use those descriptors. Instead, just allocate ath_buf entries.
2012-07-14 02:07:51 +00:00
John Baldwin
f5afad7389 Cast a bus address to a uintmax_t for a debug printf to fix the build on
arm.
2012-07-11 15:04:20 +00:00
John Baldwin
ba59181d1c Map ATH_KTR_* to 0 when ATH_DEBUG is not defined. This effectively NOPs
out their use in that case.
2012-07-11 12:10:13 +00:00
John Baldwin
0f078d635e Fix build when ATH_DEBUG is not defined. 2012-07-10 18:57:05 +00:00
Adrian Chadd
be4a8356bc Commit missing flags for the high/low priority (HP/LP) RX queues.
Noticed by:	everyone
2012-07-10 18:30:20 +00:00
Adrian Chadd
fda21122d0 Add some debugging and comments about what's going on when reinitialising
the FIFO.

I still see some corner cases where no RX occurs when it should be
occuring.  It's quite possible that there's a subtle race condition
somewhere; or maybe I'm not programming the RX queues right.

There's also no locking here yet, so any reset/configuration path
state change (ie, enabling/disabling receive from the ioctl, net80211
taskqueue, etc) could quite possibly confuse things.
2012-07-10 07:45:47 +00:00
Adrian Chadd
bcbb08ceb5 Flip on EDMA RX of both HP and LP queue frames.
Yes, this is in the legacy interrupt path.  The NIC does support
MSI but I haven't yet sat down and written that code.
2012-07-10 07:43:31 +00:00
Adrian Chadd
2633dc9382 Migrate the ATH_KTR_* fields out to if_ath_debug.h . 2012-07-10 06:11:39 +00:00
Adrian Chadd
6abbbae5d3 Print the TX buffer if this error condition is asserted.
I need to figure out why this is occuring.  Hopefully I can get enough
descriptor dumps to figure it out.
2012-07-10 06:10:49 +00:00
Adrian Chadd
62206b7681 Add/fix EDMA RX behaviour.
* For now, kickpcu should hopefully just do nothing - the PCU doesn't need
  'kicking' for Osprey and later NICs. The PCU will just restart once
  the next FIFO entry is pushed in.

* Teach "proc" about "dosched", so it can be used to just flush the
  FIFO contents without adding new FIFO entries.

* .. and now, implement the RX "flush" routine.

* Re-initialise the FIFO contents if the FIFO is empty (the DP is NULL.)
  When PCU RX is disabled (ie, writing RX_D to the RX configuration
  register) then the FIFO will be completely emptied.  If the software FIFO
  is full, then no further descriptors are pushed into the FIFO and
  things stall.

This all requires much, much more thorough stress testing.
2012-07-10 06:05:42 +00:00
Adrian Chadd
f8649041a1 Reorder these so they match the capability enum order. 2012-07-10 03:48:07 +00:00
Adrian Chadd
99e8d8c3bb Implement EDMA RX for AR93xx and later chips.
This is inspired by ath9k and the reference driver, but it's a new
implementation of the RX FIFO handling.

This has some issues - notably the FIFO needs to be reprogrammed when
the chip is reset.
2012-07-10 00:08:39 +00:00
Adrian Chadd
d434a377d9 Convert sc_rxpending to a per-EDMA queue, and use that for the legacy code.
Prepare ath_rx_pkt() to handle multiple RX queues, and default the legacy
RX queue to use the HP queue.
2012-07-10 00:02:19 +00:00
Adrian Chadd
3e5e995640 Add some AR9300 HAL descriptor definition changes.
* Add a couple of RX errors;
* Add the spectral scan PHY error code;
* extend the RX flags to be a 16 bit field, rather than an 8 bit field;
* Add a new RX flag.

Obtained from:	Qualcomm Atheros
2012-07-09 23:58:22 +00:00
Adrian Chadd
3d184db2f8 Further preparations for the RX EDMA support.
Break out the DMA descriptor setup/teardown code into a method.
The EDMA RX code doesn't allocate descriptors, just ath_buf entries.
2012-07-09 08:37:59 +00:00
Adrian Chadd
0a6b6951b2 Introduce the EDMA related HAL capabilities.
Whilst here, fix a typo in a previous commit.

Obtained from:	Qualcomm Atheros
2012-07-09 07:31:26 +00:00
Adrian Chadd
d60a0680ba Extend the RX HAL API to include the RX queue identifier.
The AR93xx and later chips support two RX FIFO queues - a high and low
priority queue.

For legacy chips, just assume the queues are high priority.

This is inspired by the reference driver but is a reimplementation of
the API and code.
2012-07-09 07:19:11 +00:00
Adrian Chadd
ba7de9be0d Extend the debugging flags to include some AR9300 HAL related options.
Obtained from:	Qualcomm Atheros
2012-07-09 06:41:18 +00:00
Adrian Chadd
74732ec4e1 Extend the RX descriptor completion debugging to log the larger
AR93xx receive descriptors.

This isn't entirely complete - the AR93xx and later descriptors
don't have a link/buffer pointer; the descriptor contents just
start.
2012-07-09 06:39:46 +00:00
Adrian Chadd
6a9f8e0a06 Add a debug category for RX EDMA. 2012-07-09 05:23:02 +00:00
Adrian Chadd
f8cc9b09b0 Begin abstracting out the RX path in preparation for RX EDMA support.
The RX EDMA support requires a modified approach to the RX descriptor
handling.

Specifically:

* There's now two RX queues - high and low priority;
* The RX queues are implemented as FIFOs; they're now an array of pointers
  to buffers;
* .. and the RX buffer and descriptor are in the same "buffer", rather than
  being separate.

So to that end, this commit abstracts out most of the RX related functions
from the bulk of the driver.  Notably, the RX DMA/buffer allocation isn't
updated, primarily because I haven't yet fleshed out what it should look
like.

Whilst I'm here, create a set of matching but mostly unimplemented EDMA
stubs.

Tested:

  * AR9280, station mode

TODO:

  * Thorough AP and other mode testing for non-EDMA chips;
  * Figure out how to allocate RX buffers suitable for RX EDMA, including
    correctly setting the mbuf length to compensate for the RX descriptor
    and completion status area.
2012-07-03 06:59:12 +00:00
Adrian Chadd
f9c15ba003 .. And fix another typo. Grr. 2012-07-02 06:07:46 +00:00
Adrian Chadd
5cc9e9aef6 Fix another typo. 2012-07-02 06:06:27 +00:00
Adrian Chadd
69bc6f4f0c Fix typo. 2012-07-02 06:05:25 +00:00
Adrian Chadd
577cd9a9b2 Bring over some further HAL capabilities from the Atheros HAL, as well
as an EDMA check function.

For the AR9003 and later NICs, different TX/RX DMA and descriptor handling
code will be conditional on the EDMA check.

Obtained from:	Qualcomm Atheros
2012-07-02 06:02:12 +00:00
Adrian Chadd
c9914f098f Add in some further changes from the AR9300 HAL:
* Add a new ANI variable, for AR9003 and later chips;
* The AR9003 and later series chips support two RX queues now, so start
  down the road of supporting that;
* Add some new TX queue types - uAPSD is possible on earlier chips,
  but PAPRD is relevant to AR9003 and later.

Obtained from:	Qualcomm Atheros, Linux ath9k
2012-07-01 05:14:24 +00:00
Adrian Chadd
df91468216 Migrate the MAC/BB hang structures out from ar5416_misc.h into the HAL.
The ar9300 HAL also uses these types, so it makes no sense to duplicate
them.
2012-07-01 03:15:18 +00:00
Adrian Chadd
7eee712c27 Bring over capabilities for the AR9300 and later HAL. 2012-07-01 02:44:36 +00:00
Adrian Chadd
85f6107b86 Add OS_MEMCMP(). 2012-07-01 02:37:04 +00:00
Adrian Chadd
020841a28e Fix the HAL debugging to only use one bit to mark a message as unmaskable.
Whilst I'm here, remove the duplication of the #define.
2012-07-01 02:34:32 +00:00
Adrian Chadd
df5ea0d85b Fix a subtle corner case surrounding the handling of OFDM restart along
with AMPDU aggregate delimiters.

If there's an OFDM restart during an aggregate, the hardware ACKs
the previous frame, but communicates the RXed frame to the hardware
as having had CRC delimiter error + OFDM_RESTART phy error.
The frame however didn't have a CRC error and since the hardware ACKed
the aggregate to the sender, it thinks the frame was received.

Since I have no idea how often this occurs in the real world, add a
debug statement so trigger whenever this occurs.  I'd appreciate an
email if someone finds this particular situation is triggered.
2012-06-27 05:23:33 +00:00
Adrian Chadd
37003d2fc3 Bring over some new typedefs as part of the AR9300 HAL import. 2012-06-27 03:24:27 +00:00
Adrian Chadd
a6f801b608 Remove duplicate entries. 2012-06-27 03:00:29 +00:00
Adrian Chadd
6479ef780d Bring over the initial 802.11n bluetooth coexistence support code.
The Linux ath9k btcoex code is based off of this code.

Note this doesn't actually implement functional btcoex; there's some
driver glue and a whole lot of verification that is required.

On the other hand, I do have the AR9285+BT and AR9287+BT NICs which
this code supports..

Obtained from:	Qualcomm Atheros, Linux ath9k
2012-06-26 22:16:53 +00:00
Adrian Chadd
8405fe8662 Make sure the BAR TX session pause is correctly unpaused when a node
is reassociating.

PR:		kern/169432
2012-06-26 07:56:15 +00:00
Adrian Chadd
c312fb4adc In a complete lack of foresight on my part, my previous commit broke
the assumption that ath_softc doesn't change size based on build time
configuration.

I picked up on this because suddenly radar stuff didn't work; and
although the ath_dfs code was setting sc_dodfs=1, the main ath driver
saw sc_dodfs=0.

So for now, include opt_ath.h in driver source files.  This seems like
the sane thing to do anyway.

I'll have to do a pass over the code at some later stage and turn
the radiotap TX/RX structs into malloc'ed memory, rather than in-line
inside of ath_softc.  I'd rather like to keep ath_softc the same
layout regardless of configuration parameters.

Pointy hat to: 	adrian
2012-06-24 08:47:19 +00:00
Adrian Chadd
f8aa9fd500 Shuffle these initialisations to where they should be. 2012-06-24 08:28:06 +00:00
Adrian Chadd
d77363ad5b Change the ath_dfs_process_phy_err() method to take an mbuf rather than
a buffer pointer.

For large radar pulses, the AR9130 and later will return a series of
FFT results for software processing.  These can overflow a single 2KB
buffer on longer pulses.  This would result in undefined buffer behaviour.
2012-06-24 08:09:06 +00:00
Adrian Chadd
e1b5ab97e8 Introduce an optional ath(4) radiotap vendor extension.
This includes a few new fields in each RXed frame:

* per chain RX RSSI (ctl and ext);
* current RX chainmask;
* EVM information;
* PHY error code;
* basic RX status bits (CRC error, PHY error, etc).

This is primarily to allow me to do some userland PHY error processing
for radar and spectral scan data.  However since EVM and per-chain RSSI
is provided, others may find it useful for a variety of tasks.

The default is to not compile in the radiotap vendor extensions, primarily
because tcpdump doesn't seem to handle the particular vendor extension
layout I'm using, and I'd rather not break existing code out there that
may be (badly) parsing the radiotap data.

Instead, add the option 'ATH_ENABLE_RADIOTAP_VENDOR_EXT' to your kernel
configuration file to enable these options.
2012-06-24 07:01:49 +00:00
Adrian Chadd
a183985e6f On second thought, let's just set both CRC and PHY errors together on
frames that have it and let the upper layer sort it out.

PR:		kern/169362
2012-06-24 06:37:28 +00:00