Commit graph

43480 commits

Author SHA1 Message Date
Adrian Chadd
7ddf19492c rtwn: add support for register IO debugging
Add support to read/write the MAC/PHY registers.

Hide it behind RTWN_DEBUG.

This doesn't cover the RF registers as they require a different
IO path, but I haven't yet debugged the RF paths.

Locally tested:

* RTL8192CU, STA
* RTL8188EU, STA
* RTL8812AU / RTL8821AU, STA

Differential Revision:	https://reviews.freebsd.org/D48084
Reviewed by:	bz
2024-12-31 11:11:07 -08:00
Yoshihiro Takahashi
41b30bbc1a uart: Add support for Brainboxes / Intashield serial cards.
PR:		283226
Reported by:	Cameron Williams
2024-12-31 18:04:27 +09:00
Adrian Chadd
4fad98b5c8 rtwn: remove SEQ_SEL, replace with a QOS bit
I've reviewed all of the linux vendor and upstream drivers.
This SEQ_SEL field isn't a mask and doesn't ever look like it
it was; instead this bit is set to tag QoS data frames.

In fact, it effectively was set to 0 for STA frames and potentially 1
for broadcast/multicast frames as the STA macid of 0 and broadcast/
multicast macid of 1 maps to that. In AP modes it would be tagged
based on bit 0.

So, bring it in line with the vendor and linux drivers.

Locally tested:

* RTL8192CU, STA, hostap
* RTL8188EU, STA
* RTL8192EU, STA

Differential Revision:	https://reviews.freebsd.org/D48092
2024-12-30 17:35:13 -08:00
John Baldwin
365b89e8ea nvmf: Switch several ioctls to using nvlists
For requests that handoff queues from userspace to the kernel as well
as the request to fetch reconnect parameters from the kernel, switch
from using flat structures to nvlists.  In particular, this will
permit adding support for additional transports in the future without
breaking the ABI of the structures.

Note that this is an ABI break for the ioctls used by nvmf(4) and
nvmft(4).  Since this is only present in main I did not bother
implementing compatability shims.

Inspired by:	imp (suggestion on a different review)
Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D48230
2024-12-30 13:52:21 -05:00
Kyle Evans
b313229969 pci: avoid accidental clobbering of regs on some fdt platforms
Most pci controllers will just have a single reg for the config space,
but others (e.g., on Apple Silicon) may have more following that to
describe, e.g., controller port space.  Bump the "ranges" rid space up
to avoid overriding these other memory resources.

Reviewed by:	jhb
Differential Revision:	https://reviews.freebsd.org/D43921
2024-12-28 21:57:03 -06:00
Fuqian Huang
792e47a51a ocs_fc: print instance_index value rather than pointer itself in ocs_cam.c
In function ocs_scsi_recv_tmf, print instance_index rather than
the pointer itself to avoid printing out kernel pointer to user space.

PR: 238659
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Reviewed-by: imp
2024-12-28 14:12:35 -07:00
John Baldwin
225c5e535b nvmft: Fix typo in error message if an I/O queue fails to handoff
Sponsored by:	Chelsio Communications
2024-12-28 14:54:29 -05:00
Gordon Bergling
d40330306c sound(4): Fix a typo in a source code comment
- s/orginally/originally/

MFC after:	3 days
2024-12-28 07:41:43 +01:00
Gordon Bergling
3db51fb172 isci(4): Fix a typo in a source code comment
- s/kength/length/

MFC after:	3 days
2024-12-28 07:41:34 +01:00
Adrian Chadd
791170aaf7 rtwn: make sure RCR_APPFCS stays set in monitor mode / mode changes.
My previous commit meant that APPFCS wasn't enabled during monitor
mode and likely other corner cases.

Ensure it stays on at all times.

This, amusingly, fixes monitor mode in RTL8812AU/RTL8821AU - without it,
I don't see HT/VHT frames in monitor mode but I can still receive them
in normal STA mode.

