summaryrefslogtreecommitdiff
path: root/sys/dev/virtio
AgeCommit message (Collapse)Author
2025-12-19vtnet: improve consistencyMichael Tuexen
Use sbuf_new_for_sysctl() instead of sbuf_new_auto() when exposing the flags via sysctl. MFC after: 1 week
2025-12-19vtnet: expose features via sysctl treeMichael Tuexen
Right now the 64-bit flags field needs to be casted to a 32-bit field, because clang warns if more than 32-bits are used. Once clang is fixed, this restriction will be removed and more bits will be added. Reviewed by: markj, Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54288
2025-12-18vtnet: expose flags via sysctl treeMichael Tuexen
Provide the flags used for a vtnet interface via the sysctl tree. This is mostly used for debugging purposes. Reviewed by: Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D54283
2025-12-18vtnet: define flags in a consistent wayMichael Tuexen
This allows adding flags in the upper 32 bits in a consistent way. No functional change intended. MFC after: 1 week
2025-11-10vtnet: fix enabling/disabling tsoMichael Tuexen
Transmit segment offloading depends on transmit checksum offloading. Enforce that constraint. This also fixes a bug, since if_hwassist bits are from the CSUM_ space, not from the IFCAP_ space. PR: 290773 Reviewed by: Timo Völker Tested by: lg@efficientip.com MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53629
2025-11-10vtnet: don't provide VIRTIO_NET_HDR_F_DATA_VALIDMichael Tuexen
According to section 5.1.6.2.1 of version 1.3 of the virtio specification, the driver MUST NOT set VIRTIO_NET_HDR_F_DATA_VALID in the flags. So don't do that. Reviewed by: Timo Völker MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53650
2025-11-04virtio: Fix polling in virtqueue_dequeue()Mark Johnston
The access of vq->vq_ring.used->idx needs to be volatile-qualified, otherwise the compiler may optimize virtqueue_poll() into an infinite loop if there is no data available upon the first poll. Prior to commit ad17789a8569 this wasn't a problem since an external function call after each poll inhibited the optimization. PR: 289930 MFC after: 3 days Sponsored by: Klara, Inc. Fixes: ad17789a8569 ("virtio: Remove the unused poll method")
2025-10-28virtio(4): Fix a couple of typos in kernel messagesGordon Bergling
- s/reponse/response/ - s/Cannnot/Cannot/ MFC after: 1 week
2025-09-30vtnet: disable hardware TCP LRO by defaultMichael Tuexen
Hardware TCP LRO results in problems in settings with IP forwarding being enabled. In case of nodes without IP forwarding, using software LRO is also beneficial in general, since it can provide better information about what was received on the wire. Therefore, disable hardware TCP LRO by default. By tuning the loader tunable, this can be changed. PR: 263229 Reviewed by: Timo Völker MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52684
2025-09-28vtnet: improve control of transmit offloadingMichael Tuexen
Keep the hwassist flags for transmit checksum offload and transmit segment offload in sync with the enabled capabilities. Reported by: Timo Völker Reviewed by: Timo Völker MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52765
2025-09-26vtnet: improve interface capability handlingMichael Tuexen
Enable the handling of the IFCAP_RXCSUM_IPV6 handling by handling IFCAP_RXCSUM and IFCAP_RXCSUM_IPV6 as a pair. Also make clear, that software and hardware LRO require receive checksum offload. Reviewed by: Timo Völker MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52682
2025-09-08vtnet: fix compilation for NOIP configsMichael Tuexen
Reported by: bz Fixes: 3008f30d2c2c ("vtnet: improve checksum offloading") MFC after: 3 days
2025-09-08vtnet: improve checksum offloadingTimo Völker
When transmitting a packet over the vtnet interface, map the csum flags CSUM_DATA_VALID | CSUM_PSEUDO_HDR to the virtio flag VIRTIO_NET_HDR_F_DATA_VALID. When receiving a packet over the virtio network channel, translate the virtio flag VIRTIO_NET_HDR_F_NEEDS_CSUM not to CSUM_DATA_VALID | CSUM_PSEUDO_HDR, but to CSUM_TCP, CSUM_TCP_IPV6, CSUM_UDP, or CSUM_UDP_IPV6. The second change fixes a series of issue related to checksum offloading for if_vtnet. While there, improve the stats counters to allow a detailed view on what is going on in relation to checksum offloading. PR: 165059 Reviewed by: tuexen, manpages MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D51686
2025-09-08Revert "vtnet: improve checksum offloading"Michael Tuexen
This reverts commit 1c23d8f9f39870951c1d0dfbb112fc4e53237737. Will be committed again with correct authorship.
2025-09-08Revert "vtnet: fix compilation for NOIP configs"Michael Tuexen
This reverts commit 7c448f5aab8be6977d0860e608e7d497b495d28c. Will be committed again with correct authorship.
2025-09-06vtnet: fix compilation for NOIP configsMichael Tuexen
Reported by: bz Fixes: 1c23d8f9f398 ("vtnet: improve checksum offloading") MFC after: 3 days Sponsored by: Netflix, Inc.
2025-09-05vtnet: Prefer "hardware" accounting for the multicast and total number of ↵Joyu Liao
octets sent When ALTQ is enabled, this driver does "hardware" accounting and soft accounting at the same time. Prefer the "hardware" one to make the logic simpler. Reviewed by: zlei MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44817
2025-09-05vtnet: Do "hardware" accounting for the total number of received octetsJoyu Liao
While here, advertise the IFCAP_HWSTATS capability to avoid the net stack from double counting it. Co-authored-by: zlei Reviewed by: zlei MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D44816
2025-09-04vtnet: improve checksum offloadingMichael Tuexen
When transmitting a packet over the vtnet interface, map the csum flags CSUM_DATA_VALID | CSUM_PSEUDO_HDR to the virtio flag VIRTIO_NET_HDR_F_DATA_VALID. When receiving a packet over the virtio network channel, translate the virtio flag VIRTIO_NET_HDR_F_NEEDS_CSUM not to CSUM_DATA_VALID | CSUM_PSEUDO_HDR, but to CSUM_TCP, CSUM_TCP_IPV6, CSUM_UDP, or CSUM_UDP_IPV6. The second change fixes a series of issue related to checksum offloading for if_vtnet. While there, improve the stats counters to allow a detailed view on what is going on in relation to checksum offloading. PR: 165059 Reviewed by: tuexen, manpages MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51686
2025-08-28vtnet: Do not compare boolean with integerZhenlei Huang
The type of variable promisc and allmulti was changed from int to bool by commit [1]. [1] 7dce56596f36 Convert to if_foreach_llmaddr() KPI MFC after: 3 days
2025-08-28vtnet: mark statistic counters with CTLFLAG_STATSMichael Tuexen
Reviewed by: Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51999
2025-08-28vtnet: fix computation of sysctl variablesMichael Tuexen
Fix the aggregation of the interface level counters * dev.vtnet.X.tx_task_rescheduled, * dev.vtnet.X.tx_tso_offloaded, * dev.vtnet.X.tx_csum_offloaded, * dev.vtnet.X.rx_task_rescheduled, * dev.vtnet.X.rx_csum_offloaded, and * dev.vtnet.X.rx_csum_failed. Also ensure that dev.vtnet.X.tx_defrag_failed only counts the number of times m_defrag() fails. While there, mark sysctl-variables used for exporting statistics as such (CTLFLAG_STATS). Reviewed by: Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51999
2025-08-21vtnet, ptnet: include opt_*.h files earlyMichael Tuexen
Include opt_inet.h and opt_inet6.h early in the files including virtio_net.h, since they use INET and/or INET6. While there, remove redundant inclusion of sys/types.h, since it is included already by sys/param.h. There was a discussion to include opt_inet.h and opt_inet6.h also in virtio_net.h. glebius suggested to add a mechanism for files to check, if required opt_*.h files were included. virtio_net.h will be the first consumer of this mechanism. Reviewed by: glebius, Peter Lei MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52046
2025-08-21virtio: Remove the unused poll methodAndrew Turner
This was used by virtio_mmio to poll via another driver. This support has been removed so we can remove it from here too. Reviewed by: br Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D51993
2025-08-21virtio/mmio: Remove the unused virtio_mmio_if.mAndrew Turner
The only driver I know that implemented this interface was removed 7 months ago. Remove the interface and platform from the softc. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D51992
2025-08-19random: Make random_source definitions constMark Johnston
We can do so trivially, so make these tables read-only. No functional change intended. Reviewed by: cem, emaste MFC after: 2 weeks Sponsored by: Stormshield Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D52003
2025-06-23virtio_blk: Limit use of indirect descriptorsAndrew Turner
Pass 0 as the number of indirect descriptors when they are not supported. This fixes an issue on the Arm FVP model where we don't negotiate them, however pass a number of segments greater than VIRTIO_MAX_INDIRECT. This leads to virtqueue_alloc failing and virtio_blk failing to attach. Reviewed by: Harry Moulton <harry.moulton@arm.com> Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D50909
2025-06-21newbus: replace leftover device unit wildcardsAhmad Khalifa
Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
2025-06-11machine/stdarg.h -> sys/stdarg.hBrooks Davis
Switch to using sys/stdarg.h for va_list type and va_* builtins. Make an attempt to insert the include in a sensible place. Where style(9) was followed this is easy, where it was ignored, aim for the first block of sys/*.h headers and don't get too fussy or try to fix other style bugs. Reviewed by: imp Exp-run by: antoine (PR 286274) Pull Request: https://github.com/freebsd/freebsd-src/pull/1595
2025-05-26diskinfo: print attachment field for virtio_blk devicesRobert Wing
PR: 286280 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50489
2025-04-28vtnet(4): Replaced compiletime checks for ALTQ support to runtime checksBjoern Jakobsen
Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
2025-04-28vtnet(4): Added tunable hw.vtnet.altq_disableBjoern Jakobsen
Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
2025-04-28vtnet(4): Small fix to style so that it follows the styleguideBjoern Jakobsen
Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
2025-04-08virtio_p9fs: Support attaching to pci and mmioAndrew Turner
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-01-02Use bus_generic_detach to detach and delete child devices during detachJohn Baldwin
This is simpler and more robust than individual calls to device_delete_child. Differential Revision: https://reviews.freebsd.org/D47972
2024-11-29tcp: extend the use of the th_flags accessor functionRichard Scheffenegger
Formally, there are 12 bits for TCP header flags. Use the accessor functions in more (kernel) places. No functional change. Reviewed By: cc, #transport, cy, glebius, #iflib, kbowling Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D47063
2024-10-25virtio_p9fs: Simplify vt9p_req_wait() a bitMark Johnston
Remove an always-false check for whether the request has already completed before sleeping. Even if the request is complete, the response tag is updated while holding the channel lock, which is also held here. No functional change intended. Sponsored by: Klara, Inc.
2024-10-25virtio_p9fs: Check for completions after enabling interruptsMark Johnston
Otherwise we can end up with a lost interrupt, causing lost request completion wakeups and hangs in the filesystem layer. Continue processing until we enable interrupts and then observe an empty queue, like other virtio drivers do. Sponsored by: Klara, Inc.
2024-10-25virtio_p9fs: Fix handling of a full request queueMark Johnston
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.
2024-10-25virtio_p9fs: Fix some style issuesMark Johnston
- Remove superfluous newlines. - Use bool literals. - Replace an unneeded SYSINIT with static initialization. No functional change intended. Sponsored by: Klara, Inc.
2024-07-26Deprecate contigfree(9) in favour of free(9)Bjoern A. Zeeb
As of 9e6544dd6e02c46b805d11ab925c4f3b18ad7a4b contigfree(9) is no longer needed and should not be used anymore. We leave a wrapper for 3rd party code in at least 15.x but remove (almost) all other cases from the tree. This leaves one use of contigfree(9) untouched; that was the original trigger for 9e6544dd6e02 and is handled in D45813 (to be committed seperately later). Sponsored by: The FreeBSD Foundation Reviewed by: markj, kib Tested by: pho (10h stress test run) Differential Revision: https://reviews.freebsd.org/D46099
2024-07-24newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh
Sponsored by: Netflix
2024-07-11vt: Add vd_bitblt_argbEmmanuel Vadot
This blit an ARGB image on the dedicated vd. This also adds vt_fb_bitblt_argb which will works for most of the vt backends Differential Revision: https://reviews.freebsd.org/D45929 Reviewed by: tsoome Sponsored by: Beckhoff Automation GmbH & Co. KG
2024-07-07virtio_p9fs: fix panic on qemu/kvmDanilo Egea Gondolfo
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
2024-07-04vtblk: Invoke busdma completion callbacks when pollingMark Johnston
vtblk_poll_request() is used for kernel dumps and for fetching the block device's identifier string during device probing. In the latter case, it was not calling bus_dmamap_sync() after completing the I/O, but this is required in general. Thus: - Factor out per-request code from vtblk_queue_completed(). - Use it in vtblk_poll_request() once virtqueue_poll() finishes. - While here, assert that virtqueue_poll() returns the request that we expect. Reported by: KMSAN Fixes: 782105f7c898 ("vtblk: Use busdma") Reviewed by: cperciva, imp Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D45665
2024-06-28net: Remove unneeded NULL check for the allocated ifnetZhenlei Huang
Change 4787572d0580 made if_alloc_domain() never fail, then also do the wrappers if_alloc(), if_alloc_dev(), and if_gethandle(). No functional change intended. Reviewed by: kp, imp, glebius, stevek MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45740
2024-06-24p9fs: use M_WAITOK where appropriateEd Maste
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
2024-06-24p9fs: move NULL check immediately after allocationEd Maste
Reported by: Shawn Webb (HardenedBSD) Reviewed by: dfr Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45719
2024-06-19Add an implementation of the 9P filesystemDoug Rabson
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-16virtio(4): Fix two typos in KASSERT messagesGordon Bergling
- s/emtpy/empty/ MFC after: 5 days