History log of /freebsd-current/sys/net80211/ieee80211_amrr.c
Revision Date Author Comments
# cd9fee3d 05-Feb-2024 Bjoern A. Zeeb <bz@FreeBSD.org>

net80211: amrr_init: change order of commands

First run the KASSERT before trying to do the free operation.
Better for reporting and debugging.
Add a guard setting the value to NULL afterwards. NULL pointers
are a lot easier to test for.

MFC after: 3 days
Reviewed by: cc
Differential Revision: https://reviews.freebsd.org/D43751


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

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

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


# 08f5e6bb 21-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (7 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all low hanging fruits as MPSAFE.

Reviewed by: markj
Approved by: kib (mentor, blanket)
Differential Revision: https://reviews.freebsd.org/D23626


# c1475a19 17-Jan-2020 Conrad Meyer <cem@FreeBSD.org>

net80211: Move rate printing in amrr_node_stats() to a separate method

This makes amrr_node_stats() cleaner and allows the rate printing to be
reusable.

Submitted by: Neel Chauhan <neel at neelc.org>
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D22318


# 9df9e936 24-Jan-2019 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# 4367c2d1 12-Jan-2019 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: fix possible panic for some drivers after r342211

Check if rate control structures were allocated before trying to
access them in various places; this was possible before on
allocation failure (unlikely), but was revealed after r342211
where allocation was deferred.

In case if driver uses wlan_amrr(4) and it is loaded it
is possible to reproduce the panic via

sysctl net.wlan.<number>.rate_stats

(for wlan0 the number will be 0).

Tested with: RTL8188EE, AP mode + RTL8188CUS, STA mode.

MFC after: 3 days


# 810490a0 23-Jul-2017 Andriy Voskoboinyk <avos@FreeBSD.org>

net80211: do not allow to unload rate control module if it is still in use.

Keep 'nrefs' counter up-to-date, so 'kldunload wlan_amrr' with 1+ active
wlan(4) interface will not lead to kernel panic.

MFC after: 5 days


# f6930bec 02-Oct-2016 Andriy Voskoboinyk <avos@FreeBSD.org>

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


# eec88845 01-Jul-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] teach AMRR to log the initial MCS rate as "MCS X"

Otheriwse it logs it as the rate value, which is 0x80 (MCS flag) + MCS,
which isn't that helpful.

Approved by: re (gjb)


# 73931706 15-Mar-2016 Adrian Chadd <adrian@FreeBSD.org>

[net80211] Begin implementing rate control module stats.

* Implement a new ratectl method, which defaults to returning nothing;
* Add a top level sysctl (net.wlan.X.rate_stats) to extract it;
* Add ratectl info for the 'amrr' module.

Tested:

* urtwn(4), STA mode

Differential Revision: https://reviews.freebsd.org/D5630


# 8ec07310 01-Feb-2016 Gleb Smirnoff <glebius@FreeBSD.org>

These files were getting sys/malloc.h and vm/uma.h with header pollution
via sys/mbuf.h


# b9b53389 25-May-2015 Adrian Chadd <adrian@FreeBSD.org>

Convert malloc/free back to #define's, as part of OS portability work.

DragonflyBSD uses the FreeBSD wireless stack and drivers. Their malloc()
API is named differently, so they don't have userland/kernel symbol
clashes like we do (think libuinet.)

So, to make it easier for them and to port to other BSDs/other operating
systems, start hiding the malloc specific bits behind defines in
ieee80211_freebsd.h.

DragonflyBSD can now put these portability defines in their local
ieee80211_dragonflybsd.h.

This should be a great big no-op for everyone running wifi.

TODO:

* kill M_WAITOK - some platforms just don't want you to use it
* .. and/or handle it returning NULL rather than waiting forever.
* MALLOC_DEFINE() ?
* Migrate the well-known malloc names (eg M_TEMP) to net80211
namespace defines.


# ebb12408 20-Aug-2014 Adrian Chadd <adrian@FreeBSD.org>

After much toying around with this AMRR initial rate stuff,
I've decided that for 11n rates it's best to start (very) low and work
our way up.

