Commit graph

43512 commits

Author SHA1 Message Date
Adrian Chadd
dd58d03a2a rtwn: set the maximum A-MPDU size correctly for RTL8812AU/RTL8821AU
The vendor driver sets it to 64k or 128k depending upon chipset,
along with bit 31 being set in hal/rtl8812a_hal_init.c:SetHwReg8812A().

Differential Revision:	 https://reviews.freebsd.org/D48118
Obtained from:	https://github.com/lwfinger/rtl8812au
Reviewed by:	bz
2025-01-07 18:32:56 -08:00
Adrian Chadd
d82bfe73a3 rtwn: don't set the RTS/CTS primary channel field for RTL8812AU/RTL8821AU
According to the rtl8812au reference driver, this seems to control
the bandwidth used by lower-bandwidth frames when transmitted in
a higher bandwidth channel.  For example, transmitting a 20MHz frame
on an 80MHz channel (eg in hostap mode) is doable, but you may want
to at least duplicate the RTS/CTS exchange across all four 20MHz
subchannels, AND perhaps duplicate the 20MHz frame.

I haven't fired this up with a spectrum analyser to see what the
result is.

The vendor driver doesn't bother with this and it doesn't change
performance.  My guess is that for modes like AP mode we MAY wantto
be able to control the RTS/CTS bandwidth choices rather than letting
the firmare do it, but we're not there yet.

The rtl8812au code in hal/rtl8812a_xmit.c:SCMapping_8812() has
the gory details, but then the one place it's used just has it
commented out and 0 (ie "do not care") is always programmed in.

Differential Revision:	https://reviews.freebsd.org/D48113
Obtained from:	https://github.com/lwfinger/rtl8812au
Reviewed by:	bz
2025-01-07 18:32:42 -08:00
Konstantin Belousov
6ba2c036a0 pci_find_cap_method(): limit number of iterations for finding a capability
Powered down device might return 0xff of extended config registers
reads, causing loop.

PR:	283815
Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D48348
2025-01-07 17:34:59 +02:00
Ariel Ehrenberg
080f68d0ab mlx5_core: Add steering support for IPsec with IPv6
ipv6 flow tables were not connected to previous FS tables.
Created an additional table to serve as IPsec RX root.
This table has 2 rules for redirecting the received packets
to ipv4/ipv6 based on the IP family in the packet header.

Sponsored by:	   NVidia networking
2025-01-07 02:53:37 +02:00
Adrian Chadd
93411b39ff rtwn: calculate control rate for VHT rate frames
If the passed in rate is a VHT rate, use rtwn_ctl_vhtrate() to
find a suitable rate for RTS/CTS.

Differential Revision:	 https://reviews.freebsd.org/D48295
Reviewed by:	bz, cy, emaste
2025-01-05 09:21:53 -08:00
Daniel Schaefer
48b9d78a0a hda: Add patch for Framework Laptop Intel 13th gen
It uses the same audio codec as 12th gen (PCI ID 0x0002).
Actually everything is the same, except the CPU.

Signed-off-by: Daniel Schaefer <dhs@frame.work>
2025-01-05 08:23:04 -05:00
Andrew Turner
b714eacb79 acpi: Pass the correct device to acpi_pcib_osc
Fix a copy-and-paste error in acpi_pcib_request_feature where the
child device was passed into acpi_pcib_osc rather than the pcib
device.

Reviewed by:	garga, jhb
Fixes:	ba1904937d ("acpica: Extract _OSC parsing to a common file")
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48285
2025-01-03 16:10:41 +00:00
Andrew Turner
143dff0f9c pci: Only claim to support PCI ASPM on x86
We claim to support Active State Power Management, but don't appear to
do anything different in the kernel when it's enabled other than tell
the firmware we do.

This breaks VMware Fusion on Apple Silicon when it's enabled as it
expects the kernel to enable the ports. As it is reported to be needed
on some x86 servers keep it enabled there, but disable on non-x86
architectures.

Reported by:	kp, tuexen
Reviewed by:	tuexen, mav, imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D48303
2025-01-03 16:10:41 +00:00
Adrian Chadd
64ecfc27db rtwn: add forcerate flag to TX descriptor setup
When doing firmware rate control there will be situations where
the rate being passed in needs to actually override the rate
control selection.  So add a flag to the descriptor setup path
to indicate that indeed this particular rate should be forced,
rather than rely on the firmware rate control.

