Commit Graph

323 Commits

Author SHA1 Message Date
Adrian Chadd
f4ac78a284 rum(4): fix stats interpretation in rum_ratectl_task()
Testing:

* WUSB54GC, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3690
2015-10-03 22:26:59 +00:00
Adrian Chadd
342ced03e2 rum(4): set short/long retry limits
Now device will use retry limit, which is set via 'ifconfig <interface>
maxretry <number>'.

Tested:

* Tested on WUSB54GC, STA mode.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3689
2015-10-03 22:22:26 +00:00
Adrian Chadd
c42e124eca rum(4): fix sequence number generation.
* drop erroneous RT2573_TX_MORE_FRAG flag;
* provide RT2573_TX_HWSEQ where needed.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3672
2015-10-03 22:15:59 +00:00
Adrian Chadd
210ab3c258 net80211: drop ieee80211_beacon_offsets parameter from ieee80211_beacon_alloc() and ieee80211_beacon_update()
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3659
2015-10-03 22:12:25 +00:00
Adrian Chadd
bc813c40bf net80211: drop redundant 3rd parameter from iv_key_set().
The MAC can be fetched from the key struct.

I added the ndis updates to make it compile.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3657
2015-10-03 21:48:27 +00:00
Adrian Chadd
ed5711a11b rum(4): drop unused 'node id' parameter.
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3655
2015-10-03 20:53:10 +00:00
Adrian Chadd
2cb9ef8d38 rum(4): add support for hardware encryption (WEP, TKIP and CCMP).
This diff includes:

* Transmitter Addresses, Keys and TKIP MIC addition to the Security Key Table.
* Proper SEC Control Registers initialization and maintenance.
* Additional flags and values in TX descriptor, which are required for encryption support.
* Error checking in RX path.

Tested:

* Tested on WUSB54GC, STA (WEP, TKIP, CCMP), HOSTAP (CCMP) and IBSS (CCMP, WPA-None) modes.
* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode (CCMP+TKIP)

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3640
2015-10-03 20:49:08 +00:00
Adrian Chadd
0e3b4c60e4 rum(4): implement iv_update_beacon call (fixes client power save support).
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3632
2015-10-03 20:45:43 +00:00
Adrian Chadd
a19dbd8d6f rum(4): attach rum_update_slot to ic_updateslot.
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3631
2015-10-03 20:44:16 +00:00
Adrian Chadd
b780f86455 rum(4): split rum_prepare_beacon() into 'alloc' and 'set' stages
Note: I manually had to merge this; I merged in the "put beacon_offsets
into vap" commit before this.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3628
2015-10-03 17:49:11 +00:00
Adrian Chadd
50a31b4887 rum(4): add support for AHDEMO mode.
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3627
2015-10-03 17:34:11 +00:00
Adrian Chadd
42769826d3 rum(4): simplify rum_set_bssid(), rum_set_macaddr() and rum_update_promisc()
Tested:

* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3626
2015-10-03 17:30:57 +00:00
Adrian Chadd
1ba67b1130 rum(4): do not corrupt MAC address
Don't override the NIC MAC address with an overridden MAC address for
a VAP.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3625
2015-10-03 17:18:35 +00:00
Adrian Chadd
aa81f85365 rum(4): add error handling for rum_enable_tsf_sync() and rum_prepare_beacon()
Tested:

* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode
  Note: haven't tested AP mode yet; will do once the rest of the
  AP mode / power save commits are in.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3624
2015-10-03 17:11:21 +00:00
Adrian Chadd
6095f7cad3 rum(4): move some code from rum_init() into separate function.
Tested:

* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3623
2015-10-03 16:37:38 +00:00
Adrian Chadd
0698c0b3d1 rum(4): add error handling in initialization path
Tested:

