aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio
Commit message (Collapse)AuthorAgeFilesLines
...
* virtio console: plug set-but-not-used varsMateusz Guzik2021-12-141-3/+3
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* vtnet: plug set-but-not-used varsMateusz Guzik2021-12-141-5/+5
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* Convert vm_page_alloc() callers to use vm_page_alloc_noobj().Mark Johnston2021-10-201-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 MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D31986
* Add missing const after 6c4f95161d6eAlex Richardson2021-10-111-1/+1
| | | | | | I accidentally didn't include hunk in the committed patch. Fixes: 6c4f95161d6e ("virtio: make the write_config buffer argument const")
* virtio: make the write_config buffer argument constAlex Richardson2021-10-116-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
* Add SDT probes virtqueue::enqueue_segments:{entry,return}Stephen J. Kiernan2021-08-271-0/+10
| | | | | | | | | | | This allows one to be able to map the sglist entries passed into the vq_ring_enqueue_segments() function to the segment indexes used in the virtqueue. This function normally gets inlined and may not available via FBT probes. Differential Revision: https://reviews.freebsd.org/D31620
* virtio: Add KMSAN hooks for network and block devicesMark Johnston2021-08-112-1/+7
| | | | | | This ensures that host-written data is marked as initialized. Sponsored by: The FreeBSD Foundation
* Only use byte register access in legacy virtio pciAndrew Turner2021-08-111-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
* virtio: enable VTNET_LEGACY_TX when ALTQ is enabled.Luiz Otavio O Souza2021-07-291-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")
* newbus: Move from bus_child_{pnpinfo,location}_src to ↵Warner Losh2021-06-235-9/+7
| | | | | | | | | | | | | | | | | | | | | | bus_child_{pnpinfo,location} with sbuf Now that the upper layers all go through a layer to tie into these information functions that translates an sbuf into char * and len. The current interface suffers issues of what to do in cases of truncation, etc. Instead, migrate all these functions to using struct sbuf and these issues go away. The caller is also in charge of any memory allocation and/or expansion that's needed during this process. Create a bus_generic_child_{pnpinfo,location} and make it default. It just returns success. This is for those busses that have no information for these items. Migrate the now-empty routines to using this as appropriate. Document these new interfaces with man pages, and oversight from before. Reviewed by: jhb, bcr Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D29937
* virtio_scsi: Zero stack-allocated CCBsMark Johnston2021-05-171-0/+2
| | | | | | | Fixes: 3394d4239b ("cam: allocate CCBs from UMA for SCSI and ATA IO") Reported by: syzbot+2e9ce63919709feb3d1c@syzkaller.appspotmail.com Reviewed by: trasz Sponsored by: The FreeBSD Foundation
* virtio-modern: fix PCI common read/write functions on big endian targetsAlfredo Dal'Ava Junior2021-05-071-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
* virtio_blk: Fix issuing T_GET_ID before DRIVER_OK statusKa Ho Ng2021-05-051-2/+18
| | | | | | | | | | | DRIVER_OK status is set after device_attach() succeeds. For now postpone disk_create to attach_completed() method. MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Reviewed by: grehan Approved by: lwhsu (mentor) Differential Revision: https://reviews.freebsd.org/D30049
* Fix vtnet TCP lro panicAlexander V. Chernikov2021-04-191-1/+2
| | | | | Differential Revision: https://reviews.freebsd.org/D29900 Reviewed by: hps, kp
* virtio_pci_legacy: Allow memory space for configurationKa Ho Ng2021-03-201-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> MFC after: 2 weeks Reviewed by: rpokala, bryanv, jhb Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D28818
* virtio_pci_legacy: Use the table BAR and PBA BAR from MSI-X capKa Ho Ng2021-03-201-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> MFC after: 2 weeks Reviewed by: bryanv, jhb Approved by: philip (mentor) Differential Revision: https://reviews.freebsd.org/D28817
* 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 will be MFC instantly as discussed with re(gjb). MFC after: instantly PR: 254366 Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D29331
* bhyve: virtio shares definitions between sys/dev/virtioKa Ho Ng2021-03-162-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
* if_vtnet: Fix pointer-sign and used parameter warningsAlex Richardson2021-02-222-24/+24
| | | | | Reviewed By: grehan Differential Revision: https://reviews.freebsd.org/D28726
* 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
* virtio_blk: Add modern (V1) supportBryan Venteicher2021-01-192-65/+125
| | | | | | | | | | | Rework the header file changes from 2cc8a52 to use our canonical upstream, Linux. geom_disk already checks DISKFLAG_CANDELETE for BIO_DELETE so remove an unnecessary check. Reviewed by: grehan (mentor) Differential Revision: https://reviews.freebsd.org/D27902