Commit graph

42828 commits

Author SHA1 Message Date
Joshua Kinard 80828c6fab kern: Remove leftover saf1761otg bits
Almost all code related to the saf1761 driver was removed in commit
44796b7e82, except for two small bits related to saf1761otg support.
This patch completes the removal.

PR:		279302
Signed-off-by:	Joshua Kinard <freebsd@kumba.dev>
Reviewed by:	mhorne
MFC after:	3 days
Fixes:		44796b7e82 ("mips: remove saf1761")
2024-06-03 12:52:58 -03:00
Dmitry Salychev 645a228481
ds1307: Return error code instead of boolean
It's probably a copy-paste leftover from the other functions which
return a boolean value and generates annoying "CLOCK_SETTIME error 1"
from subr_rtc.c on Traverse Ten64 in verbose mode.

No functional changes intended.

MFC after:	3 days
2024-06-03 15:41:11 +02:00
Mark Johnston 542f9494b7 proto: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston 66d2d42a1f uart: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston a3b460d499 mvs: Use device_set_desc(f)()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston de140d60d5 virtio: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston bad36a4998 acpi: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston 801b12ba89 qlnx: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston 17bfbc400f siis: Use device_set_desc(f)()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston 54482989d3 etherswitch: Use device_set_desc(f)()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:41 -04:00
Mark Johnston a1b8445115 cxgbe: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Mark Johnston 796bcf1845 cxgb: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Mark Johnston a866a40b9b bhnd: Use device_set_descf()
Here we are in a device probe routine with no locks held.  M_WAITOK
allocations are ok.  No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Mark Johnston 25b839dfd2 ata: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
Mark Johnston a74b496507 ahci: Use device_set_desc(f)()
No functional change intended.

MFC after:	1 week
2024-06-02 19:38:40 -04:00
John Baldwin c7c037fad1 bhnd: Remove orphaned driver for the BHND USB core
This was only connected to the build for MIPS and has been
disconnected from the build since MIPS was removed.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D45432
2024-06-01 13:25:12 -07:00
John Baldwin 0f1d148cfd pci: Use kobj typedefs for new-bus method prototypes
Reviewed by:	kp, imp
Differential Revision:	https://reviews.freebsd.org/D45405
2024-06-01 13:24:29 -07:00
Alan Somers 9d449caddd md: round-trip the MUSTDEALLOC and RESERVE options
If those options are requested when the device is created, ensure that
they will be reported by MDIOCQUERY.

MFC after:	2 weeks
Reviewed by:	imp
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1270
2024-06-01 12:40:19 -06:00
Chuck Tuffli ce75bfcac9 nvme: Change namespace device name
Changes the device name for NVMe and NVMe-oF namespaces from using "ns"
to "n" to be more compatible with other operating systems. For example,
a device which was previously /dev/nvme0ns1 is now /dev/nvme0n1.

Preserves the existing functionality by creating alias from nvmeXnY to
nvmeXnsY.

Reviewed by:	imp
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D45414
2024-06-01 04:14:14 -07:00
Kevin Lo 345fd21a6a Add a new USB ID for Xiaomi mini USB WiFi 2024-05-31 09:40:03 +08:00
Mark Johnston bbe42332e5 bnxt_re: Explicitly cast pointer-to-integer conversions
Reported by:	Jenkins
Fixes:	acd884dec9 ("RDMA/bnxt_re: Add bnxt_re RoCE driver")
2024-05-28 09:12:42 -04:00
Sumit Saxena acd884dec9 RDMA/bnxt_re: Add bnxt_re RoCE driver
This patch introduces the RoCE driver for the
Broadcom NetXtreme-E 10/25/50/100/200G RoCE HCAs.

The RoCE driver is a two part driver that relies
on the bnxt_en NIC driver to operate. The changes
needed in the bnxt_en driver is included through
another patch "L2-RoCE driver communication interface"
in this set.

Presently, There is no user space support, Hence
recommendation to use the krping kernel module for
testing. User space support will be incorporated in
subsequent patch submissions.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45011
2024-05-28 10:36:11 +00:00
Chandrakanth patil 862af86f4b bnxt_en: Driver version update to 230.0.133.0
Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45010
2024-05-28 10:36:11 +00:00
Chandrakanth patil 3d8bbe0011 bnxt_en: Firmware header version update to 1.10.3.42
This file is automatically generated from the firmware code to
export the driver interfaces.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45009
2024-05-28 10:36:11 +00:00
Chandrakanth patil c9965974a5 bnxt_en: Firmware error recovery support
Implement firmware error recovery support for Thor adapters.
This entails enabling the capability for the firmware to initiate
error recovery. Specifically, the firmware will send the reset notify
asynchronous event to notify the driver of an error and impending reset.
Subsequently, the driver will queue a task to execute the following steps.

1. Deactivate the allocated resources.
2. Await completion of the firmware's recovery process.
3. Configure the resources and reactivate the network interface.

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45008
2024-05-28 10:36:11 +00:00
Chandrakanth patil 032899b59c bnxt_en: Added support for priority queues extended stats
Below priority queues extended stats are exposed to sysctl:

tx_bytes_pri{0-7}
rx_bytes_pri{0-7}
tx_packets_pri{0-7}
rx_packets_pri{0-7}

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45007
2024-05-28 10:36:11 +00:00
Chandrakanth patil 050d28e13c bnxt_en: L2-RoCE driver communication interface
- Added Aux bus support for RoCE.
- Implemented the ulp ops that are required by RoCE driver.
- Restructure context memory data structures
- DBR pacing support

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45006
2024-05-28 10:36:10 +00:00
Chandrakanth patil 35b53f8c98 bnxt_en: Add PFC, ETS & App TLVs protocols support
Created new directory "bnxt_en" in /dev/bnxt and /modules/bnxt
and moved source files and Makefile into respective directory.

ETS support:

   - Added new files bnxt_dcb.c & bnxt_dcb.h
   - Added sysctl node 'dcb' and created handlers 'ets' and
     'dcbx_cap'
   - Add logic to validate user input and configure ETS in
     the firmware
   - Updated makefile to include bnxt_dcb.c & bnxt_dcb.h

PFC support:

   - Created sysctl handlers 'pfc' under node 'dcb'
   - Added logic to validate user input and configure PFC in
     the firmware.

App TLV support:

   - Created 3 new sysctl handlers under node 'dcb'
       - set_apptlv (write only): Sets a specified TLV
       - del_apptlv (write only): Deletes a specified TLV
       - list_apptlv (read only): Lists all APP TLVs configured
   - Added logic to validate user input and configure APP TLVs
     in the firmware.

Added Below DCB ops for management interface:

   - Set PFC, Get PFC, Set ETS, Get ETS, Add App_TLV, Del App_TLV
     Lst App_TLV

Reviewed by:            imp
Approved by:            imp
Differential revision:  https://reviews.freebsd.org/D45005
2024-05-28 10:15:29 +00:00
Keith Reynolds 1c45a62a2f qlnxe: Fix multiple locking issues
Multiple issues are reported with WITNESS and code inspection of the
locking and lock initialization.

PR:		278084
MFC after:	1 week
2024-05-27 23:41:05 -07:00
Kevin Bowling fb78e20b4e Revert "qlnxe: Fix multiple locking issues"
This commit is missing a file, revert so I can do it correctly,
atomically.

