History log of /freebsd-current/sys/dev/rtwn/if_rtwn.c
Revision Date Author Comments
# 713db49d 10-Jan-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: deal with lost state transitions

Since 5efea30f039c4 we can possibly lose a state transition which can
cause trouble further down the road.
The reproducer from 643d6dce6c1e 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


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# b3512b30 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

rtwn: clean up empty lines in .c and .h files


# 2b9f12f6 24-Aug-2020 Bjoern A. Zeeb <bz@FreeBSD.org>

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


# 786ac703 10-Mar-2019 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# b84b3638 26-Jan-2019 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# 9fbe631a 01-Jan-2018 Adrian Chadd <adrian@FreeBSD.org>

[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.


# 59ed13aa 28-May-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

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.


# 90589b90 20-Mar-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

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)


# 60b9567d 23-Jan-2017 Kevin Lo <kevlo@FreeBSD.org>

Add support for the Realtek RTL8192EU chipset.
Committed over the D-Link DWA-131 rev E1 on amd64 with WPA.

Reviewed by: avos


# 3111723c 21-Jan-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: enable LDPC support where possible

Tested with RTL8821AU, STA mode.


# 09606165 16-Jan-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# b8ad00b0 30-Dec-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# d067ef0f 06-Nov-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# 1318032e 06-Nov-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: reset watchdog timer on device shutdown.


# c15d8692 05-Nov-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: fix Rx filter setup for some multi-vap configuratons.

- Correctly refresh Rx filter when AP (IBSS) vap is created after STA vap.
- Block any RCR updates during TSF correction (IBSS mode).
- Set CBSSID* bits during vap creation, not when it was started / stopped.
- Cache current state to prevent unnecessary register reads.

Tested with RTL8188CE, STA + AP mode.


# 8361f9cd 05-Nov-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: pause beacon queue during scanning.

Tested with RTL8821AU, AP + AP mode.


# 7453645f 17-Oct-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn(4), urtwn(4): merge common code, add support for 11ac devices.

All devices:
- add support for rate adaptation via ieee80211_amrr(9);
- use short preamble for transmitted frames when needed;
- multi-bss support:
* for RTL8821AU: 2 VAPs at the same time;
* other: 1 any VAP + 1 sta VAP.
RTL8188CE:
- fix IQ calibration bug (reason of significant speed degradation);
- add h/w crypto acceleration support.
USB:
- A-MPDU Tx support;
- short GI support;
Other:
- add support for RTL8812AU / RTL8821AU chipsets
(a/b/g/n only; no ac yet);
- split merged code into subparts:
* bus glue (usb/*, pci/*, rtl*/usb/*, rtl*/pci/*)
* common (if_rtwn*)
* chip-specific (rtl*/*)
- various other bugfixes.

Due to code reorganization, module names / requirements were changed too:
urtwn urtwnfw -> rtwn rtwn_usb rtwnfw
rtwn rtwnfw -> rtwn rtwn_pci rtwnfw

Tested with RTL8188CE, RTL8188CUS, RTL8188EU and RTL8821AU.

Tested by: kevlo, garga,
Peter Garshtja <peter.garshtja@ambient-md.com>,
Kevin McAleavey <kevin.mcaleavey@knosproject.com>,
Ilias-Dimitrios Vrachnis <id@vrachnis.com>,
<otacilio.neto@bsd.com.br>
Relnotes: yes


# b7c89047 06-Sep-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: fix firmware readiness check in rtwn_load_firmware().


# 6ab1306e 20-Jun-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: fix Tx processing, add some busdma synchronization.

1) Unload mbuf instead of descriptor in rtwn_tx_done().
2) Add more synchronization for device visible mappings before
touching the memory.
3) Improve watchdog timer logic.

Reported and tested by: mva

Approved by: re (gjb)


# a7c31fe1 26-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

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.


# 354df9d4 26-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: replace hardcoded rate indices with their names (similar to r289758).

- Use macros to define rate indices; don't hardcode them in code.
- Add method for 'rate' -> 'rate index' conversion
(and array for the opposite).
- Determine if rate is CCK / OFDM via appropriate macro.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D4837


# fb6844d8 16-May-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: fix double free in raw xmit path.

Reported by: mva


# a061fea6 29-Apr-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211 + drivers: hide size of 'bands' array behind a macro.

Auto-replace 'howmany(IEEE80211_MODE_MAX, 8)' with 'IEEE80211_MODE_BYTES'.
No functional changes.


# 31021a2b 20-Apr-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: replace internal LE_READ_*/LE_WRITE_* macro with system
le*dec / le*enc functions.

Replace net80211 specific macros with system-wide bytestream
encoding/decoding functions:
- LE_READ_2 -> le16dec
- LE_READ_4 -> le32dec
- LE_WRITE_2 -> le16enc
- LE_WRITE_4 -> le32enc

+ drop ieee80211_input.h include, where it was included for these
operations only.

Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D6030


# 5036353a 21-Feb-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: import r290048.

- Fix scanning from AUTH state.

Tested by: Simone Mario Lombardo <evil.lombo@gmail.com>

PR: 203105
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D4820


# 798e1ce3 26-Jan-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: do not start vap when initialization fails

- Start vap(s) (via ieee80211_start_all()) only when initialization
succeeds; stop the first vap otherwise (via ieee80211_stop());
- Do not try to stop a device multiple times
(move (sc->sc_flags & RTWN_RUNNING) check to urtwn_stop_locked()).

Tested by: kevlo
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D5058


# 5274f944 26-Jan-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: use ieee80211_restart_all() for device reset

Tested by: kevlo
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D5057


# 6420fb29 11-Jan-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: import r290022 (do not filter out control frames in the RX path)

Tested by: kevlo
Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D4838


# 950678b4 09-Jan-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

rtwn: fix sequence number assignment (part of r290630)

Reviewed by: kevlo
Approved by: adrian (mentor)
Differential Revision: https://reviews.freebsd.org/D4819


# 0046e186 07-Jan-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211 drivers: fix ieee80211_init_channels() usage

Fix out-of-bounds read (all) / write (11n capable) for drivers
that are using ieee80211_init_channels() to initialize channel list.

Tested with:
* RTL8188EU, STA mode.
* RTL8188CUS, STA mode.
* WUSB54GC, HOSTAP mode.

Approved by: adrian (mentor)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D4818


# bcaed14b 31-Dec-2015 Adrian Chadd <adrian@FreeBSD.org>

[rtwn] bring over initial rtwn driver.

This is a port from openbsd. It's incomplete and unstable, but it's better
than nothing. I have no plans to MFC this until it's complete and stable.

Submitted by: kevlo