Commit Graph

70 Commits

Author SHA1 Message Date
Andriy Voskoboinyk
02e3fed58c rtwn(4): decode some bit fields + merge duplicate code.
Add macros for R12A_RXDMA_PRO register (descriptions were seen in the
RTL8822B vendor driver) and merge 2 r21au_init_burstlen() copies.

No functional change intended.
2018-06-19 00:38:28 +00:00
Matt Macy
d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00
Andriy Voskoboinyk
5f792f7478 rtwn(4): de-hardcode ('h/w rate index' - 'corresponding MCS index') constant 2018-03-16 01:03:10 +00:00
Andriy Voskoboinyk
8f1ef22fca rtwn(4): reset Tx power values before calling get_txpower()
for RTL8192C / RTL8188E (like it is done for other chipsets).
2018-03-10 23:47:03 +00:00
Adrian Chadd
9fbe631a1a [net80211] convert all of the WME use over to a temporary copy of WME info.
This removes the direct WME info access in the ieee80211com struct and instead
provides a method of fetching the data.  Right now it's a no-op but eventually
it'll turn into a per-VAP method for drivers that support it (eg iwn, iwm,
upcoming ath10k work) as things like p2p support require this kind of behaviour.

Tested:

* ath(4), STA and AP mode

TODO:

* yes, this is slightly stack size-y, but it is an important first step
  to get drivers migrated over to a sensible WME API.  A lot of per-phy things
  need to be converted to per-VAP before P2P, 11ac firmware, etc stuff shows up.
2018-01-02 00:07:28 +00:00
George V. Neville-Neil
b61cdf0e4e Add support for RealTek 8812 over USB
Tested with ALFA AWUS036ACH

MFC after:	1 week
2017-12-03 22:02:30 +00:00
Andriy Voskoboinyk
7e19293450 rtwn_usb(4): add few USB IDs.
Submitted by:	wfpower@yandex.ru (via github).
2017-10-30 08:57:08 +00:00
Andriy Voskoboinyk
0cc18edf18 rtwn(4): some initial preparations for (basic) VHT support.
Rename RTWN_RIDX_MCS to RTWN_RIDX_HT_MCS before adding 802.11ac
MCS rate indexes (they have different offset).

No functional change intended.
2017-08-28 22:14:16 +00:00
Andriy Voskoboinyk
ac1b5d811f rtwn(4): deduplicate r92c_write_txpower(). 2017-08-27 13:02:51 +00:00
Andriy Voskoboinyk
5c7083ce99 rtwn(4): change type for Tx power values (RTL8192C / RTL8188EU).
Tx power values can easily fit into uint8_t + only 8 bits are written
to registers; values may overflow only in case if ROM contains
malformed data (but limit is checked anyway).

Tested with RTL8188CUS, dev.rtwn.1.debug=0x2000 (no changes).
2017-08-27 12:44:56 +00:00
Andriy Voskoboinyk
9dba612805 rtwn_usb: add support for fragmented Rx.
Since device can pass multiple frames in a single payload temporary
Rx buffer was big enough to hold all of them; now the driver can
concatenate a single frame from multiple payloads.

The Rx buffer size may be configured via tunable (dev.rtwn.%d.rx_buf_size).

Tested with:
 - rtl8188cus, rtl8188eu and rtl8821au (STA mode).
 - (by kevlo) rtl8192cu and rtl8188eu.

PR:		218527
Reviewed by:	kevlo
Differential Revision:	https://reviews.freebsd.org/D11705
2017-07-30 23:35:21 +00:00
Andriy Voskoboinyk
ff97f477b9 rtwn: drop unnecessary / wrong conversion.
The 'chan' field occupies only one byte.
2017-07-30 21:50:45 +00:00
Andriy Voskoboinyk
c5ad99fc69 rtwn: add Rx descriptor structures for common code.
Remove any chipset specific usage of Rx descriptor structure / bits
from common code to prevent misuse of fields that may differ
between various chipsets.

