Commit Graph

427 Commits

Author SHA1 Message Date
Gavin Atkinson
109005cc14 Switch if_run.c to use a bitmap for debug levels rather than arbitrary
values. This more closely matches other wifi drivers in the tree.
The bitmap levels have been based closely on other drivers (primarily
[u]rtwn(4)) in the hope that one day these can be unified into a shared
wifi-debug framework.

This is the first step of several pieces of work I'm planning on doing
with the run(4) driver. I may well adjust and refine some of the debug
bitmaps at a later date.

Reviewed by:	adrian, avos
Differential Revision:	https://reviews.freebsd.org/D8704
2016-12-07 22:52:12 +00:00
Andriy Voskoboinyk
4a19d71238 net80211 + drivers: convert to ieee80211_crypto_get_key_wepidx().
Proposed by:	adrian
2016-12-07 22:16:07 +00:00
Andriy Voskoboinyk
8e61c3f8e3 rsu: fix printf format specifiers. 2016-12-06 06:12:01 +00:00
Andriy Voskoboinyk
31847d9434 rsu: add hardware crypto support (WEP, TKIP and CCMP).
This change includes firmware commands for key setup +
some additional checking via CAMREAD / CAMWRITE registers.
Nothing (except rsu_delete_key() for pairwise keys) is deferred;
to ensure that things are done in order rsu_set_key() will wait
until key deletion task will be finished.

Tested with Asus USB-N10 (all ciphers).

Differences from initial (reviewed) patch:
- Pause AC queues before disassociation - since CMD_DISCONNECT clears
crypto state all pending frames must be processed / dropped before it.
- Check sc_running flag before trying to set static keys.
- Clear key index from bitmap even when firmware command fails
(it will be invalidated via CAMWRITE anyway).

Reviewed by:	adrian, kevlo
Tested by:	kevlo
Differential Revision:	https://reviews.freebsd.org/D8706
2016-12-06 00:13:49 +00:00
Andriy Voskoboinyk
c057023b75 rsu: fix RSSI reporting, partially revert r288414.
- Append RCR_APP_PHYSTS bit after firmware loading - otherwise
firmware will reset the register and this modification will be lost.
(without it Rx PHY descriptor section will contain garbage).
- Check if R92S_RXDW0_PHYST bit is set (like it is done in rtwn(4)) -
even if infosz is non-zero the section may not contain anything useful.
- In case, if descriptor is absent (A-MPDU?) use last calibrated RSSI
(rtwn(4) uses RSSI from the previous (sub)frame; probably, this
approach should be used here too).

Tested with Asus USB-N10, STA mode.
2016-12-04 21:40:49 +00:00
Andriy Voskoboinyk
6127805391 rsu: fix frame processing in the Rx path (similar to r292207).
- Fill in Rx radiotap header correctly (for every packet in a chain;
not once per chain).
- Fix rate / flags fields in Rx radiotap.
- Add debug messages for discarded frames.
- Pass received control (< sizeof(struct ieee80211_frame)) frames
to net80211 (if allowed by device filter; cannot happen yet).

Tested with Asus USB-N10.

Differential Revision:	https://reviews.freebsd.org/D5723
2016-12-03 16:02:53 +00:00
Andriy Voskoboinyk
bcb071810a rsu: remove unused structures / variables. 2016-12-03 14:26:58 +00:00
Andriy Voskoboinyk
935b4fcccd rsu: add support for hardware multicast filter setup.
The algorithm is the same as in rtwn(4).

Tested with Asus USB-N10 (STA) + RTL8188CUS (AP).
2016-11-27 18:06:03 +00:00
Andriy Voskoboinyk
5dbbb84e42 rsu: various scanning fixes.
- Set IEEE80211_FEXT_SCAN_OFFLOAD flag; firmware can send null data
frames when associated.
- Check IEEE80211_SCAN_ACTIVE scan flag instead of IEEE80211_F_ASCAN
ic flag; the last is never set since r170530.
- Eliminate software scan (net80211) <-> site_survey (driver) race:
 * override ic_scan_curchan and ic_scan_mindwell pointers so net80211
will not try to finish scanning automatically;
 * inform net80211 about current status via ieee80211_cancel_scan()
and ieee80211_scan_done();
 * remove corresponding workaround from rsu_join_bss().

Now the driver can associate to an AP with hidden SSID.

Tested with Asus USB-N10.
2016-11-27 12:03:34 +00:00
Andriy Voskoboinyk
babfcab670 rsu: fix R92S_TXDW1_QSEL_H2C definition (0x1f -> 0x13).
Without this fix firmware ignores all but first 32 commands
(= almost everything (except plain Tx / Rx) stops working).