* Tested on WUSB54GC, STA mode.
* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3622
2015-10-03 16:21:06 +00:00
Adrian Chadd
b2a76342fd rum(4): simplify error handling rum_raw_xmit()
Move the mbuf free responsibility to the caller of the hardware xmit
function, not the hardware xmit function itself.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3621
2015-10-03 15:58:00 +00:00
Adrian Chadd
aca2cf3032 rum(4): check mbuf size before accessing its contents
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3610
2015-10-03 15:52:58 +00:00
Adrian Chadd
a6ccd477ac rum(4): add TSF field into radiotap headers
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3607
2015-10-03 15:49:55 +00:00
Adrian Chadd
99feb20233 run(4): Add initial support for IBSS merge.
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3592
2015-10-03 15:48:21 +00:00
Adrian Chadd
30c00a2d89 Remove beacon offsets usage from if_rum.
Differential Revision: https://reviews.freebsd.org/D3658
2015-10-03 06:35:17 +00:00
Adrian Chadd
3eaa0cd531 urtwn(4): fix sequence numbering for QoS frames
Tested:

* urtwn0: MAC/BB RTL8188EU, RF 6052 1T1R, STA mode

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3684
2015-10-03 06:07:01 +00:00
Adrian Chadd
1517a7ba0b ural(4): reduce copy-paste in ural_newstate().
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3656
2015-10-03 05:55:16 +00:00
Adrian Chadd
f28c2f5e54 rum(4): add command queue for running sleepable tasks in non-sleepable contexts
Tested:

* Tested on WUSB54GC, STA mode.
* rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3629
2015-10-03 05:46:35 +00:00
Adrian Chadd
e7b7db3d59 rum(4): some non-functional changes / cleanup
* Remove unused sc_txtap_len/sc_rxtap_len fields.
* Remove unused ackrate variable.
* Remove unneded warning in rum_update_mcast().
* Use nitems().
* Replace some hardcoded values for RT2573_MAC_CSR1 register.
* Remove second argument for RUM_LOCK_ASSERT() - it is always the same.

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3605
2015-10-03 05:44:05 +00:00
Adrian Chadd
d847071cf6 rum(4): sync rum_enable_tsf(_sync) with run(4).
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3611
2015-10-02 15:30:37 +00:00
Adrian Chadd
a05022b22c rum(4): create few wrappers.
Tested:

rum0: <Belkin Belkin 54g USB Network Adapter, class 0/0, rev 2.00/0.01, addr 22> on usbus0
rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3609
2015-10-02 15:28:44 +00:00
Adrian Chadd
cc9ae76160 rum(4): move common part of rum_bbp_write() and rum_bbp_read() into rum_bbp_busy().
Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3608
2015-10-02 15:26:33 +00:00
Adrian Chadd
6d8043213d rum(4): reduce code duplication.
Tested:

rum0: <Belkin Belkin 54g USB Network Adapter, class 0/0, rev 2.00/0.01, addr 21> on usbus0
rum0: MAC/BBP RT2573 (rev 0x2573a), RF RT2528

Submitted by:	<s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3606
2015-10-02 15:22:00 +00:00
Adrian Chadd
a3767659f0 modify the rssi logic a bit to actually return a useful rssi.
The fullmac firmware doesn't seem to populate a useful rssi indicator
in the RX descriptor, so if one plotted said values, they'd basically
look like garbage.

The reference driver implements a "get current rssi" firmware command
which I guess is really meant for station operation only (as hostap
operation would need rssi per station, not a single firmware read.)

So:

* populate sc_currssi during each calibration run;
* use this in the RX path instead of trying to reconstruct the RSSI
  value and passing it around as a pointer;
* do up a quick hack to map the rssi hardware value to some useful
  signal level;
* the survey results provide an RSSI value between 0..100, so just
  do another quick hack to map it into some usefulish signal level;
* supply a faked noise floor - I haven't yet found how to pull it
  out of the firmware.

The scan results and the station RSSI information is now more useful
for indicating signal strength / distance.
2015-09-30 05:19:16 +00:00
Adrian Chadd
85dafc6977 rsu(4): Add support for 1T2R and 2T2R NICs.
This logic is mostly crimed from the reference driver and the linux
r92su driver.

I verified that it (a) worked on the rsu hardware I have, and (b)
did traffic testing whilst watching what ath(4) sent as a hostap.
It successfully sent MCS8..15 rates (which requires 2-stream reception)
as well as MCS0..7 (which is 1-stream.)

