Commit Graph

968 Commits

Author SHA1 Message Date
Adrian Chadd
b09e37a185 Fix a panic introduced in a previous commit - non-beaconing modes (eg STA)
don't setup the avp mcast queue.

This is a bit annoying though - it turns out the mcast queue isn't
initialised for STA mode but it's then touched to see whether anything
is in it.  That should be fixed in a subsequent commit.

Noticed by:	gperez@entel.upc.edu
PR:		kern/165895
2012-03-10 19:58:23 +00:00
Adrian Chadd
9c85ff9164 Don't flood the cabq/mcastq with frames.
In a very noisy 2.4GHz environment (with HT/40 enabled, making it worse)
I saw the following occur:

* the air was considered "busy" a lot of the time;
* the cabq time is quite short due to staggered beacons being enabled;
* it just wasn't able to keep up TX'ing CABQ frames;
* .. and the cabq would swallow up all the TX ath_buf's.

This patch introduces a twiddle which allows the maximum cabq depth to be
set, forcing further frames to be dropped.

It defaults to the TX buffer count at the moment, so the default behaviour
isn't changed.

I've also started fleshing out a similar setup for the data path, so
it doesn't swallow up all the available TX buffers and preventing management
frames (such as ADDBA) out.

PR:		kern/165895
2012-03-10 04:14:04 +00:00
Adrian Chadd
c5940c30a7 Document that we may end up with some suboptimal handling of data
frames with stations in power saving mode.

I'm not (yet) sure how to handle TX'ing aggregates frames to stations
that are in power saving mode, or whether that's even a feasible thing
to do. So in order to (mostly) not forget, leave a couple of comments
in the code.

The code presently assumes that the aggregation TID state for an ath_node
is locked not by the ath_node lock or a node+TID lock, but behind the
hardware queue said TID maps to.  This assumption is going to be
incorrect for stations in power saving mode as we'll be TX'ing frames
on the multicast queue.

In any case, I'm afraid its a "later problem". :/
2012-03-09 22:58:34 +00:00
Adrian Chadd
91d92caece Should the mcast queue be locked here? In case more multicast traffic
comes along?

This commit was brought to you via an Atheros AR5210, associated to an 3x3
HT40 11na access point.  Yes, this driver still works with it.
2012-03-09 22:41:09 +00:00
Adrian Chadd
e86fd7a715 Insert extra paranoia into the ath(4) driver.
This function must be called with both the source and destination TXQs
locked or things will get hairy.

I added this as part of some debugging in a PR but it turned out to not
be the cause.  I still think it's -correct- so, here it is.
2012-03-09 08:36:30 +00:00
Adrian Chadd
b1f3262c73 Correctly initialise the TXQ link pointer to the last descriptor in
the last buffer in the list.

The current behaviour (due to me, so pointy hat is firmly on my head here)
was incorrect - it was setting the link pointer to the last descriptor
of the _first_ buffer in the TXQ.  Instead, it should have set it to the
last descriptor in the _last_ buffer in the TXQ.

This showed up as occasional TX stalls with frames in the TXQ but no
TX progress being made.  Further inspection showed the TXQ looked like
it contained multiple "lists" of frames - there'd be a list of correct
frames, then a NULL link pointer, but there'd be a next buffer in the
list.

Since this code is only called upon an interface reset, it's likely
this only began showing up when I started doing stress testing
in environments which annoy the radios enough to cause lockups.

I've not yet any TX stalls with this patch applied.

PR:		kern/165866
2012-03-08 23:53:38 +00:00
Adrian Chadd
a887b1e359 Wrap another ATH_LOCK around the scanning flag.
PR:		kern/163318
2012-03-02 03:11:53 +00:00
Adrian Chadd
c98cefc5db Wrap the scan code state change stuff behind ATH_LOCK and the PCU fiddling
behind the PCU lock.

sc_scanning is being checked without ATH_LOCK behind held and could
in theory run from multiple threads.
2012-03-02 02:57:10 +00:00
Gavin Atkinson
1748d1e513 Correct capitalization of "Hz" in user-visible text (manpages, printf(),
etc).

MFC after:	3 days
2012-02-28 13:19:34 +00:00
Adrian Chadd
cc86f1ea4d Add in some debugging code to check whether the current rate table has
been bait-and-switched from the rate control code.