Tested with ASUS USB-N10.
2016-11-26 20:26:29 +00:00
Andriy Voskoboinyk
bdc7291ec9 net80211: convert all ieee80211_input_mimo*() consumers
to ieee80211_add_rx_params() + drop last (ieee80211_rx_stats) parameter

Note: there is an additional check for ieee80211_get_rx_params()
return value (which does not exist in the original diff).

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8207
2016-10-12 20:50:13 +00:00
Adrian Chadd
e97796e2b6 [net80211] extend the ieee80211_rx_stats struct to include more information.
There are a variety of more interesting RX statistics that we should
keep track of but we don't.  This is a starting point for adding more
information.

Specifically:

* now the RX rate information and some of the packet status is
  passed up;
* The 32 bit or 64 bit TSF is passed up;
* the PHY mode is passed up;
* the "I'm decap'ed AMSDU!" state is passed up;
* number of RX chains is bumped to 4.

This is all mostly a placeholder for getting the data into the RX status
before we pass it up to net80211 - unfortunately we don't yet enforce
that drivers provide it, nor do we pass the provided info back up the
stack so anyone can use the data.

We're going to need to use some of this data moving forward.
Notably, now that some hardware can do AMSDU decap for us (the intel iwm
driver can do it when we flip it on; the ath10k port I'm doing does
it for us) then we need to pass it up through the stack so the duplicate
RX sequence numbers and crypto/IV details don't cause the packet to
be dropped and/or counted against a replay counter.

It's also the beginning of being able to do more interesting node
accounting in net80211.  Specifically, once drivers start populating
per-packet rate information, AMPDU information, timestamps, etc,
we can start providing histograms of rate-versus-RSSI, account
for receive time spent per node and other such interesting things.

(Note: I'm also hoping to include ranging and RTT information for
future chipset support; and it's likely going to include it in
this kind of fashion.)
2016-10-08 01:12:29 +00:00
Andriy Voskoboinyk
f6930bec33 net80211: ieee80211_ratectl*: switch to reusable KPI
Replace various void * / int argument combinations with common structures:
- ieee80211_ratectl_tx_status for *_tx_complete();
- ieee80211_ratectl_tx_stats for *_tx_update();

While here, improve amrr_tx_update() for a bit:
1. In case, if receiver is not known (typical for Ralink USB drivers),
refresh Tx rate for all nodes on the interface.
2. There was a misuse:
- otus(4) sends non-decreasing counters (as originally intended);
- but ural(4), rum(4) and run(4) are using 'read & clear' registers
to obtain statistics for some period of time (and those 'last period'
values are used as arguments for tx_update()). If arguments are not big
enough, they are just discarded after the next call.

Fix: move counting into *_tx_update()
(now otus(4) will zero out all node counters after every tx_update() call)

Tested with:
- Intel 3945BG (wpi(4)), STA mode.
- WUSB54GC (rum(4)), STA / HOSTAP mode.
- RTL8188EU (urtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8037
2016-10-02 20:35:55 +00:00
Andriy Voskoboinyk
fbc9d202d8 rsu: do not restart calibration task when going out of RUN state.
Clear 'sc_calibrating' flag and stop calibration task when interface
is not associated; this fixes possible panic after detach.

Reported and tested by:	hselasky
Reviewed by:	adrian
MFC after:	6 days
2016-09-25 19:13:07 +00:00
Andriy Voskoboinyk
887a63246c net80211: remove IEEE80211_RADIOTAP_TSFT field from transmit definitions.
This field may be used for received frames only.

Differential Revision:	https://reviews.freebsd.org/D3826
Differential Revision:	https://reviews.freebsd.org/D3827
2016-09-20 18:53:42 +00:00
Andriy Voskoboinyk
d204cea9f8 rum: fix possible panic on device detach (similar to r302034).
Tested with WUSB54GC, STA/AP modes.
2016-09-07 16:19:20 +00:00
Andriy Voskoboinyk
4c90f11b3c rum: use mgmt frame rate for EAPOL frames. 2016-09-07 12:07:02 +00:00
Andriy Voskoboinyk
93ae47478c rum: use m_get2() in Rx path. 2016-09-06 12:00:16 +00:00
Andriy Voskoboinyk
c84bb70268 rum: fix frame length checks in Rx path.
Split usbd_xfer_status() check:
- Check xfer length: must be longer, than Rx descriptor size.
- Check frame size: must be shorter than xfer length.
- Discard too short frames.

Tested with WUSB54GC, STA/MONITOR modes.
2016-09-06 06:40:59 +00:00
Andriy Voskoboinyk
c57ee45ba9 rum: do not restart device when protmode / rtsthreshold is changed. 2016-09-05 19:42:35 +00:00
Adrian Chadd
cdf039af74 [run] fix TSF locking in RX radiotap.
Submitted by:	Imre Vadasz <imre@vdsz.com>
2016-06-04 07:18:39 +00:00
Andriy Voskoboinyk
6fc44742fd urtw: fix unused variable assignments.
Append CWmax and retry limitation to tp->maxretry instead of rewriting it
(will restore pre-r198194 behavior).

Noticed by:	pfg, hps

Reported by:	Coverity
CID:		1304937, 1304920
2016-06-02 12:01:58 +00:00
Andriy Voskoboinyk
a7c31fe1e9 urtwn, rtwn, rsu: switch to ieee80211_add_channel_list_2ghz().
- Use device's channel list instead of default one (from
ieee80211_init_channels()); adds 12 - 14 2GHz channels.
- Add ic_getradiocaps() method.
2016-05-26 16:39:11 +00:00
Andriy Voskoboinyk
2a06b6b33f urtw: switch to ieee80211_add_channel_list_2ghz().
- Use device's channel list instead of default one (from
ieee80211_init_channels()).
- Add ic_getradiocaps() method.
2016-05-26 16:15:10 +00:00
Andriy Voskoboinyk
5a62dab132 zyd: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one (adds 12, 13 and 14
2GHz channels).
- Add ic_getradiocaps() method.

