Commit graph

42818 commits

Author SHA1 Message Date
Ed Maste e6b88237c6 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: 1efd69f933 ("p9fs: move NULL check immediately after alloc...")
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45721
2024-06-24 22:02:13 -04:00
Kenneth D. Merry 31354813f3 Add an isp(4) tunable to default to ispfw(4) firmware.
ispfw(4) recently gained firmware for Qlogic 27XX and 28XX
FC controllers, and isp(4) now selects the newer of firmware in
flash or in ispfw(4) to load for those controllers.

This differs from the previous behavior (which remains for older
controllers), which was to always load the ispfw(4) firmware if it
is available.

This adds a loader tunable, hint.isp.N.fwload_force to default to
loading the ispfw(4) firmware, whether or not it is newer than the
firmware in flash.  This allows the user to always use the known
firmware version included with the kernel.

Note that there is an existing fwload_disable tunable that tells
the driver to always load the firmware from flash and ignore
ispfw(4).  If fwload_disable is set, fwload_force will be ignored.
So users with existing fwload_disable tunables will have the same
behavior.

If a user specifies both fwload_force and fwload_disable for the
same controller, the isp(4) driver prints a warning message,
and fwload_disable will be honored.

The user can see which firmware is active through the
dev.isp.N.fw_version* sysctl variables.

share/man/man4/isp.4:
	Document the new loader tunable.

sys/dev/isp/isp.c:
	In isp_load_risc_flash(), changet the decision logic to
	also consider ISP_CFG_FWLOAD_ONLY.  Load the flash firmware
	and get the version, so the user knows what it is, but if
	the user set fwload_force, honor that.  If the user didn't
	set fwload_force, the behavior remains to select the newer
	firmware version.

sys/dev/isp/isp_pci.c:
	Add a new fwload_force tunable.  Print out a warning if the
	user sets both fwload_disable and fwload_force.

sys/dev/isp/ispvar.h:
	Add a new ISP_CFG_FWLOAD_FORCE configuration bit.

Reviewed by:	mav
MFC after:	1 week
Sponsored by:	Spectra Logic
Differential Revision:	<https://reviews.freebsd.org/D45688>
2024-06-24 16:47:55 -04:00
Kenneth D. Merry 137b004e2b Fix the isp(4) driver with 9.x firmware.
The isp(4) driver (and ispfw(4) firmware) previously only included
firmware for Qlogic controllers up to 8Gb.  It recently gained
firmware for the 27XX and 28XX series controllers along with
improved firmware loading capabilities.

The 9.x firmware available for the 27XX and 28XX controllers in
ispfw(4) adds login state for NVMe devices in the top nibble of
the login state in the port database (isp_pdb_24xx_t in ispmbox.h).

This breaks the check at the end of isp_getpdb() to make sure the
device is in the right login state.  As a result, it breaks device
discovery for many (perhaps all?) FC devices.  In my testing with
IBM LTO-6 drives attached to a quad port 16Gb Qlogic 2714, they
don't show up when they are directly connected (and in loop mode)
or connected via a switch (and in fabric mode).

So, mask off the top bits of of the login state before checking it.
This shouldn't break anything, because all of the existing login
states defined in ispmbox.h are in the low nibble.

sys/dev/isp/ispmbox.h:
	Add a FCP login state mask define, and a NVMe login state
	shift.

sys/dev/isp/isp.c:
	In isp_getpdb(), make sure we're only looking at the FCP
	login state bits when we try to determine whether a device
	is in the right login state.

MFC after:	1 week
Sponsored by:	Spectra Logic
Reviewed by:	mav
Differential Revision:	<https://reviews.freebsd.org/D45660>
2024-06-24 16:47:55 -04:00
Ed Maste 1efd69f933 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
2024-06-24 15:36:11 -04:00
Doug Moore dc048255b3 mlx5: use roundup_pow_of_two
Use roundup_pow_of_two in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:22:52 -05:00
Doug Moore 87177ce3aa irdma: Use round{up,down}_pow_of_two
Use roundup_pow_of_two and rounddown_pow_of_two in place of expressions.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:20:49 -05:00
Doug Moore 5fc42387d7 cxgbe: use order_base_2
Use order_base_2 in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:18:42 -05:00
Doug Moore 7bb73f7315 cxgb: use rounddown_pow_of_two
In two places, use the rounddown_pow_of_two macro in place of expressions.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:17:02 -05:00
Doug Moore 4bbdabc2bd aic7xxx: use rounddown_pow_of_two
Use the roundown_pow_of_two macro in place of an expression.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:14:55 -05:00
Doug Moore c8b0c33b03 log2: move log2 functions from linuxkpi to libkern
Linux has a header file that defines an ilog2 function and some simple
functions/macros that use it: roundup_pow_of_two, is_power_of_2,
rounddown_pow_of_two, and order_base_2.  This change moves three of
those simple functions (all but is_power_of_2) from linuxkpi to
libkern.  It also deletes a few implementations of these functions
that have previously been copied into code for various device drivers,
so that they can use the libkern version.  The is_power_of_2 macro was
not moved because powerof2 in param.h provides almost the same service
already (except that they disagree about whether 0 is a power of two).

