Commit graph

43222 commits

Author SHA1 Message Date
Stephan de Wit
7a6a323c05 axgbe: fix link issues for gigabit external SFP PHYs and 100/1000 fiber modules
Within the code path of autonegotiation for gigabit SFP modules was a bug, causing
a report of LINK_ERR for cases where an external SFP PHY was present. Fixing this issue
did not resolve to a link however, as it turned out that while autonegotiation interrupts
were happening, it's resulting status cannot be correctly determined in all cases. In these
specific cases we have no other option than to assume a module has negotiated to 1Gbit/s.

PHY-specific configuration has been delegated to the miibus driver, if an external PHY is present.
It's possible that the i2c bus does not recognize a PHY on the first pass, so in all cases we
retry up to a maximum of 5 times during each link poll pass to ensure we didn't miss the presence
of an external PHY.

This commit also addresses link issues on both 100 mbit and 1Gb fiber modules. Not all of these modules
have the correct data set according to SFF-8472, as such we first check for gigabit compliance and
the associated baudrate, otherwise we resort back to determining what type of fiber module is plugged
in by checking the baudrate, cable length and wavelength and setting the MAC speed accordingly.
2025-07-09 10:05:49 +02:00
Stephan de Wit
499530a71b axgbe: also validate configuration register in GPIO expander
It is possible for a machine to boot into a state in which the configuration register,
responsible for controlling wether an I/O signal is considered an input or output,
contains randomized values. It was assumed this was programmed by the BIOS.

If I/O is reversed, it's possible for the driver to think an SFPP module has been inserted
when there is none, leading to unrecoverable I2C errors.

The configuration register should contain a state which is determined and provided by the BIOS,
hence no hard-coded values are programmed here.
2025-07-09 10:05:49 +02:00
Stephan de Wit
f45a2d1e5a axgbe: several patches from 22.1 not yet present in FreeBSD 2025-07-09 10:05:49 +02:00
Roger Pau Monné
dfde5dff70 x86/xen: fix accounted interrupt time
The current addition to the interrupt nesting level in
xen_arch_intr_handle_upcall() needs to be compensated in
xen_intr_handle_upcall(), otherwise interrupts dispatched by the upcall handler
end up seeing a td_intr_nesting_level of 2 or more, which makes them assume
there's been an interrupt nesting.

Such extra interrupt nesting count lead to statclock() reporting idle time as
interrupt, as the call from interrupt context will always be seen as a nested
one (td->td_intr_nesting_level >= 2) due to the nesting count increase done by
both xen_arch_intr_handle_upcall() and intr_execute_handlers().

Fix this by adjusting the nested interrupt count before dispatching interrupts
from xen_intr_handle_upcall().

PR: 277231
Reported by: Matthew Grooms <mgrooms@shrew.net>
Fixes: af610cabf1 ('xen/intr: adjust xen_intr_handle_upcall() to match driver filter')
Sponsored by: Cloud Software Group
Reviewed by: Elliott Mitchell <ehem+freebsd@m5p.com>
2025-07-09 10:05:48 +02:00
Ad Schellevis
bc99862101 ixgbe: workaround to prevent an i2c bus read to keep trying to read an empty slot
When executing `ifconfig -v` this will lead to stalls for a second per
interface due to the timeout being set to a static 10 without a module
placed, this patch makes sure this is only allowed once per insertion.
2025-07-09 10:05:47 +02:00
Hareshx Sankar Raj
6f3c8060d5 qat: add disable safe dc mode for QAT SPR devices
Build and sysctl configuration modes are introduced for QAT SPR
devices to disable safe dc mode. A new QAT driver build option
‘QAT_DISABLE_SAFE_DC_MODE’ is required to build the QAT driver
with code that allows a request to be sent to FW to override the
‘History Buffer’ mitigation. Default QAT driver builds do not
include this ‘QAT_DISABLE_SAFE_DC_MODE’ build option. Even if the
QAT driver was built with code that allows a request to be sent to
FW to override the ‘History Buffer’ mitigation, the QAT driver must
still be configured using sysctl to request an override of the
‘History Buffer’ mitigation if desired. The default QAT driver
configuration option sysctl dev.qat.X.disable_safe_dc_mode does not
allow override of the mitigation. The new sysctl attribute
disable_safe_dc_mode is to be set to 1 for overriding the history
buffer mitigation. Firmware for qat_4xxx is updated for this change.
If this mode is enabled, decompression throughput increases but may
result in a data leak if num_user_processes is more than 1.
This option is to be enabled only if your system is not prone to
user data leaks.

Reviewed by:	markj, ziaee
MFC after:	2 weeks
Sponsored by:   Intel Corporation
Differential Revision:  https://reviews.freebsd.org/D50379

(cherry picked from commit 5a8e5215cef0dac1115853889e925099f61bb5fa)
2025-07-09 10:05:45 +02:00
Mark Johnston
621a05d72e igc: Fix some issues in igc_neweitr()
The justification is the same as in commit
fb876eef219e ("e1000: Fix some issues in em_newitr()").

Reviewed by:	kbowling
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50548

(cherry picked from commit ef062029ceffacb6bde3a5639a2bd8c4d59ca1df)
2025-07-09 10:05:45 +02:00
Mark Johnston
226e032c30 igc: Initialize helper variables in igc_neweitr()
The justification is the same as in commit
a5b5220b1807 ("e1000: Initialize helper variables in em_newitr()").

Reviewed by:	kbowling
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50547

(cherry picked from commit d6a9f49185797c6b67e517a3d83ef63436c8d4f3)
2025-07-09 10:05:45 +02:00
Mark Johnston
e8094a411e e1000: Fix some issues in em_newitr()
- Load packet and byte counters exactly once, as they can be
  concurrently mutated.
- Rename bytes_packets to bytes_per_packet, which seems clearer.
- Use local variables that have the same types as the counter values,
  rather than truncating unsigned long to u32.

Reviewed by:	kbowling
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50416

(cherry picked from commit 731c145612dd6ffe457a562959a5c027acf13334)
2025-07-09 10:05:44 +02:00
Mark Johnston
9ed58debcc e1000: Initialize helper variables in em_newitr()
Due to races with the threaded transmit and receive paths, it's possible
to have r/tx_bytes != 0 && r/tx_packets == 0, in which case the maximum
byte count could be left uninitialized.  Initialize them to zero to
handle this case.

PR:		286819
Reviewed by:	kbowling
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D50416

(cherry picked from commit e0267657f3965a56d877075fe3d4d41b8afb2faf)
2025-07-09 10:05:44 +02:00
Krzysztof Galazka
6308635e13 ice(4): Update E830-XXV device ids
Device ID for E830-XXV adapters was changed from 12D3
to 12DE. Update driver accordingly and bump version
number.

Also remove subdevice id for E830-XXV-4 for OCP 3.0,
which was cancelled.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>

Approved by:	kbowling (mentor), erj (mentor)
Tested by:	Gowthamkumar K S <gowtham.kumar.ks@intel.com>
Sponsored by:   Intel Corporation
Differential Revision:	https://reviews.freebsd.org/D50327