Differential Revision:	https://reviews.freebsd.org/D6171
2016-05-26 15:56:27 +00:00
Andriy Voskoboinyk
83829b483d ural: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one (+ 12, 13 and 14
2GHz channels).
- Add ic_getradiocaps() method.

Differential Revision:	https://reviews.freebsd.org/D6170
2016-05-26 15:12:54 +00:00
Andriy Voskoboinyk
99bb30a9e0 run: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one (from
ieee80211_init_channels()).
- Add ic_getradiocaps() method.

Differential Revision:	https://reviews.freebsd.org/D6144
2016-05-26 15:05:37 +00:00
Pedro F. Giffuni
25cd047538 dev/usb: unsigned some loop indexes.
Although usually small, values produced by nitems() are unsigned.
By unsigning the corresponding indexes we avoid signed vs unsigned
comparisons. This may have some effect on performance, although given the
small sizes the effect will not be perceivable, and it makes the code
clearer.

Respect the style of the changed files: one uses u_int while the other
uses "unsigned int".

Reviewed by:	hselasky
2016-05-06 15:09:21 +00:00
Pedro F. Giffuni
207332450e dev/usb: minor spelling fixes in comments.
No functional change.

Reviewed by:	hselasky
2016-05-02 17:44:03 +00:00
Andriy Voskoboinyk
7b45c9dfe1 rum: switch to ieee80211_add_channel_list_*()
- Use device's channel list instead of default one
(from ieee80211_init_channels()).
- Add ic_getradiocaps() method.

Added channels:
2GHz band: 12, 13 and 14.
5Ghz band: 34, 38, 42, 46 and 165.

Tested with WUSB54GC, STA / MONITOR modes.

Differential Revision:	https://reviews.freebsd.org/D6125
2016-05-01 18:53:12 +00:00
Andriy Voskoboinyk
a061fea6ee net80211 + drivers: hide size of 'bands' array behind a macro.
Auto-replace 'howmany(IEEE80211_MODE_MAX, 8)' with 'IEEE80211_MODE_BYTES'.
No functional changes.
2016-04-29 22:14:11 +00:00
Pedro F. Giffuni
057b4402bf sys/dev: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 15:03:15 +00:00
Adrian Chadd
b60322c9b4 [rsu] We don't do A-MPDU transmit right now, so don't bother registering
for it.
2016-04-06 00:41:06 +00:00
Andriy Voskoboinyk
349156a945 rum: add legacy power saving support (STA mode).
Tested with WUSB54GC, STA mode + WRT54GC / RTL8188EU in HOSTAP mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D5546
2016-03-21 22:29:24 +00:00
Andriy Voskoboinyk
96e29c261d rum: simplify error handling in rum_newstate().
Tested with WUSB54GC, STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D5544
2016-03-21 22:14:48 +00:00
Andriy Voskoboinyk
3770442708 rum: do not try to restore bssid/TSF synchronization when device
is not associated.

Tested with WUSB54GC, STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D5543
2016-03-21 21:33:30 +00:00
Andriy Voskoboinyk
fd7dae9c98 rum: separate some microcontroller vendor-specific requests into
rum_do_mcu_request()

