Commit Graph

285 Commits

Author SHA1 Message Date
Adrian Chadd
3233d0c654 First cut at attempting to buffer frames until we see a beacon.
The iwn(4) firmware forgets most of its channel state after an RXON
command.  This means that any beacons its seen on passive 5GHz channels
are forgotten upon an association/authorisation request.
This unfortuantely means that 5GHz association almost always fails -
the assoc and/or auth frames are dropped with a status of "passive
channel, haven't seen a beacon yet." (0x90.)

So:

* add an xmit queue, global, to buffer frames
* modify the xmit path to use the mbuf tag from net80211
  to specify raw frame details
* buffer xmit frames from both raw and non-raw paths
* if a beacon is seen in the RX path, schedule a taskqueue to
  send said frames and un-buffer things.
* flush frames during state change back to INIT, or NIC
  down/up/detach.

This isn't the final shape I'd like this to be in but it certainly
is better than 5GHz "not working at all".

Tested:

* Intel 5100, STA mode (before spilling coffee)
* Intel 5300, STA mode (after spilling coffee)

Story:

* This has been bugging me at work for months, which I just
  worked around by throwing an ath(4) into my Lenovo T400 cardbus
  slot.

* Our ops director discovered indeed FreeBSD runs well on the
  Lenovo T420p, except for that pesky 5GHz thing.  So now developers
  also can have a T420p running FreeBSD to do work with.
  Their #1 feedback to me - "boy it'd be nice if 5GHz wifi worked."

* .. then, I was at NANOG but stuck with 5GHz only wifi and no ath(4)
  NIC to put in a laptop - and I snapped.

Thus, the reason this is actually work related.

MFC after:	2 weeks
Sponsored by:	Norse Corp, Inc.
2015-06-19 01:44:17 +00:00
Adrian Chadd
5d97054765 Disable bgscan for now - it interferes with 11n activity and general
stability.

I'll re-enable it once the scan overhaul is done - the NIC itself
can do bgscan, but not how we're doing it.

MFC after:	2 weeks
Sponsored by:	Norse Corp, Inc.
2015-06-04 05:37:07 +00:00
Gleb Smirnoff
272f6ade9b Change three methods in struct ieee80211com, namely ic_updateslot,
ic_update_mcast and ic_update_promisc, to pass pointer to the ieee80211com,
not to the ifnet.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 19:53:29 +00:00
Gleb Smirnoff
9dbbcd5d9a Use ic_printf() instead of if_printf(). 2015-05-25 15:12:23 +00:00
Gleb Smirnoff
e6feb66faf Store softc in ic_softc and access it without using struct ifnet.
Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 15:09:17 +00:00
Gleb Smirnoff
c8550c0278 Make net80211 drivers supply their device name to the net80211 layer, so
that the latter doesn't need to go through struct ifnet to get their name.

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2015-05-25 13:51:13 +00:00
Adrian Chadd
64b9bdcf18 Various iwn(4) fixes.
* simplify channel logic for determining RF gain setting in scan setup
* don't set TX timer on error
* free node references for unsent frames on device stop
* set maxfrags to IWN_MAX_SCATTER-1 (first segment is used by TX command)
* add missing IWN_UNLOCK() from interrupt path when the hardware
  disappears.
* pass control frames to host
* nitems() instead of local macro

Tested:

* Intel 5100, STA mode

PR:		kern/196264
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
2015-05-16 05:59:25 +00:00
Eitan Adler
f05e369aa2 iwn, wlan: fix typos
Fxi tow typos

Obtained from:	DragonFlyBSD
MFC after:	3 days
2015-04-10 20:55:17 +00:00
Adrian Chadd
bbd01a4100 Remove a private copy of ieee80211_add_ssid().
PR:		kern/196116
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
2014-12-19 01:41:51 +00:00
Gleb Smirnoff
c8dfaf382f Mechanically convert to if_inc_counter(). 2014-09-19 03:51:26 +00:00
Adrian Chadd
9dd099b274 Implement htprotmode handling.
This is separate to 11g protection - the default is to RTS protect
11n frames, including A-MPDU frames.

Tested:

* Intel 5100, STA mode
2014-09-08 07:16:00 +00:00
Adrian Chadd
339503ab41 (more) correctly account TX completion status for A-MPDU session frames.
The rules turn out to be:

* for non-aggregation session TX queues - it's either sent or not sent.
* for aggregation session TX queues - if nframes=1, then the status reflects
  the completed transmission.
* however, for nframes > 1, then this is just a status reflecting what
  the initial transmission did.  The compressed BA (immediate or delayed)
  may not have yet been received, so the actual frame status is in the
  compressed BA updates.