This will avoid the panic that I saw and will avoid sending invalid rates
(eg 11a/11g OFDM rates when in 11b, on 11b-only NICs (AR5211)) where the
rate table is not "big".

It also will point out situations where this occurs for the 11n NICs
which will have sufficiently large rate tables that "invalid rix" doesn't
occur.

I'll try to follow this up with a commit that adds a current operating mode
check. The "rix" is only relevant to the current operating mode and rate
table.

PR:	kern/165475
2012-02-26 06:04:44 +00:00
Adrian Chadd
d52f713265 Attempt to further fix some of the concurrency/reset issues that occur.
* ath_reset() is being called in softclock context, which may have the
  thing sleep on a lock.  To avoid this, since we really _shouldn't_
  be sleeping on any locks, break out the no-loss reset path into a tasklet
  and call that from:

  + ath_calibrate()
  + ath_watchdog()

  This has the added advantage that it'll end up also doing the frame
  RX cleanup from within the taskqueue context, rather than the softclock
  context.

* Shuffle around the taskqueue_block() call to be before we grab the lock
  and disable interrupts.

  The trouble here is that taskqueue_block() doesn't block currently
  queued (but not yet running) tasks so calling it doesn't guarantee
  no further tasks (that weren't running on _A_ CPU at the time of this
  call) will complete.  Calling taskqueue_drain() on these tasks won't
  work because if any _other_ thread calls taskqueue_enqueue() for whatever
  reason, everything gets very angry and stops working.

  This slightly changes the race condition enough to let ath_rx_tasklet()
  run before we try disabling it, and thus quietens the warnings a bit.

  The (more) true solution will be doing something like the following:

  * having a taskqueue_blocked mask in ath_softc;
  * having an interrupt_blocked mask in ath_softc;
  * only calling taskqueue_drain() on each individual task _after_ the
    lock has been acquired - that way no further tasklet scheduling
    is going to occur.
  * Then once the tasks have been blocked _and_ the interrupt has been
    disabled, call taskqueue_drain() on each, ensuring that anything
    that _was_ scheduled or running is removed.

  The trouble is if something calls taskqueue_enqueue() on a task
  after taskqueue_blocked() has been called but BEFORE taskqueue_drain()
  has been called, ta_pending will be set to 1 and taskqueue_drain()
  will sit there stuck in msleep() until you hard-kill the machine.

PR: kern/165382
PR: kern/165220
2012-02-25 19:12:54 +00:00
Adrian Chadd
398bca2e5e Use the passed-in channel rather than ic->ic_curchan.
I'm not sure _why_ the ic is NULL here, but I've seen it occasionally do
this after I've been tinkering with things for a while.  It ends up
crashing in a call to ath_chan_set() via the net80211 scan code and scan
task.
2012-02-23 08:32:54 +00:00
Adrian Chadd
7b1144d245 Break out the radar code into a separate source file.
This mirrors the internal HAL organisation and reduces the differences
between the HAL codebases slightly.

Obtained from:	Atheros
2012-02-20 03:07:07 +00:00
Adrian Chadd
107fdf9681 Try to ensure that ieee80211_newstate() and the vap_newstate methods
hold the lock.

This is part of my series of work to try and capture when net80211
locking isn't.

ObNote: it'd be nice to be able to mark a lock as "assert if the lock
is dropped", so I could capture functions which decide that dropping
and reacquiring the lock is a good idea (without re-checking the
sanity of the state protected by the lock.)
2012-02-18 09:18:06 +00:00
Adrian Chadd
2a4106cfef Fix the return type.
Submitted by:	arundel
Found by:	clang/llvm
2012-02-17 08:45:08 +00:00
Adrian Chadd
e78719adf9 Enforce some consistent ordering and handling of interrupt disable/enable
with RX/TX halting.

* Always disable/enable interrupts during a channel change, just to simply
  things.

* Ensure that the ath taskqueue has completed and is paused before
  continuing.

This dramatically reduces the instances of overlapping RX and reset
conditions.

PR:	kern/165220
2012-02-17 03:46:38 +00:00
Adrian Chadd
21008bf10d Begin breaking out the txrx stop code into a locked and unlocked variant.
PR:	kern/165220
2012-02-17 03:23:01 +00:00
Adrian Chadd
5a86e1369c Fix the usefir128 config bit flipping. 2012-02-14 20:06:28 +00:00
Adrian Chadd
cfa5ef068f Improve the radar register config API.
* Fix the "enabled" flag to actually reflect whether radar detection is
  enabled or not.