Differential Revision:	https://reviews.freebsd.org/D48112
2024-12-27 17:46:38 -08:00
Gavin Atkinson
6ea1ce222c bhnd: Fix a few use after frees when releasing resources
The resource list entry needs to be looked up using rman_get_* prior
to releasing the resource.

Fixes:		9dbf5b0e68 new-bus: Remove the 'rid' and 'type' arguments from BUS_RELEASE_RESOURCE
2024-12-27 11:55:05 -05:00
Ahmad Khalifa
3e8f4a3059 efirt: use correct ABI for runtime EFI functions
When calling EFI RT methods through no fault path.

MFC after:	1 week
2024-12-25 04:00:09 +02:00
Gleb Smirnoff
c21f5751ef acpi_ibm: pass brightness events to evdev(4)
unless the dev.acpi_ibm.0.handlerevents sysctl is set to process
them internally.  The default for the latter is to ignore them,
so passing to evdev(4) is enabled by default.

Reviewed by:		wulf, imp
Tested on:		Lenovo Thinpad X11 Carbon 7Th Gen
Differential Revision:	https://reviews.freebsd.org/D48174
2024-12-23 18:10:56 -08:00
Bojan Novković
6e8233df18 hwpmc_x86: Fix NULL deref when loading on unsupported hardware
The pmc_md_{intialize, finalize} routines rely on a machine-dependent
structure to register the appropriate PMC interrupt handler. However,
the vendor-specific routines that allocate this structure may return
NULL for unsupported hardware, leading to a panic when the hwpmc module
gets loaded. This patch adds additional checks that fix this issue.

Reported by:	Michael Butler (imb@protected-networks.net)
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D48168
2024-12-23 11:00:57 +01:00
Vladimir Kondratyev
38b67578fb hid: Correctly handle signed/unsigned quantities in kernel HID parser.
Wrong signedness of usage value results in inverted range check in hmt(4)
driver that allows out of bound array access leading to panic.

Reported by:	many
Sponsored by:	Future Crew, LLC
Obtained from:	NetBSD
NetBSD PR:	kern/53605
PR:		274014, 282592
2024-12-22 06:16:11 +03:00
Adrian Chadd
9efd215411 rtwn: create a new HAL routine for enabling STA mode beacon processing
For some NICs (notably the rtl8192cu that I'm working on) the
firmware rate adaptation requires beacon processing to be enabled.

Instead of making assumptions in the if_rtwn beacon routines (and
honestly all of that should be in the HAL too), create a HAL method
for enabling/disabling beacon processing specifically in STA mode.

Since this isn't necessarily required for all NICs (notably the RTL8188E
NICs, where some will do firmware rate control and some will require
driver rate control), only enable it for the RTL8192CU and RT8192EU.

The RTL8188E and RTL8812/RTL8821 just have no-op routines for now.

Locally tested:

* RTL8192CU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48066
Reviewed by:	bz
2024-12-20 12:40:19 -08:00
Bjoern A. Zeeb
d7c69a3448 sdhci: add missing bus_add_child DEVMETHOD.
Add the missing bus_add_child DEVMETHOD.  This is needed for the RPi5
running with a MMCCAM kernel and the worproject/rpi5-uefi to avoid a
kernel panic on boot when SDIO tries to attach to a 'Intel Bay Trail'
controller.

Reviewed by:	imp
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D48152
2024-12-20 07:18:54 +00:00
Adrian Chadd
300c843b07 rtwn: bring the r92c rate control setup selection in line with tx descriptors
The rate control message was doing 11g+11n without 11b rates, but
the TX descriptor setup supports also falling back on 11b rates
when doing multi-rate retry / per-descriptor rate control.

So, line them up.  They're not exactly the same as the TX path
supports pure-N and pure-G modes which the rate control configuration
does not, but there'll need to be a lot more work on supporting
those operating modes anyway (around things like self-generated
frame rate control/masks, beacon config, RTS/CTS selection, etc.)