This reverts commit 29684d08fa.
2024-05-27 23:39:23 -07:00
Keith Reynolds 29684d08fa qlnxe: Fix multiple locking issues
Multiple issues are reported with WITNESS and code inspection of the
locking and lock initialization.

PR:		278084
MFC after:	1 week
2024-05-27 23:13:10 -07:00
Keith Reynolds e3ec564ecb qlnxe: Fix promiscuous and allmulti settings
PR:		278087
MFC after:	1 week
2024-05-27 22:57:44 -07:00
Fuqian Huang 9370f49ad1 qlnx: qlnxe: Fix kernel address leakage
In function qlnx_rdma_deregister_if,
the address of object rdma_if will be printed out.
rdma_if is the address of a global variable qlnxr_drv,
which is passed from dev/qlnx/qlnxr/qlnxr_os.c
A kernel address leakage happens.
Fix this by removing the printf statement.

PR:		238646
MFC after:	1 week
2024-05-27 22:45:52 -07:00
Fuqian Huang ae38977758 qlxge: replace device_printf with QL_DPRINT2
QL_DPRINT2 checks the debug level first before printing.
Replace device_printf with QL_DPRINT2 to check debug level
first before printing out the kernel pointers.

PR:		238656
MFC after:	1 week
2024-05-27 22:40:12 -07:00
Fuqian Huang 3d6c7ee87e qlxgbe: fix debug prints in ql_os.c
QL_DPRINT2 checks the debug level first and then prints.
Replace device_printf with QL_DPRINT2 to check debug level
first before printing out the kernel pointers.

PR:		238655
MFC after:	1 week
2024-05-27 22:32:16 -07:00
Fuqian a58b4ee025 qlxgbe: Remove pointer printing in ql_ioctl.c
PR:		238653
MFC after:	1 week
2024-05-27 22:18:52 -07:00
Zhenlei Huang 2439ae9483 mlx4, mlx5: Eliminate redundent NULL check for packet filter
mlx4 and mlx5 are Ethernet devices and ether_ifattach() does an
unconditional bpfattach(). From commit 16d878cc99 [1] and on, we
should not check ifp->if_bpf to tell us whether or not we have any bpf
peers that might be interested in receiving packets. And since commit
2b9600b449 [2], ifp->if_bpf can not be NULL even after the network
interface has been detached.

No functional change intended.

1. 16d878cc99 Fix the following bpf(4) race condition which can result in a panic
2. 2b9600b449 Add dead_bpf_if structure, that should be used as fake bpf_if during ifnet detach

Reviewed by:	kp, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D45196
2024-05-28 12:46:04 +08:00
Warner Losh d09ee08f10 nvme: Count number of alginment splits
When possible, we split up I/Os to NVMe drives that advertise a
preferred alignment. Add a counter for this.

Sponsored by:		Netflix
Reviewed by:		chuck, mav
Differential Revision:	https://reviews.freebsd.org/D45311
2024-05-24 08:32:47 -06:00
Brooks Davis fb9013f215 pcm: centralize 32-bit ioctl compat
Move all handlng of struct sndstioc_nv_arg(32) to sndstat_ioctl() and
make the functions that actually do the work take a buffer and size or
size pointer.  The 32-bit compat work is minimal so just inline it.

Remove checks that we've got a 32-bit process for 32-bit ioctls.  We
don't check that default ioctls are from 64-bit processes on 64-bit
systems.

Reviewed by:	christos
Differential Revision:	https://reviews.freebsd.org/D45307
2024-05-23 17:15:09 +01:00
Christos Margiolis 425a7bc465 sound: Fix minchn, maxchn and fmts in sndstat_get_caps()
The current implementation (incorrectly) passes the channel encoding
value to AFMT_CHANNEL(), which will always return 0, since the channel
number bits are masked out by AFMT_ENCODING().

Also add missing fmts initialization and aggregate encoding formats into
it directly.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45312
2024-05-23 02:57:55 +02:00
Christos Margiolis 5d980fadf7 sound: Handle unavailable devices in various OSS IOCTLs
mixer(8)'s -a option is used to print information about all mixer
devices in the system. To do this, it loops from 0 to
mixer_get_nmixers(), and tries to open "/dev/mixer%d". However, this
approach doesn't work when there are disabled/unregistered mixers in the
system, or when an audio device simply doesn't have a mixer.

mixer_get_nmixers() calls SNDCTL_SYSINFO and returns
oss_sysinfo->nummixers, whose value is the number of currently _enabled_
mixers only. Taking the bug report mentioned below (277615) as an
example, suppose a system with 8 mixer devices total, but 3 of them are
either disabled or non-existent, which means they will not show up under
/dev, meaning we have 5 enabled mixer devices, which is also what the
value of oss_sysinfo->nummixers will be. What mixer(8) will do is loop
from 0 to 5 (instead of 8), and start calling mixer_open() on
/dev/mixer0, up to /dev/mixer4, and as is expected, the first call will
fail right away, hence the error shown in the bug report.

To fix this, modify oss_sysinfo->nummixers to hold the value of the
maximum unit in the system, which, although not necessarily "correct",
is more intuitive for applications that will want to use this value to
loop through all mixer devices.

Additionally, notify applications that a device is
unavailable/unregistered instead of skipping it. The current
implementations of SNDCTL_AUDIOINFO, SNDCTL_MIXERINFO and
SNDCTL_CARDINFO break applications that expect to get information about
a device that is skipped. Related discussion can be found here:
https://reviews.freebsd.org/D45135#1029526

It has to be noted, that other applications, apart from mixer(8), suffer
from this.

PR:		277615
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45256
2024-05-23 02:57:17 +02:00
Christos Margiolis e07f917850 sound: Separate implementations for SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
FreeBSD's implementation of SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO
does not exactly work as intended. The problem is essentially that both
IOCTLs return the same information, while in fact the information
returned currently by dsp_oss_audioinfo() is what _only_
SNDCTL_ENGINEINFO is meant to return.

This behavior is also noted in the OSS manual [1] (see bold paragraph in
"Audio engines and device files" section), but since e8c0d15a64
("sound: Get rid of snd_clone and use DEVFS_CDEVPRIV(9)") we can
actually fix this, because we now expose only a single device for each
soundcard, and create the engines (channels) internally.
SNDCTL_ENGINEINFO will now report info about all channels in a given
device, and SNDCTL_AUDIOINFO[_EX] will only report information about
/dev/dspX.

To make this work, we also have to modify the SNDCTL_SYSINFO IOCTL to
report the number of audio devices and audio engines correctly.

While here, modernize the minimum and maximum channel counting in both
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO. Currently these IOCTLs will
report only up to 2 channels, which is no longer the case.

[1] http://manuals.opensound.com/developer/SNDCTL_AUDIOINFO.html

PR:		246231, 252761
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45164
2024-05-23 02:57:04 +02:00
Lutz Bichler 93ad59a251 snd_hda: Add patch for Asus UX331UAL
PR:		242802
MFC after:	1 day
Differential Revision:	https://reviews.freebsd.org/D45238
2024-05-23 00:19:50 +02:00
Ryan Libby bea2bf458d tpm_if.m: declare bus addresses as bus_size_t not bus_addr_t
Do like bus_space(9) does.  This fixes the build on platforms where
bus_addr_t and bus_size_t are different (like i386 PAE).

Reviewed by:	jhibbits
Fixes:		c2e9c5bbf0 tpm: Refactor TIS and add a SPI attachment
Differential Revision:	https://reviews.freebsd.org/D45287
2024-05-22 07:55:04 -07:00
Andrew Turner 131c1718c6 dev/hwpmc: Fix the dmc620 MD4 macro
Add braces to the dmc620 MD4 macro to fix the GCC build.