This is currently a no-op as firmware rate control isn't working
in-tree, but it is working for me locally with other changes.
Without this, there's no way to force low rates for management,
DHCP traffic, and to allow fixed rate via "ifconfig wlanX ucastrate Y"
to function.

Locally tested:

* RTL8192CU, STA mode (firmware and driver/net80211 rate control)

Differential Revision:	https://reviews.freebsd.org/D48100
Reviewed by:	bz, gavin
2025-01-02 17:24:01 -08:00
Adrian Chadd
2be951a526 rtwn: enable VHT if it's configured in the device
If the driver attach path adds the VHT flag then add the 20/40/80 MHz
VHT channels.

This is a no-op right now as nothing is enabling it.

Differential Revision:	https://reviews.freebsd.org/D48097
Reviewed by:	bz
2025-01-02 17:18:16 -08:00
John Baldwin
925e1016b1 puc: Use device_delete_children if attach fails
This is slightly simpler than deleting individual devices.

Differential Revision:	https://reviews.freebsd.org/D47974
2025-01-02 13:25:38 -05:00
John Baldwin
d174ffca3a mfi: Use bus_generic_detach to simplify deleting children during detach
Differential Revision:	https://reviews.freebsd.org/D47973
2025-01-02 13:25:27 -05:00
John Baldwin
11a9117871 Use bus_generic_detach to detach and delete child devices during detach
This is simpler and more robust than individual calls to
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47972
2025-01-02 13:25:12 -05:00
John Baldwin
0ac15e476d spibus: Use bus_generic_* directly instead of wrappers
Differential Revision:	https://reviews.freebsd.org/D47971
2025-01-02 13:25:01 -05:00
John Baldwin
aa48c1ae08 etherswitch: Cleanup detach and delete of child devices during detach
Call bus_generic_detach first and return any error.  Remove no longer
needed individual device_delete_child calls.

Differential Revision:	https://reviews.freebsd.org/D47970
2025-01-02 13:24:46 -05:00
John Baldwin
3ddaf8200b Use bus_generic_detach instead of device_delete_children in detach
While here, check for errors from bus_generic_detach and move it to
the start of detach if necessary.

Differential Revision:	https://reviews.freebsd.org/D47969
2025-01-02 13:24:28 -05:00
John Baldwin
20f932af29 bhnd bcma/siba: Remove duplicate call to device_delete_children
bcma/siba_add_children already call device_delete_children if an error
occurs.

Differential Revision:	https://reviews.freebsd.org/D47968
2025-01-02 13:24:13 -05:00
John Baldwin
919f911ea4 siba: Use device_delete_children in siba_add_children
Differential Revision:	https://reviews.freebsd.org/D47967
2025-01-02 13:23:54 -05:00
John Baldwin
64d1a02e4e Check for errors from bus_generic_detach in various drivers
In some cases, move the call to bus_generic_detach earlier so that any
detach failures from child devices do not leave the parent device
partially detached.

Differential Revision:	https://reviews.freebsd.org/D47966
2025-01-02 13:23:41 -05:00
John Baldwin
6da28bb2a3 csa/emu10kx: Simplify deleting child devices
Use bus_generic_detach to detach and delete all child devices instead
of several explicit calls to device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47965
2025-01-02 13:23:28 -05:00
John Baldwin
faf0bf43df cgem: Cleanup detaching of child miibus device
Move bus_generic_detach earlier in place of the existing
device_delete_child.

Differential Revision:	https://reviews.freebsd.org/D47964
2025-01-02 13:23:16 -05:00
John Baldwin
160179ea3e Remove now-redundant calls to device_delete_children
Earlier calls to bus_generic_detach now take care of deleting
children.

Differential Revision:	https://reviews.freebsd.org/D47962
2025-01-02 13:22:50 -05:00
John Baldwin
4e62c3cafa Remove now-redundant calls to device_delete_child
Deleting a child explicitly before calling bus_generic_detach is now
redundant, so remove those calls and rely on bus_generic_detach to
delete children instead.

