Commit graph

130 commits

Author SHA1 Message Date
Bjoern A. Zeeb 713db49d06 net80211: deal with lost state transitions
Since 5efea30f03 we can possibly lose a state transition which can
cause trouble further down the road.
The reproducer from 643d6dce6c can trigger these for example.
Drivers for firmware based wireless cards have worked around some of
this (and other) problems in the past.

Add an array of tasks rather than a single one as we would simply
get npending > 1 and lose order with other tasks.  Try to keep state
changes updated as queued in case we end up with more than one at a
time.  While this is not ideal either (call it a hack) it will sort
the problem for now.
We will queue in ieee80211_new_state_locked() and do checks there
and dequeue in ieee80211_newstate_cb().
If we still overrun the (currently) 8 slots we will drop the state
change rather than overwrite the last one.
When dequeing we will update iv_nstate and keep it around for historic
reasons for the moment.

The longer term we should make the callers of
ieee80211_new_state[_locked]() actually use the returned errors
and act appropriately but that will touch a lot more places and
drivers (possibly incl. changed behaviour for ioctls).

rtwn(4) and rum(4) should probably be revisted and net80211 internals
removed (for rum(4) at least the current logic still seems prone to
races).

PR:		271979, 271988, 275255, 263613, 274003
Sponsored by:	The FreeBSD Foundation (in 2023)
MFC after:	3 days
Reviewed by:	cc
Differential Revision: https://reviews.freebsd.org/D43389
2024-02-14 19:47:21 +00:00
Bjoern A. Zeeb 75f298492a Revert "Enter the network epoch in USB WiFi drivers when processing input"
This reverts commit 17c328b6ae.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-12-01 00:48:54 +00:00
Bjoern A. Zeeb 1c6dd33d26 Revert "Widen EPOCH(9) usage in PCI WLAN drivers."
This reverts commit b65f813c1a.
As a side effect this also seems to fix wtap which seems to have
lost the epoch over the input path in between.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2023-12-01 00:48:54 +00:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 2ff63af9b8 sys: Remove $FreeBSD$: one-line .h pattern
Remove /^\s*\*+\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:18 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Elliott Mitchell da6ae2cf17 rtwm: purge EOL release compatibility
Remove FreeBSD 11 support

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/603
Differential Revision: https://reviews.freebsd.org/D35560
2023-02-04 09:13:10 -07:00
Justin Hibbits ec22a3a259 DrvAPI: Trivial mechanical conversions for various drivers
Mechanically convert the following drivers, with trivial changes:
* ipw(4)
* igc(4)
* enetc(4)
* malo(4)
* nfe(4)
* bxe(4)
* awg(4)
* otus(4)
* rtwn(4)
* bnxt(4)
* ath(4)

Sponsored by:	Juniper Networks, Inc.
2022-12-21 15:36:59 -05:00
John Baldwin 8bc615f591 rtwn: Fix mismatches in array bounds.
Reported by:	GCC -Warray-parameter
Reviewed by:	imp, emaste
Differential Revision:	https://reviews.freebsd.org/D37550
2022-12-07 12:33:21 -08:00
John Baldwin 1bbc46a868 rtwn: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 12:22:04 -07:00
John Baldwin 50e3b6aa48 rtwn: Restore RF_ENV control type after initializing RF.
Both rwlwifi in Linux and rtwn in OpenBSD restore this register,
and the existing code was saving the value and not using it.

Reported by:	-Wunused-but-set-variable
Reviewed by:	imp
Obtained from:	OpenBSD
Differential Revision:	https://reviews.freebsd.org/D34838
2022-04-07 17:01:28 -07:00
Hans Petter Selasky 75d20a5e38 rtwn(4): Add new USB ID.
Submitted by:	Wensi <supdrewin@outlook.com>
PR:		261098
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-11 21:19:53 +01:00
Hans Petter Selasky 2891a28052 rtwn(4): Add new USB ID.
Submitted by:	arved@
PR:		260952
MFC after:	1 week
Sponsored by:	NVIDIA Networking
2022-01-07 14:02:30 +01:00
Andreas Wetzel cd6f0b4769 rtwn/usb: add product ID for Asus USB N10 Nano Rev. B1
According to information found on the internet the following products
use exactly the same hardware but probably different USB IDs:
- Edimax EW-7811Un V2 (v2)
- Edimax EW-7811GLN 2.0A (v2)
I am not adding them as I cannot verify.