Reviewed by:	brooks, imp, jhb
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45266
2024-05-22 08:19:49 +00:00
Andrew Turner f55e866488 pci: Fix pci_host_generic_acpi with gcc
In pci_host_generic_acpi.c we loop over pci_acpi_quirks to check if
we need to handle any quirks. GCC doesn't like the terminatin as it
sets a fixed width string to 0.

As this the array is only ever used in this file change to use nitems
to find when to stop the loop.

Reviewed by:	brooks, imp, jhb, emaste
Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D45265
2024-05-22 08:19:38 +00:00
Christos Margiolis 64f4e2db6d sound: Correctly check nvlist_unpack() error
The current check is never false and if nvlist_unpack() fails, we might
panic later down the road.

PR:		266144
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45237
2024-05-20 16:18:33 +02:00
Christos Margiolis 074d337ad6 sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS*
SNDSTIOC_ADD_USER_DEVS* expects a user-supplied sndstioc_nv_arg->nbytes,
however we currently do not check whether this size is actually valid,
which results in a panic when SNDSTIOC_ADD_USER_DEVS* is called with an
invalid size. sndstat_add_user_devs() calls
sndstat_unpack_user_nvlbuf(), which then calls malloc() with that size.

PR:		266142
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	brooks
Differential Revision:	https://reviews.freebsd.org/D45236
2024-05-20 16:18:28 +02:00
Christos Margiolis 5d1a5d6f1f sound: Prevent uninitialized variable destruction in chn_init()
If dsp_unit2name() fails, we'll get to out2 with b, bs and devinfo
uninitialized, which will result in a panic.

Reported by:	Pierre Pronchery <pierre@freebsdfoundation.org>
Reported by:	Coverity Scan
CID:		1545029, 1545025
Pull-request:	https://github.com/freebsd/freebsd-src/pull/1240
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45272
2024-05-20 16:14:25 +02:00
Christos Margiolis 2db2292dac sound: Get rid of redundant assignments in chn_init()
c is allocated with M_ZERO.

Reported by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45273
2024-05-20 16:14:17 +02:00
Navdeep Parhar 64a00f877f cxgbe(4): Consolidate all mk_set_tcb_field_ulp in one place.
MFC after:      1 week
Sponsored by:   Chelsio Communications
2024-05-17 15:52:33 -07:00
Navdeep Parhar cca3506dc1 cxgbe(4): sc->port is indexed by port_id and not tx_chan.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-05-17 15:42:23 -07:00
Andrew Turner 097bd33dd7 uart: DBG2 support to find the debug uart
The Debug Port Table 2 (DBG2) contains information on which devices
can be used for debugging purposes.

Add support to the uart driver to use the DBG2 table when enabled from
loader.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D44359
2024-05-17 16:07:15 +00:00
Andrew Turner 2790ff2145 dev/psci: Fix a function name
dd a missing underscore to arm_smccc_1_2_* to fix the GCC build.

Sponsored by:	Arm Ltd
2024-05-17 13:19:59 +00:00
Emmanuel Vadot ae38a1a1bf linuxkpi: spinlock: Simplify code
Just use a typedef for spinlock_t, no need to create a useless
structure.

Reviewed by:		bz, emaste
Sponsored by:		Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D45205
2024-05-16 09:39:36 +02:00
Jessica Clarke fc59fc3c1f uart: Honour clock-frequency in FDT for UART_FDT_CLASS if present
The StarFive VisionFive 2 has a Synopsys DesignWare ABP UART, whose
driver uses UART_FDT_CLASS rather than UART_FDT_CLASS_AND_DEVICE as it
has its own separate newbus driver. This UART is driven by a 24MHz clock
as specified in the FDT, but we don't currently look at the property
here, instead passing down 0 and letting the default value be used in
the 8250 driver (~1.8MHz). As a result the divisor is misconfigured for
the current baud rate for the entire kernel boot process. Once the
newbus driver attaches the correct frequency is saved in the softc, but
that does not take effect until the next time ns8250_param is called and
the divisor is recalculated, namely when userspace runs and /dev/console
is opened (note that ns8250_init does not get called when the newbus
device corresponding to the current console attaches).

Fix this issue by attemmpting to get the current clock frequency as for
the UART_FDT_CLASS_AND_DEVICE_CASE, but falling back to 0 rather than
failing on error.

Reviewed by:	imp, mhorne
Differential Revision:	https://reviews.freebsd.org/D45159
2024-05-15 16:53:33 +01:00
Christos Margiolis 305db91d4b sound: Remove ncards variable from sound_oss_card_info()
The loop counter is also the card's index, so ncards is redundant.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45144
2024-05-14 15:42:20 +02:00
Christos Margiolis 278953360e snd_hda: Rename LENOVO_I* to LENOVO_IDEAPAD*
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45105
2024-05-14 15:42:15 +02:00
Christos Margiolis 54cc353f50 snd_hda: Add patch for Lenovo Ideapad 3
Reported by:	bsd-lists@bsdforge.com
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D45100
2024-05-14 15:42:04 +02:00
Warner Losh 0dd84c3b11 nvme: Add comment about where tr->deadline is set
It's easy to overlook the chain of events that lead to tr->deadline
being updated. Add a comment here to explain what otherwise looks like
an oversight w/o careful study.

Sponsored by:		Netflix
2024-05-13 16:14:04 -06:00
Warner Losh c931cf6af0 nvme: Slight simplification
We don't need to dereference qpair to get the ctrlr pointer each time,
so use the cached value. It's not going to change. No change intended.

Sponsored by:		Netflix
2024-05-13 16:14:04 -06:00
Warner Losh 9db8ca92b9 nvme: Slight reworking this loop to match FreeBSD style
Update the comment for the code, and slightly rework the code in the
'fast exit' paradigm that FreeBSD generally tries to do.

Sponsored by:		Netflix
2024-05-13 16:14:04 -06:00
Warner Losh 5a178b831a nvme: Add locking asserts
nvme_qpair_complete_tracker and nvme_qpair_manual_complete_tracker have
to be called without the qpair lock, so assert its unowned.

Sponsored by:		Netflix
2024-05-13 16:14:03 -06:00
John Baldwin da4230af3f nvme/f: Use strlcpy instead of strncpy + manual string termination
Reviewed by:	dab, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45153
2024-05-13 12:04:03 -07:00
John Baldwin 01fc488381 nvme: Use strlcpy instead of strncpy to ensure termination
Reviewed by:	dab, imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D45152
2024-05-13 12:03:49 -07:00
Ahmad Khalifa 881ae768f2 usb: Remove uneeded revision verbosity from quirks list
Seperate usb quirks that target specific revisions from those that
dont. Alot of the quirks dont use lo_rev and hi_rev, so we can abstract
the 0x0000, 0xffff into a macro.

[[ This commit is a bit more churn than we like. I carefully reviewed
   each one and they are all good. The end product is better -- imp ]]

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1153
2024-05-11 13:32:57 -06:00
Ahmad Khalifa 64e05e9065 usb: Fix quirks list
In some cases, the USB_QUIRK_VP macro was being misused. Instead of
setting quirks to the intended value, the first two supplied quirks
would go into lo_rev and hi_rev. Replace it with USB_QUIRK_VO which only
takes the needed args. This also makes the Dummy products, which where
being used to correctly set vendor only quirks, not necessary.

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1153
2024-05-11 13:32:37 -06:00
Warner Losh e84a75f936 nvme: Add telemetry page definitions
Add definition for page types 7 and 8 for host initiated telemetry and
controller initiated telemetry (they differ by one byte, but that byte
that's defined in the host version is reserved in the controller
version).

