aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio
Commit message (Collapse)AuthorAgeFilesLines
* vtnet: fix enabling/disabling tsoMichael Tuexen2025-11-101-4/+24
| | | | | | | | | | | | 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
* vtnet: don't provide VIRTIO_NET_HDR_F_DATA_VALIDMichael Tuexen2025-11-101-6/+1
| | | | | | | | | | 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
* virtio: Fix polling in virtqueue_dequeue()Mark Johnston2025-11-041-1/+2
| | | | | | | | | | | | | | 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")
* virtio(4): Fix a couple of typos in kernel messagesGordon Bergling2025-10-282-6/+6
| | | | | | | - s/reponse/response/ - s/Cannnot/Cannot/ MFC after: 1 week
* vtnet: disable hardware TCP LRO by defaultMichael Tuexen2025-09-301-1/+1
| | | | | | | | | | | | | | 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
* vtnet: improve control of transmit offloadingMichael Tuexen2025-09-281-4/+12
| | | | | | | | | | 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
* vtnet: improve interface capability handlingMichael Tuexen2025-09-261-20/+11
| | | | | | | | | | 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
* vtnet: fix compilation for NOIP configsMichael Tuexen2025-09-081-0/+9
| | | | | | Reported by: bz Fixes: 3008f30d2c2c ("vtnet: improve checksum offloading") MFC after: 3 days
* vtnet: improve checksum offloadingTimo Völker2025-09-082-109/+113
| | | | | | | | | | | | | | | | | | | 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
* Revert "vtnet: improve checksum offloading"Michael Tuexen2025-09-082-113/+109
| | | | | This reverts commit 1c23d8f9f39870951c1d0dfbb112fc4e53237737. Will be committed again with correct authorship.
* Revert "vtnet: fix compilation for NOIP configs"Michael Tuexen2025-09-081-9/+0
| | | | | This reverts commit 7c448f5aab8be6977d0860e608e7d497b495d28c. Will be committed again with correct authorship.
* vtnet: fix compilation for NOIP configsMichael Tuexen2025-09-061-0/+9
| | | | | | | Reported by: bz Fixes: 1c23d8f9f398 ("vtnet: improve checksum offloading") MFC after: 3 days Sponsored by: Netflix, Inc.
* vtnet: Prefer "hardware" accounting for the multicast and total number of ↵Joyu Liao2025-09-041-6/+2
| | | | | | | | | | | | 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
* vtnet: Do "hardware" accounting for the total number of received octetsJoyu Liao2025-09-041-0/+3
| | | | | | | | | | 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
* vtnet: improve checksum offloadingMichael Tuexen2025-09-042-109/+113
| | | | | | | | | | | | | | | | | | | 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
* vtnet: Do not compare boolean with integerZhenlei Huang2025-08-281-2/+2
| | | | | | | | | 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
* vtnet: mark statistic counters with CTLFLAG_STATSMichael Tuexen2025-08-281-28/+42
| | | | | | Reviewed by: Timo Völker MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D51999
* vtnet: fix computation of sysctl variablesMichael Tuexen2025-08-281-14/+117
| | | | | | | | | | | | | | | | | | 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
* vtnet, ptnet: include opt_*.h files earlyMichael Tuexen2025-08-211-3/+3
| | | | | | | | | | | | | | | | | 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
* virtio: Remove the unused poll methodAndrew Turner2025-08-212-6/+0
| | | | | | | | | 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
* virtio/mmio: Remove the unused virtio_mmio_if.mAndrew Turner2025-08-214-192/+3
| | | | | | | | | 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
* random: Make random_source definitions constMark Johnston2025-08-191-1/+1
| | | | | | | | | | | 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
* virtio_blk: Limit use of indirect descriptorsAndrew Turner2025-06-231-1/+5
| | | | | | | | | | | | | | 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
* newbus: replace leftover device unit wildcardsAhmad Khalifa2025-06-211-1/+1
| | | | | | Reviewed by: imp, jhb Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D50913
* machine/stdarg.h -> sys/stdarg.hBrooks Davis2025-06-111-2/+1
| | | | | | | | | | | | | 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
* diskinfo: print attachment field for virtio_blk devicesRobert Wing2025-05-271-0/+2
| | | | | | PR: 286280 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D50489
* vtnet(4): Replaced compiletime checks for ALTQ support to runtime checksBjoern Jakobsen2025-04-282-56/+47
| | | | | | Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
* vtnet(4): Added tunable hw.vtnet.altq_disableBjoern Jakobsen2025-04-282-1/+16
| | | | | | Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
* vtnet(4): Small fix to style so that it follows the styleguideBjoern Jakobsen2025-04-282-5/+5
| | | | | | Signed-off-by: Bjoern Jakobsen <Bjoern.Jakobsen@lrz.de> Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1679
* virtio_p9fs: Support attaching to pci and mmioAndrew Turner2025-04-081-1/+1
| | | | | | | | | | 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
* Use bus_generic_detach to detach and delete child devices during detachJohn Baldwin2025-01-022-15/+7
| | | | | | | This is simpler and more robust than individual calls to device_delete_child. Differential Revision: https://reviews.freebsd.org/D47972
* tcp: extend the use of the th_flags accessor functionRichard Scheffenegger2024-11-292-2/+2
| | | | | | | | | | | 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
* virtio_p9fs: Simplify vt9p_req_wait() a bitMark Johnston2024-10-251-13/+13
| | | | | | | | | | | 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.
* virtio_p9fs: Check for completions after enabling interruptsMark Johnston2024-10-251-1/+5
| | | | | | | | | | 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.
* virtio_p9fs: Fix handling of a full request queueMark Johnston2024-10-251-2/+1
| | | | | | | | | | | | 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.
* virtio_p9fs: Fix some style issuesMark Johnston2024-10-251-20/+6
| | | | | | | | | | - Remove superfluous newlines. - Use bool literals. - Replace an unneeded SYSINIT with static initialization. No functional change intended. Sponsored by: Klara, Inc.
* Deprecate contigfree(9) in favour of free(9)Bjoern A. Zeeb2024-07-262-3/+3
| | | | | | | | | | | | | | | 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
* newbus: globally replace device_add_child(..., -1) with DEVICE_UNIT_ANYWarner Losh2024-07-251-1/+1
| | | | Sponsored by: Netflix
* vt: Add vd_bitblt_argbEmmanuel Vadot2024-07-111-0/+12
| | | | | | | | | 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
* virtio_p9fs: fix panic on qemu/kvmDanilo Egea Gondolfo2024-07-071-2/+2
| | | | | | | | | | | | | | | | 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
* vtblk: Invoke busdma completion callbacks when pollingMark Johnston2024-07-041-27/+39
| | | | | | | | | | | | | | | | | | | | 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
* net: Remove unneeded NULL check for the allocated ifnetZhenlei Huang2024-06-281-13/+3
| | | | | | | | | | | 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
* p9fs: use M_WAITOK where appropriateEd Maste2024-06-251-6/+1
| | | | | | | | | | | 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
* p9fs: move NULL check immediately after allocationEd Maste2024-06-241-6/+5
| | | | | | | Reported by: Shawn Webb (HardenedBSD) Reviewed by: dfr Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D45719
* Add an implementation of the 9P filesystemDoug Rabson2024-06-192-0/+550
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* virtio(4): Fix two typos in KASSERT messagesGordon Bergling2024-06-161-2/+2
| | | | | | - s/emtpy/empty/ MFC after: 5 days
* virtio: Use device_set_descf()Mark Johnston2024-06-022-6/+2
| | | | | | No functional change intended. MFC after: 1 week
* vtnet: use CURVNET_SET() instead of CURVNET_SET_QUIET()Gleb Smirnoff2024-04-181-1/+1
| | | | | | | | We don't expect the VNET context to be set for virtqueue neither for taskqueue handlers. Suggested by: zec Fixes: 3f2b9607756d0f92ca29c844db0718b313a06634
* vtscmi: Add a virtio-scmi driverCristian Marussi2024-04-114-0/+588
| | | | | | | | | | | Add a new virtio backend to support SCMI VirtIO devices (type 32) as defined by the VirtIO specification since version v1.2. https://docs.oasis-open.org/virtio/virtio/v1.2/cs01/virtio-v1.2-cs01.pdf Reviewed by: andrew, bryanv Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D43047
* vtnet: set VNET context in RX handlerGleb Smirnoff2024-03-281-0/+2
| | | | The context is required for NIC-level pfil(9) filtering.