Checked with: 	RTL8821AU in STA mode.
2017-07-06 07:37:33 +00:00
Andriy Voskoboinyk
3737697159 rtwn_usb: reject too long (>16K) mbufs.
While here move RTWN_TXBUFSZ constant from common to USB specific code
(it's not used anywhere else).
2017-07-04 07:07:08 +00:00
Kevin Lo
2cd325579c - Fix incorrect values in the computation of CCK and OFDM transmit power
for the rtl8188eu chipset
- Rename struct r92c_rom member names: s/channel_plan/reserved5/,
  s/xtal_calib/channel_plan to be compliant with definitions of the efuse
  in vendor hal_pg.h
2017-06-17 14:39:25 +00:00
Kevin Lo
a8cf90eb9a Change R88E_EFUSE_MAX_LEN to use the same value as the vendor's driver
that contains the length of the efuse content.

Reviewed by:	avos
2017-06-07 09:10:24 +00:00
Andriy Voskoboinyk
5acae76adf rtwn: drop obsolete (since r319460) code.
Tested with RTL8188EU, STA mode.
2017-06-01 21:20:44 +00:00
Andriy Voskoboinyk
59ed13aa49 rtwn: fix connection problems with 'options RTWN_WITHOUT_UCODE'
sc_set_media_status() callback may involve some generic code in addition to
firmware-specific part (e.g., link status register setup for RTL8188E);
so, remove 'RTWN_WITHOUT_UCODE' ifdefs around it.

Tested with RTL8188CUS, RTL8188EU and RTL8821AU, STA mode.
2017-05-28 22:51:06 +00:00
Andriy Voskoboinyk
8d4d46ffb6 rtwn_usb: fix build with 'options RTWN_WITHOUT_UCODE' 2017-05-28 22:38:19 +00:00
Andriy Voskoboinyk
6b322760df rtwn: remove out-of-bounds access + fix debug output.
Omit unused rates while initializing / dumping Tx power values.

They were not accessed anywhere (except for debugging), so this is
(mostly) no-op.

Tested with
 * RTL8188EU, STA mode.
 * RTL8812AU, STA mode.

Found by:	PVS-Studio
2017-04-12 07:21:54 +00:00
Andriy Voskoboinyk
90589b904f rtwn: fix node id assignment.
Do not assign new id if node is reused.

Tested with RTL8821AU, HOSTAP mode + RTL8188EU, STA mode
(with inactivity timeout == 90)
2017-03-20 08:10:35 +00:00
Andriy Voskoboinyk
2e184b72c3 rtwn: drop unneeded (after r315583) code.
Tested with RTL8188EU, HOSTAP mode + RTL8821AU, STA mode
(fast-frames / A-MSDU).
2017-03-19 20:51:28 +00:00
Andriy Voskoboinyk
f631357540 net80211 drivers: fix rate setup for EAPOL frames, obtain Tx parameters
directly from the node.

- Use ni_txparms directly instead of calculating them manually every time
- Move M_EAPOL flag check upper; otherwise it may be skipped due to
'ucastrate' / 'mcastrate' check
- Use 'mgtrate' for control frames too (see ifconfig(8), mgtrate parameter)
- Add few more M_EAPOL checks where it was missing (zyd(4), ural(4),
urtw(4))
- Few unrelated cleanups

Tested with:
 - Intel 6205 (iwn(4)), STA mode;
 - WUSB54GC (rum(4)), HOSTAP mode + RTL8188EU (rtwn(4)), STA mode.

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D9811
2017-02-26 20:49:35 +00:00
Kevin Lo
a6bac5b604 Sort REALTEK section and remove duplicate entry for RTL8192CU. 2017-01-24 03:00:22 +00:00
Kevin Lo
60b9567d16 Add support for the Realtek RTL8192EU chipset.
Committed over the D-Link DWA-131 rev E1 on amd64 with WPA.

Reviewed by:	avos
2017-01-24 02:35:38 +00:00
Andriy Voskoboinyk
3111723c09 rtwn: enable LDPC support where possible
Tested with RTL8821AU, STA mode.
2017-01-21 15:03:58 +00:00
Andriy Voskoboinyk
09606165a0 rtwn: export more stats to net80211
Setup more ieee80211_rx_stats fields for received frames:
 - pktflags:
  * IEEE80211_RX_F_FAIL_FCSCRC;
  * IEEE80211_RX_F_AMPDU;
  * IEEE80211_RX_F_AMPDU_MORE;
  * IEEE80211_RX_F_SHORTGI;
 - rate flags (CCK, OFDM, HT);
 - width;
 - phytype;
 - rate;
 - rx_tsf;
 - rssi;
 - nf;
 - ieee, freq (RTL8188EU only, when ht40 support is disabled).

Tested with:
 - RTL8188CE, RTL8188EU, RTL8821AU (STA / AP modes, i386)
 - (by kevlo) RTL8188EU and RTL8812AU (amd64)

Reviewed by:	adrian (previous version), kevlo
Differential Revision:	https://reviews.freebsd.org/D9021
2017-01-17 00:35:23 +00:00
Kevin Lo
68c3c0258d Increase retry count to 100 in r88e_fw_cmd() and r92c_fw_cmd(). 2017-01-13 02:11:16 +00:00
Andriy Voskoboinyk
bd99d5d4d8 rtwn: fix R92C_TXDW4_RTSRATE_M definition (0x3f -> 0x1f)
Submitted by:	kevlo
2017-01-11 23:32:40 +00:00
Andriy Voskoboinyk
ae60d856a3 rtwn_pci(4): fix possible race while accessing 'matched_chip' variable. 2017-01-10 01:09:39 +00:00
Andriy Voskoboinyk
5c06728ccb rtwn_usb(4): do not try to modify global static structure.
Use a local copy for modifications instead.

Tested with RTL8821AU (AP) + RTL8188EU (STA).

Reported by:	hselasky
2017-01-09 23:42:02 +00:00
Andriy Voskoboinyk
0866194cab rtwn_usb(4): fix Rx buffer size calculation.
Use device-specific Rx buffer size to ensure that data will not be
truncated + add a warning if truncation was detected (the driver
cannot handle this case correctly yet).

Tested with:
 - RTL8188CUS, RTL8188EU and RTL8821AU, STA / AP modes.
2017-01-08 23:41:17 +00:00
Kevin Lo
094fba962f Add new USB device ID. 2017-01-06 14:05:31 +00:00
Kevin Lo
d01f7b29a9 In rtl8188eu, read R92C_HSSI_PARAM2(0)) register to detect whether it needs
to enable CCK high power feature or not.

