aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio
Commit message (Collapse)AuthorAgeFilesLines
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-2318-36/+0
| | | | | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/ Similar commit in current: (cherry picked from commit 95ee2897e98f)
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-07-2515-15/+15
| | | | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix (cherry picked from commit 4d846d260e2b9a3d4d0a701462568268cbfe7a5b)
* if_vtnet: improve dumping a kernelMichael Tuexen2023-02-011-1/+20
| | | | | | | | | | | | Disable software LRO during kernel dumping, because having it enabled requires to be in a network epoch, which might or might not be the case depending on the code path resulting in the panic. Reviewed by: markj Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D34787 (cherry picked from commit 53236f905dbf4f3d58b1d5eff5c9b14f100d0c5d)
* virtio: Silence a -Wunused warningMark Johnston2022-11-211-16/+6
| | | | | | | | | | | Remove virtio_swap_endian(). htole*() are nops on little-endian platforms. No functional change intended. MFC after: 1 week Reviewed by: corvink, jhb Differential Revision: https://reviews.freebsd.org/D37298 (cherry picked from commit db494ceb65ef301c8fb48f57b60c4f7a9cfebba5)
* vtpci_legacy_register_msix: eliminate write only variable devWarner Losh2022-10-021-3/+0
| | | | | | Sponsored by: Netflix (cherry picked from commit 76e96756633e5d33f334bb48bedf981557272ead)
* kerneldump: remove physical argument from d_dumperMitchell Horne2022-06-271-3/+2
| | | | | | | | | | | | | The physical address argument is essentially ignored by every dumper method. In addition, the dump routines don't actually pass a real address; every call to dump_append() passes a value of zero for physical. Reviewed by: markj MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D35173 (cherry picked from commit 489ba2223676ec251ab1bfe2906d2a62959c8ce3)
* Add missing const after 6c4f95161d6eAlex Richardson2022-05-071-1/+1
| | | | | | | I accidentally didn't include hunk in the committed patch. Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const") (cherry picked from commit 9017870541daf46358c6cbaa3d4a40e1bffaaaa1)
* virtio: make the write_config buffer argument constAlex Richardson2022-05-076-19/+19
| | | | | | | | | | No functional change intended, but noticed that we could add const here while adding linuxkpi support for virtio. Reviewed By: bryanv, imp Differential Revision: https://reviews.freebsd.org/D32370 (cherry picked from commit 6c4f95161d6e38ba3fd50ca1cceee3110cbfa02e)
* virtio_random(8): MFC: avoid deadlock at shutdown time (regression fix)Eugene Grosbein2022-03-191-0/+35
| | | | | | | | | | | | | | | | | FreeBSD 13+ running as virtual guest may load virtio_random(8) driver by means of devd(8) unless the driver is blacklisted or disabled via device.hints(5). Currently, the driver may prevent the system from rebooting or shutting down correctly. This change deactivates virtio_random at very late stage during system shutdown sequence to avoid deadlock that results in kernel hang. PR: 253175 Tested by: tom Relnotes: yes (cherry picked from commit adbf7727b3a2aad3c2faa6e543ee7fa7a6c9a3d5)
* if_vtnet(4): Restore the ability to set promisc mode.Aleksandr Fedorov2022-02-231-3/+7
| | | | | | | | | | | PR: 254343, 255054 Reviewed by: vmaffione (mentor), donner Approved by: vmaffione (mentor), donner MFC after: 2 weeks Sponsored by: vstack.com Differential Revision: https://reviews.freebsd.org/D30639 (cherry picked from commit fc035df8af32d496885e5da26e519ce6a262c9bf)
* Convert vm_page_alloc() callers to use vm_page_alloc_noobj().Mark Johnston2021-11-031-2/+1
| | | | | | | | | | | | | | | Remove page zeroing code from consumers and stop specifying VM_ALLOC_NOOBJ. In a few places, also convert an allocation loop to simply use VM_ALLOC_WAITOK. Similarly, convert vm_page_alloc_domain() callers. Note that callers are now responsible for assigning the pindex. Reviewed by: alc, hselasky, kib Sponsored by: The FreeBSD Foundation (cherry picked from commit a4667e09e6520dc2c4b0b988051f060fed695a91)
* Only use byte register access in legacy virtio pciAndrew Turner2021-09-271-24/+8
| | | | | | | | | | | | Some simulators don't implement arbitrary sized memory access to the virtio PCI registers. Follow Linux and use single byte accesses to read and write to these registers. Reviewed by: bryanv, emaste (previous version) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31424 (cherry picked from commit 89c085b8993d7d1e7b137f99fa6df94c37c3a68a)
* virtio-modern: fix PCI common read/write functions on big endian targetsAlfredo Dal'Ava Junior2021-08-301-4/+8
| | | | | | | | | | | | | Virtio modern has the common data organized in little endian, but on powerpc64 BE it was reading and writing in the wrong endian. Submitted by: Leonardo Bianconi <leonardo.bianconi@eldorado.org.br> Reviewed by: bryanv, alfredo Sponsored by: Eldorado Research Institute (eldorado.org.br) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D28947 (cherry picked from commit fb53b42e36a9745d0a33821175a962c7a15eeeaa)
* bhyve: virtio shares definitions between sys/dev/virtioKa Ho Ng2021-08-122-0/+7
| | | | | | | | | | | | | | Definitions inside usr.sbin/bhyve/virtio.h are thrown away. Definitions in sys/dev/virtio are used instead. This reduces code duplication. Sponsored by: The FreeBSD Foundation Reviewed by: grehan Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D29084 (cherry picked from commit 54ac6f721efccdba5a09aa9f38be0a1c4ef6cf14)
* virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.Luiz Otavio O Souza2021-08-051-0/+4
| | | | | | | | | | | ALTQ only works on network drivers which use if_start (rather than if_transmit). vtnet uses if_start if built with VTNET_LEGACY_TX. Default to that the kernel is built with ALTQ enabled, to reduce user surprise. MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") (cherry picked from commit 5afe81a7b23afd27289ca40e04a6a764134d6273)
* if_vtnet: Fix pointer-sign and used parameter warningsAlex Richardson2021-07-052-24/+24
| | | | | | | Reviewed By: grehan Differential Revision: https://reviews.freebsd.org/D28726 (cherry picked from commit c1b554c868195ed10ac1eb25fa9ca4a5baae4638)
* virtio_blk: Fix issuing T_GET_ID before DRIVER_OK statusKa Ho Ng2021-06-281-2/+18
| | | | | | | | | | | | DRIVER_OK status is set after device_attach() succeeds. For now postpone disk_create to attach_completed() method. Sponsored by: The FreeBSD Foundation Reviewed by: grehan Approved by: lwhsu (mentor) Differential Revision: https://reviews.freebsd.org/D30049 (cherry picked from commit 4e1e1d667fc84460c131dfe617b39072e87473ab)
* virtio_pci_legacy: Allow memory space for configurationKa Ho Ng2021-04-031-6/+18
| | | | | | | | | | | | For guests running under some kind of VMMs, configuration structure is available in memory space but not I/O space. Reported by: Yuan Rui <number201724@me.com> Reviewed by: rpokala, bryanv, jhb Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D28818 (cherry picked from commit cf5d1112408ddef3fdff8212599727c49ba90fa4)
* virtio_pci_legacy: Use the table BAR and PBA BAR from MSI-X capKa Ho Ng2021-04-031-14/+60
| | | | | | | | | | | | | The MSI-X resource shouldn't be assumed to be always on BAR1. The Virtio v1.1 Spec did not specify that MSI-X table and PBA BAR has to be BAR1 either. Reported by: Yuan Rui <number201724@me.com> Reviewed by: bryanv, jhb Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D28817 (cherry picked from commit faf9a4e9142a02c289ee543a6091bd4b925c6a63)
* vtnet: fix TSO for TCP/IPv6Michael Tuexen2021-03-181-4/+4
| | | | | | | | | | | | | | | | | | | | The decision whether a TCP packet is sent over IPv4 or IPv6 was based on ethertype, which works correctly. In D27926 the criteria was changed to checking if the CSUM_IP_TSO flag is set in the csum-flags and then considering it to be TCP/IPv4. However, the TCP stack sets the flag to CSUM_TSO for IPv4 and IPv6, where CSUM_TSO is defined as CSUM_IP_TSO|CSUM_IP6_TSO. Therefore TCP/IPv6 packets gets mis-classified as TCP/IPv4, which breaks TSO for TCP/IPv6. This patch bases the check again on the ethertype. This fix is instantly MFCed. Approved by: re(gjb) PR: 254366 Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D29331 (cherry picked from commit d4697a6b56168876fc0ffec1a0bb1b24d25b198e)
* virtio_mmio: Delete a stale #if 0'ed debug printJessica Clarke2021-01-211-4/+1
| | | | | | | | This was blindly moved in r360722 but the variable being printed is not yet initialised. It's of little use and can easily be added back in the right place if needed by someone debugging, so just delete it. Reported by: bryanv
* virtio: Reduce boilerplate for device driver module definitionsJessica Clarke2021-01-217-40/+21
| | | | | | | | | | | Rather than have every device register itself for both virtio_pci and virtio_mmio, provide a VIRTIO_DRIVER_MODULE wrapper to declare both, merge VIRTIO_SIMPLE_PNPTABLE with VIRTIO_SIMPLE_PNPINFO and make the latter register for both buses. This also has the benefit of abstracting away the available transports and their names. Reviewed by: bryanv Differential Revision: https://reviews.freebsd.org/D28073
* virtio_mmio: Fix V1 device probing spec conformance (section 4.2.3.1.1)Jessica Clarke2021-01-214-12/+46
| | | | | | | | | | | | | | | | | We must check MagicValue not just Version before anything else, and then we must check DeviceID and immediately abort if zero (and this must not be an error). Do all this when probing rather than at the start of attaching as that's where this belongs, and provides a clear boundary between the device detection and device initialisation parts of the specified driver initialisation process. This also means we don't create empty device instances for placeholder devices, reducing clutter on systems that pre-allocate a large number, such as QEMU's AArch64 virt machine (which provides 32). Reviewed by: bryanv Differential Revision: https://reviews.freebsd.org/D28070
* virtio_mmio: Fix a style(9) issueJessica Clarke2021-01-211-1/+1
|
* virtio: Handle possible failure of virtio_finalize_features()Bryan Venteicher2021-01-197-65/+149
| | | | | | | | Try to standardize how drivers negotiate feature and the function names Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27930
* if_vtnet: Add counter for received host LROBryan Venteicher2021-01-192-0/+4
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27928
* if_vtnet: Misc Tx path cleanupBryan Venteicher2021-01-192-29/+41
| | | | | | | | | - Add and fix a few error path counters - Improve sysctl descriptions - Use flags consistently to determine IPv4 vs IPv6 Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27926
* if_vtnet: Set lro_nsegs for host LRO packetsBryan Venteicher2021-01-191-0/+10
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27933
* if_vtnet: Resort softc fieldsBryan Venteicher2021-01-191-7/+7
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27925
* if_vtnet: Remove unnecessary TUNABLE_INTs because of CTLFLAG_RDTUNBryan Venteicher2021-01-191-15/+9
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27923
* if_vtnet: Schedule Rx task if pending items when enabling interruptBryan Venteicher2021-01-191-4/+10
| | | | | | | | | | | | | Prior to V1, the driver would enable interrupts and then notify the host that DRIVER_OK. Since for V1, DRIVER_OK needs to be set before notifying the virtqueues, there may be items in the queues waiting to be processed by the time interrupts are enabled. This fixes a bug where the Rx queue would appear stuck, only being usable after an interface down/up cycle. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27922
* if_vtnet: Disable F_MTU feature if MTU is invalidBryan Venteicher2021-01-192-0/+15
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27931
* if_vtnet: Limit allocations of unused virtqueuesBryan Venteicher2021-01-191-13/+27
| | | | | | | | | For multiqueue, we may use fewer than the provided maximum number of queues. Try to limit allocations of the unused queues: no interrupts, no indirect descriptors, and no taskqueues. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27921
* if_vtnet: Rework 4be723f63 max multiqueue pairs checkBryan Venteicher2021-01-192-18/+32
| | | | | | | | Verify the max_virtqueue_pairs is within the range allowed by the spec. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27920
* if_vtnet: Add support for software LROBryan Venteicher2021-01-192-24/+122
| | | | | | | | | | | | | This useful when running on hosts that support checksum offloading but not the GUEST_TSO (LRO) feature. Or potentially, some GRO-like support when doing forwarding. Only enable SW LRO when the host LRO is not available since both tends to be harmful, and difficult to enable/disable selectively with only a single IFCAP_LRO flag. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27919
* if_vtnet: Set the interface max TSO valuesBryan Venteicher2021-01-191-1/+16
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27917
* if_vtnet: Add support for CTRL_GUEST_OFFLOADS featureBryan Venteicher2021-01-192-31/+127
| | | | | | | | | | | | | | This allows the Rx checksum and LRO to be modified without a full reinit of the device. Remove IFCAP_RXCSUM_IPV6 from the interface capabilities since in VirtIO Rx checksums are just enabled or disabled for all protocols. Properly update IFCAP_LRO if LRO is becomes disabled when Rx checksums are disabled. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27916
* if_vtnet: Move ioctl handlers into separate functionsBryan Venteicher2021-01-191-62/+106
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27914 https://reviews.freebsd.org/D27915
* if_vtnet: Cleanup the reinit processBryan Venteicher2021-01-192-46/+46
| | | | | | | | In modern VirtIO, the virtqueues cannot be notified before setting DRIVER_OK status. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27932
* if_vtnet: Cleanup the interface setup methodsBryan Venteicher2021-01-191-38/+21
| | | | | | | | Defer the ether_ifattach until the interface capabilities are configured Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27913
* if_vtnet: Only set IFCAP_JUMBO_MTU when jumbo MTU is supportedBryan Venteicher2021-01-191-4/+7
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27912
* if_vtnet: Move the Tx interrupt threshold into the Txq structureBryan Venteicher2021-01-192-36/+33
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27911
* if_vtnet: Defer updating generated MAC address until attachedBryan Venteicher2021-01-191-23/+37
| | | | | | | | | | | | This improves spec compliance because the driver is not suppose to notify the device prior to setting the DRIVER_OK status, which could happen with the VIRTIO_NET_F_CTRL_MAC_ADDR. The VIRTIO_NET_F_MAC feature should always be negotiated so would be a rare situation. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27910
* if_vtnet: Remove at attach PROMISC handlingBryan Venteicher2021-01-191-25/+0
| | | | | | | | | This may have been required in an early, early, early version of the specification but I cannot find any reference to it, and a promiscuous default seems very odd so remove this code. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27909
* if_vtnet: Support VIRTIO_NET_F_SPEED_DUPLEXBryan Venteicher2021-01-192-23/+39
| | | | | | | | | | | | This features lets the guest driver know the speed and duplex of the "link". Instead of trying to support many media types based on the possible/likely speeds/duplexes, only use the speed to set the interface baudrate. Cleanup ifmedia code to match other drivers. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27908
* if_vtnet: Support VIRTIO_NET_F_MTUBryan Venteicher2021-01-192-5/+12
| | | | | | | | | | This feature lets the guest driver know the maximum MTU size supported by the host device. If set, use this to limit the acceptable MTUs, and improve how the receive mbuf cluster size then is selected. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27907
* if_vtnet: Rx path cleanupBryan Venteicher2021-01-192-311/+296
| | | | | | | | | | | | | | | | | | - Fix the NEEDS_CSUM and DATA_VALID checksum flags. The NEEDS_CSUM checksum is incomplete (partial) so offer a fallback for the driver to calculate the checksum. Simplify DATA_VALID because we know the host has validated the checksum. - Default 4K mbuf clusters for mergeable buffers. May need to scale this down to 2K clusters in certain configurations such many queue pairs, big queues (like 4096 in GCP), and low memory. - Use the MTU when calculated the receive mbuf cluster size when not doing TSO/LRO. This will need more adjustment once the MTU feature is supported. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27906
* virtio_blk: Use DISKFLAG_WRITE_PROTECT for RO disksBryan Venteicher2021-01-191-22/+10
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27905
* if_vtnet: Add initial modern (V1) supportBryan Venteicher2021-01-193-352/+421
| | | | | | | | | | | Very basic support to get packets flowing on modern QEMU but still several conformance issues remain that will be addressed in later commits. First of many passes at cleaning up various accumulated cruft Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27904
* virtio_scsi: Add modern (V1) supportBryan Venteicher2021-01-192-31/+69
| | | | | Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27903