(cherry picked from commit 0fed8828c95a9d2cbcb43147ff851ca6f2c21d0f)
2025-07-09 10:05:43 +02:00
Andrew Turner
2de03270e7 virtio_p9fs: Support attaching to pci and mmio
Some implementations of the virtio 9p transport are implemented on
virtio_mmio, e.g. the Arm FVP. Use the correct macro so the driver
attaches when this is the case.

Reviewed by:	markj
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D49600
2025-07-09 10:05:40 +02:00
Mark Johnston
8c24349f5e virtio_p9fs: Fix handling of a full request queue
If, when submitting a request, the virtqueue is full, we sleep until an
interrupt has fired, then restart the request.  However, while sleeping
the channel lock is dropped, and in the meantime another thread may have
reset the per-channel SG list, so upon retrying we'd (re)submit whatever
happened to be left over in the previous request.

Fix the problem by rebuilding the SG list after sleeping.

Sponsored by:	Klara, Inc.
2025-06-20 09:55:28 +02:00
Mark Johnston
bd436fec4b virtio_p9fs: Fix some style issues
- Remove superfluous newlines.
- Use bool literals.
- Replace an unneeded SYSINIT with static initialization.

No functional change intended.

Sponsored by:	Klara, Inc.
2025-06-20 09:55:22 +02:00
Danilo Egea Gondolfo
014dcda455 virtio_p9fs: fix panic on qemu/kvm
When the module is loaded on a system running on qemu/kvm the "modern"
virtio infrastructure is used and virtio_read_device_config() will end
up calling vtpci_modern_read_dev_config(). This function cannot read
values of arbitrary sizes and will panic if the p9fs mount tag size is
not supported by it.

Use virtio_read_device_config_array() instead. It was tested on both
bhyve and qemu/kvm.

PR: 280098
Co-authored-by: Mark Peek <mp@FreeBSD.org>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1320
2025-06-20 09:54:55 +02:00
Ed Maste
3e04ab7f01 p9fs: use M_WAITOK where appropriate
device_attach routines are allowed to sleep, and this routine already
has other M_WAITOK allocations.