* Add flags for the relstep/relpwr checks.
2012-02-14 20:05:28 +00:00
Adrian Chadd
807675317e Attempt to address some potential vap->iv_bss race conditions.
There are unfortunately a number of situations where vap->iv_bss is changed
or freed by some code in net80211.  Because multiple threads can concurrently
be doing work (and the vap->iv_bss access isn't at all done behind any kind
of lock), it's quite possible that:

* a change will occur in one thread - eg, by a call through
  ieee80211_sta_join1();
* a state change occurs in another thread - eg an RX is scheduled
  in the ath tasklet and it calls ieee80211_input_mimo_all(), which
  does dereference vap->iv_bss;
* these two executing concurrently, causing things to explode.

Another instance is ath_beacon_alloc() which takes an ieee80211_node *.
It's called with the vap->iv_bss node from ath_newstate(). If the node has
changed in the meantime (say it's been freed elsewhere) the reference
that it grabbed _before_ refcounting it may be stale.

I would _prefer_ that these sorts of things were serialised somewhere but
that may be a bit much to ask.  Instead, the best we can (currently) hope
is that the underlying bss node is still (somewhat) valid.

There is a related PR (kern/164382) described by the first case above.
That should be fixed by properly serialising the RX path and reset path
so an RX can't occur at the same time as the vap free/shutdown path.

This is inspired by some related fixes in r212127.

PR: kern/165060
2012-02-13 00:28:41 +00:00
Adrian Chadd
2af3b95bf2 Enforce the hardware chainmask when allowing the user to override the
chainmask.

This way a disabled radio chain can't be enabled by a user.
2012-02-10 10:10:41 +00:00
Adrian Chadd
dc8552d525 .. oops, use the right chainmask. 2012-02-10 10:09:16 +00:00
Adrian Chadd
a865860d09 Add in a new driver feature to allow the TX and RX chainmask to be
overridden at attach time.

Some 802.11n NICs may only have one physical antenna connected.
The radios will be very upset if you try enabling radios which aren't
connected to antennas.

This allows hints to override the TX and RX chainmask.

These hints are:

hint.ath.X.rx_chainmask
hint.ath.X.tx_chainmask

They can be set at either boot time or in kenv before the module is loaded.

This and the previous HAL commit were sponsored in late 2011 by Hobnob, Inc.

Sponsored by:	Hobnob, Inc.
2012-02-10 10:01:09 +00:00
Adrian Chadd
40ffb20de6 Extend the HAL code to allow the RX and TX chainmask to be overridden
by capabilities.

Add an ar5416SetCapability() function, which contains logic to override
the chainmask and update the relevant stream.

This is designed to be called after the attach function, which presets
the TX/RX chainmask and stream.

TODO: check the chainmask against the hardware chainmask so non-existing
chains aren't enabled.
2012-02-10 09:58:20 +00:00
Adrian Chadd
ab4343580d Contribute some example code which demonstrates how to initialise the
radar parameters for the AR5416 and later NICs.

These parameters have been tested on the following NICs:

* AR5416
* AR9160
* AR9220
* AR9280

And yes, these will return radar pulse parameters and (for AR9160 and later)
radar FFT information as PHY errors.

This is again not enough to do radar detection, it's just here to faciliate
development and validation of radar detection algorithms.

The (pulse, not FFT) decoding code for AR5212, AR5416 and later NICs exist
in the HAL.

This code is disabled for now as generating radar PHY errors can quickly
cause issues in busy environment.s  Some further debugging of the RX path
is needed.

Finally, these parameters are likely not useful for the AR5212 era NICs.
The madwifi-dfs branch should have suitable example parameters for the
11a era NICs.
2012-02-06 20:23:21 +00:00
Adrian Chadd
1db689c583 Support AR9281/AR5B91 - a 1x2 stream device based on the AR9280.
* Override the TX/RX stream count if the EEPROM reports a single RX or
  TX stream, rather than assuming the device will always be a 2x2 strea
  device.

* For AR9280 devices, don't hard-code 2x2 stream.  Instead, allow the
  ar5416FillCapabilityInfo() routine to correctly determine things.

The latter should be done for all 11n chips now that
ar5416FillCapabilityInfo() will set the TX/RX stream count based on the
active TX/RX chainmask in the EEPROM.

Thanks to Maciej Milewski for donating some AR9281 NICs to me for
testing.
2012-01-31 22:31:16 +00:00
Adrian Chadd
54517070b5 Correctly fetch the TX/RX stream count from the HAL.
Pointy hat to: me
2012-01-31 22:27:35 +00:00
Adrian Chadd
7f925de11a Radar API related fixes.
* For legacy NICs, the combined RSSI should be used.
  For earlier AR5416 NICs, use control chain 0 RSSI rather than combined
  RSSI.
  For AR5416 > version 2.1, use the combined RSSI again.

* Add in a missing AR5212 HAL method (get11nextbusy) which may be called
  by radar code.

This serves no functional change for what's currently in FreeBSD.
2012-01-30 23:07:27 +00:00
Adrian Chadd
bfa5e92751 Oops, commit a missing implementation change.
Whilst I'm here, add a comment about what would happen in this function
if hypothetically you had a radar pattern matching detector written.
2012-01-28 22:24:59 +00:00
Adrian Chadd
ead404d417 Change the prototype so the radar enable can fail. 2012-01-28 21:44:42 +00:00
Adrian Chadd
06fc4a109d Two changes from my DFS work:
* Grab the net80211com lock when calling ieee80211_dfs_notify_radar().
* Use the tsf extend function to turn the 64 bit base TSF into a per-
  frame 64 bit TSF.  This will improve radiotap logging (which will
  now have a (more) correct per-frame TSF, rather then the single TSF64
  value read at the beginning of ath_rx_proc().
2012-01-28 21:37:33 +00:00
Adrian Chadd
7ebd03d755 Add some node debugging which has helped me track down which particular
concurrent vap->iv_bss free issues have been occuring.
2012-01-26 07:03:30 +00:00
Adrian Chadd
ee2e64dd6b Fix up some style(9) indenting and reorganise some of the hal methods.
There should be no functional change due to this commit.
2012-01-24 06:12:48 +00:00
Adrian Chadd
eb1d1f1de3 Add a missing HAL method macro. I'm using this as part of some personal
DFS radar stuff.
2012-01-24 06:07:05 +00:00
Adrian Chadd
a86e181b4c Break out the "memory" EEPROM data read method from being AR9130 specific
to being more generic.

Other embedded SoCs also throw the configuration/PCI register
info into flash.

For now I'm just hard-coding the AR9280 option (for on-board AR9220's on
AP94 and commercial designs (eg D-Link DIR-825.))

TODO:

* Figure out how to support it for all 11n SoC NICs by doing it in
  ar5416InitState();
* Don't hard-code the EEPROM size - add another field which is set
  by the relevant chip initialisation code.
* 'owl_eep_start_loc' may need to be overridden in some cases to 0x0.
  I need to do some further digging.
2012-01-15 19:22:34 +00:00
Adrian Chadd
fad901eb2b Re-enable the PHY radar error frames if sc_dodfs is set.
This was messing up a local port of the atheros reference radar detection
code; I'll fix the port instead.
2012-01-11 00:18:33 +00:00
Adrian Chadd
d4365d165b style(9) changes. This shouldn't change functionality. 2012-01-11 00:16:44 +00:00
Adrian Chadd
f5d9d54516 .. the AR5416 HAL code touches the MIMO parts in HAL_CHANNEL,
so this is also needed.

Pointed out by:	bz
2012-01-07 20:23:05 +00:00
Adrian Chadd
ac2dae5070 Commit a temporary workaround for people who are building kernels
where they've disabled all the wireless devices/framework.

This is just a build workaround. If you're actively using wireless,
you must still define AH_SUPPORT_AR5416 as I'm not sure what else
will break!

The real solution is to make the module build depend if AH_SUPPORT_AR5416
is defined, as well as make the 11n code in if_ath_tx.c and if_ath_tx_ht.c
completely optional (maybe depend upon ATH_SUPPORT_11N.)
2012-01-07 20:13:55 +00:00
Adrian Chadd
c0711b9756 If frames are dumped out of the queue, let's at least see what they are.
This shows that the majority of the weird traffic I see here are probe
frames that haven't been sent out, but I can also trigger this condition
by doing ICMP w/ -i 0.3 - enough to trigger the TX during actual scanning,
but not fast enough to stop scanning from occuring.

PR:		kern/163689
2012-01-01 01:08:51 +00:00
Dimitry Andric
a3388f6d69 Reapply r228785 now it has been tested by Adrian. Also add comments
with the old AR_SCR_SLE_XXX values, with a short explanation why they
were changed.

Reviewed by:	adrian
MFC after:	1 week
2011-12-30 02:58:37 +00:00
Adrian Chadd
613f73a82d AR5416 has 14 GPIO pins, from 0->13. 2011-12-26 08:21:29 +00:00
Adrian Chadd
404b0e8b91 Since the only thing with a mux is the AR5416 and later, and we're now
doing split software/hardware LED configuration, we can now simply
treat "softled" as an "output" mux type.

This works fine on this DWA-552. Previous generation (pre-11n NICs) don't
have a GPIO mux - only input/output configuration - so they ignore this
field.
2011-12-26 07:48:29 +00:00
Adrian Chadd
3440495a52 Flesh out configurable hardware based LED blinking.
The hardware (MAC) LED blinking involves a few things:

* Selecting which GPIO pins map to the MAC "power" and "network" lines;
* Configuring the MAC LED state (associated, scanning, idle);
* Configuring the MAC LED blinking type and speed.

The AR5416 HAL configures the normal blinking setup - ie, blink rate based
on TX/RX throughput.  The default AR5212 HAL doesn't program in any
specific blinking type, but the default of 0 is the same.

This code introduces a few things:

* The hardware led override is configured via sysctl 'hardled';
* The MAC network and power LED GPIO lines can be set, or left at -1
  if needed.  This is intended to allow only one of the hardware MUX
  entries to be configured (eg for PCIe cards which only have one LED
  exposed.)

TODO:

* For AR2417, the software LED blinking involves software blinking the
  Network LED.  For the AR5416 and later, this can just be configured
  as a GPIO output line.  I'll chase that up with a subsequent commit.

* Add another software LED blink for "Link", separate from "activity",
  which blinks based on the association state.  This would make my
  D-Link DWA-552 have consistent and useful LED behaviour (as they're
  marked "Link" and "Activity."

* Don't expose the hardware LED override unless it's an AR5416 or later,
  as the previous generation hardware doesn't have this multiplexing
  setup.
2011-12-26 07:47:05 +00:00
Adrian Chadd
a497cd8806 Setup the initial LED state on attach and resume.
Some of the NICs I have here power up with the LEDs blinking, which is
incorrect. The blinking should only occur when the NIC is attempting
to associate.

* On powerup, set the state to HAL_LED_INIT, which turns on the "Power" MAC
  LED but leaves the "Network" MAC LED the way it is.

* On resume, also init it to HAL_LED_INIT unless in station mode, where
  it's forced to HAL_LED_RUN. Hopefully the net80211 state machine will
  call newstate() at some point, which will refiddle the LEDs.

I've tested this on a handful of 11n and pre-11n NICs. The blinking
behaviour is slightly more sensible now.
2011-12-26 06:25:12 +00:00
Adrian Chadd
2942e03f5c Update the hardware LED blinking code to do something useful rather than
relying on what the register defaults are.

This forces the blink mode to be proportional to the TX and RX frames
which match the RX filter.

This (along with a few tweaks to if_ath_led.c to configure the correct
GPIO pins) allows my DWA-552 AR5416 NIC to blink the LEDs in a useful
fashion, however those LEDs are marked "Link" and "Act(ivity)", which
don't really map well to the "power" / "network" LED interface which
the MAC provides. Some further tinkering is needed to see what other
useful operating modes are possible.
2011-12-26 06:07:21 +00:00
Adrian Chadd
6558ffd99a Refactor out the software LED config code into a common function, called
ath_led_config().

The eventual aim is to have both software and hardware based LED
configuration done here.
2011-12-26 05:46:22 +00:00
Adrian Chadd
c65ee21d46 First pass of LED related code changes.
Migrate the LED code out of if_ath.c and into if_ath_led.c.
These routines are _all_ software based LED blinking.
2011-12-26 05:37:09 +00:00
Adrian Chadd
7e97436b0e Do a quick style(9) pass of some of the code introduced with 802.11n
support.
2011-12-26 05:26:35 +00:00
Adrian Chadd
252b52fd58 Disable the code which hard-sets the LEDs on. This prevents the LED
state from correctly updating things.

The reference driver directly enables/disables the LED state as required,
rather than nailing it up like it currently is.  That'll have to come
later by adding some further HAL methods.

Obtained from:	Atheros
2011-12-23 09:09:10 +00:00