So, from now on, the initial rate for AMRR 11n is MCS4.
It doesn't try MCS12 or MCS20 - at low signal strengths those don't
work very well at all.

AMRR will step the rate control up over time if things work out better.

Tested:

* Intel 5100
* Intel 5300 (using local diffs to test out 3x3 stream support)


# 5140f9e6 09-Nov-2013 Adrian Chadd <adrian@FreeBSD.org>

Fix AMRR to correctly select the initial rate.

There were two bugs:

* If the initial lowest rate didn't go through the loop at least once,
the AMRR rate index would be the highest rate in the table
(eg the rix mapping to MCS15) but rate would stay at the default
value, namely 0.

This meant that the initial rate selection would be MCS15 _but_ the
node ni_txrate value would be MCS0.

* If the node is 11n, then break out of the loop correctly. Beforehand,
my initial 11n AMRR commit would immediately exit out as it would
fail the 11n check, then it would always fall through to the non-11n
rate which would then see if it was < 36mbit (ie, "72"), which would
always match. Hence, it'd always return MCS15.

Tested:

* Intel Centrino 2230 STA (local changes), STA mode
* Intel Wifi 5100, STA


# 7f0660a0 30-Oct-2013 Adrian Chadd <adrian@FreeBSD.org>

Don't treat the node as an 11n node if 11n rates are disabled.

For now, the AMRR code only knows about _either_ MCS or non-MCS rates.
It doesn't know how to downgrade (ie, doing 11b CCK rates if MCS0 isn't
reliable.)

PR: kern/183428


# c3322cb9 28-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

Include necessary headers that now are available due to pollution
via if_var.h.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# 76039bc8 26-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

The r48589 promised to remove implicit inclusion of if_var.h soon. Prepare
to this event, adding if_var.h to files that do need it. Also, include
all includes that now are included due to implicit pollution via if_var.h

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# f8d390be 04-Jul-2013 Adrian Chadd <adrian@FreeBSD.org>

Document the current 11n rate selection shortcoming in the AMRR code.


# f8bf74f2 04-Jul-2013 Adrian Chadd <adrian@FreeBSD.org>

Implement basic 802.11n awareness in the PHY and AMRR rate control code.

* Add 802.11n 2ghz and 5ghz tables, including legacy rates and up to
MCS23 rates (3x3.)

* Populate the rate code -> rate index lookup table with MCS _and_
normal rates, but _not_ the basic rate flag. Since the basic rate flag
is the same as the MCS flag, we can only use one.

* Introduce some accessor inlines that do PLCP and rate table lookup/access
and enforce that it doesn't set the basic rate bit. They're not
designed for MCS rates, so it will panic.

* Start converting drivers that use the rate table stuff to use the
accessor inlines and strip the basic flag.

* Teach AMRR about basic 11n - it's still as crap for MCS as it is
being used by iwn, so it's not a step _backwardS_.

* Convert iwn over to accept 11n MCS rates rather than 'translate' legacy
to MCS rates. It doesn't use a lookup table any longer; instead it's a
function which takes the current node (for HT parameters) and the
rate code, and returns the hardware PLCP code to use.

Tested:

* ath - it's a no-op, and it works that way
* iwn - both 11n and non-11n


# f88910cd 12-Jan-2011 Matthew D Fleming <mdf@FreeBSD.org>

sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.

Commit the net* piece.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 82878b11 11-May-2010 Rui Paulo <rpaulo@FreeBSD.org>

MFC r206367, r206358, r206370, r206371, r206372, r206398, r206415,
r206416, r206417, r206418, r206418:

net80211 ratectl framework.


# 380fe2df 28-Apr-2010 Rui Paulo <rpaulo@FreeBSD.org>

When in the RUN -> AUTH -> RUN FSM transition happens, we'll call the
ratectl_node_init() functions and since ni_rtctls was already
malloc'ed() we will panic. Fix this by using the already malloc'ed
pointer.

Found by: bschmidt
Reviewed by: bschmidt


# 645fe19a 08-Apr-2010 Rui Paulo <rpaulo@FreeBSD.org>

Use M_NOWAIT instead of M_WAITOK to avoid race conditions.

MFC after: 1 month


# b6108616 07-Apr-2010 Rui Paulo <rpaulo@FreeBSD.org>

