git: eaf619fddcb2 - main - vtnet: improve interface capability handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 26 Sep 2025 10:35:57 UTC
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=eaf619fddcb21859311b895a0836da3171a01531
commit eaf619fddcb21859311b895a0836da3171a01531
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-09-26 09:45:12 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2025-09-26 10:12:51 +0000
vtnet: improve interface capability handling
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
---
share/man/man4/vtnet.4 | 4 +++-
sys/dev/virtio/network/if_vtnet.c | 31 +++++++++++--------------------
2 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/share/man/man4/vtnet.4 b/share/man/man4/vtnet.4
index 0594ca70e99a..636ce4cc9b60 100644
--- a/share/man/man4/vtnet.4
+++ b/share/man/man4/vtnet.4
@@ -22,7 +22,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd September 16, 2025
+.Dd September 26, 2025
.Dt VTNET 4
.Os
.Sh NAME
@@ -54,6 +54,8 @@ TCP segmentation offload (TSO), TCP large receive offload (LRO),
hardware VLAN tag stripping/insertion features, a multicast hash filter,
as well as Jumbo Frames (up to 9216 bytes), which can be
configured via the interface MTU setting.
+TCP/UDP receive checksum offload cannot be configured independently for IPv4
+and IPv6.
Selecting an MTU larger than 1500 bytes with the
.Xr ifconfig 8
utility configures the adapter to receive and transmit Jumbo Frames.
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 528ff3372097..a4bb57adc609 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -1153,11 +1153,9 @@ vtnet_setup_interface(struct vtnet_softc *sc)
}
if (virtio_with_feature(dev, VIRTIO_NET_F_GUEST_CSUM)) {
- if_setcapabilitiesbit(ifp, IFCAP_RXCSUM, 0);
-#ifdef notyet
/* BMV: Rx checksums not distinguished between IPv4 and IPv6. */
+ if_setcapabilitiesbit(ifp, IFCAP_RXCSUM, 0);
if_setcapabilitiesbit(ifp, IFCAP_RXCSUM_IPV6, 0);
-#endif
if (vtnet_tunable_int(sc, "fixup_needs_csum",
vtnet_fixup_needs_csum) != 0)
@@ -1370,27 +1368,20 @@ vtnet_ioctl_ifcap(struct vtnet_softc *sc, struct ifreq *ifr)
if ((mask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_LRO)) ==
IFCAP_LRO && vtnet_software_lro(sc))
reinit = update = 0;
-
- if (mask & IFCAP_RXCSUM)
+ /*
+ * VirtIO does not distinguish between receive checksum offload
+ * for IPv4 and IPv6 packets, so treat them as a pair.
+ */
+ if (mask & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
if_togglecapenable(ifp, IFCAP_RXCSUM);
- if (mask & IFCAP_RXCSUM_IPV6)
if_togglecapenable(ifp, IFCAP_RXCSUM_IPV6);
+ }
if (mask & IFCAP_LRO)
if_togglecapenable(ifp, IFCAP_LRO);
-
- /*
- * VirtIO does not distinguish between IPv4 and IPv6 checksums
- * so treat them as a pair. Guest TSO (LRO) requires receive
- * checksums.
- */
- if (if_getcapenable(ifp) & (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) {
- if_setcapenablebit(ifp, IFCAP_RXCSUM, 0);
-#ifdef notyet
- if_setcapenablebit(ifp, IFCAP_RXCSUM_IPV6, 0);
-#endif
- } else
- if_setcapenablebit(ifp, 0,
- (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6 | IFCAP_LRO));
+ /* Both SW and HW TCP LRO require receive checksum offload. */
+ if ((if_getcapenable(ifp) &
+ (IFCAP_RXCSUM | IFCAP_RXCSUM_IPV6)) == 0)
+ if_setcapenablebit(ifp, 0, IFCAP_LRO);
}
if (mask & IFCAP_VLAN_HWFILTER) {