PR:		254280
MFC after:	1 week
2021-12-06 09:43:26 +02:00
Bjoern A. Zeeb 9a6695532b net80211/drivers: improve ieee80211_rx_stats for band
While IEEE80211_R_BAND was defined, there was no place to store the
band.  Add a field for that, adjust ieee80211_lookup_channel_rxstatus()
to require it, and update drivers passing "R_{FREQ|IEEE}" in already to
provide the band as well.  For the moment keep the fall-back code
requiring all three fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian
Differential Revision: https://reviews.freebsd.org/D30662
2021-10-22 09:55:54 +00:00
Andriy Gapon 7544c1d20d rtwn: make sure to not write in upper bits of txdseq
ni_txseqs is kept as 16-bit counter, but we need to trim the upper four
bits as they may have special meanings for the firmware / hardware.
For instance, bit 15 enables hardware / firmware generation of sequence
numbers that overrides sequence numbers programmed by the driver.

Reviewed by:	adrian
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D30814
2021-06-21 11:05:04 +03:00
Dmitry Chagin 434c46c006 rtwn_usb(4): Add a USB ID for the TP-Link Archer T2U v3.
PR:		256203
Submitted by:	Steve Kargl sgk at troutmask.apl.washington.edu
MFC after:	2 weeks
2021-05-27 21:52:10 +03:00
Bjoern A. Zeeb 3917c9ba65 rtwn: narrow the epoch area
Rather than placing the epoch around the entire receive loop which
might call into rtwn_rx_frame() and USB and sleep, split the loop
into two[1] and leave us with one unlock/lock cycle as well.

PR:		249925
Reported by:	thj, (rkoberman gmail.com)
Tested by:	thj
Suggested by:	adrian [1]
Reviewed by:	adrian
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation (initially, paniced my iwl lab host)
Differential Revision:	https://reviews.freebsd.org/D26554
2020-09-29 20:46:25 +00:00
Mateusz Guzik b3512b30db rtwn: clean up empty lines in .c and .h files 2020-09-01 21:33:31 +00:00
Mark Johnston f4d7179ad3 rtwn(4): Add support for the Belkin N300.
PR:		249034
Submitted by:	Salvador Martínez Mármol <salvica@kapj.net>
MFC after:	1 week
2020-08-31 15:32:45 +00:00
Bjoern A. Zeeb 2b9f12f6b2 net80211: enhance getflags*() and ieee80211_add_channel*()
For ieee80211_add_channel+*() we are passing in an int flag for
ht40 and in some cases another int flag for vht80 where we'd only
need two bits really.
Convert these variables to a bitflag and fold them together into one.
This also allows for VHT160 and VHT80P80 and whatever may come to
be considered. Define the various options currently needed.

Change the drivers (rtwn and rsu) which actually set this bit to non-0.
For convenience the "1" currently used for HT40 is preserved.

Enahnce getflags_5ghz() to handle the full set of VHT flags based
on the input flags from the the driver.

Update the regdomain implementation as well to make use of the new
flags and deal with higher [V]HT bandwidths.

ieee80211_add_channel() specifically did not take flags so it will
not support naything beyond 20Mhz channels.

Note: I am not entirely happy with the "cbw_flag[s]" name, but we
do use chan_flags elsewhere already.

