From: jan Date: Sun, 9 Jun 2024 16:25:27 +0000 (+0000) Subject: Introduce IFCAP_VLAN_HWOFFLOAD for vio(4). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=1a9be79712301e20fcea43efea0745b6d6b7ffd2;p=openbsd Introduce IFCAP_VLAN_HWOFFLOAD for vio(4). Add IFCAP_VLAN_HWOFFLOAD to signal hardware like vio(4) can handle checksum or TSO offloading with inline VLAN tags. tested by Mark Patruck, sf@ and bluhm@ ok sf@ and bluhm@ --- diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index bc92b15c567..121bb1e8f75 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.399 2024/01/11 17:22:04 jan Exp $ +.\" $OpenBSD: ifconfig.8,v 1.400 2024/06/09 16:25:27 jan Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: January 11 2024 $ +.Dd $Mdocdate: June 9 2024 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -294,6 +294,9 @@ tag. On transmit, the device can add the .Xr vlan 4 tag. +.It Sy VLAN_HWOFFLOAD +On transmit, the device can handle checksum or TSO offload without +.Sy VLAN_HWTAGGING . .It Sy WOL The device supports Wake on LAN (WoL). .It Sy hardmtu diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 2c257a430a2..3e44dce7120 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.472 2024/05/18 02:44:22 jsg Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.473 2024/06/09 16:25:27 jan Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -125,7 +125,7 @@ #define HWFEATURESBITS \ "\024\1CSUM_IPv4\2CSUM_TCPv4\3CSUM_UDPv4" \ - "\5VLAN_MTU\6VLAN_HWTAGGING\10CSUM_TCPv6" \ + "\5VLAN_MTU\6VLAN_HWTAGGING\7VLAN_HWOFFLOAD\10CSUM_TCPv6" \ "\11CSUM_UDPv6\15TSOv4\16TSOv6\17LRO\20WOL" struct ifencap { diff --git a/sys/dev/pv/if_vio.c b/sys/dev/pv/if_vio.c index 8ce83ed0575..9451796816f 100644 --- a/sys/dev/pv/if_vio.c +++ b/sys/dev/pv/if_vio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vio.c,v 1.37 2024/06/04 09:51:52 jan Exp $ */ +/* $OpenBSD: if_vio.c,v 1.38 2024/06/09 16:25:28 jan Exp $ */ /* * Copyright (c) 2012 Stefan Fritsch, Alexander Fiveg. @@ -604,7 +604,11 @@ vio_attach(struct device *parent, struct device *self, void *aux) ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST; ifp->if_start = vio_start; ifp->if_ioctl = vio_ioctl; - ifp->if_capabilities = IFCAP_VLAN_MTU; + ifp->if_capabilities = 0; +#if NVLAN > 0 + ifp->if_capabilities |= IFCAP_VLAN_MTU; + ifp->if_capabilities |= IFCAP_VLAN_HWOFFLOAD; +#endif if (virtio_has_feature(vsc, VIRTIO_NET_F_CSUM)) ifp->if_capabilities |= IFCAP_CSUM_TCPv4|IFCAP_CSUM_UDPv4| IFCAP_CSUM_TCPv6|IFCAP_CSUM_UDPv6; diff --git a/sys/net/if.h b/sys/net/if.h index ae50958ee5a..8552fff022c 100644 --- a/sys/net/if.h +++ b/sys/net/if.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if.h,v 1.216 2024/04/11 15:08:18 bluhm Exp $ */ +/* $OpenBSD: if.h,v 1.217 2024/06/09 16:25:28 jan Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -249,6 +249,7 @@ struct if_status_description { #define IFCAP_CSUM_UDPv4 0x00000004 /* can do IPv4/UDP csum */ #define IFCAP_VLAN_MTU 0x00000010 /* VLAN-compatible MTU */ #define IFCAP_VLAN_HWTAGGING 0x00000020 /* hardware VLAN tag support */ +#define IFCAP_VLAN_HWOFFLOAD 0x00000040 /* hw offload w/ inline tag */ #define IFCAP_CSUM_TCPv6 0x00000080 /* can do IPv6/TCP checksums */ #define IFCAP_CSUM_UDPv6 0x00000100 /* can do IPv6/UDP checksums */ #define IFCAP_TSOv4 0x00001000 /* IPv4/TCP segment offload */ diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 9915a94390c..9a0414f1bc6 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.218 2023/12/23 10:52:54 bluhm Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.219 2024/06/09 16:25:28 jan Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -523,7 +523,7 @@ vlan_up(struct vlan_softc *sc) /* * Note: In cases like vio(4) and em(4) where the offsets of the * csum can be freely defined, we could actually do csum offload - * for VLAN and QINQ packets. + * for QINQ packets. */ if (sc->sc_type != ETHERTYPE_VLAN) { /* @@ -531,10 +531,14 @@ vlan_up(struct vlan_softc *sc) * ethernet type (0x8100). */ ifp->if_capabilities = 0; - } else if (ISSET(ifp0->if_capabilities, IFCAP_VLAN_HWTAGGING)) { + } else if (ISSET(ifp0->if_capabilities, IFCAP_VLAN_HWTAGGING) || + ISSET(ifp0->if_capabilities, IFCAP_VLAN_HWOFFLOAD)) { /* * Chips that can do hardware-assisted VLAN encapsulation, can * calculate the correct checksum for VLAN tagged packets. + * + * Hardware which does checksum offloading, but not VLAN tag + * injection, have to set IFCAP_VLAN_HWOFFLOAD. */ ifp->if_capabilities = ifp0->if_capabilities & (IFCAP_CSUM_MASK | IFCAP_TSOv4 | IFCAP_TSOv6);