Sponsored by:		Netflix
2024-05-11 12:09:50 -06:00
John Baldwin 473c90ac04 uio: Use switch statements when handling UIO_READ vs UIO_WRITE
This is mostly to reduce the diff with CheriBSD which adds additional
constants to enum uio_rw, but also matches the normal style used for
uio_segflg.

Reviewed by:	kib, emaste
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D45142
2024-05-10 13:43:36 -07:00
John Baldwin f75764fea3 md: Merge two switch statements in mdstart_vnode
While here, use bp->bio_cmd instead of auio.uio_rw to drive read vs
write behavior.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D45155
2024-05-10 13:43:23 -07:00
John Baldwin 50884a0b09 nvmf_transport: Remove invalid assertion
This is leftover from an earlier iteration of the code where 'nt' was
not dynamically allocated but was the passed in 'ops' pointer so was
always alive.

Reported by:	Coverity Scan
CID:	 	1545042
Sponsored by:	Chelsio Communications
2024-05-10 09:13:40 -07:00
John Baldwin 1f029b86bb nvmf: Use strlcpy instead of strncpy to ensure termination
Reported by:	Coverity Scan
CID:	 	1545054
Sponsored by:	Chelsio Communications
2024-05-10 08:56:51 -07:00
Justin Hibbits 10eea8dc8c tpm20: Support partial reads
Summary:
In some cases the TPM utilities may read only a partial block, instead
of a full block.  If a new command starts while in the middle of a read
it may cause the TPM to go catatonic and no longer respond to SPI.

Reviewed by:	kd
Obtained from:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D45140
2024-05-10 14:35:28 -04:00
Ed Maste 2e0c027e69 ukswitch: fix non-debug build
PR:		278847
Sponsored by:	The FreeBSD Foundation
2024-05-10 08:53:15 -04:00
Andrew Turner f91e9401c2 dev/psci: Check all compat strings
When searching for the PSCI FDT node we only check a few compat strings.
Use the existing compat_data array to check all strings the driver may
attach to.

Sponsored by:	Arm Ltd
Differential Revision:	https://reviews.freebsd.org/D44913
2024-05-10 09:29:24 +00:00
HP van Braam c733dc7a6f ahc(4): Default to memory mapped IO
When this driver was written it made sense to make this default to off,
but these days almost all BIOSses will do the right thing. Furthermore
non-mmio communication only works on Intel architectures.

So lets default to allowing mmio, but not change the semantics of the
AHC_ALLOW_MEMIO flag to not break existing installs. Also document the
already existing hint.ahc.<unit>.allow_memio.

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp (small style tweak)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1219
2024-05-09 20:15:08 -06:00
Christos Margiolis 24d5cc14dd sound: Rename oss_audioinfo->real_device to oss_audioinfo->legacy_device
The OSS manual now documents this field as "legacy_device".

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45138
2024-05-09 21:08:34 +02:00
Christos Margiolis e6df8c379b sound: Add missing oss_mixerinfo devnode and legacy_device fields
They are missing from soundcard.h and are in fact used by some
applications, such as OSS' ossinfo(1):
http://manuals.opensound.com/developer/ossinfo.c.html

