git: c0598ba49d2c - stable/14 - vtnet: improve interface capability handling
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 29 Sep 2025 19:42:34 UTC
The branch stable/14 has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=c0598ba49d2cc785a174e34e687b48298b95f8a0 commit c0598ba49d2cc785a174e34e687b48298b95f8a0 Author: Michael Tuexen <tuexen@FreeBSD.org> AuthorDate: 2025-09-26 09:45:12 +0000 Commit: Michael Tuexen <tuexen@FreeBSD.org> CommitDate: 2025-09-29 19:42:07 +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 Differential Revision: https://reviews.freebsd.org/D52682 (cherry picked from commit eaf619fddcb21859311b895a0836da3171a01531) --- 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 4a58822e7095..8b96445f0f04 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 949b3ba0e5bb..c2f55bb37054 100644 --- a/sys/dev/virtio/network/if_vtnet.c +++ b/sys/dev/virtio/network/if_vtnet.c @@ -1151,11 +1151,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) @@ -1368,27 +1366,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) {