Reviewed by:	avos
2017-01-05 02:04:53 +00:00
Andriy Voskoboinyk
0642856a1e rtwn: fix possible buffer overrun.
r297596 was not merged properly into new code; restore lost part.
2017-01-04 00:26:41 +00:00
Andriy Voskoboinyk
b8ad00b0ed rtwn: add (untested) radar detection support for RTL8821AU
(disabled by default).

To enable it, dev.rtwn.%d.radar_detection tunable need to be set
to a nonzero value.

Tested with RTL8821AU, AP mode (no radar events were seen - so,
I have no idea if it is really correct / working)

Reviewed by:	adrian
Differential Revision:	https://reviews.freebsd.org/D8903
2016-12-30 22:24:01 +00:00
Kevin Lo
0351824ff8 - Fix incorrect values in the computation of OFDM and MCS Tx power.
- Make power a uint8_t rather than a uint16_t.
- Replace the hardcoded RF chains.

Reviewed by:	avos
2016-12-30 03:08:46 +00:00
Andriy Voskoboinyk
0ea682eb8e rtwn: silence compiler warning (-Wmaybe-uninitialized).
Reported by:	adrian
2016-12-29 22:36:16 +00:00
Kevin Lo
12bc234158 Merge r92c_init_rf_common() into r92c_init_rf(). In r88eu_attach.c, we could
use r92c_init_rf() rather than r92c_init_rf_common() when sc_init_rf()
callback is invoked.

While here, constantly use RF chain instead of RF path in comment.

Reviewed by:	avos
2016-12-20 01:13:11 +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
4786190d2f rtwn: fix bitmap size calculation.
Tested with RTL8188CE, STA mode.
2016-12-03 17:27:10 +00:00
Kevin Lo
3094a376e4 Fix logic error so the R92C_TDECTRL register value is updated correctly.
Reviewed by:	avos
2016-12-03 14:41:53 +00:00
Kevin Lo
f55d404d45 Update struct r12a_rom.
Reviewed by:	avos
2016-11-21 09:23:42 +00:00
Kevin Lo
0ae37b2f01 For RTL8812AU:
- The Tx power (diff) values should be signed
- Fix an off by one error when reading Tx power (diff) values

Reviewed by:	avos, adrian
Differential Revision:	https://reviews.freebsd.org/D8571
2016-11-19 07:28:00 +00:00
Andriy Voskoboinyk
800762ee73 rtwn: drop excessive includes.
Since rom_defs.h is included in rxxx_var.h there is no need to
include both of them.

Submitted by:	kevlo
2016-11-14 20:37:07 +00:00
Andriy Voskoboinyk
a14f9888d9 rtwn: enable 11n support for RTL8188CE.
- Increase Rx buffer size from MCLBYTES to MJUMPAGESIZE.
- Provide an additional defragmentation routine for frames larger
than MCLBYTES; that is required by A-MSDU / Atheros Fast-Frames
support to work with current Tx path implementation.

Enabled features list for RTL8188CE:
- Atheros Fast-Frames;
- A-MPDU (Tx / Rx);
- A-MSDU (Tx / Rx; 4k only);
- Short Guard Interval.

Tested with:
- RTL8188CE (STA+AP) + RTL8821AU (STA).
- RTL8188CE (STA) + RTL8188CUS (AP).

Relnotes:	yes
2016-11-12 17:58:37 +00:00
Andriy Voskoboinyk
d067ef0f0d rtwn: add HOSTAP / IBSS mode support for RTL8188CE.
NOTE: some multi-vap configurations (e.g., STA+IBSS) are not stable;
that will be fixed later.

Tested with:
 - RTL8188CE, STA + AP mode;
 - RTL8188CE, IBSS mode;
 - RTL8188CUS, IBSS mode;
 - RTL8188EU, IBSS mode.

Relnotes:	yes
2016-11-06 23:13:13 +00:00
Andriy Voskoboinyk
77cbc47958 rtwn_pci: omit tx_done() stage if device is not running.
rtwn_usb: drain USB transfers during device shutdown; this fixes possible
panic with 'options IEEE80211_SUPPORT_SUPERG' during device detach.

Tested with RTL8188CE, STA mode.
2016-11-06 19:17:39 +00:00
Andriy Voskoboinyk
519e6c0fc2 rtwn: fix Tx ring cleanup.
Do not try to clear stale Tx descriptor entries when there are some
running vaps; just free node references - rtwn_pci_tx_done() will free
mbufs without creating holes in the Tx descriptor space.
Also, reset only 2 first entries in the beacon ring - other will not be
used anyway.

Tested with RTL8188CE, STA + STA mode.
2016-11-06 18:11:19 +00:00
Andriy Voskoboinyk
1acd7ad907 rtwn: reduce shutdown time for RTL8188CE. 2016-11-06 17:24:16 +00:00