Tested:

* RTL8712, 1T1R NIC, MCS rates 0..7.
* RTL8712, 1T2R NIC, MCS rates 0..15

TODO:

* Find a 2T2R NIC!
2015-09-29 06:56:00 +00:00
Adrian Chadd
24c2763fb1 urtwn driver fixes - missing include, free node references, shut down xfers first
* include opt_wlan.h like a good little wlan driver;
* add a function to free the mbufq /and/ the node references on it, or we will leak
  said node references;
* free the mbufq upon NIC shutdown otherwise we may end up with a full list that
  we never begin transmit work on, and thus never drain it;
* .. which frees it upon NIC detach too;
* ensure urtwn_start() gets called after the completion of frame TX even if the
  pending queue is empty, otherwise transmit will stall.  It's highly unlikely that
  the usb tx queue would be empty whilst the incoming send queue is full, but hey,
  who knows.

This passes some iperf testing with and without the NIC being actively removed during
said active iperf test.

Tested:

* urtwn0: MAC/BB RTL8188EU, RF 6052 1T1R ; STA mode
2015-09-29 05:03:24 +00:00
Adrian Chadd
3a8545c312 include opt_wlan.h . Tsk adrian. 2015-09-28 01:16:44 +00:00
Adrian Chadd
ac9e537ce0 Free the TX/RX list buffers /before/ tearing down net80211 state.
Otherwise buffers in the RX queue get freed with their parent vap
being gone and you end up with a juicy kernel panic.
2015-09-26 22:20:30 +00:00
Adrian Chadd
74d7b9a832 * Add 11n HT40 support - i needed to send both HTINFO and HTCAP fields
in the join message so the firmware would pick it up.