Locally tested:

* RTL8192CU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48081
Reviewed by:	bz
2024-12-19 08:08:24 -08:00
Adrian Chadd
eb6314510c rtwn: disable a workaround introduced earlier for RTL8192CU TX performance
I'm unable to reproduce the original problem with my RTL8192CU USB
devices with the current codebase and I can't find any reference
to what this power register is doing - I see it defined in drivers,
but it's not described or used anywhere.

This reverts 7f74097165 -
rtwn_usb(4): fix Tx instability with RTL8192CU chipsets

In any case being able to do higher rate RTS/CTS is beneficial.

Local testing:

* rtl8192cu, STA mode, TX/RX testing

PR:		233949

Differential Revision:	https://reviews.freebsd.org/D48026
Reviewed by:	imp
2024-12-19 08:07:28 -08:00
Adrian Chadd
aaaca5f288 rtwn: add a default OFDM / CCK rate for self-generated frames
I noticed during testing that the MAC was generating MCS7 ACKs and
MCS7 block-ACK frames in response to MCS frames from its peer.
This is very suboptimal - it means that unless you're very close
to your peer (in this case a 2GHz AP), you'll end up failing a lot
of ACKs.

Linux faced the opposite problem in rtl8xxxu - the rate set being
programmed in here included a lot MORE rates, including MCS 0->7
and OFDM 6M->54M.  This meant that they were INTENTIONALLY telling
the hardware to transmit at higher rates, and their fix was to
mask out the higher rates so self-generated frames don't try the
high rates at all.

Now, I am not sure why I'm not seeing any OFDM or HT basic rates.
We don't mark any OFDM / HT rates as basic in net80211 (in
ieee80211_phy.c) so I'm going to need to go and do a review of the
standard to see what's up.  Additionally, the HT rate set that we
populate isn't tagging any of the HT rates as IEEE80211_RATE_BASIC,
so the code I added for now is a no-op.

So:

* Extend rtwn_get_rates() and its consumers to populate the HT rateset
  with basic rates if they're provided
* Add a default 2GHz / 5GHz mask, inspired by linux, applied over the
  basic rates provided.
* Make sure there's at least an OFDM rate (for 2G/5G) rate available if
  the peer node is HT, which avoids the MAC defaulting to MCS7 when
  generating ACK/block-ACK.
* Add register definitions for INIDATA/INIRTS, which set the default
  data rate when the driver doesn't specify the initial data / RTS/CTS
  rates in the TX descriptor.
* Leave a comment about why I've modified the mask from Linux.

Locally tested:

* RTL8192CU, STA mode
* RTL8188EU, STA mode
* RTL8192EU, STA mode
* RTL8812AU, STA mode

Differential Revision:	https://reviews.freebsd.org/D48019
Reviewed by:	bz
2024-12-19 08:06:29 -08:00
Adrian Chadd
4e2bd8cf08 rtwn: set the shortgi flag in the RTL8192C rate control setup message
Enable the short-GI flag configuring the rate mask.

Obtained from:

* Realtek vendor driver, rtl8192cu

Differential Revision:	 https://reviews.freebsd.org/D48013
Reviewed by:	bz, imp
2024-12-19 08:05:26 -08:00
Franco Fichtner
38663adb61 Revert "ixl: fix multicast filters handling"
This reverts commit 89e7335942.

PR:		281125
Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
MFC after:	3 days
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1545
2024-12-19 13:49:30 +00:00
Slava Shwartsman
b762b199af mlx5: Eliminate the use of mlx5_rule_fwd_action
Driver defined all flow context actions in MLX5_FLOW_CONTEXT_ACTION_*,
no need to duplicate them with mlx5_rule_fwd_action.

Sponsored by:   NVidia networking
MFC after:      1 week
2024-12-19 01:59:42 +02:00
Adrian Chadd
371a4ee9a3 rtwn: add SGI flag for the rate control message
This is straight from all the drivers, linux and vendor.

