HardenedBSD src tree
Go to file
Adrian Chadd d99eb8230e rtwn: change the USB TX transfers to only do one pending transfer per endpoint
I found I was getting constant device timeouts when doing anything
more complicated than a single SSH on laptop with RTL8811AU.

After digging into it, i found a variety of fun situations, including
traffic stalls that would recover w/ a shorter (1 second) USB transfer
timeout.  However, the big one is a straight up hang of any TX endpoint
until the NIC was reset.  The RX side kept going just fine; only the
TX endpoints would hang.

Reproducing it was easy - just start up a couple of traffic streams
on different WME AC's - eg a best effort + bulk transfer, like
browsing the web and doing an ssh clone - throw in a ping -i 0.1
to your gateway, and it would very quickly hit device timeouts every
couple of seconds.

I put everything into a single TX EP and the hangs went away.
Well, mostly.

So after some MORE digging, I found that this driver isn't checking
if the transfers are going into the correct EPs for the packet
WME access category / 802.11 TID; and would frequently be able
to schedule multiple transfers into the same endpoint.

Then there's a second problem - there's an array of endpoints
used for setting up the USB device, with .endpoint = UE_ADDR_ANY,
however they're also being setup with the same endpoint configured
in multiple transfer configs.  Eg, a NIC with 3 or 4 bulk TX endpoints
will configure the BK and BE endpoints with the same physical endpoint
ID.  This also leads to timed out transfers.

My /guess/ was that the firmware isn't happy with one or both of the
above, and so I solved both.

* drop the USB transfer timeout to 1 second, not 5 seconds -
  that way we'll either get a 1 second traffic pause and USB transfer
  failure, or a 5 second device timeout.  Having both the TX timeout
  and the USB transfer timeout made recovery from a USB transfer
  timeout (without a NIC reset) almost impossible.

* enforce one transfer per endpoint;
* separate pending/active buffer tracking per endpoint;
* each endpoint now has its own TX callback to make sure the queue /
  end point ID is known;
* and only frames from a given endpoint pending queue is going
  into the active queue and into that endpoint.
* Finally, create a local wme2qid array and populate it with the
  endpoint mapping that ensures unique physical endpoint use.

Locally tested:

* rtl8812AU, 11n STA mode
* rtl8192EU, 11n STA mode (with diffs to fix the channel config / power
  timeouts.)

Differential Revision: https://reviews.freebsd.org/D47522
2024-11-20 17:56:56 -08:00
.cirrus-ci
.github
bin sh(1): -l is only valid in cli option not as set -l 2024-11-20 14:15:41 +01:00
cddl
contrib
crypto
etc
gnu
include
kerberos5
lib libc: Note that getentropy is nearly POSIX 2024 2024-11-20 14:30:34 -05:00
libexec
release release: install wireless firmware onto disc1 and dvd 2024-11-20 13:05:04 +00:00
rescue
sbin
secure
share igc.4: Remove non-existent timer tunables 2024-11-20 16:59:23 -07:00
stand stand: drop inttypes.h from safe list 2024-11-20 12:49:48 -07:00
sys rtwn: change the USB TX transfers to only do one pending transfer per endpoint 2024-11-20 17:56:56 -08:00
targets
tests netinet: handle blackhole routes 2024-11-20 16:52:41 +01:00
tools nanobsd: Remove dependency on bsdlabel 2024-11-20 22:31:56 +00:00
usr.bin
usr.sbin bsdinstall: add menu to install firmware 2024-11-20 13:06:06 +00:00
.arcconfig
.arclint
.cirrus.yml
.clang-format
.git-blame-ignore-revs
.gitattributes
.gitignore
.mailmap
CONTRIBUTING.md
COPYRIGHT
LOCKS
MAINTAINERS
Makefile
Makefile.inc1
Makefile.libcompat
Makefile.sys.inc
ObsoleteFiles.inc
README.md
RELNOTES
UPDATING

FreeBSD Source:

This is the top level of the FreeBSD source directory.

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms. A large community has continually developed it for more than thirty years. Its advanced networking, security, and storage features have made FreeBSD the platform of choice for many of the busiest web sites and most pervasive embedded networking and storage devices.

For copyright information, please see the file COPYRIGHT in this directory. Additional copyright information also exists for some sources in this tree - please see the specific source directories for more information.

The Makefile in this directory supports a number of targets for building components (or all) of the FreeBSD source tree. See build(7), config(8), FreeBSD handbook on building userland, and Handbook for kernels for more information, including setting make(1) variables.

For information on the CPU architectures and platforms supported by FreeBSD, see the FreeBSD website's Platforms page.

For official FreeBSD bootable images, see the release page.

Source Roadmap:

Directory Description
bin System/user commands.
cddl Various commands and libraries under the Common Development and Distribution License.
contrib Packages contributed by 3rd parties.
crypto Cryptography stuff (see crypto/README).
etc Template files for /etc.
gnu Commands and libraries under the GNU General Public License (GPL) or Lesser General Public License (LGPL). Please see gnu/COPYING and gnu/COPYING.LIB for more information.
include System include files.
kerberos5 Kerberos5 (Heimdal) package.
lib System libraries.
libexec System daemons.
release Release building Makefile & associated tools.
rescue Build system for statically linked /rescue utilities.
sbin System commands.
secure Cryptographic libraries and commands.
share Shared resources.
stand Boot loader sources.
sys Kernel sources (see sys/README.md).
targets Support for experimental DIRDEPS_BUILD
tests Regression tests which can be run by Kyua. See tests/README for additional information.
tools Utilities for regression testing and miscellaneous tasks.
usr.bin User commands.
usr.sbin System administration commands.

For information on synchronizing your source tree with one or more of the FreeBSD Project's development branches, please see FreeBSD Handbook.