aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/virtio/network
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
* 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
* 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
* 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
* 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
* 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
* vtnet: set VNET context in RX handlerGleb Smirnoff2024-03-281-0/+2
| | | | The context is required for NIC-level pfil(9) filtering.
* vtnet: Avoid ifdefs based on __NO_STRICT_ALIGNMENTWarner Losh2024-02-051-12/+12
| | | | | | | | | | | | | Some platforms require an adjustment of the ethernet hearders. Rather than make this be on __NO_STRICT_ALIGNMENT being defined, define VTNET_ETHER_ALIGN to be either 0 or ETHER_ALIGN (aka 2). Add a test to the if statements to only do them when != 0. This eliminates the #ifdef sprinkled in the code, still communicates the intent and gives the same compiled results. Sponsored by: Netflix Reviewed by: bz, bryanv Differential Revision: https://reviews.freebsd.org/D43654
* vtnet: Account for the padding when selecting allocation sizeWarner Losh2024-02-052-1/+16
| | | | | | | | | | | | | | | | While we account for the padding in the length of the mbuf we use, we do not account for it when we 'guess' the size of the mbuf to allocate based in the MTU of the device. This leads to a situation where we might fail if the mtu is close to a bucket size (say 2018) such that the added padding would push us over the edge for a full-sized packet. mtu of 2018 is super rare (2016 and 2020 would both work), but fix it none-the-less. It's a shame we can't just set VTNET_RX_HEADER_PAD to 2 in this case. The 4 seems hard-coded somewhere I've not found documented (I think it's in the protocol given the comments about VIRTIO_F_ANY_LAYOUT). Sponsored by: Netflix Reviewed by: bz Differential Revision: https://reviews.freebsd.org/D43656
* vtnet: Adjust for ethernet alignment.Warner Losh2024-01-291-0/+21
| | | | | | | | | | | | | | | | | | | If the header that we add to the packet's size is 0 % 4 and we're strictly aligning, then we need to adjust where we store the header so the packet that follows will have it's struct ip header properly aligned. We do this on allocation (and when we check the length of the mbufs in the lro_nomrg case). We can't just adjust the clustersz in the softc, because it's also used to allocate the mbufs and it needs to be the proper size for that. Since we otherwise use the size of the mbuf (or sometimes the smaller size of the received packet) to compute how much we can buffer, this ensures no overflows. The 2 byte adjustment also does not affect how many packets we can receive in the lro_nomrg case. PR: 271288 Sponsored by: Netflix Reviewed by: bryanv Differential Revision: https://reviews.freebsd.org/D43224
* virtio(4): Fix a typo in a source code commentGordon Bergling2024-01-221-1/+1
| | | | | | - s/recevied/received/ MFC after: 3 days
* Revert "vtnet: Adjust rx buffer so IP header 32-bit aligned"Warner Losh2023-12-281-1/+1
| | | | | | | | This reverts commit 9e6d11ce9a51d75ed6a94e180f2fb4e9188a2ba4. This wasn't right to start with... Requested by: markj
* Revert "vtnet: Better adjust for ethernet alignment."Warner Losh2023-12-281-28/+3
| | | | | | | | This reverts commit e9da71cd35d46ca13da4396d99e0af1703290e68. This was inadvertantly pushed and turns out ot be not quite right. Requested by: markj
* vtnet: Better adjust for ethernet alignment.Warner Losh2023-12-281-3/+28
| | | | | | | | | | | | | | | | | | | Move adjustment of the mbuf from where we allocate it to where we are about to queue it to the device. Do this only on those platforms that require it. This allows us to receive an entire jumbo frame on other platforms. It also doesn't make the adjustment on subsequent frames when we queue mulitple mbufs for LRO operations. For the normal use case on armv7, there's no difference because we only ever allocate one mbuf. However, for the LRO cases it increases what's available in LRO. It also ensure that we get enough mbufs in those cases as well (though I have no ability to test this on a LRO scenario with armv7). This has the side effect of reverting 527b62e37e68. Fixes: 527b62e37e68 Sponsored by: Netflix
* vtnet: Adjust rx buffer so IP header 32-bit alignedWarner Losh2023-12-211-1/+1
| | | | | | | | | | Call madj(m, ETHER_ALIGN) to offset rx buffers when allocating them. This improves performance everywhere, and allows armv7 to work at all. PR: 271288 (PR had a different fix than I wound up with) MFC After: 3 days Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D43136
* sys: Automated cleanup of cdefs and other formattingWarner Losh2023-11-271-1/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* virtio: remove virtio_alloc_virtqueues' flags argMina Galić2023-09-181-10/+2
| | | | | | | | | | | | | | | | | Summary: the flags argument is unused. Its initial design idea has been superceded by the addition of virtio_setup_intr and related APIs. Sponsored by: The FreeBSD Foundation Reviewers: bryanv Reviewed By: bryanv Subscribers: cognet, imp Differential Revision: https://reviews.freebsd.org/D41850
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-162-4/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* vtnet: allow IFF_ALLMULTI to be set without VIRTIO_NET_F_CTRL_RXKristof Provost2023-08-111-2/+5
| | | | | | | | | | | | If the host doesn't announce VIRTIO_NET_F_CTRL_RX we cannot disable all multicast traffic. Previously we'd refuse to set the IFF_ALLMULTI flag, which is the exact opposite of what is actually happening. This broke things such as igmpproxy. See also: https://redmine.pfsense.org/issues/14301 Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D41356
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-122-2/+2
| | | | | | | | | 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
* net: replace IFF_KNOWSEPOCH with IFF_NEEDSEPOCHGleb Smirnoff2023-04-171-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Expect that drivers call into the network stack with the net epoch entered. This has already been the fact since early 2020. The net interrupts, that are marked with INTR_TYPE_NET, were entering epoch since 511d1afb6bf. For the taskqueues there is NET_TASK_INIT() and all drivers that were known back in 2020 we marked with it in 6c3e93cb5a4. However in e87c4940156 we took conservative approach and preferred to opt-in rather than opt-out for the epoch. This change not only reverts e87c4940156 but adds a safety belt to avoid panicing with INVARIANTS if there is a missed driver. With INVARIANTS we will run in_epoch() check, print a warning and enter the net epoch. A driver that prints can be quickly fixed with the IFF_NEEDSEPOCH flag, but better be augmented to properly enter the epoch itself. Note on TCP LRO: it is a backdoor to enter the TCP stack bypassing some layers of net stack, ignoring either old IFF_KNOWSEPOCH or the new IFF_NEEDSEPOCH. But the tcp_lro_flush_all() asserts the presence of network epoch. Indeed, all NIC drivers that support LRO already provide the epoch, either with help of INTR_TYPE_NET or just running NET_EPOCH_ENTER() in their code. Reviewed by: zlei, gallatin, erj Differential Revision: https://reviews.freebsd.org/D39510
* net: use pfil_mbuf_{in,out} where we always have an mbufGleb Smirnoff2023-02-141-5/+1
| | | | | | | This finalizes what has been started in 0b70e3e78b0. Reviewed by: kp, mjg Differential revision: https://reviews.freebsd.org/D37976
* Mechanically convert if_vtnet(4) to IfAPIJustin Hibbits2023-01-242-169/+167
| | | | | | Reviewed By: bryanv Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37799
* virtio: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-061-4/+1
|
* if_vtnet: improve dumping a kernelMichael Tuexen2022-04-181-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 MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D34787
* vtnet: offset is only used for INET or INET6.John Baldwin2022-04-131-0/+6
|
* if_vtnet(4): Restore the ability to set promisc mode.Aleksandr Fedorov2022-02-051-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
* vtnet: Mark MRG_RXBUF headers as initialized before loading fieldsMark Johnston2022-01-201-0/+1
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* vtnet: don't leak pfil(9) data on detachGleb Smirnoff2022-01-051-0/+5
| | | | | PR: 260667 Submitted by: <ghuckriede blackberry.com>
* virtio: plug some of set-but-not-used varsMateusz Guzik2021-12-141-0/+6
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* vtnet: plug set-but-not-used varsMateusz Guzik2021-12-141-5/+5
| | | | Sponsored by: Rubicon Communications, LLC ("Netgate")
* virtio: Add KMSAN hooks for network and block devicesMark Johnston2021-08-111-1/+4
| | | | | | This ensures that host-written data is marked as initialized. Sponsored by: The FreeBSD Foundation