Differential Revision:	https://reviews.freebsd.org/D48004
Reviewed by:	bz, imp
2024-12-18 15:48:45 -08:00
Adrian Chadd
745a858247 rtwn: update rtwn_get_rates() to separate out the CCK/OFDM and HT rates
The 32 bit bitmap is enough for CCK/OFDM rates and MCS0..15, but
won't work for > MCS15, nor VHT rates.

So, break out the legacy rates and HT rates.

* break the rates and htrates out
* document which calls are looking up basic rates and which care
  about the rates themselves
* ensure the rate bitmap passed into the rate control firmware call
  (which isn't enabled yet!) is capped at 28 bits so they don't
  set the mode field.

Differential Revision:	https://reviews.freebsd.org/D47993
Reviewed by:	bz, imp
2024-12-18 15:48:10 -08:00
Adrian Chadd
638fcd53db rtwn: bump up the RX USB buffers
We should just keep the RX pipeline busy.

Differential Revision:	https://reviews.freebsd.org/D47990
Reviewed by:	imp
2024-12-18 15:47:37 -08:00
Adrian Chadd
25af78d0bd ath_rate_sample: correct the "best rate" calculation
This should be a *9 rather than a *10 so higher stream MCS rates
(eg comparing MCS0 and MCS8) that have slightly longer average transmit
times (but better burst transmit times) get considered.

This mirrors what the later code does when considering if a rate
change is needed.

Locally tested:

* AR9280, AP mode
* AR9380, AP mode

Differential Revision:	https://reviews.freebsd.org/D47988
Reviewed by:	imp
2024-12-18 15:46:52 -08:00
Adrian Chadd
0ea7f8ca66 rtwn: try enforcing net80211 regulatory / txpower limits for 11n chips
This is an attempt to reverse engineer what the actual transmit power
calculations are doing and apply net80211 limits on them.  It doesn't
look as simple as just applying the check at the end - there are plenty
of places where offsets are calculated between different PHY modes and
1 / 2 antenna MCS transmit rates.

There are also some places where the offset being added is negative,
so handle the potential underflow so when things hit 0, they don't
just wrap and cause the maximum transmit power into the registers.

This is being done to aide in power/performance debugging - if there
are issues with the transmit power being wrongly calculated and are too
high, the output waveform will be distorted and it will effect performance.
Being able to drop the transmit power by a few dB here and there can
quickly identify if this is happening (because suddenly higher MCS
rates / OFDM rates suddenly work better!)

I've tested each NIC through the transmit power values from 0 dBm
to 30dBm via ifconfig (and they're all capped far before that,
normally around 20-25dBm) and they're not underflowing.

Locally tested:

* RTL8192CU, STA
* RTL8192EU, STA
* RTL8188EU, STA

Differential Revision:	https://reviews.freebsd.org/D47987
Reviewed by:	bz, imp
2024-12-18 15:46:15 -08:00
Adrian Chadd
6858c6b1e1 rtwn: refactor out the TX power register power dump, condense output
* Refactor out the TX power register register dump - it's done in
  a couple places and it makes sense to refactor it.

* Condense the output into a few lines per transmit chain.  It's
  very long with the 8 and 16 MCS rates, and it made it difficult
  to eyeball what's going on when tweaking TX power.

Differential Revision:	https://reviews.freebsd.org/D47986
Reviewed by:	bz, imp
2024-12-18 15:45:47 -08:00
Adrian Chadd
b71805e991 rtwn: add APIs for setting transmit power
The RTL8188/RTL8192/RTL8821/RTL8812 NICs all seem happy to have
their transmit power changed at runtime - and it does seem to do
what's expected - the transmit power level does change.

So, add the API call here, even though it's all currently no-ops.
A follow-up commit will land changes for the chipsets to both
limit transmit power to the configured / regulatory limit AND
allow reconfiguration at runtime.

Differential Revision:	https://reviews.freebsd.org/D47979
Reviewed by:	bz, imp
2024-12-18 15:45:24 -08:00
Adrian Chadd
cf6b389f7c rtwn: add tx power training for RTL8812/RTL8821
This apparently kicks off TX power level self-calibration, which
can't hurt.

Locally tested:

* RTL8812AU, STA
* RTL8821AU, STA

Obtained from:	Linux rtw88

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

Reviewed by:	bz, imp
2024-12-18 11:31:18 -08:00
Jessica Clarke
e1060f6dfd ofw: Fix inverted bcmp in ofw_bus_node_status_okay
Otherwise this matches any two-character status except for ok.

Fixes:		e5e94d2de9 ("Expand OpenFirmware API with ofw_bus_node_status_okay method")
MFC after:	1 week
2024-12-17 20:51:56 +00:00
Jari Sihvola
35a2229b67 Add StarFive JH7110's STG clocks
This is identical to AON clocks. The only difference is
BUS_PASS_ORDER_LAST which was needed for some reason. This has clocks
needed by PCIe controller driver.

Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47920
2024-12-16 15:27:23 -04:00
Jari Sihvola
ce3fbcdd14 jh7110: Add sys clocks for STG & PCIE
This patch adds some SYS clocks for StarFive JH7110. They are necessary
for getting STG clocks and PCIe driver working.

Reviewed by:	mhorne
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D47981
2024-12-16 15:27:23 -04:00
Gleb Smirnoff
2ef97d8b75 xen/netfront: use iflladdr_event to send ARPs
Avoids usage of arp_ifinit() and if_foreach_addr_type().  The former
isn't encouraged to be used in drivers and the latter is about to
change to not expose struct ifaddr.

Reviewed by:		royger, ehem_freebsd_m5p.com
Differential Revision:	https://reviews.freebsd.org/D48053
2024-12-16 06:49:29 -08:00
Ariel Ehrenberg
2fb2c03512 mlx5_core: fix "no space" error on sriov enablement
Change POOL_NEXT_SIZE define value from 0 to BIT(30), since this define
is used to request the available maximum sized flow table, and zero doesn't
make sense for it, whereas many places in the driver use zero explicitly
expecting the smallest table size possible but instead due to this
define they end up allocating the biggest table size unawarely.

Sponsored by:	NVidia networking
2024-12-16 00:27:53 +02:00
Ariel Ehrenberg
29a9d7c6ce mlx5_core: fix panic on sriov enablement
Align the code of fdb steering with flow steering core
and add missing parts in namespace initialization and
in prio logic

PR:	281714
Sponsored by:	NVidia networking
2024-12-16 00:27:31 +02:00
Bojan Novković
d5ce54dddf hwpmc_x86: Register interrupt handler using the dynamic NMI registration interface
Register the PCINT handler using the nmi_{register, remove}_handler
interfaces (introduced in D46421) in preparation for hwt(4)'s
Intel Processor Trace backend. No functional change intended.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D47989
2024-12-15 16:39:36 +01:00
Bojan Novković
04e8326721 x86: Allow sharing of perfomance counter interrupts
This patch refactors the Performance Counter interrupt setup code to
allow sharing the interrupt line between multiple drivers.
More specifically, Performance Counter interrupts are used by both
hwpmc(4) and hwt(4)'s upcoming Intel Processor Trace backend.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D46420
2024-12-15 16:39:36 +01:00
Adrian Chadd
35e63136a8 rtwn: add a register value for R92C_FPGA0_POWER_SAVE, and other bits
* add a register value for the R92C_FPGA0_POWER_SAVE register
* add the field names and mask
* add a mask for the 40MHz upper/lower bits in R92C_RMRR; I think
  I need to debug and overhaul the 20/40MHz config path to get 40MHz
  working right.

Local testing:

* rtl8188eu, sta mode
* rtl8192cu, sta mode
2024-12-13 18:17:52 -08:00
Adrian Chadd
7b71689c9c rtwn: update RTL8812AU/RTL8821AU receive path to include VHT info
* RX frames with short-GI can be either HT or VHT
* Add placeholders for RX VHT rate, PHY type, etc

Differential Revision:	https://reviews.freebsd.org/D47902
2024-12-13 18:17:40 -08:00
Adrian Chadd
7722d5e214 rtwn: add RTL8812/RTL8821 VHT80 channel programming, spur management
* add VHT80 channel programming
* add VHT80 spur management, sync with Linux rtw88

Obtained from: Linux rtw88

Differential Revision:	https://reviews.freebsd.org/D47901
2024-12-13 18:17:27 -08:00
John Baldwin
7c89253bda vmm: Initialize error in vmmdev_rw
CID:		1568045
Reported by:	Coverity Scan
Reviewed by:	markj
Fixes:		4008758105 vmm: Validate credentials when opening a vmmdev
Differential Revision:	https://reviews.freebsd.org/D48073
2024-12-13 11:52:31 -05:00
Andrew Turner
1f5c50a861 pci_host_generic:Add pcib_request_feature on ACPI
In the ACPI attachment add support for the pcib_request_feature method.
This uses the common _OSC handling.

Reviewed by:	imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48048
2024-12-12 18:00:23 +00:00
Andrew Turner
deb36d0c65 pci_host_generic: Support ACPI_IVAR_HANDLE
In the ACPI attachment support the ACPI_IVAR_HANDLE ivar. While here
use the common ivar function to support the common ivars.

Reviewed by:	imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48047
2024-12-12 18:00:23 +00:00
Andrew Turner
7cafe75c8c pci: Make generic_pcie_read_ivar non static
Allow this to be called from attachments to allow more ivars to be
implemented.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48046
2024-12-12 18:00:23 +00:00
Andrew Turner
fafb43abd0 pci: Use a switch statement when reading ivars
In pci_host_generic.c use a switch statement rather than a series
of if statements.

Reviewed by:	imp
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48045
2024-12-12 18:00:23 +00:00
Andrew Turner
ba1904937d acpica: Extract _OSC parsing to a common file
This will be used by pci_host_generic_acpi.c so needs to be in a
common location.

Reviewed by:	imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48044
2024-12-12 18:00:22 +00:00
John Baldwin
70693a4538 cxgbe tom: Restore support for zerocopy TCP receive for aio_read()
The commit to introduce TCP_USE_DDP support had a couple of bugs that
broke support for zerocopy receive via aio_read().  First, the length
and offset arguments to mk_update_tcb_for_ddp() were reversed which
prevented DDP from working.  Second, the AIO state in the toep was
initialized too late when the first aio_read() request was queued.

Reported by:	Harshavardhan Tanneru @ Chelsio
Fixes:		eba13bbc37 cxgbe: Support TCP_USE_DDP on offloaded TOE connections
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-12-10 21:23:47 -05:00
Kyle Evans
36a80f4264 usb: serial: make more commands execute synchronously
The termios layer wants some level of guarantee that we've actually
submitted param changes to the hardware when our functions return, so we
need to do a little more waiting to avoid violating those guarantees.

This is especially important as some hardware has some minimum timing
specifications around this stuff, and without being less asynchronous
the software dealing with these devices can't reasonably operate the
hardware without more excessive delays than they should need.

More specifically, we make sure that:
 - The command to start transfers is finished before we toggle DTR/RTS
 - The status_change command finishes before we return, which may change
    some fields in the softc that we need for a subsequent call into
    usb_serial
 - cfg_param finishes before we re-enable transfers, and we ensure that
    RTS is appropriately toggled before we return to userland

This has been observed to fix some flakiness in connecting to some
ESP32 devices.

Tested by:	kenrap from Libera
Reviewed by:	imp, kib
Differential Revision:	https://reviews.freebsd.org/D47952
2024-12-10 19:23:41 -06:00