Since the linux definitions of these functions were copied into
FreeBSD 11 years ago, linux has improved them, and this change
provides those improvements.  In particular, a giant table of log
values for evaluating ilog2 for constant values is no longer
necessary.

Reviewed by:	alc, markj (previous version)
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 02:00:31 -05:00
Doug Moore a94ed493b5 dev/mana: replace power2 function
Replace is_power_of_2(length) with power2(length).  When length != 0, as in
this case, they produce the same result.  This will allow an implementation
of is_power_of_two to be dropped.

Reviewed by:	alc, markj
Differential Revision:	https://reviews.freebsd.org/D45536
2024-06-24 01:55:01 -05:00
Baptiste Daroussin 3fdf11fe8f acpi_timer: remove leftovers from Garbage-collect ACPI-safe timer and friends
Reviewed by:	cperciva
Differential Revision:	https://reviews.freebsd.org/D45669
2024-06-21 14:06:26 +02:00
Baptiste Daroussin 2933c05c56 acpi_timer: remove unused variable
the fixes kernel building after 00d061855d
2024-06-21 09:53:42 +02:00
Colin Percival 00d061855d Garbage-collect ACPI-safe timer and friends
In 2001 when the ACPI timer was introduced, it included code to check
for a bug present in some Pentium II and Pentium III chipsets; if the
bug was found to be present, ACPI-safe (which was slower but had a
workaround for the bug) would be used rather than ACPI-fast (which
read the same timer but without the workaround).

In a8b89dff6a (September 2021) I disabled this check by default,
with a loader tunable available to re-enable it; I announced at the
time that it would go away in FreeBSD 15 if I didn't receive any
reports of problems.  I have received no such problems, so this code
is now going away.