The new size for filler is chosen according to the most recent official
version of soundcard.h, which includes those 2 fields.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45137
2024-05-09 21:08:28 +02:00
Christos Margiolis 59d98edae3 sound: Fix oss_sysinfo->numcards
According to the OSS manual, oss_sysinfo->numcards holds the number of
detected audio devices in the system, while the current ncards variable,
whose value is assigned to oss_sysinfo->numcards, holds the number of
currently registered devices only.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D45136
2024-05-09 21:08:01 +02:00
Christos Margiolis 2f31a5eb75 sound: Remove nmix variable from mixer_oss_mixerinfo()
nmix is used to compare against oss_mixerinfo->dev, which is a
user-supplied value to select the mixer device (if not -1, in which case
we'll select the default one) we want to fetch the information of. It is
also used to set oss_mixerinfo->dev in case it is -1.

However, nmix is at best redundant, since we have the loop counter
already (i), and confusing at worst.

For example, suppose a system with 3 mixer devices. We call
SNDCTL_MIXERINFO with oss_mixerinfo->dev=1, meaning we want to get
information for /dev/mixer1. Suppose /dev/mixer0 detaches while inside
the loop, so we'll hit the loop's "continue" case, and nmix won't get
incremented (i.e will stay 0 for now). At this point nmix counts 1
device less, so when it reaches 1, we'll be fetching /dev/mixer2's
information instead of /dev/mixer1's.

This is also true in case the mixer device disappears prior to the call
to mixer_oss_mixerinfo().

Simply remove nmix and use the loop counter to both set
oss_mixerinfo->dev and check against it in case a non -1 value is
supplied.

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45135
2024-05-09 21:07:48 +02:00
Florian Walpen 5687c71d5f snd_hdsp(4): RME HDSP 9632 and HDSP 9652 sound card driver.
Add a sound(4) bridge device driver for the RME HDSP 9632 and HDSP 9652
sound cards. These cards require a nowadays rare PCI 32bit (not PCIe)
slot, but still see use due to their value and wealth of features.
The HDSP 9632 is mostly comparable to the newer HDSPe AIO, while the
HDSP 9652 is similar to the HDSPe RayDAT. These HDSPe PCIe cards are
supported by the snd_hdspe(4) driver which was taken as a starting point
for development of snd_hdsp(4).

Implementation is kept separately due to substantial differences in
hardware configuration and to allow easy removal in case PCI 32bit
support would be phased out in the future.

The snd_hdsp(4) kernel module is not enabled by default, and can be
loaded at runtime with kldload(8) or during boot via loader.conf(5).
Basic operation was tested with both cards, not including all optional
cable connectors and expansion boards. Features should be roughly on par
with the snd_hdspe(4) supported cards.

Reviewed by:	christos, br
Differential Revision:	https://reviews.freebsd.org/D45112
2024-05-09 19:36:40 +01:00
Ed Maste 82f43db382 ip17x: fix non-debug build
PR:		278847
Reviewed by:	jhibbits
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45133
2024-05-09 14:22:11 -04:00
Roger Pau Monné ee72bc1d1f xen/debug: remove usage of sbuf_{clear,finish}() on drained sbuf
Using sbuf_clear() on a drained sbuf is explicitly prohibited, and using
sbuf_finish() after printing a trace leads to a single trace being printed, as
after calling sbuf_finish() further attempts to use the same sbuf will lead to
a panic.

While there also switch to using xen_emergency_print() instead of attempting to
write directly to the hypervisor console.  xen_emergency_print() can be
implemented per-arch to use a different mechanism than the console hypercall
(note the default implementation still uses the console hypercall).

Fixes: df62b8a25f ('xen: add a handler for the debug interrupt')
Sponsored by: Cloud Software Group
Reviewed by: markj
Differential review: https://reviews.freebsd.org/D45060
2024-05-09 12:50:08 +02:00
John Baldwin ebcfab998e nvme: Explicitly align struct nvme_command on an 8 byte boundary
This was already true for most architectures due to uint64_t structure
members.  However, i386 is special in that it only requires 4 byte
alignment for uint64_t.  As a result, casts from struct nvme_command
to struct nvmf_fabric_cmd were raising a "cast increases alignment"
warning on i386.  Explicitly aligning struct nvme_command pacifies
this warning on i386.

Reported by:	rscheff
Sponsored by:	Chelsio Communications
2024-05-08 16:05:39 -07:00
Ed Maste 7ef6ce5174 smsc(4): update to mention Microchip
Microchip Technology acquired SMSC in 2012, and all current products
and datasheets refer to the devices supported by this driver as
Microchip parts.  Mention SMSC in a parenthetical comment to explain
the driver's name.

Reviewed by:	imp
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45115
2024-05-08 14:18:46 -04:00
Peter Jeremy 3fe25a9bfc
mii: Add support for Realtek RTL8211F-VD PHY
The RTL8211F-VD is a replacement/upgrade for the RTL8211F. Based on
bb726b753f,
the only difference is the lack of the PCR2 register, which FreeBSD
doesn't use.

This fixes autonegotiation problems using the RTL8211F with ukphy(4).
Reviewed by:	manu, bz
MFC after:	1 month
Differential Revision:  <https://reviews.freebsd.org/D45109
2024-05-08 18:17:00 +10:00
John Baldwin 29d7e39f56 nvme: Bump the alignment of struct nvme_health_information_page to 8
This ensures that embedded uint64_t values used for statistics
counters are aligned when allocating a structure on the stack or as
part of a containing structure.  In particular this quiets
-Waddress-of-packed-member warnings from GCC when compiling the code
in nvmfd to update the stats.

Reported by:	GCC
2024-05-07 13:54:00 -07:00
Jari Sihvola 0612538e3a jh7110: Add StarFive JH7110 clock/reset generator drivers
Implement a core clknode driver for the JH7110 (StarFive VisionFive v2)
platform.

Add clock/reset generator drivers for the PLL, SYS, and AON clock
groupings.

Co-authored-by: mhorne
Reviewed by:    mhorne
Sponsored by:   The FreeBSD Foundation (mhorne's contributions)
Differential Revision:  https://reviews.freebsd.org/D43037
2024-05-07 13:07:36 -03:00
Mitchell Horne 6ea05fce8e Revert "jh7110: Add StarFive JH7110 clock/reset generator drivers"
I did not set the author field properly; revert to fix this.

This reverts commit 5d6d627897.
2024-05-07 13:05:31 -03:00
Mitchell Horne c8b472aa4b jh7110: enable MMC driver
Add a variant of the existing dwmmc driver, and enable it in the GENERIC
kernel.

Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44026
2024-05-07 13:02:57 -03:00
Mitchell Horne 5d6d627897 jh7110: Add StarFive JH7110 clock/reset generator drivers
Implement a core clknode driver for the JH7110 (StarFive VisionFive v2)
platform.

Add clock/reset generator drivers for the PLL, SYS, and AON clock
groupings.

Co-authored-by:	mhorne
Reviewed by:	mhorne
Sponsored by:	The FreeBSD Foundation (mhorne's contributions)
Differential Revision:	https://reviews.freebsd.org/D43037
2024-05-07 13:02:57 -03:00
John Baldwin 1d425ef341 nvmf: Add explicit alignment for struct nvmf_fabric_cmd
This avoids -Wcast-align warnings from clang when upcasting from
struct nvmf_fabric_cmd to struct nvmf_fabric_prop_set_cmd.

Reported by:	bapt
Sponsored by:	Chelsio Communications
2024-05-06 15:19:39 -07:00
John Baldwin a7db82cfd9 nvmf_tcp: Correct tests for PDU direction
Add parentheses to ensure the correct order of operations.

Reported by:	GCC
2024-05-06 14:03:48 -07:00
John Baldwin e75a79f40b nvmf: Remove packing pragmas from nvmf_proto.h
The protocol structures do not need explicit packing and static
assertions verify the size of all the structures as well as the
offsets of several key fields.  The pragma triggers warnings when
building with GCC.

Sponsored by:	Chelsio Communications
2024-05-06 14:03:44 -07:00
Christos Margiolis 2b14465faa sound: Update pcm/vchan.c LICENSE header
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2024-05-06 20:47:33 +02:00
Christos Margiolis 3af2beb8b2 sound: Remove unused "num" argument from chn_init() and related callers
It is always -1 (i.e unused).

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D45095
2024-05-06 20:35:55 +02:00
Christos Margiolis 77ab4263bc sound: Rename pcm_getparentchannel() to vchan_getparentchannel()
Follow the rest of the vchan.c naming convention.

No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45016
2024-05-06 20:35:55 +02:00
Christos Margiolis 7ad5f383fc sound: Move vchan-related code to pcm/vchan.*
pcm/sound.* contains code that should be part of pcm/vchan.*.

Changes:
- pcm_setvchans() -> vchan_setnew()
- pcm_setmaxautovchans() -> vchan_setmaxauto()
- hw.snd.maxautovchans moved to pcm/vchan.c
- snd_maxautovchans declaration moved to pcm/vchan.h and definition to
  pcm/vchan.c

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45015
2024-05-06 20:35:55 +02:00
Christos Margiolis c597c55792 sound: Use nitems() where possible
No functional change intended.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D45014
2024-05-06 20:35:55 +02:00
Christos Margiolis 72cbd38107 sound: Remove unused dsp_cdevs[] fields and devices
These fields and devices are unused as of e8c0d15a64 ("sound: Get rid
of snd_clone and use DEVFS_CDEVPRIV(9)").

While here, remove unused SND_DEV_* defines from pcm/sound.h and convert
the list to an enum.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45013
2024-05-06 20:35:55 +02:00
Christos Margiolis 923e0040a5 sound: Move chip.h contents to pcm/sound.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44997
2024-05-06 20:35:55 +02:00
Christos Margiolis 7398d1ece5 sound: Remove hw.snd.version and SND_DRV_VERSION
hw.snd.version and SND_DRV_VERSION define the sound driver version and
are meant to be used in bug reports, but because these values are
constant, there is not much useful information we can extract from them.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch, emaste
Differential Revision:	https://reviews.freebsd.org/D44996
2024-05-06 20:35:06 +02:00
Christos Margiolis 139bcec852 sound: Convert pcm_chn_add() to void
It always returns 0.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44998
2024-05-06 20:27:18 +02:00
Christos Margiolis 76f95bae09 sound: Add __assert_unreachable() to default cases in pcm_chn_add() and pcm_chn_remove()
We should normally never enter these cases.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44994
2024-05-06 20:26:56 +02:00
Christos Margiolis 2e9962ef57 sound: Merge pcm_chn_create() and chn_init()
Follow-up of b3ea087c05 ("sound: Merge
pcm_chn_destroy() and chn_kill()")

While here, add device_printf()'s to all failure points. Also fix an
existing bug where we'd unlock an already unlocked channel, in case we
went to "out" (now "out2") before locking the channel.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D44993
2024-05-06 20:26:37 +02:00
Konstantin Belousov c097967b9a mlx5en: add diagnostic in one more case of failed eeprom read preparation
Sponsored by:	Nvidia Networking
MFC after:	1 week
2024-05-06 06:15:35 +03:00
HP van Braam 6279646f47 aic7xxx: make target mode enable a device hint
Previously it was only possible to enable target mode for these drivers
by rebuilding the kernel with AHC_TMODE_ENABLE or AHD_TMODE_ENABLE and a
bitmask of which units to statically enable for target mode.

There is no space-savings in the driver by not having AHC_TMODE_ENABLE
set, so in addition to the compile time option lets also introduce some
tunables:

hint.ahc.<unit>.tmode_enable=0/1
hint.ahd.<unit>.tmode_enable=0/1

For compatibility the old behavior is retained, but it can be overridden
with tunables

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp, mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/1208
2024-05-04 08:40:38 -06:00
HP van Braam 34db47a9db aic7xxx: aicasm correct include file
aicasm just puts the value of the "-i" passed include file in the
generated file with quotes around it. This means that there are manual
edits made to aic7xxx_reg_print.c and aic79xx_reg_print.c

now we check to see if the value passed to '-i' starts with a '<', if it
does don't output the quotes.

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp (minor code simplification)
Pull Request: https://github.com/freebsd/freebsd-src/pull/1209
2024-05-04 08:39:02 -06:00
Justin Hibbits c2e9c5bbf0 tpm: Refactor TIS and add a SPI attachment
Summary:
Though mostly used in x86 devices, TPM can be used on others, with a
direct SPI attachment.  Refactor the TPM 2.0 driver set to use an
attachment interface, and implement a SPI bus interface.

Test Plan:
Tested on a Raspberry Pi 4, with a GeeekPi TPM2.0 module (SLB9670
TPM) using security/tpm2-tools tpm2_getcaps for very light testing against the
spibus attachment.

Reviewed by:	kd
Obtained from:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D45069
2024-05-03 16:26:11 -04:00
John Baldwin a15f7c96a2 nvmft: The in-kernel NVMe over Fabrics controller
This is the server (target in SCSI terms) for NVMe over Fabrics.
Userland is responsible for accepting a new queue pair and receiving
the initial Connect command before handing the queue pair off via an
ioctl to this CTL frontend.

This frontend exposes CTL LUNs as NVMe namespaces to remote hosts.
Users can ask LUNS to CTL that can be shared via either iSCSI or
NVMeoF.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44726
2024-05-02 16:38:30 -07:00
John Baldwin 5e3e444230 nvme: Add constants for the Fused Operation (FUSE) field in commands
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44845
2024-05-02 16:31:02 -07:00
John Baldwin a1eda74167 nvmf: The in-kernel NVMe over Fabrics host
This is the client (initiator in SCSI terms) for NVMe over Fabrics.
Userland is responsible for creating a set of queue pairs and then
handing them off via an ioctl to this driver, e.g. via the 'connect'
command from nvmecontrol(8).  An nvmeX new-bus device is created
at the top-level to represent the remote controller similar to PCI
nvmeX devices for PCI-express controllers.

As with nvme(4), namespace devices named /dev/nvmeXnsY are created and
pass through commands can be submitted to either the namespace devices
or the controller device.  For example, 'nvmecontrol identify nvmeX'
works for a remote Fabrics controller the same as for a PCI-express
controller.

nvmf exports remote namespaces via nda(4) devices using the new NVMF
CAM transport.  nvmf does not support nvd(4), only nda(4).

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44714
2024-05-02 16:29:37 -07:00
John Baldwin 59144db3fc nvmf_tcp: Add a TCP transport for NVMe over Fabrics
Structurally this is very similar to the TCP transport for iSCSI
(icl_soft.c).  One key difference is that NVMeoF transports use a more
abstract interface working with NVMe commands rather than transport
PDUs.  Thus, the data transfer for a given command is managed entirely
in the transport backend.

Similar to icl_soft.c, separate kthreads are used to handle transmit
and receive for each queue pair.  On the transmit side, when a capsule
is transmitted by an upper layer, it is placed on a queue for
processing by the transmit thread.  The transmit thread converts
command response capsules into suitable TCP PDUs where each PDU is
described by an mbuf chain that is then queued to the backing socket's
send buffer.  Command capsules can embed data along with the NVMe
command.

On the receive side, a socket upcall notifies the receive kthread when
more data arrives.  Once enough data has arrived for a PDU, the PDU is
handled synchronously in the kthread.  PDUs such as R2T or data
related PDUs are handled internally, with callbacks invoked if a data
transfer encounters an error, or once the data transfer has completed.
Received capsule PDUs invoke the upper layer's capsule_received
callback.

struct nvmf_tcp_command_buffer manages a TCP command buffer for data
transfers that do not use in-capsule-data as described in the NVMeoF
spec.  Data related PDUs such as R2T, C2H, and H2C are associated with
a command buffer except in the case of the send_controller_data
transport method which simply constructs one or more C2H PDUs from the
caller's mbuf chain.

Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44712
2024-05-02 16:28:47 -07:00
John Baldwin aa1207ea4f nvmf: Add infrastructure kernel module for NVMe over Fabrics
nvmf_transport.ko provides routines for managing NVMeoF queue pairs
and capsules.  It provides a glue layer between transports (such as
TCP or RDMA) and an NVMeoF host (initiator) and controller (target).

Unlike the synchronous API exposed to the host and controller by
libnvmf, the kernel's transport layer uses an asynchronous API built
on callbacks.  Upper layers provide callbacks on queue pairs that are
invoked for transport errors (error_cb) or anytime a capsule is
received (receive_cb).

Data transfers for a command are usually associated with a callback
that is invoked once a transfer has finished either due to an error
or successful completion.

For an upper layer that is a host, command capsules are allocated and
populated with an NVMe SQE by calling nvmf_allocate_command.  A data
buffer (described by a struct memdesc) can be associated with a
command capsule before it is transmitted via nvmf_capsule_append_data.
This function accepts a direction (send vs receive) as well as the
data transfer callback.  The host then transmits the command via
nvmf_transmit_capsule.  The host must ensure that the data buffer
described by the 'struct memdesc' remains valid until the data
transfer callback is called.  The queue pair's receive_cb callback
should match received response capsules up with previously transmitted
commands.

For the controller, incoming commands are received via the queue
pair's receive_cb callback.  nvmf_receive_controller_data is used to
retrieve any data from a command (e.g. the data for a WRITE command).
It can be called multiple times to split the data transfer into
smaller sizes.  This function accepts an I/O completion callback that
is invoked once the data transfer has completed.
nvmf_send_controller_data is used to send data to a remote host in
response to a command.  In this case a callback function is not used
but the status is returned synchronously.  Finally, the controller can
allocate a response capsule via nvmf_allocate_response populated with
a supplied CQE and send the response via nvmf_transmit_capsule.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44711
2024-05-02 16:28:32 -07:00
John Baldwin 2f7b0de1de nvmft: Add NVMeoF controller routines shared between kernel and userland
This includes functions to validate NVMe Qualified Names, compute an
initial value of the CAP property, validate changes to the CC
property, and populate the Identify Controller data structure for an
I/O controller.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44709
2024-05-02 16:27:53 -07:00
John Baldwin bbd5b6fe91 nvmf_tcp.h: Internal header shared between userspace and kernel
- Helper macros for specific SGL types used with the TCP transport

- An inline function which validates various fields in TCP PDUs

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44708
2024-05-02 16:27:38 -07:00
John Baldwin d86edc181a nvmf.h: New header defining ioctls for NVMe over Fabrics
This defines structures, ioctl commands, and related constants used
for both the Fabrics host and controller.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44706
2024-05-02 16:27:13 -07:00
John Baldwin 52d5738dc5 nvmf_proto.h: Add additional types and constants from the 1.1 spec
- Add opcode, command structure, and new error code for Disconnect
  fabrics opcode.

- Add a generic struct nvmf_fabric_command.

- Add constants for special controller ID values.

- Add constants for the cattr field in the Connect command and the
  default value for the kato field in the Connect command.

- Add constants for the offset of controller properties (Fabrics
  version of controller registers).

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44705
2024-05-02 16:26:56 -07:00
John Baldwin 878d102ab9 nvmf_proto.h: Update for use in FreeBSD
- Replace SPDK_STATIC_ASSERT with _Static_assert.

- Remove SPDK_ and spdk_ prefixes from types and constants.

- Switch to using FreeBSD headers, e.g. <dev/nvme/nvme.h> in place of
  "spdk/nvme_spec.h".

- Add a definition of NVME_NQN_FIELD_SIZE (from SPDK's nvme_spec.h).

- Remove constant for the fabrics opcode as this is already present in
  <dev/nvme/nvme.h>.

- Use types from <dev/nvme/nvme.h> for NVMe structures including
  struct nvme_sgl_descriptor, struct nvme_command, and
  struct nvme_completion.

- Use plain uint16_t in place of struct spdk_nvme_status.

Reviewed by:	imp
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44704
2024-05-02 16:26:33 -07:00
John Baldwin f2e737683e nvmf_proto.h: NVMe over Fabrics protocol definitions
This is a copy of spdk/include/spdk/nvmf_spec.h as of commit
470e851852bb948334a272c9f8de495020fa082f from Intel's SPDK.
Subsequent commits will modify it to be suitable header for the
kernel, but importing the stock file first makes it easier to see
how the resulting header is derived from the original.

Reviewed by:	imp
Obtained from:	SPDK (https://github.com/spdk/spdk.git)
Sponsored by:	Chelsio Communications
Differential Revision:	https://reviews.freebsd.org/D44703
2024-05-02 16:26:16 -07:00
Navdeep Parhar c6c6d4aff9 cxgbe/tom: Fix the rx channel selection in options2.
This affects TOE operation when multiple rx c-channels are in use for
offload, which is an unusual configuration.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 17:07:15 -07:00
Navdeep Parhar 7f10048f98 cxgbe(4): Query TPCHMAP once and not once per port.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 16:32:55 -07:00
Navdeep Parhar 480ff89c67 cxgbe(4): Rename rx_c_chan to rx_chan.
It is the equivalent of tx_chan but for receive so rx_chan is a better
name.  Initialize both using helper functions and make sure both are
displayed in the sysctl MIB.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 16:07:24 -07:00
Navdeep Parhar 21aba39655 cxgbe(4): Minor tweaks to comments.
No functional change intended.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 13:02:45 -07:00
Navdeep Parhar 9de0036b55 cxgbe(4): Initialize mps_bg_map to an invalid value if it's not known.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 13:02:44 -07:00
Navdeep Parhar 4d1362cdc7 cxgbe(4): Do not read hardware registers to determine the number of ports.
PORTVEC obtained from the firmware is the authoritative source of this
information, and nports (calculated from PORTVEC) is available by the
time t4_port_init runs.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 13:02:44 -07:00
Andrew Gallatin 13a5a46c49 Fix new users of MAXPHYS and hide it from the kernel namespace
In cd85379104, kib made maxphys a load-time tunable.  This made
the #define MAXPHYS in sys/param.h  almost entirely obsolete, as
it could now be overridden by kern.maxphys at boot time, or by
opt_maxphys.h.

However, decades of tradition have led to several new, incorrect, uses
of MAXPHYS in other parts of the kernel, mostly by seasoned
developers.  I've corrected those uses here in a mechanical fashion,
and verified that it fixes a bug in the md driver that I was
experiencing.

Since using MAXPHYS is such an easy mistake to make, it is best to
hide it from the kernel namespace.  So I've moved its definition to
_maxphys.h, which is now included in param.h only for userspace.

That brings up the fact that lots of userspace programs use MAXPHYS
for different reasons, most of them probably wrong.  Userspace consumers
that really need to know the value of maxphys should probably be
changed to use the kern.maxphys sysctl.  But that's outside the scope
of this change.

Reviewed by: imp, jkim, kib, markj
Fixes: 30038a8b4e ("md: Get rid of the pbuf zone")
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D44986
2024-04-30 15:29:06 -04:00
Navdeep Parhar 857d74b634 cxgbe(4): Allocate a taskqueue per port instead of per channel.
All the channels are not used on all boards and there's no point
allocating taskqueues that will never be used.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-30 11:11:23 -07:00
Navdeep Parhar 2965ae5914 cxgbe(4): Shared code update to deal with partial failure in query_params.
Obtained from:	Chelsio Communications
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-29 13:51:41 -07:00
Navdeep Parhar 43f6f08488 cxgbe(4): Reword the comment explaining the atid/cookie split.
Avoid a magic constant while here.  No functional change intended.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-29 13:40:40 -07:00
Navdeep Parhar f0ee6112eb cxgbe(4): Add missing description for a port type.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-29 13:27:48 -07:00
Navdeep Parhar 1c7f9c8b46 cxgbe(4): Retire t4_intr_clear.
The firmware clears the interrupts already and it has a better idea of
exactly what to clear for which generation of the ASIC.  There is no
need for the driver to get involved.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-04-29 12:34:51 -07:00
Navdeep Parhar b59c5d97ed cxgbe(4): Add a helper function to locate MPS/MAC registers.
These register blocks are at different locations in different chips.

MFC after:      1 week
Sponsored by:   Chelsio Communications
2024-04-29 12:14:36 -07:00
Navdeep Parhar f76effed14 cxgbe(4): Remove tx_modq lookup table.
The driver always uses the same modulation queue as the channel and the
table is unnecessary.

MFC after:      1 week
Sponsored by:   Chelsio Communications
2024-04-29 11:26:49 -07:00
Stephan de Wit 2b8df536a6 axgbe: Various stability improvements
Hook in RSS glue.

Default to "off" for the split header feature to ensure netmap
compatibility.

Change the PCS indirection register values based on hardware type
(ported from Linux).

Move tunable settings to sysctl_init() and set the defaults there.
Ensure it's called at the right time by moving it back.

Reset PHY RX data path when mailbox command times out (Ported from
Linux).

Check if VLAN HW tagging is enabled before assuming a VLAN tag
is present in a descriptor.

Disable the hardware filter since multicast traffic is dropped
in promisc mode.

Remove unnecessary return statement.

Missing sfp_get_mux, causing a race between ports to read
SFP(+) sideband signals.

Validate and fix incorrectly initialized polarity/configuration
registers.

Remove unnecessary SFP reset.

axgbe_isc_rxd_pkt_get has no error state, remove unnecessary
big packet check.

Enable RSF to prevent zero-length packets while in Netmap mode.

DMA cache coherency update (ported from Linux).

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1103
2024-04-28 19:57:51 -06:00
Christos Margiolis 7cc1afc558 sound: Remove chn_timeout check from chn_init()
This check is not related to channel initializion, but is also
unnecessary, since sysctl_hw_snd_timeout() takes care of checking if
chn_timeout is within bounds.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44992
2024-04-28 21:48:25 +02:00
Christos Margiolis e56c8996fc sound: Add missing space in dev.pcm.X.mode description
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44990
2024-04-28 21:48:24 +02:00
Christos Margiolis a24050e2b7 sound: Move pcm_chnref() and pcm_chnrelease() to pcm/channel.c
Improve code layering. These are channel functions, and so they do not
belong in pcm/sound.c.

While here, assert in chn_ref() that new refcount won't be negative.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44985
2024-04-28 21:48:24 +02:00
Christos Margiolis b3ea087c05 sound: Merge pcm_chn_destroy() and chn_kill()
pcm_chn_destroy() acts like a wrapper around chn_kill(), and
additionally calls a few more functions that should in fact be part of
chn_kill()'s logic. Merge pcm_chn_destroy()'s functionality in
chn_kill() to improve readability, as well as code layering.

While here, convert chn_kill() to void as it currently always returns 0.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44984
2024-04-28 21:48:24 +02:00
Christos Margiolis 25723d6636 sound: Retire unit.*
The unit.* code is largely obsolete and imposes limits that are no
longer needed nowadays.

- Capping the maximum allowed soundcards in a given machine. By default,
  the limit is 512 (snd_max_u() in unit.c), and the maximum possible is
  2048 (SND_UNIT_UMAX in unit.h). It can also be tuned through the
  hw.snd.maxunit loader(8) tunable. Even though these limits are large
  enough that they should never cause problems, there is no need for
  this limit to exist in the first place.
- Capping the available device/channel types. By default, this is 32
  (snd_max_d() in unit.c). However, these types are pre-defined in
  pcm/sound.h (see SND_DEV_*), so the cap is unnecessary when we know
  that their number is constant.
- Capping the number of channels per-device. By default, the limit 1024
  (snd_max_c() in unit.c). This is probably the most problematic of the
  limits mentioned, because this limit can never be reached, as the
  maximum is hard-capped at either hw.snd.maxautovchans (16 by default),
  or SND_MAXHWCHAN and SND_MAXVCHANS.

These limtits are encoded in masks (see SND_U_MASK, SND_D_MASK,
SND_C_MASK in unit.h) and are used to construct a bitfield of the form
[dsp_unit, type, channel_unit] in snd_mkunit() which is assigned to
pcm_channel->unit.

This patch gets rid of everything unit.*-related and makes a slightly
different use of the "unit" field to only contain the channel unit
number. The channel type is stored in a new pcm_channel->type field, and
the DSP unit number need not be stored at all, since we can fetch it
from device_get_unit(pcm_channel->dev). This change has the effect that
we no longer need to impose caps on the number of soundcards,
device/channel types and per-device channels. As a result the code is
noticeably simplified and more readable.

Apart from the fact that the hw.snd.maxunit loader(8) tunable is also
retired as a side-effect of this patch, sound(4)'s behavior remains the
same.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	dev_submerge.ch
Differential Revision:	https://reviews.freebsd.org/D44912
2024-04-28 21:48:24 +02:00
Christos Margiolis fa28452549 sound: Assert that we do not enter chn_sleep() with CHN_F_SLEEPING
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj, emaste
Differential Revision:	https://reviews.freebsd.org/D44959
2024-04-28 21:48:24 +02:00
Christos Margiolis 03614fcba2 sound: Fix panic caused by sleeping-channel destruction during asynchronous detach
Currently we are force-destroying all channels unconditionally in
pcm_killchan(). However, since asynchronous audio device detach is
possible as of 44e128fe9d, if we do not check whether the channel is
sleeping or not and forcefully kill it, we will get a panic from
cv_timedwait_sig() (called from chn_sleep()), because it will try to use
a freed lock/cv.

Modify pcm_killchan() (renamed to pcm_killchans() since that's a more
appropriate name now) to loop through the channel list and destroy only
the channels that are awake, otherwise wake up the sleeping thread and
try again. This loop is repeated until all channels are awakened and
destroyed.

To reduce code duplication, implement chn_shutdown() which wakes up the
channel and sets CHN_F_DEAD, and use it in pcm_unregister() and
pcm_killchans().

Reported by:	KASAN
Fixes:		44e128fe9d ("sound: Implement asynchronous device detach")
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44923
2024-04-28 21:48:24 +02:00
Christos Margiolis b18b990d8e sound: Wrap dsp_clone() and mixer_clone() with bus_topo_lock()
Make sure that the softc isn't freed in between the checks.

Sponsored by:	The FreeBSD Foundation
MFC after;	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44991
2024-04-28 21:48:24 +02:00
Christos Margiolis 074d6fbebc sound: Fix NULL dereference in dsp_clone() and mixer_clone()
If we only have a single soundcard attached and we detach it right
before entering [dsp|mixer]_clone(), there is a chance pcm_unregister()
will have returned already, meaning it will have set snd_unit to -1, and
thus devclass_get_softc() will return NULL here.

While here, 1) move the calls to dsp_destroy_dev() and mixer_uninit()
below the point where we unset SD_F_REGISTERED, and 2) follow what
mixer_clone() does and make sure we don't use a NULL d->dsp_dev in
dsp_clone().

Reported by:	KASAN
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D44924
2024-04-28 21:48:24 +02:00
Florian Walpen 9718d4ab99 snd_hdspe(4): Recognize newer firmware's PCI vendor id.
At least for HDSPe RayDAT cards, newer firmware comes with RME's own PCI
vendor id instead of the Xilinx one. Other HDSPe cards are probably also
affected. Update snd_hdspe(4) to recognize both the old Xilinx and the
new RME vendor ids.

Differential Revision:	https://reviews.freebsd.org/D44978
MFC after: 1 day
2024-04-27 09:48:37 +01:00
Mark Johnston b6a0ed7c78 wg: uma_zcreate() does not fail
No functional change intended.

MFC after:	1 week
2024-04-24 08:45:40 -04:00
Mark Johnston 964064937e dpaa: uma_zcreate() does not fail
No functional change intended.

MFC after:	1 week
2024-04-24 08:45:24 -04:00
HP van Braam d31b677356 ahc(4)/ahd(4): target mode: cancel outstanding AIOs and INOTs
When disabling a lun there can still be outstanding AIOs and INOTs, when
this happens previously the lun would just fail to disable and trying to
re-use the lun would break the card.

isp(4) in target mode does the same thing when disabling a lun, in
testing this allows re-starting of ctld(8) with connected initiators and
allows initiators to gracefully resume afterwards.

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp, mav
Pull Request: https://github.com/freebsd/freebsd-src/pull/1190
2024-04-23 14:57:19 -06:00
HP van Braam 65971073d9 ahc(4) clean up old Linux defines
Linux removed theirs starting in 2018 in commit:
"scsi: aic7xxx: Fix build using bare-metal toolchain"

Also remove now-useless sys/cdefs.h includes

Signed-off-by: HP van Braam <hp@tmm.cx>
Reviewed by: imp, mav, emaste
Pull Request: https://github.com/freebsd/freebsd-src/pull/1189
2024-04-23 14:56:11 -06:00
Lexi Winter 05a95d19cb alc(4): disable MSI-X by default on Killer cards
Several users with alc(4)-based "Killer" Ethernet cards have reported
issues with this driver not passing traffic, which are solved by
disabling MSI-X using the provided tunable.

To work around this issue, disable MSI-X by default on this card.

This is done by having msix_disable default to 2, which means
"auto-detect".  The user can still override this to either 0 or 1 as
desired.

Since these are slow (1Gbps) Ethernet ICs used in low-end systems, it's
unlikely this will cause any practical performance issues; on the other
hand, the card not working by default likely causes issues for many new
FreeBSD users who find their network port doesn't work and have no idea
why.

PR:		230807
MFC after:	1 week

Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1185
2024-04-22 22:36:35 -06:00