Whilst here, I fiddled with debugging and formatting a bit.

There's also RTS attempts (what the atheros chips call "short retries")
which weren't being logged and they aren't yet being used in the rate
control statistics updates.  For now, at least log them.

TODO:

* This still isn't 100% correct! So I have to tinker with this some more.
  (The failures aren't always failures..)
* Extend the rate control API in net80211 so it can take both short and
  long retry counts.

Tested:

* Intel 5100, STA mode
2014-09-08 03:16:28 +00:00
Adrian Chadd
f7efe7e999 Bring over some more status codes from the Linux iwlwifi driver.
The (eventual) intention is to create MIB counters for transmitted
frame completion to count how many packets with each status are
transmitted.

Note the difference between A-MPDU and non A-MPDU status.

Obtained from:	Linux iwlwifi/dvm driver
2014-09-08 03:12:42 +00:00
Adrian Chadd
18aabe98d0 Inform the rate control code if a single frame AMPDU transmission succeeds
but has some retries.

Without this, single frame transmission in AMPDU will always look like
it succeeded fine, and thus AMRR will think it's totally fine to just
keep upping the rate upwards.

Now, this is still not quite right!  For multi-frame aggregates the
completion happens in two parts - the TX done and the BA received.
The driver is currently double accounting those a little - there's no
way to say to the rate control code "I completed X frames, Y worked fine,
there were Z retries." And it's a bit odd with iwn, as the firmware
retransmits frames for us so we don't get to see how many retransmits
happened; only that it took longer than normal.  I may have to extend
the rate control API to properly track that.

So this may keep the rate lower than it should be, but that's better
than keeping it higher than it should be.

Tested:

* 5100, STA mode
2014-08-28 07:44:59 +00:00
Adrian Chadd
bc0203e201 Fix antenna configuration, microcode version checks and rate selection
in preparation for the 5300 3x3 NIC.

During this particular adventure, I did indeed discover that a whole
swath of things made little to no sense.

Those included, and are fixed here:

* A lot of the antenna configuration bits assume the NIC has two receive
  chains.  That's blatantly untrue for NICs that don't.
* There was some disconnect between the antenna configuration when
  forming a PLCP rate DWORD (which includes the transmit antenna
  configuration), separate to the link quality antenna configuration.

  So now there's helper functions to return which antenna configurations
  to use and those are used wherever an antenna config is required.

* The 5300 does up to three stream TX/RX (so MCS0->23), however
  the link quality table has only 16 slots.  This means all of the
  rate entries are .. well, dual-stream rates.  If this is the case,
  the "last MIMO" parameter can't be 16 or it panics the firmware.
  Set it to 15.

* .. and since yes it has 16 slots, it only would try retransmitting
  from MCS8->MCS23, which can be quite .. terrible.  Hard-code the last
  two retry slots to be the lowest configured rate.

* I noticed some transmit configuration command stuff is different
  based on firmware API version, so I lifted that code from Linux.

* Add / augment some more logging to make it easier to capture this
  stuff.

Now, 3x3 is still terrible because the link quality configuration is
plainly not good enough.  I'll have to think about that.
However, the original goal of this - 3x3 operation on the Intel
5300 NIC - actually worked.

There are also rate control bugs in the way this driver handles
notifying the net80211 rate control code when AMPDU is enabled.
It always steps the rate up to the maximum rate possible - and
this eventually ends in much sadness.  I'll fix that later.

As a side note - 2GHz HT40 now works on all the NICs I have tested.

As a second side note - this exposed some bad 3x3 behaviour in
the ath(4) rate control code where it starts off at a 3-stream rate
and doesn't downgrade quickly enough.  This makes the initial
dhcp exchange take a long time.  I'll fix the ath(4) rate code
to start at a low fixed 1x1 MCS rate and step up if everything
works out.

Tested:

* Intel 2200
* Intel 2230
* Intel 5300
* Intel 5100
* Intel 6205
* Intel 100

TODO:

* Test the other NICs more thoroughly!

Thank you to Michael Kosarev <russiane39@gmail.com> for donating the
Intel 5300 NIC and pestering me about it since last year to try and
make it all work.
2014-08-28 03:18:27 +00:00
Adrian Chadd
8f1d4b2dd6 Do the iwn(4) panic reinitialisation under IWN_LOCK().
I've checked each of the functions being called and there's either a
_locked version or it's supposed to be called with IWN_LOCK() held.
2014-08-03 03:51:33 +00:00
Adrian Chadd
43f2450f5d Shadow RAM support is apparently not at all working on the Intel 5300 Wifi.
Tested:

* Intel 5300 3x3 wifi
* Intel 5100
2014-06-14 06:54:03 +00:00
John Baldwin
0f698bd800 - Don't check the dma map address for a static DMA mapping against NULL
to determine if the mapping is valid.
- Don't explicitly destroy the dmap map for static DMA mappings.

Reviewed by:	adrian
2014-06-13 19:40:02 +00:00
Gavin Atkinson
9194f39024 Remove debugging printf that crept in in r266770.
Submitted by:	adrian, nwhitehorn
MFC after:	2 weeks
2014-05-27 23:05:12 +00:00
Gavin Atkinson
a94ec03f8f Add support for the Intel Centrino Wireless-N 105 chipset.
MFC after:	2 weeks
Relnotes:	yes
2014-05-27 19:39:57 +00:00
Edward Tomasz Napierala
8acd0be199 Make iwn(4) able to get itself back into working condition after
"fatal firmware error" happens.  Previously it was neccessary to reset
it manually, using "/etc/rc.d/netif restart".

Approved by:	adrian@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-05-22 15:29:25 +00:00
Edward Tomasz Napierala
43c2aa0f86 Erm, revert r266544; wrong tree. 2014-05-22 15:00:32 +00:00
Edward Tomasz Napierala
983aa498d5 Make iwn(4) able to get itself back into working condition after
"fatal firmware error" happens.  Previously it was neccessary to reset
it manually, using "/etc/rc.d/netif restart".

Approved by:	adrian@
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
2014-05-22 14:56:34 +00:00
Adrian Chadd
fa5ff59a78 Fix the required calibration flags for the Centrino 1000 NIC. 2014-05-10 05:56:10 +00:00
Christian Brueffer
48a098e360 Add a missing comma between error message definitions.
CID:		1199266
Found with:	Coverity Prevent(tm)
MFC after:	1 week
2014-04-13 18:51:39 +00:00
Adrian Chadd
26bb40d804 Handle the newer-style bluetooth message format from the (at least)
Centrino 2230 firmware.

This fixes the general statistics block to be actually valid.

I've verified this by contrasting the output of iwnstats before and
after the change.  The general block is now correct.

Tested:

* Intel 5100 (old format stats message)
* Intel 2230 (new format stats message)
2014-03-04 08:01:56 +00:00
Adrian Chadd
0840bbcdf3 Add the bluetooth information structs to the firmware RX statistics message.
It turns out that there's a variant format of the RX statisitcs notification
from the intel firmware.  It's even more whacked - the non-BT variant has
bluetooth fields; apparently some later NICs return even _more_ bluetooth
related fields.

I'll commit the statistics structure changes here - it's a no-op for the
driver.  I'll later teach the driver code to populate a statistics structure
from the received message after reformatting things correctly.

I don't _think_ it's going to fix anything related to sensitivity programming
as the CCK/OFDM (non-11n) fields are in the same place for both formats.
But the HT structure and the general statistics aren't in the same place.

I'll go find some NIC(s) that spit out the other format and when I find one,
I'll go and update the driver to handle things correctly.

Tested:

* Intel 5100 (which returns the legacy, non-BT format)

Obtained from:	Linux iwlwifi
2014-03-01 02:57:22 +00:00
Adrian Chadd
49f79cfd5f Track and expose the latest statistics from the firmware.
Tested:

* Intel Centrino 6205
2014-02-24 02:37:04 +00:00
Adrian Chadd
892ebbbd84 Reserve a bit for statistics debugging. I'll hopefully use it soon. 2014-02-24 02:13:20 +00:00
Adrian Chadd
2e9afe9597 Fix a typo. 2014-02-23 23:13:53 +00:00
Adrian Chadd
d31cb7480b Fix indentation. 2014-02-23 21:43:15 +00:00
Gavin Atkinson
e4b141d4eb Add support for the Intel Centrino Wireless-N 135 chipset.
MFC after:	2 weeks
2014-01-08 13:59:33 +00:00
Kevin Lo
5945b5f5ab Rename definition of IEEE80211_FC1_WEP to IEEE80211_FC1_PROTECTED.
The origin of WEP comes from IEEE Std 802.11-1997 where it defines
whether the frame body of MAC frame has been encrypted using WEP
algorithm or not.
IEEE Std. 802.11-2007 changes WEP to Protected Frame, indicates
whether the frame is protected by a cryptographic encapsulation
algorithm.

Reviewed by:	adrian, rpaulo
2014-01-08 08:06:56 +00:00
Adrian Chadd
25a9c4c83a Move the retune notification print to a debug print.
Yes, I still have to do the retune.  But I'm giving in to many people
pestering me (very gently!) about this.

Tested:

* Intel Centrino 6205
2014-01-05 00:46:31 +00:00
Marius Strobl
e0c758686c - Probe with BUS_PROBE_DEFAULT instead of 0.
- Remove clearing PCIM_CMD_INTxDIS; pci(4) will do that as appropriate since
  r189367.

MFC after:	1 week
2013-12-30 16:46:50 +00:00
Marius Strobl
7b23a8b2c0 - There's no need to keep track of resource IDs.
- Simplify MSI allocation and release. For a single one, we don't need to
  fiddle with the MSI count and pci_release_msi(9) is smart enough to just
  do nothing in case of INTx.
- Don't allocate MSI as RF_SHAREABLE.
- Use DEVMETHOD_END.
- Use NULL instead of 0 for pointers.

MFC after:	1 week
2013-12-29 19:32:27 +00:00
Adrian Chadd
13b535ff9c Fix the Intel 6150 support.
This chip doesn't require the temperature sensor offset, either v1 or
v2.  Doing so causes the initial calibration test to fail.

Tested:

* Intel Centrino 6150
2013-12-28 05:50:53 +00:00
Adrian Chadd
929f6e3c8b Add some initial support for the Intel 6235.
Tested:

* Intel 5100
* Intel 6235

Obtained from:	mav, others
2013-12-09 03:40:02 +00:00
Adrian Chadd
a22cfd04e7 Refactor out the scan id and scan vap as part of the scan work.
Make the scan state optional - we'll obviously need a vap, but we now
won't require the scan state.  the only thing the scan state is needed
for is to check for the list of SSIDs to scan - which we can now
just plain ignore by passing in NULL as the scan state pointer.

Tested:

* Intel 5100 (STA)
2013-12-07 08:32:15 +00:00
Adrian Chadd
6c214017d0 Add a channel parameter to iwn_scan().
This is in preparation for being able to use iwn_scan() to do an off
channel scan to reset the RF tuning.

It should be a no-op.

Tested:

* Intel 5100 (STA)
2013-12-07 08:25:24 +00:00
Adrian Chadd
b860b2a9aa Refactor out the scan channel to be assigned early on in iwn_scan()
rather than it all being a mess of 'c' and 'ic->ic_curchan'.

Tested:

* Intel 5100 (STA)
2013-12-07 08:20:24 +00:00
Adrian Chadd
92d7ab9562 Begin fleshing out some code to handle tracking PLCP error rates
in preparation for the scan based retune logic.

The linux iwlwifi driver does a rescan (onto a non-active channel)
to force an RF retune when the PLCP error rates exceed a certain threshold.

* Add code to track HT PLCP rate errors;
* Separate out the PLCP error count fetch and update so the delta
  can be used when checking for PLCP error rates;
* Implement the PLCP error logic from iwlwifi;
* For now, just print out whenever the error rate exceeds the
  threshold.

The actual scan based retune will take a bit more effort; the scan
command code right now assumes that a scan state is passed in.
This does need to change to be more flexible (both for this and
in preparation for scanning multiple channels at once.)

Tested:

* 5100 (STA mode)
* 2200 (STA mode)
* 2230 (STA mode)
2013-12-07 08:03:10 +00:00
Adrian Chadd
90a4274834 Add some PLCP thresholds from Linux iwlwifi driver in preparation for
working on some RF tuning issues.

The linux iwlwifi driver has these thresholds which they use to see
if there are PLCP errors over a certain interval.  If they hit this,
they trigger a single-channel (different from active channels!)
scan to retune the RF front-end.
2013-12-07 06:45:09 +00:00
Adrian Chadd
352c016bc1 * Sort the copyright lines by date
* Ok ok, I've touched this enough to claim part of it.
2013-12-02 05:45:11 +00:00
Adrian Chadd
fee842aa2a Overhaul the iwn(4) scan infrastructure to be slightly more "correct"
for these chipsets.

* Correctly set the active/passive flag in the scan request - this is
  NOT a "is the channel active|passive"; it's to do with whether we
  have an SSID to actively scan for or not.  The firmware takes care
  of the active/passive setup of the channel.

* Calculate the active/passive dwell time based on the beacon interval
  and the channel mode, rather than using a hard coded value.

* For now, hardcode the scan service_time.  It's defined as:

  31:22 - number of beacon intervals to come back onto the home channel
          for;
  0:21  - time (microseconds) to come back onto the home channel for.

  When doing an active scan when the NIC is active (whether we're associated
  or not - it only matters if we've setup the NIC to a destination or not)
  this determines how much time to stay on the home channel for when
  scanning.  We can tune this based on the amount of active traffic.

  For now it's 4 beacon intervals and 100 microseconds.

* Fix the "good crc threshold" setting.  It differs based on the NIC
  firmware.  Some older firmware required a workaround; the later
  firmware instead treats the field as a flag.

* Enforce that we are not sending a scan command if one is already
  pending.  Any time this is done is a bug and it absolutely needs
  to be fixed - so be very loud.

* Add the SCAN flag to a few debug messages that are scan related but
  only occuring under STATE.

Now, this does get noisy when you're scanning in an actively busy 2GHz
network as the firmware (for reason I don't quite yet understand) seems
hell bent on staying on some passive channels longer than it should.
However, it should eventually recover and complete the scan.

This is a work in progress; please let me know if things get stuck or
if things improve!

Tested:

* intel centrino 2200
* intel centrino 2230
* intel 6200
* intel 5100
* intel 4965 (gets upset, but that's a known issue)

Obtained from:	linux iwlwifi
2013-12-02 03:59:45 +00:00
Adrian Chadd
d27bb17b9c Log the rx ring offset as part of the debug message. 2013-12-02 03:49:33 +00:00
Adrian Chadd
30ca148cf7 Oops - fix bad indent. Sorry! 2013-12-02 03:43:37 +00:00
Adrian Chadd
9d8e8cd665 Add some sanity checks to the TLV fetch.
Obtained from:	Linux iwlwifi
2013-12-02 03:42:39 +00:00
Adrian Chadd
c6f810c6a4 Add some code to double-check whether we're correctly populating the
TX ring according to what the firmware requires.

The firmware requires A-MPDU sub-frames to be at a very specific ring
offset - that is, the ring slot offset should be (seqno % 256.)

This holds for every NIC I've tested thus far except the 4965,
which starts erroring out here shortly before the firmware panics.
Which is good, it's doing what it's supposed to (read: capture that
we've screwed up somewhere.)

The specifics about getting this stuff right:

* the initial seqno allocation should match up with the ringid.
* .. yes, this means we can start at a ring offset that isn't zero.
* .. because we program the start seqno in the firmware message
  to setup the AC.
* The initial seqno allocation may be non-zero _and_ frames may be
  being transmitted during a-mpdu negotiation.  I faced similar
  issues on ath(4) and had to software queue frames to that node+TID
  during A-MPDU negotiation.
* seqno allocation should be in lockstep with ring increments.
* If we fail to transmit some segment, no, we shouldn't reuse that
  ring slot.  We should just transmit a BAR (which we aren't yet
  doing, sigh) and move onto the next seqno.
* In theory there shouldn't be any holes in the seqno space when
  we are transmitting frames.

Tested:

* 4965 (throws problems, so yes we have to fix this);
* 5100 (seems ok);
* 6200 (seems ok);
* 2200 (seems ok);
* 2230 (seems ok).
2013-12-02 03:40:51 +00:00
Eitan Adler
7a22215c53 Fix undefined behavior: (1 << 31) is not defined as 1 is an int and this
shifts into the sign bit.  Instead use (1U << 31) which gets the
expected result.

This fix is not ideal as it assumes a 32 bit int, but does fix the issue
for most cases.

A similar change was made in OpenBSD.

Discussed with:	-arch, rdivacky
Reviewed by:	cperciva
2013-11-30 22:17:27 +00:00
Adrian Chadd
011a151b50 Disable this debugging - it's far too verbose when doing TX rate debugging. 2013-11-29 22:36:00 +00:00
Adrian Chadd
2f1b79906d Use the correct endian-ness accessor for this TLV field.
(It's coming from firmware and thus it's defined as little-endian.)
2013-11-29 22:35:24 +00:00
Adrian Chadd
3b64bbd285 Add definitions for the microcode TLV flags entry (type 18.)
This isn't used anywhere just yet!

Obtained from:	Linux iwlwifi
2013-11-26 08:58:08 +00:00
Adrian Chadd
b9066e384d Add a new debug section. 2013-11-26 08:57:25 +00:00
Eitan Adler
c1e1ddd57f Centrino Wireless-N 2200 does not have bluetooth support. 2013-11-16 04:29:02 +00:00
Adrian Chadd
6171f42c9f Fix (I think!) the scan timeouts on the intel NICs.
This field needs to be (a) set, and (b) greater than the other timeouts
(passive, active, maxquiet, etc.)  It also is in microseconds, not
milliseconds.

I hope this will fix the scan hangs that people are seeing.

Obtained from:	Linux iwlwifi
2013-11-14 07:27:00 +00:00
Adrian Chadd
1650f039d0 This is "scan_flags" from Linux. 2013-11-14 07:21:09 +00:00
Adrian Chadd
48777c4c5a Leave a note that the 5300 is a 3x3 NIC. 2013-11-13 09:32:11 +00:00
Adrian Chadd
ade5fbb745 Correctly initialise the 2-chain antenna mask in the link quality table.
The previous code simply hard-coded IWN_ANT_AB which is only correct for
some of the NICs.

Now, if the NIC is a 1-stream TX, you need to set IWN_ANT_AB and _not_
just a single antenna.  The Intel 5100 firmware panics the moment the
link quality table is updated.

So!

* no secondary antenna? Set it to IWN_ANT_AB;
* two-stream device? Transmit on the full transmit antenna configuration.

Tested:

* Intel 5100, STA
* Intel 2200 (eadler)

Obtained from:	Linux iwlwifi
2013-11-13 07:09:00 +00:00
Adrian Chadd
a704cc7f5f Commit over some work to prepare the iwn(4) driver for further chipset
support.

* Extend the hardware base_params structure to include a bunch of hardware
  flags indicating what is and isn't supported.

* Convert a bunch of the initial hardware configuration conditionals to
  consult the base_params structure.

* Add new calibration code for temperature calibration for the Centrino 2xxx
  series NICs.

* Add new bluetooth coexistence code for Centrino 2xxx series NICs.

* For NICs that support PAN (personal area networking), use a different
  transmit queue and command queue setup, in preparation for said
  PAN support.

* Extend the calibration array in iwn_softc to include enough space for
  the new calibration types.

Tested (by myself, if not mentioned):

* Intel 4965
* Intel 5100
* Intel 6150
* Intel 2230
* Intel 2200 (eadler)
* Intel 1030
* Intel 6200
* Intel 6230
* Intel 6250
* Intel 6150
* Intel 100

What doesn't work:

* Intel 6235 - fails in calibration at startup

TODO:

* Testing on Intel 53xx series hardware

Submitted by:	Cedric Gross <cg@cgross.info>
2013-11-12 05:58:23 +00:00
Adrian Chadd
1c4ec1b709 Fix up the link quality lookup and re-enable multi-rate retry.
This is a terrible solution that at least behaves mostly correctly.

It walks the currently active rate table looking for rates to match.
It assumes that the code matches the setup path in the link quality
setup code (much like the previous, much simpler but even more hackish
math did.)

It's O(n), but n<15, so we're okay for the time being.

Tested:

* Intel 5100, STA - 11a, 11n, 11bg modes.
2013-11-12 05:49:01 +00:00
Adrian Chadd
f1705377c5 Grr. For some odd reason, setting this to a single antenna on my 5100
(which is a 1x2 device) panics the firmware.

But, for some 6xxx devices that require IWN_ANT_BC for the TX chainmask,
the link quality entries need to represent _that_.

So, revert this for now until I can figure out what is supposed to be
going on.
2013-11-12 05:08:24 +00:00
Adrian Chadd
a67bb1257f Use the negotiated HT rate set when generating the link quality table. 2013-11-12 05:00:18 +00:00
Adrian Chadd
47b078db0b Comment what 'mimo' does in the link quality table. 2013-11-12 04:57:31 +00:00
Adrian Chadd
42e0f858ad Don't default to antennas A+B; some NICs use Antennas B+C to transmit. 2013-11-12 04:56:00 +00:00
Adrian Chadd
825e355d1d If A-MPDU transmission fails entirely, then no BA is received from the
NIC and pushed up to the driver.  Unfortunately this means there's
no rate control notification done.  Thus, if the rate control code
makes a decision that hits a crappy rate that can't succeed, the
rate code would never lower the rate and packet loss would continue.

So, fake some rate control notification in this case.
2013-11-11 09:08:22 +00:00
Adrian Chadd
559abc28c0 Replace the hard-coded RX queue value check with IWN_UNSOLICITED_RX_NOTIF. 2013-11-11 08:56:40 +00:00
Adrian Chadd
6abfec88c3 Fix off-by-one. Sorry! 2013-11-11 08:55:38 +00:00
Adrian Chadd
8ea24d528f Use IWN_NBANDS rather than a hard-coded limit.
Tested:

* Intel 5100, STA
2013-11-11 08:54:45 +00:00
Adrian Chadd
7c1c3741c3 Send EAPOL frames at the management rate, not the data rate.
Without this, a far away station with low signal strength would
associate using the management rate (by default the lowest rate)
and then the EAPOL frames would go out at the current AMRR best
guess.  This would result in association failing authentication.

Tested:

* Intel 5100, STA
* Intel 2230, STA
2013-11-11 08:53:20 +00:00
Adrian Chadd
4cfb1a088d Add some new driver definitions as part of the chip support updates:
This is a no-op for now!

* Add a new flag value for "there are no extra bits" for some random
  field;

* Add a definition for the maximum number of calibration entries in
  the calibration data cache in iwn_softc.  It's not yet used.

* Add regulatory bands for the 2030 NIC.

Submitted by:	Cedric Gross <cg@cgross.info>
2013-11-09 06:30:09 +00:00
Adrian Chadd
2a6433bc56 Add Bluetooth/PAN (personal area networking) commands.
Submitted by:	Cedric Gross <cg@cgross.info>
2013-11-04 05:52:42 +00:00
Adrian Chadd
fd070dd18f Add device ids for the Centrino 2x00 devices.
Submitted by:	Cedric Gross <cg@cgross.info>
2013-11-04 05:40:19 +00:00
Adrian Chadd
fbab6d4db3 Remove trailing whitespace.
Submitted by:	Cedric Gross <cg@cgross.info>
2013-11-04 04:10:36 +00:00
Adrian Chadd
cea884bf7d Don't base the rate table selection based on the channel mode;
it needs to check whether there are rate entries in there or not.

PR:		kern/183428
2013-10-31 02:21:48 +00:00
Adrian Chadd
e15cc8dca6 Fix the PLCP lookup code in iwn(4) to base the 11n decision on whether
the rate is 11n, rather than whether the channel is 11n.

This correctly allows the PLCP lookup code to return the legacy rates
even on an 11n channel.

PR:		kern/183430
2013-10-29 04:03:00 +00:00
Gleb Smirnoff
76039bc84f The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by:	Netflix
Sponsored by:	Nginx, Inc.
2013-10-26 17:58:36 +00:00
Adrian Chadd
494571986b add 0x8b, lifted from Linux iwlegacy/commands.h
This is "STA invalid". I saw it during some 4965 testing (kern/183260)
and I still have no idea what is causing it.

Obtained from:	Linux drivers/net/wireless/iwlegacy
2013-10-26 01:17:54 +00:00
Adrian Chadd
8cf53c1244 Begin fleshing out a knob to enable/disable bluetooth coexistence.
Some firmware versions seem to get very unhappy if they're sent btcoex
commands when they don't actually have bluetooth hardware in them.
So, disable sending them those commands.

Tested:

* 5100 (which has bluetooth, no problems)
* 4965 (which doesn't have bluetooth, but didn't seem to crash)
* 6200 (no bluetooth, seems to get unhappy being sent bluetooth commands.)
2013-10-25 19:46:52 +00:00
Adrian Chadd
2e6fe9b630 Temporarily disable multi-rate retry (link quality) and eliminate rate
index lookups.

* My recent(ish) change to iwn(4) and the net80211 rate control API to
  support 11n rates broke the link quality table use.  So, until I or
  someone else decides to fix it, let's just disable it for now.

* Teach iwn_tx_data_raw() to use the iwn_rate_to_plcp() function.

* Eliminate two uses of the net80211 rate index lookup functions - they
  are only for legacy rates and they're not needed here.

This fixes some invalid looking rate control TX issues that showed up
on my 4965 but it doesn't fix the two TX hangs I've noticed. Those look
like DMA related issues.

Tested:

* 4965, STA mode
* 5100, STA mode
2013-10-25 19:44:53 +00:00
Adrian Chadd
8a5e5a978d Break out the debug code into a new include file in preparation for
some more iwn work.
2013-10-24 01:03:42 +00:00
Adrian Chadd
b876a4a384 Add #ifdef wrapper around definitions so they aren't included multiple
times.
2013-10-24 01:02:54 +00:00
Adrian Chadd
e733e239ee Migrate iwn(4) to use the new ieee80211_tx_complete() API.
Tested:

* Intel 5100, STA mode
2013-08-29 13:56:44 +00:00
Scott Long
c68534f1d5 Update PCI drivers to no longer look at the MEMIO-enabled bit in the PCI
command register.  The lazy BAR allocation code in FreeBSD sometimes
disables this bit when it detects a range conflict, and will re-enable
it on demand when a driver allocates the BAR.  Thus, the bit is no longer
a reliable indication of capability, and should not be checked.  This
results in the elimination of a lot of code from drivers, and also gives
the opportunity to simplify a lot of drivers to use a helper API to set
the busmaster enable bit.

This changes fixes some recent reports of disk controllers and their
associated drives/enclosures disappearing during boot.

Submitted by:	jhb
Reviewed by:	jfv, marius, achadd, achim
MFC after:	1 day
2013-08-12 23:30:01 +00:00
Adrian Chadd
899de76d2d Use the correct structure size when flipping the BT coex state machine.
This showed up when doing some basic testing on the Intel 6230.

Tested:

* Intel 6230, STA mode
2013-08-11 03:39:28 +00:00
Adrian Chadd
da8848ffb4 Prepare for the PAN (personal area network) support for iwn(4).
* Break out the single, static RX context into a pointer, and ..
* .. extend it to two RX contexts - a default and a PAN context.

Whilst here, add a few extra fields in preparation for further iwn(4)
work.

Tested:

* Intel 4965, STA mode - same level of stability
* Intel 5100, STA mode - no change

Submitted by:	Cedric Gross <cg@gross.info>
2013-08-11 01:57:54 +00:00
Adrian Chadd
4030a4b2a3 Cap the number of streams supported to two for now.
I haven't yet reviewed the Intel driver(s) in more depth to see if
there are 1x1 NICs that report they support 2 transmit/receive chains..
if so then we'll have to update this.

Tested:

* Intel 4965, which is a 2x2 device with 3 RX and 2 TX chains.

PR:		kern/181132
2013-08-08 05:52:41 +00:00
Hiren Panchasara
c29173eb94 Fixing a typo.
Approved by:	sbruno (mentor, implicit)
2013-08-04 19:54:47 +00:00
Adrian Chadd
f86392791f Add in some definitions required for later iwn(4) device support.
This also clarifies a few existing fields.

Tested:

* Intel 5100

Submitted by:	Cedric GROSS <cg@gross.info>
2013-08-02 21:28:36 +00:00
Adrian Chadd
a5582fae07 Break out the iwn(4) device IDs into if_iwn_devid.h, as well as add
IDs for new devices.

* Add new device IDs
* Extend the ID probe code to include the newer range of bits used
  by later model devices

Tested:

* Intel 5100, STA mode

TODO:

* Test on Intel 4965, just to be sure

Submitted by:	Cedric GROSS <cg@gross.info>
2013-08-02 21:23:28 +00:00
Adrian Chadd
21f8dc458a Now that conf/options knows about if_iwn.h, add it to if_iwn.c.
This allows for IWN_DEBUG (and maybe more stuff later) to be a build
time configure option.
2013-08-01 21:50:50 +00:00
Adrian Chadd
38b1a25dfd iwn(4) debugging improvements.
* Add in some new register debugging under IWN_DEBUG_REGISTER
* Make IWN_DEBUG an option now for building.  I'll chase this up
  with a commit to 'options' soon.

Submitted by:	Cedric GROSS <cg@cgross.info>
2013-08-01 21:45:30 +00:00
Adrian Chadd
af4791e31f Implement some function tracing.
Submitted by:	Cedric GROSS <cg@cgross.info>
2013-07-27 14:58:23 +00:00
Adrian Chadd
98161e5ceb Support setting up the iwn debug flags during probe/attach by
checking "hint.iwn.X.debug".

Submitted by:	Cedric GROSS <cg@cgross.info>
2013-07-24 13:31:31 +00:00
Adrian Chadd
87459bff75 Add new IDs for The Intel 2230 wireless NIC.
Submitted by:	Cedric GROSS <cg@cgross.info>
2013-07-24 13:20:45 +00:00
Adrian Chadd
f8bf74f232 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
2013-07-04 21:16:49 +00:00
Adrian Chadd
2fc5db16ed Enable the station-side power management flag.
It's not enabled by default in net80211 so this is a no-op unless
if you enable it (ifconfig wlan0 powersave).

Tested:

* iwn0: <Intel WiFi Link 5100> mem 0xf4300000-0xf4301fff irq 17 at device 0.0 on pci3

TODO:

* .. test on all the other NICs
* See if I have to disable it during scan and such
* Make it configurable live, rather than only after it's done its initial
  receive calibration.
2013-07-04 19:45:34 +00:00
Hiren Panchasara
50c5badfaa Fixing incorrect id for Intel Centrino Wireless-N 130.
PR:             kern/180094
Submitted by:   Cedric <cg@cgross.info>
Approved by:    sbruno (mentor)
MFC after:      3 weeks
2013-06-30 01:05:24 +00:00
Gleb Smirnoff
c6499eccad Mechanically substitute flags from historic mbuf allocator with
malloc(9) flags in sys/dev.
2012-12-04 09:32:43 +00:00
Adrian Chadd
6ef131b446 Include opt_wlan.h so the net80211 RX debug API compiles correctly. 2012-11-30 03:14:11 +00:00