Differential Revision:	https://reviews.freebsd.org/D47961
2025-01-02 13:22:35 -05:00
John Baldwin
cf416f56eb Use the new bus_generic_detach directly in place of home-grown versions
Differential Revision:	https://reviews.freebsd.org/D47960
2025-01-02 13:22:20 -05:00
John Baldwin
b196276c20 bus_generic_detach: Delete children after detaching them
This provides better semantics as a standalone DEVMETHOD for
device_attach as bus drivers should remove child devices they created
as part of detach cleanup.  The implementation calls
bus_detach_children() first to permit child devices an opportunity to
veto the detach operation.  If that succeeds, device_delete_children()
is used to delete the child devices.

This requires fixing various drivers that were deleting devices
explicitly (via a device_t pointer cached in the softc) after calling
bus_generic_detach to stop doing that and just rely on
bus_generic_detach to remove child devices.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D47959
2025-01-02 13:21:30 -05:00
John Baldwin
28f5e880e8 Use device_delete_children instead of explicit calls to device_delete_child
This is simpler and more robust in the face of potential double-frees
(e.g. if called after bus_generic_detach which will delete devices in
a future commit).

Reviewed by:	manu, imp
Differential Revision:	https://reviews.freebsd.org/D47958
2025-01-02 13:20:21 -05:00
John Baldwin
e9d3857040 Use bus_detach_children instead of bus_generic_detach
These drivers perform additional teardown steps in between detaching
child devices and deleting child devices.

Differential Revision:	https://reviews.freebsd.org/D47957
2025-01-02 13:19:39 -05:00
Adrian Chadd
cbc331d153 rtwn: fix builds on non-x86 platforms
The powerpcspe build is spitting out uint64_t != unsigned long, so this
fails.  Comment out the logging for now to unbreak the build.
2024-12-31 14:45:52 -08:00
Adrian Chadd
aa17878371 rtwn: print out the firmware file being loaded
The firmware version isn't enough; different firmware is loaded
for different revisions of a given chip.  So print out the file too;
it'll make handling reports much easier.

Differential Revision:	https://reviews.freebsd.org/D48067
Reviewed by:	emaste
2024-12-31 13:58:17 -08:00
Adrian Chadd
06b7335701 rtwn: add rtwn_ctl_vhtrate(), some cleanups
* remove the hard-coded ridx values in rate2ridx(), use the RIDX
  defines for CCK/OFDM rates

* Add a placeholder rtwn_ctl_vhtrate() which returns the dot11rate
  control rate to use for the given VHT rate index.  Since net80211
  currently doesn't have any VHT PHY tables, there's no mapping for
  us to leverage so just return OFDM 12M for now.

* Use the new macro to convert rate index to MCS rate

* Add a printf() in rate2ridx if it's passed a HT/VHT rate.

Differential Revision:	https://reviews.freebsd.org/D48098
Reviewed by:	bz
2024-12-31 11:13:26 -08:00
Adrian Chadd
307f9c3515 rtwn: only set INIRATE if we're not doing firmware rate control.
This register (array) controls the initial rate to use for each
MACID.  There's no need to set it if firmware rate control is enabled -
it'll actually be under firmware control (and we can read it back to
see what choices the firmware is making.)

Locally tested:

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

Differential Revision:	https://reviews.freebsd.org/D48094
Reviewed by:	bz
2024-12-31 11:12:57 -08:00
Adrian Chadd
af2e102c40 rtwn: enable periodic TX reporting support on RTL8188EU NICs.
The RTL8188E firmware doesn't have the "full" offload firmware
rate control.  Instead, the vendor driver has a bunch of logic
in the driver for rate probing and selection.

Part of this is the periodic TX report - which uploads a summary
of multi-rate retries and drops per MAC.  Using it drastically
cuts down on the TX notifications - it's fired from a timer
(defaulting to ~ 1.6 seconds) and is a single receive frame in
the normal bulk RX path.

I've not ported / reimplemented the whole vendor driver rate adaption
code - instead, I'm just using the normal net80211 rate control APIs.
It seems to behave OK - I get 25-30mbit down and 20mbit up using TCP/
speedtest.

Locally tested:

* RTL8188EU, STA mode

Differential Revision:	 https://reviews.freebsd.org/D48088
Reviewed by:	fuz, bz
Obtained from:	https://github.com/lwfinger/rtl8188eu/blob/master/hal/Hal8188ERateAdaptive.c
2024-12-31 11:11:33 -08:00
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