This change should be no-op.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D5542
2016-03-21 21:02:57 +00:00
Adrian Chadd
0c91dc1d08 [urtwn] migrate urtwn out into sys/dev/urtwn/ .
There's some upcoming work to add new chipset support here and I'd
like to only add 802.11n support to one driver, instead of both
urtwn and rtwn.

There's also missing support for things like 802.11n, some powersave
work, bluetooth integration/coexistence, etc, and also newer parts
(like 8192EU, maybe some 11ac parts, not sure yet.)

So, this is hopefully the first step in a longer set of steps to unify
rtwn/urtwn and extend it with more interesting chipset and functionality
support.

Reviewed by:	kevlo
2016-03-20 03:54:57 +00:00
Andriy Voskoboinyk
ae132f1122 zyd, run, ural: do not corrupt MAC address
Do not use ic_macaddr as a storage for current BSSID;
it may be reused in vap creation procedure;
similar to r288619.

Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5513
2016-03-03 20:06:16 +00:00
Andriy Voskoboinyk
067a92f8f4 urtwn: do not filter beacon frames in HOSTAP mode while scanning
urtwn_set_rx_bssid_all() will allow to receive beacons only
when they are not denied by filter.

Revealed by D5474.

Tested with RTL8188CUS, HOSTAP mode.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5477
2016-02-29 00:05:37 +00:00
Kevin Lo
c9b6e63dd3 Add device ID for 'AboCom 802.11n' usb.
PR:	207412
Submitted by:	Philippe Michaud-Boudreault <pitwuu at gmail dot com>
2016-02-23 01:56:58 +00:00
Andriy Voskoboinyk
6e2ab41693 urtwn: shutdown the device properly
- R92C path: NetBSD (mostly)
- R88E path: TP-Link driver

Tested with RTL8188EU and RTL8188CUS.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5198
2016-02-22 01:15:02 +00:00
Andriy Voskoboinyk
7873b2abd6 urtwn: add an option to compile the driver without firmware specific code
- Add URTWN_WITHOUT_UCODE option (will disable any firmware specific code
when set).
- Do not exclude the driver from build when MK_SOURCELESS_UCODE is set
(URTWN_WITHOUT_UCODE will be enforced unconditionally).
- Do not abort initialization when firmware cannot be loaded;
behave like the URTWN_WITHOUT_UCODE option was set.
- Drop some unused variables from urtwn_softc structure.

Tested with RTL8188EU and RTL8188CUS in HOSTAP and STA modes.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4849
2016-02-22 00:48:53 +00:00
Hans Petter Selasky
d5fb67a401 Restore maximum number of host keys to 64.
Discussed with:	adrian @ and avos @
2016-02-14 16:18:39 +00:00
Hans Petter Selasky
fe3e452399 Reduce the number of supported WLAN keys in the rum driver, else we
risk bit shifting overflows. Found by D5245 / PVS.

MFC after:	1 week
2016-02-14 07:16:36 +00:00
Gleb Smirnoff
8ec07310fa These files were getting sys/malloc.h and vm/uma.h with header pollution
via sys/mbuf.h
2016-02-01 17:41:21 +00:00
Andriy Voskoboinyk
218592ceed urtwn: add temperature calibration
Redo LC calibration if temperature changed significantly since last
calibration.

Tested with RTL8188EU/RTL8188CUS in STA mode.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Obtained from:	NetBSD (mostly)
Differential Revision:	https://reviews.freebsd.org/D4966
2016-01-20 23:55:39 +00:00
Andriy Voskoboinyk
01ff64089c urtwn: rework debug handling
- Use bitmap for debug output selection.
- Add few new messages (one for URTWN_DEBUG_BEACON
and another one for URTWN_DEBUG_INTR).
- Replace an undocumented URTWN_DEBUG definition with USB_DEBUG.

Tested with RTL8188EU / RTL8188CUS in IBSS / HOSTAP modes.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4959
2016-01-20 23:27:02 +00:00
Andriy Voskoboinyk
783c605101 urtwn: use ic_updateslot method to handle slot time change
(by default it was set to 9us).

Tested with RTL8188EU / RTL8188CUS in STA mode.

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4535
2016-01-20 23:01:33 +00:00
Andriy Voskoboinyk
8a1d6d278d urtwn: add ROM structure for RTL8188EU
- Add the structure with already known fields offsets
  (some of them were taken from this driver,
  some (channel_plan, rf_* fields) - from TP-LINK official driver)
- Fix a typo / dehardcode a constant in RTL8192C ROM structure.

Tested with RTL8188EU, STA mode

Reviewed by:	kevlo
Approved by:	adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D4274
2016-01-17 00:52:21 +00:00