* Strip out the direct hardware fiddling for 40MHz mode - the firmware
  we're using doesn't require it (the rtl8712su firmware does; it
  is less 'fullmac' than what we're using.)

* Fix the mbuf handling during errors - rsu_tx shouldn't free mbufs;
  it's up to the caller to do so.  This brings it in line with
  what other drivers do or should be doing.

Tested:

* RTL8712, HT40 channel, STA mode (during this commit)
2015-09-26 07:25:53 +00:00
Adrian Chadd
0cf00015be net80211: include one copy of struct ieee80211_beacon_offsets into ieee80211vap
Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D3658
2015-09-22 06:34:07 +00:00
Adrian Chadd
44369387a1 Send a power command to the firmware to shut down the radio as well
during rsu_stop().
2015-09-22 05:48:51 +00:00
Adrian Chadd
6acf853d7a Begin fleshing out basic power-on / power-off and A-MPDU TX support.
* Add a new method to control NIC poweron / network-sleep / power off;
* Add in A-MPDU TX negotiation support, but comment it out because it
  does break TX traffic;
* blank out the tx buffer before sending a firmware message, just in case;
* go into network-sleep once associated;

TODO:

* figure out why ampdu negotiation isn't working and breaking TX traffic,
  then enable it.
2015-09-22 02:57:18 +00:00
Adrian Chadd
82e8c646b4 net80211 & wireless drivers: remove duplicate defines (noop)
- IEEE80211_DIR_DSTODS(wh) -> IEEE80211_IS_DSTODS(wh).
- N(a) -> nitems(a).
- Remove LE_READ_2(p)/LE_READ_4(p) definitions (and include ieee80211_input.h instead).
- <drvname>_TXOP_TO_US(txop) -> IEEE80211_TXOP_TO_US(txop).
- Put IEEE80211_RV(v) into ieee80211_proto.h and remove local RV(v) definitions.

Submitted by:   Andriy Voskoboinyk <s3erios@gmail.com>
Differential Revision:  https://reviews.freebsd.org/D3705
2015-09-22 02:48:59 +00:00
Adrian Chadd
39089f06bf Flip on 11n by default; update TODO items. 2015-09-21 02:32:11 +00:00
Adrian Chadd
77435f1835 Convert if_rsu to use a deferred transmit task rather than using rsu_start()
to do it directly.

Ensure that we re-queue starting transmit upon TX completion.

This solves two issues:

* It stops tx stalls - before this, if the transmit path filled the
  mbuf queue then it'd never start another transmit.

* It enforces ordering - this is very required for 802.11n which
  requires frames to be transmitted in the order they're queued.
  Since everything remotely involved in USB has an unlock/thing/relock
  pattern with that mutex, the only way to guarantee TX ordering is
  to 100% defer it into a separate thread.

This now survives an iperf test and gets a reliable 30mbit/sec.
2015-09-21 02:30:22 +00:00
Adrian Chadd
829e0b0b84 Drain the mbuf queue upon rsu_stop().
Correctly (I hope!) remove net80211 references before doing so.
Just doing a dumb mbufq drain isn't enough.

If enough traffic occurs and the mbuf queue fills up then transmit
stalls (which I'm not fixing in this commit!) but then the mbuf queue
stays full until the driver is removed.  There's also the net80211
node refcounting leak.

This just ensures that during rsu_stop and detach the mbuf queue
is purged (and references!) so the queue-full situation can be
recovered from.
2015-09-21 02:12:01 +00:00
Adrian Chadd
3d07cc29cf Disable HT40 in if_rsu for now. There's something missing in the HT40
setup pieces and so (at least) transmit doesn't work.

It'll just fall back to being a straight HT20 device and negotiate
HT20 only.

Tested by: Idwer Vollering <vidwer@gmail.com>
2015-09-20 22:52:40 +00:00
Adrian Chadd
23386fa4b6 Add in a temporary (hah!) workaround for net80211 scanning versus NIC
requirements.

Don't start the opmode and join path until a pending survey is finished.
This seems to reliably fix things.

Ideally I'd just finish off the net80211 pluggable scan stuff and implement
the methods here so if_rsu can just drive the scan machinery.
However, that's a .. later thing.

Whilst here, remove the getbuf debugging; it's okay to run out of transmit
buffers under load; it however isn't okay to not be able to send commands.
I'll fix that later.
2015-09-18 07:55:33 +00:00
Adrian Chadd
de76b5b7fe Refactor out the tx buffer free code into a routine, rsu_freebuf().
This makes it easier to add more transmit buffers, have different buffer
pools for things, etc.
2015-09-18 07:26:34 +00:00
Adrian Chadd
a12cbef7b0 Set AMPDU density/size parameters during vap creation.
Inspired from: Linux r92su
2015-09-18 05:59:15 +00:00
Adrian Chadd
237c4b4378 Add a very hacked up station only A-MPDU negotiation path.
This is enough to set things up; there are still lots of retransmits
seen but it's enough to get things working.
2015-09-18 05:03:01 +00:00
Adrian Chadd
4b9d9eee03 Add initial 11n support to if_rsu.
* Add a tunable to enable 11n if it's available, so to not anger people
  who upgrade.

  kenv hw.usb.rsu.enable_11n=1 before inserting the device.

* Add initial 11n htconfig bits;
* Enable 40MHz mode if it's available;
* Add 11n channels;
* Set 11n bits in the firmware.

It works for RX; I haven't tested TX aggregation just yet.
However the firmware doesn't do RX re-ordering, so I have to tie it into
the net80211 A-MPDU RX reorder path before I flip this on by default.

I've verified that I'm indeed actually seeing MCS 0->7 rates being received.
I haven't dug into whether it's actually transmitting 11n rates; I'll dig into
that later.
2015-09-18 04:12:11 +00:00
Adrian Chadd
a851c66778 .. oops, flip on QoS. 2015-09-17 07:04:15 +00:00
Adrian Chadd
b4d4079c85 Bring over the QoS logic from the Linux r92su driver.
* the tx descriptor TID is priority, not TID.
* the tx descriptor queue id mapping is separate from the
  TID/priority; rather than just "BE".

TODO:

* go and re-re-re-verify the queue mappings; the linux and openbsd
  mappings aren't exactly the same.  I need to verify all of this
  before I try to flip on 11n RX.
2015-09-17 04:45:29 +00:00