Reported by:	markj
Reviewed by:	markj
Fixes: 1efd69f933b6 ("p9fs: move NULL check immediately after alloc...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45721
2025-06-20 09:54:47 +02:00
Ed Maste
81718901e9 p9fs: move NULL check immediately after allocation
Reported by:	Shawn Webb (HardenedBSD)
Reviewed by:	dfr
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45719
2025-06-20 09:54:40 +02:00
Doug Rabson
1ca2f5d1f7 Add an implementation of the 9P filesystem
This is derived from swills@ fork of the Juniper virtfs with many
changes by me including bug fixes, style improvements, clearer layering
and more consistent logging. The filesystem is renamed to p9fs to better
reflect its function and to prevent possible future confusion with
virtio-fs.

Several updates and fixes from Juniper have been integrated into this
version by Val Packett and these contributions along with the original
Juniper authors are credited below.

To use this with bhyve, add 'virtio_p9fs_load=YES' to loader.conf. The
bhyve virtio-9p device allows access from the guest to files on the host
by mapping a 'sharename' to a host path. It is possible to use p9fs as a
root filesystem by adding this to /boot/loader.conf:

	vfs.root.mountfrom="p9fs:sharename"

for non-root filesystems add something like this to /etc/fstab:

	sharename /mnt p9fs rw 0 0

In both examples, substitute the share name used on the bhyve command
line.

The 9P filesystem protocol relies on stateful file opens which map
protocol-level FIDs to host file descriptors. The FreeBSD vnode
interface doesn't really support this and we use heuristics to guess the
right FID to use for file operations.  This can be confused by privilege
lowering and does not guarantee that the FID created for a given file
open is always used for file operations, even if the calling process is
using the file descriptor from the original open call. Improving this
would involve changes to the vnode interface which is out-of-scope for
this import.

Differential Revision: https://reviews.freebsd.org/D41844
Reviewed by: kib, emaste, dch
MFC after: 3 months
Co-authored-by: Val Packett <val@packett.cool>
Co-authored-by: Ka Ho Ng <kahon@juniper.net>
Co-authored-by: joyu <joyul@juniper.net>
Co-authored-by: Kumara Babu Narayanaswamy <bkumara@juniper.net>
2025-06-20 09:54:02 +02:00
Christos Margiolis
99b8be414c sound: Terminate stream properly when closing vchans
When a channel is closed, dsp_close() either calls vchan_destroy() on vchans,
or chn_abort()/chn_flush() on primary channels. However, the problem with this
is that, when closing a vchan, we end up not terminating the stream properly.

The call sequence we are interested in is the following:

	vchan_destroy(vchan) -> chn_kill(vchan) -> chn_trigger(vchan) ->
	vchan_trigger(vchan) -> chn_notify(parent)

Even though chn_notify() contains codepaths which call chn_abort(parent),
apparently we do not execute any of those codepaths in this case, so the
DMA remains unterminated, hence why we keep seeing the primary
channel(s) being interrupted even once the application has exited:

root@freebsd:~ # sndctl interrupts
dsp0.play.0.interrupts=1139
dsp0.record.0.interrupts=0
root@freebsd:~ # sndctl interrupts
dsp0.play.0.interrupts=1277
dsp0.record.0.interrupts=0
root@freebsd:~ # sndctl interrupts
dsp0.play.0.interrupts=1394
dsp0.record.0.interrupts=0

The only applications that do not have this issue are those (e.g., mpv) that
manually call ioctls which end up calling chn_abort(), like SNDCTL_DSP_HALT, to
abort the channel(s) during shutdown. For all other applications that do not
manually abort the channel(s), we can confirm that chn_abort()/chn_flush(), or
even chn_trigger(PCMTRIG_ABORT) on the parent, doesn't happen during shutdown.

root@freebsd:~ # dtrace -n 'fbt::chn_abort:entry,fbt::chn_flush:entry { printf("%s", args[0]->name); stack(); }'
dtrace: description 'fbt::chn_abort:entry,fbt::chn_flush:entry ' matched 2 probes
dtrace: buffer size lowered to 1m
^C

[...]

root@freebsd:~ # dtrace -n 'fbt::chn_trigger:entry /args[1] == -1/ { printf("%s", args[0]->name); stack(); }'
dtrace: description 'fbt::chn_trigger:entry ' matched 1 probe
dtrace: buffer size lowered to 1m
CPU     ID                    FUNCTION:NAME
  0  68037                chn_trigger:entry dsp0.virtual_play.0
	      sound.ko`chn_kill+0x134
	      sound.ko`vchan_destroy+0x94
	      sound.ko`dsp_close+0x39b
	      kernel`devfs_destroy_cdevpriv+0xab
	      kernel`devfs_close_f+0x63
	      kernel`_fdrop+0x1a
	      kernel`closef+0x1e3
	      kernel`closefp_impl+0x76
	      kernel`amd64_syscall+0x151
	      kernel`0xffffffff8103841b1

To fix this, modify dsp_close() to execute the primary channel case on both
primary and virtual channels. While what we really care about are the
chn_abort()/chn_flush() calls, it shouldn't hurt to call the rest of the
functions on the vchans as well, to avoid complicating things; they get deleted
right below, anyway.

With the patch applied:

root@freebsd:~ # dtrace -n 'fbt::chn_trigger:entry /args[1] == -1/ { printf("%s", args[0]->name); stack(); }'
dtrace: description 'fbt::chn_trigger:entry ' matched 1 probe
dtrace: buffer size lowered to 1m
CPU     ID                    FUNCTION:NAME
  1  68037                chn_trigger:entry dsp0.virtual_play.0
              sound.ko`chn_flush+0x2a
              sound.ko`dsp_close+0x330
              kernel`devfs_destroy_cdevpriv+0xab
              kernel`devfs_close_f+0x63
              kernel`_fdrop+0x1a
              kernel`closef+0x1e3
              kernel`closefp_impl+0x76
              kernel`amd64_syscall+0x151
              kernel`0xffffffff8103841b

  0  68037                chn_trigger:entry dsp0.play.0
              sound.ko`chn_notify+0x4ce
              sound.ko`vchan_trigger+0x105
              sound.ko`chn_trigger+0xb4
              sound.ko`chn_flush+0x2a
              sound.ko`dsp_close+0x330
              kernel`devfs_destroy_cdevpriv+0xab
              kernel`devfs_close_f+0x63
              kernel`_fdrop+0x1a
              kernel`closef+0x1e3
              kernel`closefp_impl+0x76
              kernel`amd64_syscall+0x151
              kernel`0xffffffff8103841b

Above we can see a chn_trigger(PCMTRIG_ABORT) on the parent (dsp0.play.0),
which is coming from the chn_abort() (inlined) in chn_notify():

root@freebsd:~ # dtrace -n 'kinst::chn_abort:entry { stack(); }'
dtrace: description 'kinst::chn_abort:entry ' matched 5 probes
dtrace: buffer size lowered to 1m
CPU     ID                    FUNCTION:NAME
  1  72580                  chn_notify:1192
              sound.ko`0xffffffff8296cab4
              sound.ko`vchan_trigger+0x105
              sound.ko`chn_trigger+0xb4
              sound.ko`chn_flush+0x2a
              sound.ko`dsp_close+0x330
              kernel`devfs_destroy_cdevpriv+0xab
              kernel`devfs_close_f+0x63
              kernel`_fdrop+0x1a
              kernel`closef+0x1e3
              kernel`closefp_impl+0x76
              kernel`amd64_syscall+0x151
              kernel`0xffffffff8103841b

We can also confirm the primary channel(s) are not interrupted anymore:

root@freebsd:/mnt/src # sndctl interrupts
dsp0.play.0.interrupts=0
dsp0.record.0.interrupts=0

In collaboration with:	adrian
Tested by:		adrian, christos, thj
Sponsored by:		The FreeBSD Foundation
MFC after:		2 days
Reviewed by:		thj, adrian, emaste
Differential Revision:	https://reviews.freebsd.org/D50488

(cherry picked from commit f6430bc61df78be070209d52b4452ae9cf4cd015)
(cherry picked from commit 0c6aa445ec0c85e7c9653d20562907742569de6f)

Approved by:		re (cperciva)
2025-05-30 00:51:30 +02:00
Tijl Coosemans
adf77cb48e snd_hda: Add shutdown method
Power down the device on shutdown similar to what is done in the case
of suspend. The device may fail to attach on next boot without this.

PR:		286385
Reviewed by:	christos, adrian
Differential Revision:	https://reviews.freebsd.org/D50306

(cherry picked from commit d9900b9ea2b27f7a0c2eda97841b9499e02e3ea7)
(cherry picked from commit 77521692f4c71213c5419268657e696532c28325)

Approved by:    re (cperciva)
2025-05-22 01:21:42 +02:00
Christos Margiolis
aff92a9f3c sound: Call PCM_RELEASE() if pcm_addchan() fails
Fixes:		fd906e47b18f ("sound: Simplify locking during device creation")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D50337

(cherry picked from commit dbfe79bbe5d5ebe296fbff2d101e0994d7881d0d)
(cherry picked from commit 3de66f369c1e8db46ae938d446a72f6ff3493356)

Approved by:    re (cperciva)
2025-05-14 16:23:53 +02:00
Arthur Kiyanovski
a1685d2560 ena: Bump driver version to v2.8.1
Changes since 2.8.0:

Bug Fixes:
* Fix LLQ normal width misconfiguration
* Check for errors when detaching children first, not last

Minor Changes:
* Remove \n from sysctl description

Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D50041

(cherry picked from commit 59b30c1a864ee8a22c2e9912301cb88674f714c9)
2025-05-01 17:51:52 +00:00
David Arinzon
3f4a674a8e ena: Fix misconfiguration when requesting regular LLQ
Patch 0a33c047a443 introduced new values to
hw.ena.force_large_llq_header. The default value of 2 means no
preference, while 0 and 1 act as the previous false and true
respectively, which allowed forcefully setting regular or large LLQ.

There are 2 ways to force the driver to select regular LLQ:

1. Setting hw.ena.force_large_llq_header = 0 via sysctl.
2. Turning on ena express, which makes the recommendation by the FW to
   be regular LLQ.

When the device supports large LLQ but the driver is forced to
regular LLQ, llq_config->llq_ring_entry_size_value is never initialized
and since it is a variable allocated on the stack, it stays garbage.

Since this variable is involved in calculating max_entries_in_tx_burst,
it could cause the maximum burst size to be zero. This causes the driver
to ignore the real maximum burst size of the device, leading to driver
resets in devices that have a maximum burst size (Nitro v4 and on. see
[1] for more information).

In case the garbage value is 0, the calculation of
max_entries_in_tx_burst divides by 0 and causes kernel panic.

The patch modifies the logic to take into account all use-cases and
ensure that the relevant fields are properly initialized.

[1]: https://docs.aws.amazon.com/ec2/latest/instancetypes/ec2-nitro-instances.html

Fixes: 0a33c047a443 ("ena: Support LLQ entry size recommendation from device")
Approved by: cperciva (mentor)
Sponsored by: Amazon, Inc.
Differential Revision: https://reviews.freebsd.org/D50040

(cherry picked from commit 56c45700f2ae15755358f2da8266247613c564df)
2025-05-01 17:51:52 +00:00
Gordon Bergling
41813f983d ath(4): Fix a typo in a source code comment
- s/chang/change/

(cherry picked from commit 3ad86f460fa81ecc036fb5af25848f10b68b4019)
2025-05-01 08:48:16 +02:00
Chandrakanth patil
b794f3126c mpi3mr: modified the log messages to be on a single line
qThis change was made after feedback from upstream, aiming to align with
the style guide for consistent log formatting. No functional changes
were made to the driver, only the formatting of the log messages.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49799

(cherry picked from commit 4494ea5406f79a6cb2d3631a723eb286ca96a9b9)
2025-04-30 11:05:54 -06:00
Chandrakanth patil
e6d4b221ba mpi3mr: Update Driver Version to 8.14.0.2.0
The driver version has been updated to 8.14.0.2.0 to reflect the
latest release. This is a version-only update with no functional
code changes.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49753

(cherry picked from commit f4d51d3e1a90dabbed26aacf1b58e20e23a19342)
2025-04-30 11:05:54 -06:00
Chandrakanth patil
f76b6e1c07 mpi3mr: Update Copyright Year to 2025
All driver source files have been updated to reflect the year 2025.
This change is cosmetic and does not affect functionality.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49752

(cherry picked from commit 69be9a247b845b35146fed4575dacb565c9c18ba)
2025-04-30 11:05:54 -06:00
Chandrakanth patil
07070742fa mpi3mr: Process LOG Data Events in Interrupt Top Half for Early Notification
The driver now processes LOG Data events in the interrupt top
half instead of the bottom half. This allows LOG events to be
handled immediately upon receipt, reducing latency and enabling
early notification to the Library or applications.

This change ensures LOG event handling occurs closer to the
firmware's generation point, improving alignment with event-driven
diagnostic and monitoring mechanisms.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49751

(cherry picked from commit df8a74fca036a0ba8026f3ae3da830dffb922faa)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
ec6fea480d mpi3mr: Enable Diag Save for All Diagnostic Fault Cases
This patch ensures the driver sets the Diag Save bit for all
diagnostic fault conditions before issuing a Diagnostic Fault Reset.

The firmware now incorporates logic to manage snapdump saving
and requires the driver to always set the Diag Save bit to enable
this feature. This change supports improved diagnostic data
collection and fault handling.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49750

(cherry picked from commit b854677d970a11e87929fa95d0e4067f911faa62)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
9980fb4d87 mpi3mr: Block I/Os While Task Management is in Progress
The driver previously blocked I/Os only for OS-initiated task
management commands. This patch extends the behavior to also
block I/Os during application-initiated task management
operations (excluding Task Abort).

Before submitting such commands to the firmware, I/O
submissions are paused for the respective device. Once the
command completes, I/O operations are resumed.

This ensures safe and consistent task management handling.

[[ Note: Warner landed this with the pending suggestion
since this change is good enough for 14.3, but chs' suggestion
for better atomics needs to be implemented soon ]]

Discussed with: imp, chs
Differential Revision:	https://reviews.freebsd.org/D49749

(cherry picked from commit 49445b54638f7b2d45942edd61c70fe0baa28f37)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
19981894d1 mpi3mr: Add NVData Parameter for Host Timestamp Synchronization
The driver now retrieves the Time Stamp value from Driver Page 1
during load and after controller reset. If the value is valid, it
is used to enable periodic host timestamp synchronization.

This adds a tunable NVData parameter to control the behavior of
host time sync, enhancing flexibility and platform-specific control.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49748

(cherry picked from commit e80317babdb9044962dcbf16c69633579cd90b00)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
05cf85775b mpi3mr: Handle Insufficient Power Fault Code
The driver now checks for insufficient power faults during the load
phase and immediately fails initialization instead of retrying.

Additionally, if an insufficient power fault is detected by the watchdog
after the controller is up, the controller is marked as unrecoverable
instead of triggering a reset.

This improves fault handling and avoids unnecessary recovery attempts
in low-power conditions.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49747

(cherry picked from commit 116c8b18a2b5278df0d1982a683193c3dba6f30c)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
94ede6230d mpi3mr: Enhance Controller Enable Retry Logic in Host Drivers
This patch improves the retry logic during the IOC enable process.
If a controller faults or if the reset history bit is detected during
the ready status check, the driver will retry initialization up to three
times or until 510 seconds have passed.

A soft reset will also be issued if the controller is detected while
waiting for the ready status.

This enhances reliability during controller initialization.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49746

(cherry picked from commit e977ed50bb2b9fce5e285756673286c5fcfb1f31)
2025-04-30 11:05:53 -06:00
Chandrakanth patil
22b4023cba mpi3mr: Set Driver Capability for OS Exposure in IOCInit
This patch updates the driver to set the OSExposure field in DriverCapability
during IOCInit to MPI3_IOCINIT_DRIVERCAP_OSEXPOSURE_NO_SPECIAL(0x1), aligning
with the latest MPI specification version 36.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49745

(cherry picked from commit d14c4ea0caebb9d0ddb613e348cb8c1a19e8d8fc)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
60cf157650 mpi3mr: Update MPI Header to Version 36
Updated the MPI header files to version 36 to align with the latest
MPI specification. This includes updated structures, field definitions,
and constants required for compatibility with updated firmware.

Reviewed by:	ssaxena, imp
Differential Revision:	https://reviews.freebsd.org/D49743

(cherry picked from commit 92f340d137ba5d6db7610ba1dae35842e2c9c8ea)
2025-04-30 11:05:52 -06:00
Chuck Silvers
46d0fea77e mpi3mr: configure larger max I/O size if the HBA firmware supports it
The max I/O size that an mpi3mr HBA supports is reported in the IOCFacts
structure (with 0 representing the legacy max I/O size of 1 MB).
By default, set the max I/O size of devices attached to mpi3mr controllers
to the smaller of the HBA's max I/O size and the kernel's maxphys.
Allow this default to be overriden by a global tunable
"hw.mpi3mr.max_sgl_entries" or by a per-controller tunable
"dev.mpi3mr.N.max_sgl_entries".

Sponsored by:	Netflix
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49090

(cherry picked from commit f2605f67a13eb1f1427ee58a097791ca25359a5e)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
1fc80c0139 mpi3mr: Track IO per target counter during queue poll with local variable
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44494

(cherry picked from commit 8d3c3b52423f9740da424aa6dd73a20e694a9e08)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
80b069913d mpi3mr: Divert large WriteSame IOs to firmware if unmap and ndob bits are set
Firmware advertises the transfer lenght for writesame commands to driver during init.
So for any writesame IOs with ndob and unmap bit set and transfer lengh is greater
than the max write same length specified by the firmware, then direct those commands
to firmware instead of hardware otherwise hardware will break.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44452

(cherry picked from commit 3f3a15543a6721100dda0e4219eb48ecbe35731a)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
810abb1258 mpi3mr: driver version update to 8.10.0.1.0
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44430

(cherry picked from commit df595fc43e908d8e85601cf6136fbcf0a60fd0f9)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
8fa8f7a848 mpi3mr: copyright year update to 2024
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44429

(cherry picked from commit 945c3ce49ed127de6ccd6d55a944d8a58291c315)
2025-04-30 11:05:52 -06:00
Chandrakanth patil
3635f18ee6 mpi3mr: mpi headers update to latest
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44428

(cherry picked from commit baabb919345f05e9892c4048a1521e5da1403060)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
14283d89e4 mpi3mr: Adding FreeBSD OS Type to Fault/Reset Reason Code
The driver is modified to add FreeBSD OS type in the upper nibble of the
fault/reset reason code for appropriate qualification of the reason code.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44427

(cherry picked from commit 3012fa8faef262c615672fc90319c777b4e3dffc)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
40089481d0 mpi3mr: diag fault success beyond F000 fault code
Accept any fault as successful for diagnostic fault reset, not just the 0xF000
code. print fault information and return.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44426

(cherry picked from commit 4034d7061a112b78d60cdb581c2d71f7cfa9f74e)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
897fcbe893 mpi3mr: Update consumer index of admin and operational reply queues after every 100 replies
Instead of updating the ConsumerIndex of the Admin and Operational ReplyQueues
after processing all replies in the queue, it will now be periodically updated
after processing every 100 replies.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44425

(cherry picked from commit eb7a4b35de89a0e22f1fb373df33d79135b68dd8)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
d22c5b277a mpi3mr: Decrement per controller and per target counter post reset
Post controller reset, If any device removal events arrive, and if
there are any outstanding IOs then the driver will unnecessarily wait
in the loop for 30 seconds before removing the device from the OS.

reset target outstanding IO counter and controller outstanding IO counter
and remove the redundant wait loop.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44424

(cherry picked from commit 571f1d0638fa6b3a08f84118a33e53f941f0820c)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
3e1b3b3d15 mpi3mr: poll reply queue and add MPI3MR_DEV_REMOVE_HS_COMPLETED flag
An outstanding IO counter per target check has been added before deleting
the target from the OS which will poll the reply queue if there are any
outstanding IOs are found.

A new flag, named "MPI3MR_DEV_REMOVE_HS_COMPLETED," is added. If a remove event
for a target occurs and before the deletion of the target resource if the add event
for another target arrives reusing the same target ID then this flag will prevent
the removal of the target reference. This flag ensures synchronization between the interrupt
top and bottom half during target removal and addition events.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44423

(cherry picked from commit 701d776c98e015160c2d0e3f4fdaf980d1d5dc83)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
a24be14366 mpi3mr: Controller state check before enabling PEL
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44422

(cherry picked from commit 042808f74707d3ce89e89463d4a03f81df6fd45a)
2025-04-30 11:05:51 -06:00
Chandrakanth patil
85be8c09ab mpi3mr: Block devices persist despite being offlined during reset
The driver removes the drive from the OS if firmware sends 'device added'
event with hidden bit or inaccessible status.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D44421

(cherry picked from commit 0d7056458db5b5dd7fdc5ccd8abab73e3ee76a20)
2025-04-30 11:05:50 -06:00
Warner Losh
25607ef485 mpi3mr: Fix confusion over | and &
Use sc->mpi3mr_debug & MPI3MR_IOT over the | version to test if a bit is
set.

CID: 1529718
Sponsored by:		Netflix

(cherry picked from commit 34f0a01b6bd4ff0e61a7066729515148400e0982)
2025-04-30 11:05:50 -06:00
Chuck Silvers
05e6c3afbc mpi3mr: add missing terminator entry to mpi3mr_identifiers array
Reported by:	KASAN
Sponsored by:	Netflix
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D43519

(cherry picked from commit 2f2da21740b462e52e81880c82b4584be5ce6195)
2025-04-30 11:05:50 -06:00
Vladimir Kondratyev
2c23fc90e5 hidraw(4): Force switch to hidraw mode on HIDIOCGRDESC ioctl
To match documentation.

Reported by:	Ihor Dutchak <ihor.youw@gmail.com>
PR:		286155
MFC after:	3 days

(cherry picked from commit fe4bdd889b5d722faa3a66e2c7d9a248e527cdb2)
2025-04-30 10:32:23 +03:00
Vladimir Kondratyev
d04cc28f97 hidraw(4): Return actual length of read data from HIDIOCG* ioctls
To match Linux.

MFC after:	3 days

(cherry picked from commit 8d4d08d571c64d8f040c2cd1d8f98844251a2238)
2025-04-30 10:32:23 +03:00
Vladimir Kondratyev
2880e12cc9 hidraw(4): Return length of written data from HIDIOCS* ioctls
To match Linux.

MFC after:	3 days

(cherry picked from commit 5ea0f1e63dbddc5452e2d85fcc03ba03a3d9cf84)
2025-04-30 10:32:22 +03:00
Vladimir Kondratyev
7545c8c116 hidraw(4): Add additional hidraw input/output report ioctls
to Linux hidraw compatibility API.

Respective Linux commit f43d3870cafa made by Dean Camera message is:

Currently the hidraw module can only read and write feature HID reports on
demand, via dedicated ioctls. Input reports are read from the device through
the read() interface, while output reports are written through the write
interface().

This is insufficient; it is desirable in many situations to be able to read and
write input and output reports through the control interface to cover
additional scenarios:

  - Reading an input report by its report ID, to get initial state
  - Writing an input report, to set initial input state in the device
  - Reading an output report by its report ID, to obtain current state
  - Writing an output report by its report ID, out of band

This patch adds these missing ioctl requests to read and write the remaining
HID report types. Note that not all HID backends will neccesarily support this
(e.g. while the USB link layer supports setting Input reports, others may not).

FreeBSD native uhid(4) compatible API already has similar ioctls.

MFC after:	3 days

(cherry picked from commit fd6690e2d5cd5b15fce2c74ab0cac77a83514f6a)
2025-04-30 10:32:22 +03:00
Vladimir Kondratyev
a55479cbfb acpi_asus_wmi(4): Handle TUF-specific hotkeys internally
- Cycle TUF laptop RGB mode on AURA key press
- Switch TUF 'Throttle Thermal Policy' with 'Fan' key

Sponsored by:	Future Crew LLC
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D48985

(cherry picked from commit 027b93c2f5e1b84d9e4569f127b632c704c53b73)
2025-04-30 10:32:22 +03:00
Vladimir Kondratyev
f530b12362 acpi_asus_wmi(4): Add support for WMI event queue
Event codes are expected to be retrieved from a queue on at least some
models. Specifically, very likely the ACPI WMI devices with _UID ATK are
queued whereas those with ASUSWMI are not.

Sponsored by:	Future Crew LLC
MFC after:	1 month
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D48984

(cherry picked from commit d5bf6a7245cc7825d17ebb00d1e7f07ae6dc32e6)
2025-04-30 10:32:22 +03:00
Vladimir Kondratyev
9b5f1a6cd6 acpi_asus_wmi(4): Improve keyboard backlight support.
- Fix maximal keyboard backlight level, Although Linux source code
  comment says that backlight level is encoded in 3 bits of data,
  actual code limits maximum level to 3.
- Add backlight(9) support for keyboard
- Turn off/on keyboard backlight on suspend/resume

Sponsored by:	Future Crew LLC
MFC after:	1 month
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D48983

(cherry picked from commit f134662a1a5726d78880385002a03b8fe68805f6)
2025-04-30 10:32:22 +03:00
Vladimir Kondratyev
6616f35456 acpi_asus_wmi(4): Add EVDEV support
Use input event device to export hotkey events.

Sponsored by:	Future Crew LLC
MFC after:	1 month
Reviewed by:	mav
Differential Revision:	https://reviews.freebsd.org/D48982

(cherry picked from commit 5e41194bfcc54fb506070f7a01d5bc00326cde66)
2025-04-30 10:32:22 +03:00
Dmitry Luhtionov
6d2885d50e ig4(4): Add Intel ACPI HID
MFC after:	1 month

(cherry picked from commit 64dcfa2593d4729f16cb3e2d97088a2e69900df1)
2025-04-30 10:32:22 +03:00
John Baldwin
14cb463635 pcib: Clear any pending slot status events during attach
Any events left over from boot firmware, etc. are not meaningful so
clear pending events during attach.  If they are still pending they
should remain asserted when the slot status register is re-read.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49950

(cherry picked from commit ff45e4759a38f44a0199b2948b7b1e987e7c71da)
2025-04-29 10:46:40 -04:00
John Baldwin
4373c15f1f pcib: Ignore power fault detected if a power controller is not present
At least some PCI-express bridges exposed by Intel Volume Management
Devices report bogus power faults in their slot status register.  As a
workaround, ignore the power fault detected flag if the slot
capability register does not indicate support for a power controller.

While the PCI-e spec does not explicitly state that the PFD flag
should always be zero if a power controller is not present, parts of
the spec do seem to assume this.  For example, the flag is included in
the "Power Controller Registers" register group in 6.7.2.4, and the
definition of the value for this flag seems to presume the presence of
a power controller:

    If a Power Controller that supports power fault detection is
    implemented, this bit is Set when the Power Controller detects a
    power fault at this slot. Note that, depending on hardware
    capability, it is possible that a power fault can be detected at
    any time, independent of the Power Controller Control setting or
    the occupancy of the slot. If power fault detection is not
    supported, this bit must not be Set.

PR:		285993
Reported by:	Jim Long <freebsd-bugzilla@umpquanet.com>
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49949

(cherry picked from commit 4c8b9f40cda7dd6b2de547b288d712c85998ce11)
2025-04-29 10:46:26 -04:00
John Baldwin
a2de254b20 acpi_pci: Use pci_has_pm and pci_clear_pme
Differential Revision:	https://reviews.freebsd.org/D49266

(cherry picked from commit 931baeb62b03029cb57459736851c4e8141e672e)
2025-04-29 10:45:14 -04:00
John Baldwin
6f27822152 dev: Use recently added improvements to PME# support to simplify drivers
Depend on the PCI bus driver clearing PME# after resume to remove the
need for clearing PME# from DEVICE_RESUME methods.

Use pci_has_pm and pci_enable_pme.

Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
Differential Revision:	https://reviews.freebsd.org/D49251

(cherry picked from commit ddaf6524682b3ab9e50f7575db319814dbbd053a)
2025-04-29 10:45:07 -04:00
John Baldwin
b8b5dbdb93 pci: Add helper routines to manage PME in device drivers
pci_has_pm is a quick check that returns true if a PCI device supports
the power management capability.

pci_enable_pme can be used in DEVICE_SUSPEND driver methods to enable
PME# during suspend.

Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>x
Differential Revision:	https://reviews.freebsd.org/D49250

(cherry picked from commit e5cbf0e881fa1851912be77c62aa7ab17f844c3d)
2025-04-29 10:44:58 -04:00
John Baldwin
b5bc47f1e1 pci: Clear active PME# and disable PME# generation
The PCI power management specification requires that the OS clear any
pending PME# interrupt and generation of PME# interrupts during
"initial operating system load".  Note that clearing a pending PME#
interrupt requires writing a 1 to the Read/Write-Clear PME bit in the
power management status register.  To handle the boot time case, clear
PME# state in pci_read_cap() when scanning new PCI devices.  This
should also cover hotplug devices.

In addition, clear this state on every PCI device after resume from
sleep in pci_resume_child before invoking the driver's DEVICE_RESUME
method.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49222

(cherry picked from commit 82d692771239f1d156a875087dff4cf09f0e8b80)
2025-04-29 10:44:25 -04:00
John Baldwin
ab9e7d209a hdaa: Don't hold a mutex while creating child devices
The lock is already not held while deleting child devices, and the
bus_topo_lock is already held when child devices are created.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49272

(cherry picked from commit 02d61f27585f52d422fc1e235ac6226e27145162)
2025-04-29 10:42:56 -04:00
John Baldwin
207e58ce8a sdhci: Use bus_topo_lock and taskqueue_bus for hotplug events
Drop SDHCI_LOCK and instead acquire bus_topo_lock when adding and
removing new-bus devices.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49271

(cherry picked from commit aaf0a7302d10912e62dcd8e047798b4a2aefa039)
2025-04-29 10:42:44 -04:00
John Baldwin
ee08e84551 mmc: Use bus_topo_lock and taskqueue_bus while adding/removing child devices
Some drivers held regular mutexes across some new-bus calls; instead
depend on bus_topo_lock to protect the relevant softc members.  This
also fixes the bus_topo_lock to be explicit in these drivers rather
than relying on the implicit Giant from taskqueue_swi_giant.  It
avoids calling sleepable routines like device_probe_and_attach from an
swi context.

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

(cherry picked from commit c0bed9bd0bda2ca9239f5913cd2d5c1bd5d29bfa)
2025-04-29 10:40:47 -04:00
John Baldwin
50c1d075dc pcib: Use taskqueue_bus for hot-plug events instead of a private taskqueue
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D49269

(cherry picked from commit b23314ecb99cedef1090bdaa486fbd25aa5a9558)
2025-04-29 10:36:16 -04:00
John Baldwin
0a515a8d36 pci: Don't cache the count of MSI/MSI-X messages before allocation
A device can in theory change the read-only fields in the MSI/MSI-X
control registers that indicate the maximum number of supported
registers in response to changing other device registers.  For
example, certain Intel networking VFs change the number of messages as
a result of changes in the PCI_IOV_ADD_VF callback.

To support this, always read the current value of the relevant control
register in the *_count and *_alloc methods.  Once messages have been
allocated, the control register value remains cached.

Reported by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>, erj
Differential Revision:	https://reviews.freebsd.org/D48890

(cherry picked from commit 346020138a0fd20085ebc285f090df38d7d18527)
2025-04-29 10:24:32 -04:00
John Baldwin
14749f40c1 pci: Cosmetic cleanups to MSI/MSI-X routines
- Use unsigned integers for various variables.  The count argument
  to the alloc method as well as the IRQ values used with the
  pcib_if.m methods should also be unsigned eventually.

- Use mallocarray to allocate arrays

- Use bool in a few places

Reviewed by:	Krzysztof Galazka <krzysztof.galazka@intel.com>
Differential Revision:	https://reviews.freebsd.org/D48889

(cherry picked from commit a3835cceb0882494628d5d075f99a86bd3464672)
2025-04-29 10:24:10 -04:00
John Baldwin
cbaa32c28a pci_host_generic: Use SYS_RES_MEMORY for the parent of I/O resource ranges
When a SYS_RES_IOPORT resource crosses a pci_host_generic bridge, it
is translated into a memory access for an associated range, so use
SYS_RES_MEMORY for the resource allocated from the parent.

Tested by:	markj
Differential Revision:	https://reviews.freebsd.org/D44207

(cherry picked from commit c19f1ad1c252f434146c7210155d805b2ed0ff95)
2025-04-29 10:18:35 -04:00
Kyle Evans
34f9dca191 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

(cherry picked from commit b313229969cc56a057dfea28506784fd5468c6f3)
2025-04-29 10:17:50 -04:00
Ryan Libby
7bc852d94d pci: propagate vpd read error
On read error, we would return -1, but not handle it, causing a zero
size malloc of value, and then we wouldd unconditionally write
value[-1 + 1] = '\0'.  This should be harmless in terms of buffer
overflow because we should get a minimum non-zero size allocation from
malloc, but it also effectively swallowed the error.

Reported by:	GCC -Wstringop-overflow
Reviewed by:	kib, se
Differential Revision:	https://reviews.freebsd.org/D45895

(cherry picked from commit 39bda097c03780e26e6a25ff59a3e8e77c77563f)
2025-04-29 10:17:01 -04:00
Sreekanth Reddy
47a360ff22 bnxt_en: Thor2 Ring counters not incrementing during traffic
The ctx_hw_stats_ext DMA address was not correctly passed to the
firmware during the HWRM_STAT_CTX_ALLOC allocation, causing stats to not
populate for Thor2.  Passing the correct DMA length resolved the issue

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49732
(cherry picked from commit fec0e2064818f991867c9851a837012ea31774da)
2025-04-27 16:02:59 -06:00
Sreekanth Reddy
4ed8c41831 bnxt_en: Unhandled async event type 76
The completion event type 76 is not supported by the driver. Instead of
flooding the dmesg with "Unknown event type" messages when this event
occurs, move the print under debug level.

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49731
(cherry picked from commit 6450d937955fcd1ab9034c49d53306e882c4a281)
2025-04-27 16:02:59 -06:00
Sreekanth Reddy
ced1133739 bnxt_en: Thor2 Specific Doorbell related changes
Doorbell offset :
For Thor controllers doorbell offset was always hardcoded to 0x10000 for
PF devices where as for Thor2 controllers doorbell offset will be
legacy_l2_db_size_kb value provided by firmware through hwrm_func_qcfg
command.

CQ Toggle & Epoch bits support :
In order to handle out of order doorbell handling as part of Dropped
Doorbell Recovery, HW expects two changes in the driver in data path.

- First change is the epoch bit changes while updating the producer
indexes of Tx. This epoch bit is toggled by the driver, each time the
queue is wrapped for that specific doorbell.

- The second change is to add a toggle bit pair to each ARM type
doorbell.  This includes the CQ_ARMALL, CQ_ARMSE, CQ_ARMENA
doorbells. The toggle bit pair in context is incremented by the chip
each time a new NQE completion is generated by the chip. To keep the
driver in-sync, the toggle bit pair will be passed in the NQE to the
host completion. This will be the toggle bit pair value that the host
must use to setup the next NQE operation. The driver will pass that
latest toggle bit pair value into the ARM type doorbells it generates to
the chip. The doorbell clients will compare the toggle bit pair in each
doorbell with the value in context.  If the values match, the doorbell
will be honored. If the values do not match, the doorbell will be
discarded.

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49730
(cherry picked from commit 39c0b8b7994b0d339bffb0b17291c4a2b14cae3a)
2025-04-27 16:02:59 -06:00
Sreekanth Reddy
32fdad17f0 bnxt_en: 400G speed support
Added 400G speed module support.

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49729
(cherry picked from commit dac78335c42dce2ce9daf5856539510a42d7d8cd)
2025-04-27 16:02:59 -06:00
Sreekanth Reddy
dd6c9bcdcc if_bnxt: add support for RX completion record type V3
Added support for  RX V3 completion record types-
CMPL_BASE_TYPE_RX_TPA_START_V3 and CMPL_BASE_TYPE_RX_L2_V3.

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49728
(cherry picked from commit 526d74f6ca55c7a4b9c0c745d13e94c7a7bb6e0b)
2025-04-27 16:02:58 -06:00
Sreekanth Reddy
baa2ff7ac8 bnxt_en: Add backing store V2 support
Add backing store V2 support.
Thor2 controllers supports only the V2 support.

MFC-After: 3 days
Reviewed-by: Warner Losh <imp@FreeBSD.org>
Differential-Revision: https://reviews.freebsd.org/D49727
(cherry picked from commit d5ce906da7c55085f93fce096ebb8bc44a3cffe5)
2025-04-27 16:02:58 -06:00
Sreekanth Reddy
e2692e8aa2 bnxt_en: Update HSI header
Update HSI header to support Thor2 controllers.

MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49726
(cherry picked from commit bb90baed6c275495b03adc5569346a59fce2a3c8)
2025-04-27 16:02:58 -06:00
Sreekanth Reddy
45e161020c bnxt_en: Add 5760X (Thor2) PCI IDs support
Add Thor2 PCI IDs.

Reviewed-by: Warner Losh <imp@FreeBSD.org>
Reviewed-by: Sumit Saxena <sumit.saxena@broadcom.com>
MFC-After: 3 days
Differential-Revision: https://reviews.freebsd.org/D49725
(cherry picked from commit 26bd37da01cff2b2024f3f63b9ca318bf3a01669)
2025-04-27 16:02:58 -06:00
Krzysztof Galazka
7313d4a3dc iflib(4): Replace admin taskqueue group with per-interface taskqueues
Using one taskqueue group with single thread to execute all admin
tasks may lead to unexpected timeouts when long running task (e.g.
handling a reset after FW update) for one interface prevents
tasks from other interfaces being executed. Taskqueue group API
doesn't let to dynamically add threads, and pre-allocating thread
for each CPU as it's done for traffic queues would be a waste
of resources on systems with small number of interfaces. Replace
global taskqueue group for admin tasks with taskqueue allocated
for each interface to allow independent execution.

Signed-off-by: Krzysztof Galazka <krzysztof.galazka@intel.com>
Reviewed by: imp, jhb
Pull Request: https://github.com/freebsd/freebsd-src/pull/1336
(cherry picked from commit 3ad01642fe9e241124553f2f18fd365ffea5d20b)
2025-04-27 16:02:58 -06:00
Vinícius Ferrão
54f842ed88 /sys/dev/bnxt: Enable NPAR support on BCM57504
This commit enables NPAR support for Broadcom 57504 10/25GbE NICs

Signed-off-by: Vinícius Ferrão <vinicius@ferrao.net.br>
Reviewed by: imp,ssaxena,nightquick@proton.me
Pull Request: https://github.com/freebsd/freebsd-src/pull/1306
(cherry picked from commit 0bff716674418ec9f8c48131fb34cafc0af671e8)
2025-04-27 16:02:58 -06:00
Colin Percival
b0bbefc465 pci: Add hw.pci.intx_reroute sysctl/tunable
INTRng can leak resources when INTx interrupts are re-routed, which is
typically harmless but can be fatal when devices are (repeatedly) hot
plugged into PCI buses on INTRng systems.  Re-routing INTx interrupts
is nonetheless still necessary on some systems, and identifying whether
the re-routing should be enabled or disabled seems to be nontrivial.

Add a hw.pci.intx_reroute sysctl/tunable so systems which don't want
legacy PCI interrupt re-routing can turn it off.  This is probably not
the best fix but it's something which can be safely included in FreeBSD
14.3.

Co-Authored-by:	jhb
Reviewed by:	bz, jhb
MFC after:	3 days
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49849

(cherry picked from commit 2187ec93ada1c7399f2f3537920f6277bec4a0ef)
2025-04-26 12:21:03 -07:00
Aaron LI
ba560cd8fb wg: Improve wg_peer_alloc() to simplify the calling
Move the necessary extra logics (i.e., noise_remote_enable() and
TAILQ_INSERT_TAIL()) from wg_ioctl_set() to wg_peer_alloc(), and thus
make it easier to be called.  Actually, the updated version is more
asymmetric to wg_peer_destroy() and thus less likely to be misused.
Meanwhile, rename it to wg_peer_create() to look more consistent with
wg_peer_destroy().

Reviewed by:	aly_aaronly.me (diff), markj
Obtained from:	DragonflyBSD 902964ab24ba (with some changes)

(cherry picked from commit 7121e9414f294d116caeadd07ebd969136d3a631)
2025-04-25 22:19:47 -05:00
Navdeep Parhar
47cdd7a9eb cxgbe(4): Add two new transceiver types.
Future firmwares will report these types to the driver.  These
transceivers work already but are misidentified as a different type.

Sponsored by:	Chelsio Communications

(cherry picked from commit c22b297062e1440676973a8aa89cbad1571e22f9)
2025-04-22 04:12:46 -07:00
Navdeep Parhar
ca9d5b10eb cxgbe(4): Perform Conventional Reset instead of FLR on the device.
The driver uses bus_reset_child on its parent to reset itself but that
performs an FLR whereas the hardware needs a Conventional Reset[1] for
full re-initialization.  Add routines that perform conventional hot
reset and use them instead.  The available reset mechanisms are:
* PCIe secondary bus reset (default)
* PCIe link bounce

hw.cxgbe.reset_method can be used to override the default.  The internal
PL_RST is also available but is for testing only.

[1] 6.6.1 in PCI Express® Base Specification 5.0 version 1.0

Sponsored by:	Chelsio Communications

(cherry picked from commit 011e3d0b8b90a4330f14b2cb7da45ed7b805ed10)
2025-04-22 04:12:46 -07:00
Navdeep Parhar
516fee5422 cxgbe(4): Block most access to the hardware as soon as the adapter stops.
Add a new hw_all_ok() routine and use it to avoid hardware access in the
public control interfaces (ifnet ioctls, ifmedia calls, etc.).  Continue
to use hw_off_limits() in the private ioctls/sysctls and other debug
code.  Retire adapter_stopped() as it's of no use by itself.

This fixes problems where ifnet slow-path operations would enter a
synch_op just before set_adapter_hwstatus(false) and touch the hardware
when it's not safe to do so.

Sponsored by:	Chelsio Communications

(cherry picked from commit e19d84979a183deb37ce6d7e385c3ccf02a3c8c7)
2025-04-22 04:12:46 -07:00
Navdeep Parhar
4e9f829561 cxgbe(4): Use correct priority in begin_synchronized_op.
It was always set to PCATCH because the driver tested (INTR_OK) instead
of (flags & INTR_OK).  Fit a WITNESS_WARN in a single line while here.

Sponsored by:	Chelsio Communications

(cherry picked from commit 04bf43505bae1bb20d315a44e977d97aed3e5733)
2025-04-22 04:12:46 -07:00
Navdeep Parhar
db403eb80e cxgbe(4): Remove some unused PCI routines and associated headers.
Sponsored by:	Chelsio Communications

(cherry picked from commit 9d76f6d042feecf16775a200ee79c4e50fc533ba)
2025-04-22 04:12:45 -07:00
Navdeep Parhar
f2c75b13f3 cxgb(4): Use routines from pci(9) instead of hand rolled equivalents.
There is no need to include private PCI headers in the driver.

Sponsored by:	Chelsio Communications

(cherry picked from commit 762d32354a18517c28933ddc29f9d3d855e450b1)
2025-04-22 04:12:45 -07:00
Navdeep Parhar
b5a68e0641 cxgbe(4): Remove smt_idx from the L2 table entry structure.
An L2 table entry isn't associated with a particular SMT (Source MAC
Table) entry.

Sponsored by:	Chelsio Communications

(cherry picked from commit f79fba05a016d53e054d6f587213889c3e31b4db)
2025-04-22 04:12:45 -07:00
Navdeep Parhar
4599a3c0b8 cxgbe(4): Make sure suspend/resume works in recovery mode.
The driver does minimal initialization in this mode and suspend/resume
should ignore resources that aren't setup.  This is for debug only.

kenv hw.cxgbe.sos="1"
kldload if_cxgbe
devctl suspend t6nex0
devctl resume t6nex0

Sponsored by:	Chelsio Communications

(cherry picked from commit f4ab14044c1de35b1aefad5449bddc5a1272f8d9)
2025-04-22 04:12:45 -07:00
Vee Agarwal
9a24acc6c8 gve: Add feature to change TX/RX ring size
This change introduces new sysctl handlers that allow the user to change
RX/TX ring sizes. As before, the default ring sizes will come from the
device (usually 1024). We also get the max/min limits from the device.
In the case min values are not provided we have statically defined
constants for the min values. Additionally, if the modify ring option is
not enabled on the device, changing ring sizes via sysctl will not be
possible.  When changing ring sizes, the interface turns down
momentarily while allocating/freeing resources as necessary.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49428

(cherry picked from commit 22fe926a62b7bca771d46502dd6a8c202f25b5be)
2025-04-18 13:52:10 +00:00
Vee Agarwal
ecc250c600 gve: Add feature to adjust RX/TX queue counts
This change introduces new sysctl handlers that allow the user to change
RX/TX queue counts. As before, the default queue counts will be the max
value the device can support. When chaning queue counts, the interface turns
down momentarily while allocating/freeing resources as necessary.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49427

(cherry picked from commit e0464f74d5579e1538ce741b0a15e6604dbc53c4)
2025-04-18 13:52:09 +00:00
Vee Agarwal
890309a67b gve: Allocate qpl per ring at ring allocation time
Every tx and rx ring has its own queue-page-list (QPL) that serves as
the bounce buffer. Previously we were allocating QPLs for all queues
before the queues themselves were allocated and later associating a QPL
with a queue. This is avoidable complexity: it is much more natural for
each queue to allocate and free its own QPL.

Signed-off-by: Vee Agarwal <veethebee@google.com>

Reviewed by:	markj
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D49426

(cherry picked from commit f8ed8382daf4b9a97056b1dba4fe4e5cb4f7485c)
2025-04-18 13:52:07 +00:00
Colin Percival
217fce1377 pci: Make PCIe Eject timeout configurable
PCIe mandates a 5 second delay between when the "Attention Button" is
pressed and when the associated device is detached; this is to allow
for the button to be pressed a second time to cancel the ejection.  On
some systems this 5 second delay may not be desireable; so introduce a
hw.pci.pcie_hp_detach_timeout sysctl (which can also be set as a loader
tunable) which specifies the timeout in milliseconds (default 5000).
If set to zero, the device is detached immediately.

Reviewed by:	jhb
MFC after:	2 weeks
Sponsored by:	Amazon
Differential Revision:	https://reviews.freebsd.org/D49585

(cherry picked from commit 9be42ee6c9c741052bdc49f13bc953bf88a24423)
2025-04-15 20:15:00 -07:00
Ariel Ehrenberg
63697ff85a mlx5en: Use connector type instead of cable type for media detection
(cherry picked from commit 89e0e3814e8ca205db7523f6ce6c63cebe4bfb0d)
2025-04-16 04:41:49 +03:00
Mark Johnston
e6a3962d7d hyperv/storvsc: Avoid conditional asserts in storvsc_xferbuf_prepare()
whu@ cannot reproduce the assertion failure which led to these ifdefs
being added in the first place, and since they appear wrong, i.e., the
assertions ought to apply to all platforms, let's remove them.

This reverts commits 0af5a0cd27 and
6f7b1310b6.

PR:		285681
Tested by:	whu
MFC after:	2 weeks

(cherry picked from commit 54a3920dc9b3b5a47cdaaa3132b4fcf1c448a737)
2025-04-15 02:25:24 +00:00