The debug.acpi.timer_test loader variable triggered a lengthy (in fact,
infinitely long) test of the ACPI timer and appears to have been
introduced as part of the process of writing the ACPI timer (and the
associated ACPI-safe workaround) in 2001; since we are dropping support
for systems with this ACPI bug, there is no need to keep that test code
either.
2024-06-21 00:19:08 -07:00
Doug Rabson e97ad33a89 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>
2024-06-19 13:12:04 +01:00
Christos Margiolis 914c2b3314 sound: Remove outdated comment in dsp_oss_engineinfo()
Since we e07f917850 ("sound: Separate implementations for
SNDCTL_AUDIOINFO[_EX] and SNDCTL_ENGINEINFO") support more than
mono/stereo.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D45605
2024-06-18 15:19:16 +02:00
Christos Margiolis 0f878cdfc5 sound: Fix oss_audioinfo's card_number, port_number and legacy_device
Although the docs advise against using them, it doesn't hurt to fill
them out correctly.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45604
2024-06-18 15:19:07 +02:00
Christos Margiolis 8e36d21259 sound: Support oss_audioinfo->cmd
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	dev_submerge.ch, markj
Differential Revision:	https://reviews.freebsd.org/D45603
2024-06-18 15:18:58 +02:00
Shailend Chand b81cbb1241 gve: Make gve_free_qpls idempotent
This fixes a panic caused by double free.

PR:	kern/279410
MFC after:	3 days
Differential Revision: https://reviews.freebsd.org/D45489
2024-06-17 23:08:31 -07:00
Kristof Provost 1389314d53 cxgbe: handle vlan PF restrictions
Co-Authored-by:	Navdeep Parhar <np@FreeBSD.org>
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D45428
2024-06-17 23:42:08 +02:00
Navdeep Parhar 2d0a012712 cxgbev(4): Pay attention to the VLAN configuration for the VF.
Make sure that the transmit traffic is tagged correctly or else the
firmware will refuse to transmit and will report an ACL violation.

On receive the hardware will make sure that tagged traffic is delivered
to the appropriate VM.  The driver only asserts that the VLAN id that
was extracted from the wire traffic matches the VF's configuration.

All this works when associating a specific VLAN id with a VF.  The
'trunk' setting likely needs more work.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-17 10:35:14 -07:00
Navdeep Parhar 4471ff1196 cxgbev(4): Shared code for the VF driver to query a VF's VLAN config.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-17 10:29:17 -07:00
Kristof Provost 7deadea2eb mlx5: handle vlan PF restrictions
Reviewed by:	kib
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D45427
2024-06-17 10:50:16 +02:00
Kristof Provost c57c261790 iovctl: allow vlan restrictions to be passed to the driver
Allow iovctl to create VFs that are restricted to specific VLAN IDs.

Reviewed by:	kib, np
MFC after:	2 weeks
Sponsored by:	Orange Business Services
Differential Revision:	https://reviews.freebsd.org/D45402
2024-06-17 10:50:15 +02:00
Navdeep Parhar ba95b4aea7 cxgbe(4): New knob to limit driver to the specified types of doorbells.
hw.cxgbe.doorbells_allowed="0xf"

The adapter's doorbells bitmap is clipped to the value specified in the
tunable, which is meant for debug and workarounds only.  There is no
change in default behavior.

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Navdeep Parhar d72db09005 cxgbe(4): Do not issue an L1CFG command from a VF.
It is pointless to attempt an operation that is not permitted.  It spams
the firmware devlog with "insufficient caps" errors that distract from
real errors.

78 2463625358 ERR CORE insufficient caps to process mailbox cmd: pfn 0x0 vfn 0x1; r_caps 0x86 wx_caps 0x82 required r_caps 0x81 w_caps 0x5

MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Navdeep Parhar d0fdafdb0e cxgbev(4): Use the correct source pf for T6 in the VF driver.
MFC after:	1 week
Sponsored by:	Chelsio Communications
2024-06-16 18:54:02 -07:00
Mark Johnston 83caa244bc jedec_dimm: Use device_set_descf()
Note that it is ok to use device_get_desc() as one of the format string
parameters because it is set using device_set_desc() (not
device_set_desc_copy()) and so won't be freed when the description is
updated.

No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 89848b3445 mana: Use device_set_desc()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston c704b87ba6 oce: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 2ef1f61df2 cfi: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 76a7917818 superio: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 3f795763e4 hidbus: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 9da1b6dc16 bxe: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 50505c853c bge: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston c0bd6ec3bb bce: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 1794a0a87e liquidio: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 443f33481e msk: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston eb634b9f4f wbwd: Use device_set_descf()
No functional change intended.
2024-06-16 16:37:26 -04:00
Mark Johnston 48f5a429c9 iicbus: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston b67f248523 nvmf: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 44d36c9731 netmap: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 48ef9cff9c amdsmn: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 1878529d2f amdsbwd: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:26 -04:00
Mark Johnston 4f0ff49fee arcmsr: Use device_set_descf()
No functional change intended.

MFC after:	1 week
2024-06-16 16:37:25 -04:00
Mark Johnston 5515e8874a wg: Implement if_transmit unconditionally
Commit bf454ca88b made wg_transmit() defined only when "device netmap"
is configured, as if_wg's if_transmit implementation should never be
called otherwise, but this breaks a requirement that interfaces
implement both or neither of if_transmit and if_qflush.

Restore the old behaviour of unconditionally defining wg_transmit().  It
contains an assertion that the interface is in netmap mode.

Reported by:	peterj
MFC after:	2 weeks
Fixes:	bf454ca88b ("wg: Add netmap support")
2024-06-16 13:33:45 -04:00
Gordon Bergling 018a361f89 virtio(4): Fix two typos in KASSERT messages
- s/emtpy/empty/

MFC after:	5 days
2024-06-16 18:02:46 +02:00
Wei Hu d0cb4674df Hyper-V: move memory alloc call for tlb hypercall out of smp_rendezvous
The allocation call could result in sleep lock violation if it is in
smp_rendezvous. Move it out. Also move the pcpu memory pointer to
vmbus_pcpu_data since it is only used on Hyper-V.

PR:		279738
Reported by:	gbe
Fixes:		2b887687ed
MFC after:	2 weeks
Sponsored by:	Microsoft
2024-06-15 14:07:58 +00:00
Warner Losh 1bce7cd885 nvme: Add Linux copatible ioctls
Add the NVME_IOCTL_ID, NVME_IOCTL_ADMIN_CMD, and NVME_IOCTL_IO_CMD Linux
compatible ioctls. These may be run on either an I/O (ns) dev or a nvme
(admin) dev. Linux allows both on either device, and programs use this
and aren't careful about having the right device open. Emulate this
feature, and implement these ioctls. The data is passed in into the
kernel in host byte order (not converted to le). Results are returned in
host order.

The timeout field is ignore, and the metadata and metadata_len fields
must be zero.

The addr field can be null, even when the data_len is non zero (FreeBSD's
ioctl interface prohibits this, Linux's just ignores the inconsistency).

Only the cdw10 is returned from the command: the status is not returned
in 'result' field. XXX need to verify that this is what Linux does on an
error signaled from the drive.

No external include file is yet available for this: most programs that
call this interface either use a linux-specific path <linux/nvme.h> or
have their own private copy of the data. It's unclear the best thing to
do.

Also, create a /dev/nvmeXnY as an alias for /dev/nvmeXnsY.

These changes allow a native build of nvme-cli to work for everything
that doesn't depend on sysfs entries in /sys, calls that use metadata,
send / receive drive data and sed functionality not in our nvme driver.

Sponsored by:		Netflix
Co-Authored-by:		Chuck Tuffli <chuck@freebsd.org>
Reviewed by:		chuck
Differential Revision:	https://reviews.freebsd.org/D45415
2024-06-14 16:40:08 -06:00
Alexander Motin 80b4232924 nvme: Fix panic on detach after ce75bfcac9
MFC after: 2 weeks
2024-06-14 15:32:10 -04:00