virtio: add loader tunables to sysctl

virtio_pci uses two loader tunables that should be more visible.
This patch adds these loader tunables to sysctl and describes them
in the virtio(4) man page.

Reviewed by:		imp (erlier version), tuexen
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D55533
This commit is contained in:
Timo Völker
2026-03-02 19:15:37 +01:00
committed by Michael Tuexen
parent 0272359ada
commit c70755bc0d
4 changed files with 42 additions and 4 deletions
+26 -2
View File
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd May 26, 2019
.Dd March 2, 2026
.Dt VIRTIO 4
.Os
.Sh NAME
@@ -54,7 +54,7 @@ The
.Nm
module provides a shared memory transport called a virtqueue.
The
.Xr virtio_pci
.Sy virtio_pci
device driver represents an emulated PCI device that the hypervisor makes
available to the VM.
This device provides the probing, configuration, and
@@ -92,6 +92,30 @@ An emulated SCSI HBA is provided by the
.Xr virtio_scsi 4
device driver.
.El
.Sh LOADER TUNABLES
Tunables can be set at the
.Xr loader 8
prompt before booting the kernel or stored in
.Xr loader.conf 5 .
.Bl -tag -width "hw.virtio.pci.transitional"
.It Va hw.virtio.pci.disable_msix
If set to 1, disables MSI-X.
The default value is 0.
.It Va hw.virtio.pci.transitional
For a transitional
.Nm
device, this tunable specifies whether to negotiate
modern mode and use the modern
.Nm
driver
.Pq 1
or to negotiate legacy mode and
use the legacy
.Nm
driver
.Pq 1 .
The default value is 0.
.El
.Sh SEE ALSO
.Xr virtio_balloon 4 ,
.Xr virtio_blk 4 ,
+6 -1
View File
@@ -97,8 +97,13 @@ MODULE_VERSION(virtio_pci, 1);
MODULE_DEPEND(virtio_pci, pci, 1, 1, 1);
MODULE_DEPEND(virtio_pci, virtio, 1, 1, 1);
SYSCTL_DECL(_hw_virtio);
SYSCTL_NODE(_hw_virtio, OID_AUTO, pci, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"VirtIO PCI driver parameters");
int vtpci_disable_msix = 0;
TUNABLE_INT("hw.virtio.pci.disable_msix", &vtpci_disable_msix);
SYSCTL_INT(_hw_virtio_pci, OID_AUTO, disable_msix, CTLFLAG_RDTUN,
&vtpci_disable_msix, 0, "If set to 1, disables MSI-X.");
static uint8_t
vtpci_read_isr(struct vtpci_common *cn)
+6 -1
View File
@@ -33,6 +33,7 @@
#include <sys/bus.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/sysctl.h>
#include <sys/module.h>
#include <machine/bus.h>
@@ -188,8 +189,12 @@ static void vtpci_modern_write_device_8(struct vtpci_modern_softc *,
bus_size_t, uint64_t);
/* Tunables. */
SYSCTL_DECL(_hw_virtio_pci);
static int vtpci_modern_transitional = 0;
TUNABLE_INT("hw.virtio.pci.transitional", &vtpci_modern_transitional);
SYSCTL_INT(_hw_virtio_pci, OID_AUTO, transitional, CTLFLAG_RDTUN,
&vtpci_modern_transitional, 0,
"If 0, a transitional VirtIO device is used in legacy mode; otherwise, in modern mode.");
static device_method_t vtpci_modern_methods[] = {
/* Device interface. */
+4
View File
@@ -30,6 +30,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/sysctl.h>
#include <sys/module.h>
#include <sys/sbuf.h>
@@ -90,6 +91,9 @@ static struct virtio_feature_desc virtio_common_feature_desc[] = {
{ 0, NULL }
};
SYSCTL_NODE(_hw, OID_AUTO, virtio, CTLFLAG_RD | CTLFLAG_MPSAFE, 0,
"VirtIO driver parameters");
const char *
virtio_device_name(uint16_t devid)
{