MFC after:	2 weeks
Reviewed by:	adrian, gnn
Sponsored by:	Rubicon Communications, LLC (d/b/a "Netgate")
Differential revision:	https://reviews.freebsd.org/D26091
2020-08-24 13:15:08 +00:00
Hans Petter Selasky 0736ad87b9 Add new USB ID.
Submitted by:		Dmitry Luhtionov <dmitryluhtionov@gmail.com>
MFC after:		1 week
Sponsored by:		Mellanox Technologies
2020-08-06 13:25:04 +00:00
Li-Wen Hsu 18db3c616f rtwn: Add a USB ID for Buffalo WI-U2-433DHP
PR:		247573
Submitted by:	HATANO Tomomi <hatanou@infolab.ne.jp>
MFC after:	1 week
2020-06-27 07:34:15 +00:00
Mark Johnston 318825636c rtwn: Add a USB ID for the TP-Link TL-WN727N.
PR:		246417
Submitted by:	Viktor G. <viktor@netgate.com>
MFC after:	1 week
2020-05-12 16:10:07 +00:00
Mark Johnston 75c600d287 rtwn: Add a new USB ID.
PR:		246315
Submitted by:	Idwer Vollering <vidwer+fbsdbugs@gmail.com>
MFC after:	1 week
2020-05-09 14:49:56 +00:00
Hans Petter Selasky d0edc32e72 Add new USB ID.
Submitted by:	Konrad Jopek <kjopek@gmail.com>
Differential Revision:	https://reviews.freebsd.org/D24142
MFC after:	1 week
Sponsored by:	Mellanox Technologies
2020-03-22 11:44:24 +00:00
Gavin Atkinson 4b156472c6 Add new USB device ID for Elecom 802.11ac USB device.
MFC after:	2 weeks
2020-03-20 04:13:39 +00:00
Hiroki Sato 28180b6298 Add MODULE_PNP_INFO() to autoload the rtwn_pci(4) kernel module.
Reviewed by:	imp
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D23807
2020-02-27 19:35:17 +00:00
Hans Petter Selasky b65f813c1a Widen EPOCH(9) usage in PCI WLAN drivers.
Make sure all occurrences of ieee80211_input_xxx() in sys/dev are
covered by a network epoch section. Do not depend on the interrupt
handler nor any taskqueues being in a network epoch section.

This patch should unbreak the PCI WLAN drivers after r357004.

Pointy hat:	glebius@
Sponsored by:	Mellanox Technologies
2020-01-30 10:28:01 +00:00
Gleb Smirnoff 17c328b6ae Enter the network epoch in USB WiFi drivers when processing input
mbuf queues.

Submitted by:	Idwer Vollering <vidwer gmail.com>
2020-01-24 21:04:33 +00:00
Gleb Smirnoff bc0bdf25c7 Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:12:31 +00:00
Jung-uk Kim 1c9c1f5903 Add support for TP-Link Archer T2U Nano.
MFC after:	2 weeks
2019-09-01 06:40:58 +00:00
Andriy Voskoboinyk 4687c67425 rtwn_pci: add device ID for RTL8192CE.
PR:		239795
Submitted by:	James Parsons <james.m.parsons@protonmail.com>
MFC after:	1 week
Relnotes:	yes
2019-08-12 08:01:21 +00:00
Andriy Voskoboinyk 786ac7035f Fix ieee80211_radiotap(9) usage in wireless drivers:
- Alignment issues:
 * Add missing __packed attributes + padding across all drivers; in
most places there was an assumption that padding will be always
minimally suitable; in few places - e.g., in urtw(4) / rtwn(4) -
padding was just missing.
 * Add __aligned(8) attribute for all Rx radiotap headers since they can
contain 64-bit TSF timestamp; it cannot appear in Tx radiotap headers, so
just drop the attribute here. Refresh ieee80211_radiotap(9) man page
accordingly.

- Since net80211 automatically updates channel frequency / flags in
ieee80211_radiotap_chan_change() drop duplicate setup for these fields
in drivers.

Tested with Netgear WG111 v3 (urtw(4)), STA mode.

MFC after:	2 weeks
2019-03-11 01:27:01 +00:00
Andriy Voskoboinyk 7f74097165 rtwn_usb(4): fix Tx instability with RTL8192CU chipsets
- Fix data frames transmission via POWER_STATUS register setup -
it seems to be set by MACID_CONFIG firmware command, which was broken*
in r290439 and later disabled in r307529.

We can re-enable it later if / when firmware rate adaptation will be
ready; however, this step will be required anyway - for firmware-less
builds.

- Force RTS / CTS protection frame rate to CCK1 (this rate works fine
without any additional setup; no better workaround is known yet).

The problem was not observed on the channel 1 or with CCK1 rate enforced
('ifconfig wlan0 ucastrate 1' for 11 b/g; not possible for 11n networks
due to ifconfig(8) bug).

* I'm not sure if it works before r290439 because - AFAIR - I never seen
firmware rate adaptation working for 10-STABLE urtwn(4)
(It needs EN_BCN bit set and RSSI updates at least).

Tested with RTL8188CUS in STA mode
(in regular mode and with disabled MRR - DARFRC*8 is set to 0)