net80211 rate control framework (net80211 ratectl).

This framework allows drivers to abstract the rate control algorithm and
just feed the framework with the usable parameters. The rate control
framework will now deal with passing the parameters to the selected
algorithm. Right now we have AMRR (the default) and RSSADAPT but there's
no way to select one with ifconfig, yet.
The objective is to have more rate control algorithms in the net80211
stack so all drivers[0] can use it. Ideally, we'll have the well-known
sample rate control algorithm in the net80211 at some point so all
drivers can use it (not just ath).

[0] all drivers that do rate control in software, that is.

Reviewed by: bschmidt, thompsa, weyongo
MFC after: 1 months


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# b032f27c 20-Apr-2008 Sam Leffler <sam@FreeBSD.org>

Multi-bss (aka vap) support for 802.11 devices.

Note this includes changes to all drivers and moves some device firmware
loading to use firmware(9) and a separate module (e.g. ral). Also there
no longer are separate wlan_scan* modules; this functionality is now
bundled into the wlan module.

Supported by: Hobnob and Marvell
Reviewed by: many
Obtained from: Atheros (some bits)


# 68e8e04e 10-Jun-2007 Sam Leffler <sam@FreeBSD.org>

Update 802.11 wireless support:
o major overhaul of the way channels are handled: channels are now
fully enumerated and uniquely identify the operating characteristics;
these changes are visible to user applications which require changes
o make scanning support independent of the state machine to enable
background scanning and roaming
o move scanning support into loadable modules based on the operating
mode to enable different policies and reduce the memory footprint
on systems w/ constrained resources
o add background scanning in station mode (no support for adhoc/ibss
mode yet)
o significantly speedup sta mode scanning with a variety of techniques
o add roaming support when background scanning is supported; for now
we use a simple algorithm to trigger a roam: we threshold the rssi
and tx rate, if either drops too low we try to roam to a new ap
o add tx fragmentation support
o add first cut at 802.11n support: this code works with forthcoming
drivers but is incomplete; it's included now to establish a baseline
for other drivers to be developed and for user applications
o adjust max_linkhdr et. al. to reflect 802.11 requirements; this eliminates
prepending mbufs for traffic generated locally
o add support for Atheros protocol extensions; mainly the fast frames
encapsulation (note this can be used with any card that can tx+rx
large frames correctly)
o add sta support for ap's that beacon both WPA1+2 support
o change all data types from bsd-style to posix-style
o propagate noise floor data from drivers to net80211 and on to user apps
o correct various issues in the sta mode state machine related to handling
authentication and association failures
o enable the addition of sta mode power save support for drivers that need
net80211 support (not in this commit)
o remove old WI compatibility ioctls (wicontrol is officially dead)
o change the data structures returned for get sta info and get scan
results so future additions will not break user apps
o fixed tx rate is now maintained internally as an ieee rate and not an
index into the rate set; this needs to be extended to deal with
multi-mode operation
o add extended channel specifications to radiotap to enable 11n sniffing

Drivers:
o ath: add support for bg scanning, tx fragmentation, fast frames,
dynamic turbo (lightly tested), 11n (sniffing only and needs
new hal)
o awi: compile tested only
o ndis: lightly tested
o ipw: lightly tested
o iwi: add support for bg scanning (well tested but may have some
rough edges)
o ral, ural, rum: add suppoort for bg scanning, calibrate rssi data
o wi: lightly tested

This work is based on contributions by Atheros, kmacy, sephe, thompsa,
mlaier, kevlo, and others. Much of the scanning work was supported by
Atheros. The 11n work was supported by Marvell.


# 63afe606 05-May-2007 Sepherosa Ziehau <sephe@FreeBSD.org>

- Nuke unnecessary header.
- Make wlan_amrr depend on wlan, so that it can find various symbols in
wlan module if wlan is not compiled into kernel.

Approved by: sam (mentor)
Tested by: kevlo


# 74828f25 26-Nov-2006 Sam Leffler <sam@FreeBSD.org>

device-independent implementation of AMRR tx rate control algorithm

Obtained from: openbsd (w/ mods)
MFC after: 1 month