PR:		233949
MFC after:	2 weeks
2019-03-04 03:02:14 +00:00
Andriy Voskoboinyk d225ba4aa7 rtwn_usb(4): fix LED blinking for RTL8192CU during scanning
Tested with RTL8188CUS, STA mode.

MFC after:	5 days
2019-03-04 01:54:28 +00:00
Andriy Voskoboinyk 6bda1ad8a2 rtwn_usb(4): add new USB id.
Submitted by:	<yklaxds@gmail.com>
Github issue:	https://github.com/s3erios/rtwn/issues/4
MFC after:	5 days
2019-01-28 02:15:41 +00:00
Andriy Voskoboinyk b84b36380e Remove 2GHz channel list copies from wireless drivers.
Wrap ieee80211_add_channel_list_2ghz into another function
which supplies default (1-14) channel list to it and drop
its copies from drivers.

Checked with RTL8188EE, country US / JP / KR / UA.

MFC after:	2 weeks
2019-01-26 17:00:55 +00:00
Andriy Voskoboinyk 9df9e9361c net80211: reuse TICKS_2_MSEC / MSEC_2_TICKS macros from sys/time.h
Replace in-place implementation with system-wide one; since it
guarantees non-zero result drop all less-than-one checks from
drivers and net80211.

MFC after:	2 weeks
2019-01-25 01:05:18 +00:00
Andriy Voskoboinyk 8733962697 rtwn(4): clear 'basic' rate bit before calculating RTS/CTS rate.
Rate tables have this bit set to indicate minimal set of basic rates;
however, it overlappes with MCS bit, so rate2ridx() will treat them as
an 11n rate.

Due to the current rates setup the issue can be reproduced only
in 5GHz band with 11n / protection enabled.

Tested with RTL8821AU, HOSTAP mode.

MFC after:	5 days
2019-01-16 12:11:29 +00:00
Andriy Voskoboinyk a461b7e5db rtwn_usb(4): add new USB id for RTL8821AU
Reported by:	Mike Tancsa <mike@sentex.net>
Tested by:	Mike Tancsa <mike@sentex.net>
MFC after:	3 days
2019-01-16 10:33:51 +00:00
Andriy Voskoboinyk fdc9504f51 rtwn_usb(4): add IQ calibration support for RTL8192CU
The code is similar to the one for RTL8188E* and probably
should be shared with RTL8188CE (needs to be tested).

Checked with RTL8188CUS, STA mode.

MFC after:	5 days
2019-01-10 05:49:47 +00:00
Andriy Voskoboinyk 48f21a05da rtwn_pci(4): sync r88ee_power_on() with OpenBSD
Tested with RTL8188EE, STA mode

Submitted by:	Farhan Khan <khanzf@gmail.com>
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D18727
2019-01-04 04:26:39 +00:00
Andriy Voskoboinyk 920dfe026c rtwn_usb(4): add USB id for TP-LINK TL-WN821N v5.
It is already mentioned in manpage, but was missing from the driver.

MFC after:	4 days
2019-01-02 18:35:40 +00:00
Andriy Voskoboinyk 0fe1808c72 rtwn_pci(4): fix panic with INVARIANTS (due to inverted assertion logic)
MFC after:	4 days
2019-01-02 17:13:55 +00:00
Andriy Voskoboinyk b3f3786e5d rtwn_pci(4): add support for RTL8188EE chipset.
Initially based on https://reviews.freebsd.org/D15692;
later deduplicated and improved a bit (Tx reports, IQ calibration support).

Submitted by:	Farhan Khan <khanzf@gmail.com>
MFC after:	4 days
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D15692
2019-01-02 06:48:53 +00:00
Andriy Voskoboinyk a163403b62 rtwn(4): rename set_name -> set_rom_opts method and reuse it for RTL8188E*
MFC after:	4 days
2019-01-02 06:03:19 +00:00
Andriy Voskoboinyk 0db82209dc rtwn(4): rename common RTL8188E* structures.
No functional change intended.

MFC after:	4 days
2019-01-02 05:43:33 +00:00
Andriy Voskoboinyk 44c68782f1 rtwn(4): do not try to start RTL8188E* MCU during device shutdown.
MFC after:	4 days
2019-01-02 05:37:30 +00:00