Skip to contentSkip to conversation

TUN/VirtioNet USO features support.

RFC PATCH Superseded Andrew Melnychenko 6 participants 25 messages Jan 25, 2022 – Feb 24, 2022

Subsystems (5)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover TUN/VirtioNet USO features support.

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 18 ++++++++++++++++--
 drivers/net/tun.c               | 15 ++++++++++++++-
 drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
 include/linux/virtio_net.h      | 11 +++++++++++
 include/uapi/linux/if_tun.h     |  3 +++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 66 insertions(+), 7 deletions(-)
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#1 lore raw

RFC PATCH 1/5 uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.
Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
 include/uapi/linux/if_tun.h | 3 +++
 1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +3 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
 #define TUNSETFILTEREBPF _IOR('T', 225, int)
 #define TUNSETCARRIER _IOW('T', 226, int)
 #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
 /* TUNSETIFF ifr flags */
 #define IFF_TUN		0x0001
@@ -88,6 +89,8 @@
 #define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */
 #define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */
 #define TUN_F_UFO	0x10	/* I can handle UFO packets */
+#define TUN_F_USO4	0x20	/* I can handle USO for IPv4 packets */
+#define TUN_F_USO6	0x40	/* I can handle USO for IPv6 packets */
 
 /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
 #define TUN_PKT_STRIP	0x0001
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#2 lore raw

Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Quoted 2 lines · Andrew Melnychenko

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.

So we don't use dedicated ioctls in the past, instead, we just probing by checking the return value of TUNSETOFFLOADS.

E.g qemu has the following codes:

int tap_probe_has_ufo(int fd)
{
    unsigned offload;

    offload = TUN_F_CSUM | TUN_F_UFO;

    if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
        return 0;

    return 1;
}

Any reason we can't keep using that?

Thanks

Quoted 22 lines

Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
  include/uapi/linux/if_tun.h | 3 +++
  1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +1 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
  #define TUNSETFILTEREBPF _IOR('T', 225, int)
  #define TUNSETCARRIER _IOW('T', 226, int)
  #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
  /* TUNSETIFF ifr flags */
  #define IFF_TUN		0x0001

include/uapi/linux/if_tun.h line 96

Quoted 8 lines
include/uapi/linux/if_tun.h +2 -0
@@ -88,6 +89,8 @@
  #define TUN_F_TSO6	0x04	/* I can handle TSO for IPv6 packets */
  #define TUN_F_TSO_ECN	0x08	/* I can handle TSO with ECN bits. */
  #define TUN_F_UFO	0x10	/* I can handle UFO packets */
+#define TUN_F_USO4	0x20	/* I can handle USO for IPv4 packets */
+#define TUN_F_USO6	0x40	/* I can handle USO for IPv6 packets */
 
  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
  #define TUN_PKT_STRIP	0x0001

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#3 lore raw

Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Hi all,

Quoted 24 lines · Jason Wang
Quoted 2 lines · Andrew Melnychenko

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.

So we don't use dedicated ioctls in the past, instead, we just probing by checking the return value of TUNSETOFFLOADS.

E.g qemu has the following codes:

int tap_probe_has_ufo(int fd)

{
     unsigned offload;

     offload = TUN_F_CSUM | TUN_F_UFO;

     if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
         return 0;

     return 1;
}
Quoted 4 lines

Any reason we can't keep using that?

Thanks

Well, even in this example. To check the ufo feature, we trying to set it. What if we don't need to "enable" UFO and/or do not change its state? I think it's a good idea to have the ability to get supported offloads without changing device behavior.

Quoted 32 lines
Quoted 31 lines

Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
  include/uapi/linux/if_tun.h | 3 +++
  1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +3 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
  #define TUNSETFILTEREBPF _IOR('T', 225, int)
  #define TUNSETCARRIER _IOW('T', 226, int)
  #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
  /* TUNSETIFF ifr flags */
  #define IFF_TUN             0x0001
@@ -88,6 +89,8 @@
  #define TUN_F_TSO6  0x04    /* I can handle TSO for IPv6 packets */
  #define TUN_F_TSO_ECN       0x08    /* I can handle TSO with ECN bits. */
  #define TUN_F_UFO   0x10    /* I can handle UFO packets */
+#define TUN_F_USO4   0x20    /* I can handle USO for IPv4 packets */
+#define TUN_F_USO6   0x40    /* I can handle USO for IPv6 packets */
 
  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
  #define TUN_PKT_STRIP       0x0001
#4 lore raw

Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Quoted 28 lines · Andrew Melnichenko

Hi all,

Quoted 24 lines · Jason Wang
Quoted 2 lines · Andrew Melnychenko

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.

So we don't use dedicated ioctls in the past, instead, we just probing by checking the return value of TUNSETOFFLOADS.

E.g qemu has the following codes:

int tap_probe_has_ufo(int fd)

{
     unsigned offload;

     offload = TUN_F_CSUM | TUN_F_UFO;

     if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
         return 0;

     return 1;
}
Quoted 7 lines
Quoted 4 lines

Any reason we can't keep using that?

Thanks

Well, even in this example. To check the ufo feature, we trying to set it. What if we don't need to "enable" UFO and/or do not change its state?

So at least Qemu doesn't have such a requirement since during the probe the virtual networking backend is not even started.

Quoted 2 lines

I think it's a good idea to have the ability to get supported offloads without changing device behavior.

Do you see a real user for this?

Btw, we still need to probe this new ioctl anyway.

Thanks

Quoted 34 lines
Quoted 33 lines
Quoted 32 lines

Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
  include/uapi/linux/if_tun.h | 3 +++
  1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +3 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
  #define TUNSETFILTEREBPF _IOR('T', 225, int)
  #define TUNSETCARRIER _IOW('T', 226, int)
  #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
  /* TUNSETIFF ifr flags */
  #define IFF_TUN             0x0001
@@ -88,6 +89,8 @@
  #define TUN_F_TSO6  0x04    /* I can handle TSO for IPv6 packets */
  #define TUN_F_TSO_ECN       0x08    /* I can handle TSO with ECN bits. */
  #define TUN_F_UFO   0x10    /* I can handle UFO packets */
+#define TUN_F_USO4   0x20    /* I can handle USO for IPv4 packets */
+#define TUN_F_USO6   0x40    /* I can handle USO for IPv6 packets */
 
  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
  #define TUN_PKT_STRIP       0x0001
#5 lore raw

Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Hi Jason,
We agree that the same can be done also using the old way, i.e. try to set specific offload - if failed, probably it is not supported. We think this is a little not scalable and we suggest adding the ioctl that will allow us to query allo the supported features in a single call.
We think this will make QEMU code more simple also in future. Do I understand correctly that you suggest to skip this new ioctl and use the old way of query for this (USO) feature and all future extensions?

Thanks

Quoted 85 lines · Jason Wang
Quoted 28 lines · Andrew Melnichenko

Hi all,

Quoted 24 lines · Jason Wang
Quoted 2 lines · Andrew Melnychenko

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.

So we don't use dedicated ioctls in the past, instead, we just probing by checking the return value of TUNSETOFFLOADS.

E.g qemu has the following codes:

int tap_probe_has_ufo(int fd)

{
     unsigned offload;

     offload = TUN_F_CSUM | TUN_F_UFO;

     if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
         return 0;

     return 1;
}
Quoted 7 lines
Quoted 4 lines

Any reason we can't keep using that?

Thanks

Well, even in this example. To check the ufo feature, we trying to set it. What if we don't need to "enable" UFO and/or do not change its state?

So at least Qemu doesn't have such a requirement since during the probe the virtual networking backend is not even started.

Quoted 2 lines

I think it's a good idea to have the ability to get supported offloads without changing device behavior.

Do you see a real user for this?

Btw, we still need to probe this new ioctl anyway.

Thanks

Quoted 34 lines
Quoted 33 lines
Quoted 32 lines

Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
  include/uapi/linux/if_tun.h | 3 +++
  1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +3 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
  #define TUNSETFILTEREBPF _IOR('T', 225, int)
  #define TUNSETCARRIER _IOW('T', 226, int)
  #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
  /* TUNSETIFF ifr flags */
  #define IFF_TUN             0x0001
@@ -88,6 +89,8 @@
  #define TUN_F_TSO6  0x04    /* I can handle TSO for IPv6 packets */
  #define TUN_F_TSO_ECN       0x08    /* I can handle TSO with ECN bits. */
  #define TUN_F_UFO   0x10    /* I can handle UFO packets */
+#define TUN_F_USO4   0x20    /* I can handle USO for IPv4 packets */
+#define TUN_F_USO6   0x40    /* I can handle USO for IPv6 packets */
 
  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
  #define TUN_PKT_STRIP       0x0001
#6 lore raw

Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.

Quoted 7 lines · Yuri Benditovich

Hi Jason,
We agree that the same can be done also using the old way, i.e. try to set specific offload - if failed, probably it is not supported. We think this is a little not scalable and we suggest adding the ioctl that will allow us to query allo the supported features in a single call.

Possibly but then you need some kind of probing. E.g we need endup with probing TUNGETSUPPORTEDOFFLOADS iotctl itself.

Quoted 1 line

We think this will make QEMU code more simple also in future.

We can discuss this when qemu patches were sent.

Quoted 3 lines

Do I understand correctly that you suggest to skip this new ioctl and use the old way of query for this (USO) feature and all future extensions?

Yes, since it's not a must. And we can do the TUNGETSUPPORTEDOFFLOADS in a separate series.

Thanks

Quoted 91 lines

Thanks

Quoted 85 lines · Jason Wang
Quoted 28 lines · Andrew Melnichenko

Hi all,

Quoted 24 lines · Jason Wang
Quoted 2 lines · Andrew Melnychenko

Added TUNGETSUPPORTEDOFFLOADS that should allow to get bits of supported offloads.

So we don't use dedicated ioctls in the past, instead, we just probing by checking the return value of TUNSETOFFLOADS.

E.g qemu has the following codes:

int tap_probe_has_ufo(int fd)

{
     unsigned offload;

     offload = TUN_F_CSUM | TUN_F_UFO;

     if (ioctl(fd, TUNSETOFFLOAD, offload) < 0)
         return 0;

     return 1;
}
Quoted 7 lines
Quoted 4 lines

Any reason we can't keep using that?

Thanks

Well, even in this example. To check the ufo feature, we trying to set it. What if we don't need to "enable" UFO and/or do not change its state?

So at least Qemu doesn't have such a requirement since during the probe the virtual networking backend is not even started.

Quoted 2 lines

I think it's a good idea to have the ability to get supported offloads without changing device behavior.

Do you see a real user for this?

Btw, we still need to probe this new ioctl anyway.

Thanks

Quoted 34 lines
Quoted 33 lines
Quoted 32 lines

Added 2 additional offlloads for USO(IPv4 & IPv6). Separate offloads are required for Windows VM guests, g.e. Windows may set USO rx only for IPv4.

---
  include/uapi/linux/if_tun.h | 3 +++
  1 file changed, 3 insertions(+)
include/uapi/linux/if_tun.h +3 -0
index 454ae31b93c7..07680fae6e18 100644
@@ -61,6 +61,7 @@
  #define TUNSETFILTEREBPF _IOR('T', 225, int)
  #define TUNSETCARRIER _IOW('T', 226, int)
  #define TUNGETDEVNETNS _IO('T', 227)
+#define TUNGETSUPPORTEDOFFLOADS _IOR('T', 228, unsigned int)
 
  /* TUNSETIFF ifr flags */
  #define IFF_TUN             0x0001
@@ -88,6 +89,8 @@
  #define TUN_F_TSO6  0x04    /* I can handle TSO for IPv6 packets */
  #define TUN_F_TSO_ECN       0x08    /* I can handle TSO with ECN bits. */
  #define TUN_F_UFO   0x10    /* I can handle UFO packets */
+#define TUN_F_USO4   0x20    /* I can handle USO for IPv4 packets */
+#define TUN_F_USO6   0x40    /* I can handle USO for IPv6 packets */
 
  /* Protocol info prepended to the packets (when IFF_NO_PI is not set) */
  #define TUN_PKT_STRIP       0x0001
#7 lore raw

RFC PATCH 2/5 driver/net/tun: Added features for USO.

In reply to Andrew Melnychenko

Added support for USO4 and USO6, also added code for new ioctl TUNGETSUPPORTEDOFFLOADS. For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously. USO enables NETIF_F_GSO_UDP_L4.

---
 drivers/net/tap.c | 18 ++++++++++++++++--
 drivers/net/tun.c | 15 ++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
drivers/net/tap.c +16 -2
index 8e3a28ba6b28..82d742ba78b1 100644
@@ -940,6 +940,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
 			if (arg & TUN_F_TSO6)
 				feature_mask |= NETIF_F_TSO6;
 		}
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
+			features |= NETIF_F_GSO_UDP_L4;
 	}
 
 	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -950,7 +954,8 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
 	 * When user space turns off TSO, we turn off GSO/LRO so that
 	 * user-space will not receive TSO frames.
 	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
+	    feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
 		features |= RX_OFFLOADS;
 	else
 		features &= ~RX_OFFLOADS;
@@ -979,6 +984,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
 	unsigned short u;
 	int __user *sp = argp;
 	struct sockaddr sa;
+	unsigned int supported_offloads;
 	int s;
 	int ret;
 
@@ -1074,7 +1080,8 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		/* let the user check for future flags */
 		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN | TUN_F_UFO))
+			    TUN_F_TSO_ECN | TUN_F_UFO |
+			    TUN_F_USO4 | TUN_F_USO6))
 			return -EINVAL;
 
 		rtnl_lock();
@@ -1082,6 +1089,13 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
 		rtnl_unlock();
 		return ret;
 
+	case TUNGETSUPPORTEDOFFLOADS:
+		supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+						TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+		if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+			return -EFAULT;
+		return 0;
+
 	case SIOCGIFHWADDR:
 		rtnl_lock();
 		tap = tap_get_tap_dev(q);
drivers/net/tun.c +14 -1
index fed85447701a..4f2105d1e6f1 100644
@@ -185,7 +185,7 @@ struct tun_struct {
 	struct net_device	*dev;
 	netdev_features_t	set_features;
 #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4)
 
 	int			align;
 	int			vnet_hdr_sz;
@@ -2821,6 +2821,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
 		}
 
 		arg &= ~TUN_F_UFO;
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
+			features |= NETIF_F_GSO_UDP_L4;
+			arg &= ~(TUN_F_USO4 | TUN_F_USO6);
+		}
 	}
 
 	/* This gives the user a way to test for new features in future by
@@ -2991,6 +2997,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 	int sndbuf;
 	int vnet_hdr_sz;
 	int le;
+	unsigned int supported_offloads;
 	int ret;
 	bool do_notify = false;
 
@@ -3154,6 +3161,12 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
 	case TUNSETOFFLOAD:
 		ret = set_offload(tun, arg);
 		break;
+	case TUNGETSUPPORTEDOFFLOADS:
+		supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+				TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+		if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+			ret = -EFAULT;
+		break;
 
 	case TUNSETTXFILTER:
 		/* Can be set only for TAPs */
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#8 lore raw

Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.

[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Andrew,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master mst-vhost/linux-next linus/master v5.17-rc1 next-20220125] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andrew-Melnychenko/TUN-VirtioNet-USO-features-support/20220125-171057
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 6e667749271e58d34238cf700e543beabdbe6184
config: arm-randconfig-r005-20220124 (https://download.01.org/0day-ci/archive/20220125/202201252109.aW3GcH2N-lkp(a)intel.com/config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 997e128e2a78f5a5434fc75997441ae1ee76f8a4)

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/3c1c2daa10c8eac3d9b546fa8caf99fcb5a40454
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Melnychenko/TUN-VirtioNet-USO-features-support/20220125-171057 git checkout 3c1c2daa10c8eac3d9b546fa8caf99fcb5a40454
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

>> drivers/net/tap.c:945:11: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
                   if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/tap.c:945:11: note: place parentheses around the '==' expression to silence this warning
                   if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                           ^
                             (                                                     )
   drivers/net/tap.c:945:11: note: place parentheses around the & expression to evaluate it first
                   if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                           ^
                       (                              )
   drivers/net/tap.c:958:19: warning: & has lower precedence than ==; == will be evaluated first [-Wparentheses]
               feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/net/tap.c:958:19: note: place parentheses around the '==' expression to silence this warning
               feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                            ^
                              (                                                     )
   drivers/net/tap.c:958:19: note: place parentheses around the & expression to evaluate it first
               feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
                            ^
               (                                       )

2 warnings generated.

vim +945 drivers/net/tap.c

919
920 static int set_offload(struct tap_queue *q, unsigned long arg)
921 {
922 struct tap_dev *tap;
923 netdev_features_t features;
924 netdev_features_t feature_mask = 0;
925
926 tap = rtnl_dereference(q->tap);
927 if (!tap)
928 return -ENOLINK;
929
930 features = tap->dev->features;
931
932 if (arg & TUN_F_CSUM) {
933 feature_mask = NETIF_F_HW_CSUM;
934
935 if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) {
936 if (arg & TUN_F_TSO_ECN)
937 feature_mask |= NETIF_F_TSO_ECN;
938 if (arg & TUN_F_TSO4)
939 feature_mask |= NETIF_F_TSO;
940 if (arg & TUN_F_TSO6)
941 feature_mask |= NETIF_F_TSO6;
942 }
943
944 /* TODO: for now USO4 and USO6 should work simultaneously */

 > 945			if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))

946 features |= NETIF_F_GSO_UDP_L4;
947 }
948
949 /* tun/tap driver inverts the usage for TSO offloads, where
950 * setting the TSO bit means that the userspace wants to
951 * accept TSO frames and turning it off means that user space
952 * does not support TSO.
953 * For tap, we have to invert it to mean the same thing.
954 * When user space turns off TSO, we turn off GSO/LRO so that
955 * user-space will not receive TSO frames.
956 */
957 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
958 feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
959 features |= RX_OFFLOADS;
960 else
961 features &= ~RX_OFFLOADS;
962
963 /* tap_features are the same as features on tun/tap and
964 * reflect user expectations.
965 */
966 tap->tap_features = feature_mask;
967 if (tap->update_features)
968 tap->update_features(tap, features);
969
970 return 0;
971 }
972

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#9 lore raw

Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.

In reply to Andrew Melnychenko
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch]

Hi Andrew,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on net-next/master]
[also build test WARNING on net/master mst-vhost/linux-next linus/master v5.17-rc1 next-20220125] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Andrew-Melnychenko/TUN-VirtioNet-USO-features-support/20220125-171057
base:   https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 6e667749271e58d34238cf700e543beabdbe6184
config: mips-allyesconfig (https://download.01.org/0day-ci/archive/20220125/202201252316.Wm0ucNBh-lkp(a)intel.com/config)
compiler: mips-linux-gcc (GCC) 11.2.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/3c1c2daa10c8eac3d9b546fa8caf99fcb5a40454
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Andrew-Melnychenko/TUN-VirtioNet-USO-features-support/20220125-171057 git checkout 3c1c2daa10c8eac3d9b546fa8caf99fcb5a40454
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=mips SHELL=/bin/bash drivers/net/

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/net/tap.c: In function 'set_offload':

>> drivers/net/tap.c:945:25: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
     945 |                 if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
         |                         ^
   drivers/net/tap.c:958:26: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
     958 |             feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
         |                          ^

vim +945 drivers/net/tap.c

919
920 static int set_offload(struct tap_queue *q, unsigned long arg)
921 {
922 struct tap_dev *tap;
923 netdev_features_t features;
924 netdev_features_t feature_mask = 0;
925
926 tap = rtnl_dereference(q->tap);
927 if (!tap)
928 return -ENOLINK;
929
930 features = tap->dev->features;
931
932 if (arg & TUN_F_CSUM) {
933 feature_mask = NETIF_F_HW_CSUM;
934
935 if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) {
936 if (arg & TUN_F_TSO_ECN)
937 feature_mask |= NETIF_F_TSO_ECN;
938 if (arg & TUN_F_TSO4)
939 feature_mask |= NETIF_F_TSO;
940 if (arg & TUN_F_TSO6)
941 feature_mask |= NETIF_F_TSO6;
942 }
943
944 /* TODO: for now USO4 and USO6 should work simultaneously */

 > 945			if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))

946 features |= NETIF_F_GSO_UDP_L4;
947 }
948
949 /* tun/tap driver inverts the usage for TSO offloads, where
950 * setting the TSO bit means that the userspace wants to
951 * accept TSO frames and turning it off means that user space
952 * does not support TSO.
953 * For tap, we have to invert it to mean the same thing.
954 * When user space turns off TSO, we turn off GSO/LRO so that
955 * user-space will not receive TSO frames.
956 */
957 if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
958 feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
959 features |= RX_OFFLOADS;
960 else
961 features &= ~RX_OFFLOADS;
962
963 /* tap_features are the same as features on tun/tap and
964 * reflect user expectations.
965 */
966 tap->tap_features = feature_mask;
967 if (tap->update_features)
968 tap->update_features(tap, features);
969
970 return 0;
971 }
972

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#10 lore raw

Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.

In reply to Andrew Melnychenko
Quoted 15 lines · Andrew Melnychenko

Added support for USO4 and USO6, also added code for new ioctl TUNGETSUPPORTEDOFFLOADS. For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously. USO enables NETIF_F_GSO_UDP_L4.

---
  drivers/net/tap.c | 18 ++++++++++++++++--
  drivers/net/tun.c | 15 ++++++++++++++-
  2 files changed, 30 insertions(+), 3 deletions(-)
drivers/net/tap.c +0 -0
index 8e3a28ba6b28..82d742ba78b1 100644

drivers/net/tap.c static int set_offload(struct tap_queue *q, unsigned long arg) · line 946

Quoted 7 lines
drivers/net/tap.c +4 -0
@@ -940,6 +940,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
  			if (arg & TUN_F_TSO6)
  				feature_mask |= NETIF_F_TSO6;
  		}
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
+			features |= NETIF_F_GSO_UDP_L4;

If kernel doesn't want to split the GSO_UDP features, I wonder how much value to keep separated features for TUN and virtio.

Thanks

Quoted 82 lines
drivers/net/tap.c +12 -2
  	}
 
  	/* tun/tap driver inverts the usage for TSO offloads, where
@@ -950,7 +954,8 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
  	 * When user space turns off TSO, we turn off GSO/LRO so that
  	 * user-space will not receive TSO frames.
  	 */
-	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
+	    feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
  		features |= RX_OFFLOADS;
  	else
  		features &= ~RX_OFFLOADS;
@@ -979,6 +984,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
  	unsigned short u;
  	int __user *sp = argp;
  	struct sockaddr sa;
+	unsigned int supported_offloads;
  	int s;
  	int ret;
 
@@ -1074,7 +1080,8 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
  	case TUNSETOFFLOAD:
  		/* let the user check for future flags */
  		if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-			    TUN_F_TSO_ECN | TUN_F_UFO))
+			    TUN_F_TSO_ECN | TUN_F_UFO |
+			    TUN_F_USO4 | TUN_F_USO6))
  			return -EINVAL;
 
  		rtnl_lock();
@@ -1082,6 +1089,13 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
  		rtnl_unlock();
  		return ret;
 
+	case TUNGETSUPPORTEDOFFLOADS:
+		supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+						TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+		if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+			return -EFAULT;
+		return 0;
+
  	case SIOCGIFHWADDR:
  		rtnl_lock();
  		tap = tap_get_tap_dev(q);
drivers/net/tun.c +8 -1
index fed85447701a..4f2105d1e6f1 100644
@@ -185,7 +185,7 @@ struct tun_struct {
  	struct net_device	*dev;
  	netdev_features_t	set_features;
  #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-			  NETIF_F_TSO6)
+			  NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4)
 
  	int			align;
  	int			vnet_hdr_sz;
@@ -2821,6 +2821,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
  		}
 
  		arg &= ~TUN_F_UFO;
+
+		/* TODO: for now USO4 and USO6 should work simultaneously */
+		if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
+			features |= NETIF_F_GSO_UDP_L4;
+			arg &= ~(TUN_F_USO4 | TUN_F_USO6);
+		}
  	}
 
  	/* This gives the user a way to test for new features in future by
@@ -2991,6 +2997,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
  	int sndbuf;
  	int vnet_hdr_sz;
  	int le;
+	unsigned int supported_offloads;
  	int ret;
  	bool do_notify = false;
 
@@ -3154,6 +3161,12 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
  	case TUNSETOFFLOAD:
  		ret = set_offload(tun, arg);

drivers/net/tun.c static long __tun_chr_ioctl(struct file *file, unsigned int cmd, · line 3172

Quoted 10 lines
drivers/net/tun.c +6 -0
  		break;
+	case TUNGETSUPPORTEDOFFLOADS:
+		supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+				TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+		if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+			ret = -EFAULT;
+		break;
 
  	case TUNSETTXFILTER:
  		/* Can be set only for TAPs */

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#11 lore raw

Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.

Quoted 30 lines · Jason Wang
Quoted 15 lines · Andrew Melnychenko

Added support for USO4 and USO6, also added code for new ioctl TUNGETSUPPORTEDOFFLOADS. For now, to "enable" USO, it's required to set both USO4 and USO6 simultaneously. USO enables NETIF_F_GSO_UDP_L4.

---
  drivers/net/tap.c | 18 ++++++++++++++++--
  drivers/net/tun.c | 15 ++++++++++++++-
  2 files changed, 30 insertions(+), 3 deletions(-)
drivers/net/tap.c +0 -0
index 8e3a28ba6b28..82d742ba78b1 100644

drivers/net/tap.c static int set_offload(struct tap_queue *q, unsigned long arg) · line 946

Quoted 7 lines
drivers/net/tap.c +4 -0
@@ -940,6 +940,10 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
                      if (arg & TUN_F_TSO6)
                              feature_mask |= NETIF_F_TSO6;
              }
+
+             /* TODO: for now USO4 and USO6 should work simultaneously */
+             if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
+                     features |= NETIF_F_GSO_UDP_L4;

If kernel doesn't want to split the GSO_UDP features, I wonder how much value to keep separated features for TUN and virtio.

Quoted 2 lines

Thanks

It's important for Windows guests that may request USO receive only for IPv4 or IPv6.
Or there is possible to implement one feature and change its "meanings" when "split" happens.
I think it's a good idea to implement an interface for iUSO4/USO6 and do it right away.

Quoted 94 lines
Quoted 93 lines
drivers/net/tap.c +12 -2
      }
 
      /* tun/tap driver inverts the usage for TSO offloads, where
@@ -950,7 +954,8 @@ static int set_offload(struct tap_queue *q, unsigned long arg)
       * When user space turns off TSO, we turn off GSO/LRO so that
       * user-space will not receive TSO frames.
       */
-     if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6))
+     if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
+         feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
              features |= RX_OFFLOADS;
      else
              features &= ~RX_OFFLOADS;
@@ -979,6 +984,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
      unsigned short u;
      int __user *sp = argp;
      struct sockaddr sa;
+     unsigned int supported_offloads;
      int s;
      int ret;
 
@@ -1074,7 +1080,8 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
      case TUNSETOFFLOAD:
              /* let the user check for future flags */
              if (arg & ~(TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
-                         TUN_F_TSO_ECN | TUN_F_UFO))
+                         TUN_F_TSO_ECN | TUN_F_UFO |
+                         TUN_F_USO4 | TUN_F_USO6))
                      return -EINVAL;
 
              rtnl_lock();
@@ -1082,6 +1089,13 @@ static long tap_ioctl(struct file *file, unsigned int cmd,
              rtnl_unlock();
              return ret;
 
+     case TUNGETSUPPORTEDOFFLOADS:
+             supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+                                             TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+             if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+                     return -EFAULT;
+             return 0;
+
      case SIOCGIFHWADDR:
              rtnl_lock();
              tap = tap_get_tap_dev(q);
drivers/net/tun.c +14 -1
index fed85447701a..4f2105d1e6f1 100644
@@ -185,7 +185,7 @@ struct tun_struct {
      struct net_device       *dev;
      netdev_features_t       set_features;
  #define TUN_USER_FEATURES (NETIF_F_HW_CSUM|NETIF_F_TSO_ECN|NETIF_F_TSO| \
-                       NETIF_F_TSO6)
+                       NETIF_F_TSO6 | NETIF_F_GSO_UDP_L4)
 
      int                     align;
      int                     vnet_hdr_sz;
@@ -2821,6 +2821,12 @@ static int set_offload(struct tun_struct *tun, unsigned long arg)
              }
 
              arg &= ~TUN_F_UFO;
+
+             /* TODO: for now USO4 and USO6 should work simultaneously */
+             if (arg & TUN_F_USO4 && arg & TUN_F_USO6) {
+                     features |= NETIF_F_GSO_UDP_L4;
+                     arg &= ~(TUN_F_USO4 | TUN_F_USO6);
+             }
      }
 
      /* This gives the user a way to test for new features in future by
@@ -2991,6 +2997,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
      int sndbuf;
      int vnet_hdr_sz;
      int le;
+     unsigned int supported_offloads;
      int ret;
      bool do_notify = false;
 
@@ -3154,6 +3161,12 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
      case TUNSETOFFLOAD:
              ret = set_offload(tun, arg);
              break;
+     case TUNGETSUPPORTEDOFFLOADS:
+             supported_offloads = TUN_F_CSUM | TUN_F_TSO4 | TUN_F_TSO6 |
+                             TUN_F_TSO_ECN | TUN_F_UFO | TUN_F_USO4 | TUN_F_USO6;
+             if (copy_to_user(&arg, &supported_offloads, sizeof(supported_offloads)))
+                     ret = -EFAULT;
+             break;
 
      case TUNSETTXFILTER:
              /* Can be set only for TAPs */
#12 lore raw

RFC PATCH 3/5 uapi/linux/virtio_net.h: Added USO types.

In reply to Andrew Melnychenko

Added new GSO type for USO: VIRTIO_NET_HDR_GSO_UDP_L4. Feature VIRTIO_NET_F_HOST_USO allows to enable NETIF_F_GSO_UDP_L4. Separated VIRTIO_NET_F_GUEST_USO4 & VIRTIO_NET_F_GUEST_USO6 features required for Windows guests.

---
 include/uapi/linux/virtio_net.h | 4 ++++
 1 file changed, 4 insertions(+)
include/uapi/linux/virtio_net.h +4 -0
index 3f55a4215f11..620addc5767b 100644
@@ -56,6 +56,9 @@
 #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
 					 * Steering */
 #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
+#define VIRTIO_NET_F_GUEST_USO4	54	/* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */
 
 #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
 #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
 #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */
 #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */
 #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4	5	/* GSO frame, IPv4 & IPv6 UDP (USO) */
 #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */
 	__u8 gso_type;
 	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#13 lore raw

Re: [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types.

Quoted 15 lines · Andrew Melnychenko

Added new GSO type for USO: VIRTIO_NET_HDR_GSO_UDP_L4. Feature VIRTIO_NET_F_HOST_USO allows to enable NETIF_F_GSO_UDP_L4. Separated VIRTIO_NET_F_GUEST_USO4 & VIRTIO_NET_F_GUEST_USO6 features required for Windows guests.

---
  include/uapi/linux/virtio_net.h | 4 ++++
  1 file changed, 4 insertions(+)
include/uapi/linux/virtio_net.h +0 -0
index 3f55a4215f11..620addc5767b 100644

include/uapi/linux/virtio_net.h line 61

Quoted 6 lines
include/uapi/linux/virtio_net.h +3 -0
@@ -56,6 +56,9 @@
  #define VIRTIO_NET_F_MQ	22	/* Device supports Receive Flow
  					 * Steering */
  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23	/* Set MAC address */
+#define VIRTIO_NET_F_GUEST_USO4	54	/* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6	55	/* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO	56	/* Host can handle USO in. */

I think it's better to be consistent here. Either we split in both guest and host or not.

Thanks

include/uapi/linux/virtio_net.h struct virtio_net_hdr_v1 { · line 139

Quoted 11 lines
include/uapi/linux/virtio_net.h +1 -0
  #define VIRTIO_NET_F_HASH_REPORT  57	/* Supports hash report */
  #define VIRTIO_NET_F_RSS	  60	/* Supports RSS RX steering */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
  #define VIRTIO_NET_HDR_GSO_TCPV4	1	/* GSO frame, IPv4 TCP (TSO) */
  #define VIRTIO_NET_HDR_GSO_UDP		3	/* GSO frame, IPv4 UDP (UFO) */
  #define VIRTIO_NET_HDR_GSO_TCPV6	4	/* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4	5	/* GSO frame, IPv4 & IPv6 UDP (USO) */
  #define VIRTIO_NET_HDR_GSO_ECN		0x80	/* TCP has ECN set */
  	__u8 gso_type;
  	__virtio16 hdr_len;	/* Ethernet + IP + tcp/udp hdrs */

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#14 lore raw

Re: [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types.

Hi all,

Quoted 29 lines · Jason Wang
Quoted 15 lines · Andrew Melnychenko

Added new GSO type for USO: VIRTIO_NET_HDR_GSO_UDP_L4. Feature VIRTIO_NET_F_HOST_USO allows to enable NETIF_F_GSO_UDP_L4. Separated VIRTIO_NET_F_GUEST_USO4 & VIRTIO_NET_F_GUEST_USO6 features required for Windows guests.

---
  include/uapi/linux/virtio_net.h | 4 ++++
  1 file changed, 4 insertions(+)
include/uapi/linux/virtio_net.h +0 -0
index 3f55a4215f11..620addc5767b 100644

include/uapi/linux/virtio_net.h line 61

Quoted 6 lines
include/uapi/linux/virtio_net.h +3 -0
@@ -56,6 +56,9 @@
  #define VIRTIO_NET_F_MQ     22      /* Device supports Receive Flow
                                       * Steering */
  #define VIRTIO_NET_F_CTRL_MAC_ADDR 23       /* Set MAC address */
+#define VIRTIO_NET_F_GUEST_USO4      54      /* Guest can handle USOv4 in. */
+#define VIRTIO_NET_F_GUEST_USO6      55      /* Guest can handle USOv6 in. */
+#define VIRTIO_NET_F_HOST_USO        56      /* Host can handle USO in. */

I think it's better to be consistent here. Either we split in both guest and host or not.

Quoted 2 lines

Thanks

The main reason that receives USO packets depends on the kernel, where transmitting the feature that VirtIO implements.
Windows systems have the option to manipulate receive offload. That's why there are two GUEST_USO features.
For HOST_USO - technically there is no point in "split" it, and there is should not be any difference between IPv4/IPv6. Technically, we either support transmitting big UDP packets or not.

Quoted 13 lines
Quoted 12 lines
include/uapi/linux/virtio_net.h +1 -0
  #define VIRTIO_NET_F_HASH_REPORT  57        /* Supports hash report */
  #define VIRTIO_NET_F_RSS      60    /* Supports RSS RX steering */
@@ -130,6 +133,7 @@ struct virtio_net_hdr_v1 {
  #define VIRTIO_NET_HDR_GSO_TCPV4    1       /* GSO frame, IPv4 TCP (TSO) */
  #define VIRTIO_NET_HDR_GSO_UDP              3       /* GSO frame, IPv4 UDP (UFO) */
  #define VIRTIO_NET_HDR_GSO_TCPV6    4       /* GSO frame, IPv6 TCP */
+#define VIRTIO_NET_HDR_GSO_UDP_L4    5       /* GSO frame, IPv4 & IPv6 UDP (USO) */
  #define VIRTIO_NET_HDR_GSO_ECN              0x80    /* TCP has ECN set */
      __u8 gso_type;
      __virtio16 hdr_len;     /* Ethernet + IP + tcp/udp hdrs */
#15 lore raw

RFC PATCH 4/5 linux/virtio_net.h: Added Support for GSO_UDP_L4 offload.

In reply to Andrew Melnychenko

Now, it's possible to convert vnet packets from/to skb.

---
 include/linux/virtio_net.h | 11 +++++++++++
 1 file changed, 11 insertions(+)
include/linux/virtio_net.h +11 -0
index a960de68ac69..9311d41d0a81 100644
@@ -17,6 +17,9 @@ static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
 	case VIRTIO_NET_HDR_GSO_UDP:
 		return protocol == cpu_to_be16(ETH_P_IP) ||
 		       protocol == cpu_to_be16(ETH_P_IPV6);
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
+		return protocol == cpu_to_be16(ETH_P_IP) ||
+		       protocol == cpu_to_be16(ETH_P_IPV6);
 	default:
 		return false;
 	}
@@ -31,6 +34,7 @@ static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
 	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
 	case VIRTIO_NET_HDR_GSO_TCPV4:
 	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
 		skb->protocol = cpu_to_be16(ETH_P_IP);
 		break;
 	case VIRTIO_NET_HDR_GSO_TCPV6:
@@ -69,6 +73,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
 			ip_proto = IPPROTO_UDP;
 			thlen = sizeof(struct udphdr);
 			break;
+		case VIRTIO_NET_HDR_GSO_UDP_L4:
+			gso_type = SKB_GSO_UDP_L4;
+			ip_proto = IPPROTO_UDP;
+			thlen = sizeof(struct udphdr);
+			break;
 		default:
 			return -EINVAL;
 		}
@@ -182,6 +191,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
 		else if (sinfo->gso_type & SKB_GSO_TCPV6)
 			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP_L4)
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP_L4;
 		else
 			return -EINVAL;
 		if (sinfo->gso_type & SKB_GSO_TCP_ECN)
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#16 lore raw

Re: [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload.

Quoted 1 line · Andrew Melnychenko

Now, it's possible to convert vnet packets from/to skb.

I suggest to change the title to "net: support XXX offload in vnet header"

Thanks

Quoted 41 lines
---
  include/linux/virtio_net.h | 11 +++++++++++
  1 file changed, 11 insertions(+)
include/linux/virtio_net.h +9 -0
index a960de68ac69..9311d41d0a81 100644
@@ -17,6 +17,9 @@ static inline bool virtio_net_hdr_match_proto(__be16 protocol, __u8 gso_type)
  	case VIRTIO_NET_HDR_GSO_UDP:
  		return protocol == cpu_to_be16(ETH_P_IP) ||
  		       protocol == cpu_to_be16(ETH_P_IPV6);
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
+		return protocol == cpu_to_be16(ETH_P_IP) ||
+		       protocol == cpu_to_be16(ETH_P_IPV6);
  	default:
  		return false;
  	}
@@ -31,6 +34,7 @@ static inline int virtio_net_hdr_set_proto(struct sk_buff *skb,
  	switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
  	case VIRTIO_NET_HDR_GSO_TCPV4:
  	case VIRTIO_NET_HDR_GSO_UDP:
+	case VIRTIO_NET_HDR_GSO_UDP_L4:
  		skb->protocol = cpu_to_be16(ETH_P_IP);
  		break;
  	case VIRTIO_NET_HDR_GSO_TCPV6:
@@ -69,6 +73,11 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb,
  			ip_proto = IPPROTO_UDP;
  			thlen = sizeof(struct udphdr);
  			break;
+		case VIRTIO_NET_HDR_GSO_UDP_L4:
+			gso_type = SKB_GSO_UDP_L4;
+			ip_proto = IPPROTO_UDP;
+			thlen = sizeof(struct udphdr);
+			break;
  		default:
  			return -EINVAL;
  		}

include/linux/virtio_net.h static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb, · line 198

Quoted 8 lines
include/linux/virtio_net.h +2 -0
@@ -182,6 +191,8 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
  			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4;
  		else if (sinfo->gso_type & SKB_GSO_TCPV6)
  			hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6;
+		else if (sinfo->gso_type & SKB_GSO_UDP_L4)
+			hdr->gso_type = VIRTIO_NET_HDR_GSO_UDP_L4;
  		else
  			return -EINVAL;
  		if (sinfo->gso_type & SKB_GSO_TCP_ECN)

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#17 lore raw

RFC PATCH 5/5 drivers/net/virtio_net.c: Added USO support.

In reply to Andrew Melnychenko

Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet.

---
 drivers/net/virtio_net.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
drivers/net/virtio_net.c +18 -4
index a801ea40908f..a45eee022be4 100644
@@ -60,13 +60,17 @@ static const unsigned long guest_offloads[] = {
 	VIRTIO_NET_F_GUEST_TSO6,
 	VIRTIO_NET_F_GUEST_ECN,
 	VIRTIO_NET_F_GUEST_UFO,
-	VIRTIO_NET_F_GUEST_CSUM
+	VIRTIO_NET_F_GUEST_CSUM,
+	VIRTIO_NET_F_GUEST_USO4,
+	VIRTIO_NET_F_GUEST_USO6
 };
 
 #define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
 				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
 				(1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
-				(1ULL << VIRTIO_NET_F_GUEST_UFO))
+				(1ULL << VIRTIO_NET_F_GUEST_UFO)  | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO4) | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO6))
 
 struct virtnet_stat_desc {
 	char desc[ETH_GSTRING_LEN];
@@ -2530,7 +2534,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
 	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
 		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
-		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6))) {
 		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
 		return -EOPNOTSUPP;
 	}
@@ -3155,6 +3161,8 @@ static int virtnet_probe(struct virtio_device *vdev)
 			dev->hw_features |= NETIF_F_TSO6;
 		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
 			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_USO))
+			dev->hw_features |= NETIF_F_GSO_UDP_L4;
 
 		dev->features |= NETIF_F_GSO_ROBUST;
 
@@ -3169,6 +3177,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->features |= NETIF_F_GRO_HW;
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
 		dev->hw_features |= NETIF_F_GRO_HW;
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6))
+		dev->hw_features |= NETIF_F_LRO;
 
 	dev->vlan_features = dev->features;
 
@@ -3200,7 +3211,9 @@ static int virtnet_probe(struct virtio_device *vdev)
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
 	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6))
 		vi->big_packets = true;
 
 	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))
@@ -3400,6 +3413,7 @@ static struct virtio_device_id id_table[] = {
 	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \
 	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \
 	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, \
+	VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_GUEST_USO4, VIRTIO_NET_F_GUEST_USO6, \
 	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, \
 	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, \
 	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \
Signature · 6 lines
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
#18 lore raw

Re: [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support.

Quoted 52 lines · Andrew Melnychenko

Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet.

---
  drivers/net/virtio_net.c | 22 ++++++++++++++++++----
  1 file changed, 18 insertions(+), 4 deletions(-)
drivers/net/virtio_net.c +11 -3
index a801ea40908f..a45eee022be4 100644
@@ -60,13 +60,17 @@ static const unsigned long guest_offloads[] = {
  	VIRTIO_NET_F_GUEST_TSO6,
  	VIRTIO_NET_F_GUEST_ECN,
  	VIRTIO_NET_F_GUEST_UFO,
-	VIRTIO_NET_F_GUEST_CSUM
+	VIRTIO_NET_F_GUEST_CSUM,
+	VIRTIO_NET_F_GUEST_USO4,
+	VIRTIO_NET_F_GUEST_USO6
  };
 
  #define GUEST_OFFLOAD_GRO_HW_MASK ((1ULL << VIRTIO_NET_F_GUEST_TSO4) | \
  				(1ULL << VIRTIO_NET_F_GUEST_TSO6) | \
  				(1ULL << VIRTIO_NET_F_GUEST_ECN)  | \
-				(1ULL << VIRTIO_NET_F_GUEST_UFO))
+				(1ULL << VIRTIO_NET_F_GUEST_UFO)  | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO4) | \
+				(1ULL << VIRTIO_NET_F_GUEST_USO6))
 
  struct virtnet_stat_desc {
  	char desc[ETH_GSTRING_LEN];
@@ -2530,7 +2534,9 @@ static int virtnet_xdp_set(struct net_device *dev, struct bpf_prog *prog,
  	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_TSO6) ||
  	        virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_ECN) ||
  		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_UFO) ||
-		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM))) {
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_CSUM) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO4) ||
+		virtio_has_feature(vi->vdev, VIRTIO_NET_F_GUEST_USO6))) {
  		NL_SET_ERR_MSG_MOD(extack, "Can't set XDP while host is implementing GRO_HW/CSUM, disable GRO_HW/CSUM first");
  		return -EOPNOTSUPP;
  	}
@@ -3155,6 +3161,8 @@ static int virtnet_probe(struct virtio_device *vdev)
  			dev->hw_features |= NETIF_F_TSO6;
  		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_ECN))
  			dev->hw_features |= NETIF_F_TSO_ECN;
+		if (virtio_has_feature(vdev, VIRTIO_NET_F_HOST_USO))
+			dev->hw_features |= NETIF_F_GSO_UDP_L4;
 
  		dev->features |= NETIF_F_GSO_ROBUST;
 

drivers/net/virtio_net.c static int virtnet_probe(struct virtio_device *vdev) · line 3182

Quoted 6 lines
drivers/net/virtio_net.c +3 -0
@@ -3169,6 +3177,9 @@ static int virtnet_probe(struct virtio_device *vdev)
  		dev->features |= NETIF_F_GRO_HW;
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_CTRL_GUEST_OFFLOADS))
  		dev->hw_features |= NETIF_F_GRO_HW;
+	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6))
+		dev->hw_features |= NETIF_F_LRO;

I think we need to use GRO_HW, see dbcf24d153884 ("virtio-net: use NETIF_F_GRO_HW instead of NETIF_F_LRO"

Thanks

Quoted 15 lines
drivers/net/virtio_net.c +3 -1
  	dev->vlan_features = dev->features;
 
@@ -3200,7 +3211,9 @@ static int virtnet_probe(struct virtio_device *vdev)
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO4) ||
  	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_TSO6) ||
  	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_ECN) ||
-	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO))
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_UFO) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO4) ||
+	    virtio_has_feature(vdev, VIRTIO_NET_F_GUEST_USO6))
  		vi->big_packets = true;
 
  	if (virtio_has_feature(vdev, VIRTIO_NET_F_MRG_RXBUF))

drivers/net/virtio_net.c static struct virtio_device_id id_table[] = { · line 3419

Quoted 7 lines
drivers/net/virtio_net.c +1 -0
@@ -3400,6 +3413,7 @@ static struct virtio_device_id id_table[] = {
  	VIRTIO_NET_F_HOST_TSO4, VIRTIO_NET_F_HOST_UFO, VIRTIO_NET_F_HOST_TSO6, \
  	VIRTIO_NET_F_HOST_ECN, VIRTIO_NET_F_GUEST_TSO4, VIRTIO_NET_F_GUEST_TSO6, \
  	VIRTIO_NET_F_GUEST_ECN, VIRTIO_NET_F_GUEST_UFO, \
+	VIRTIO_NET_F_HOST_USO, VIRTIO_NET_F_GUEST_USO4, VIRTIO_NET_F_GUEST_USO6, \
  	VIRTIO_NET_F_MRG_RXBUF, VIRTIO_NET_F_STATUS, VIRTIO_NET_F_CTRL_VQ, \
  	VIRTIO_NET_F_CTRL_RX, VIRTIO_NET_F_CTRL_VLAN, \
  	VIRTIO_NET_F_GUEST_ANNOUNCE, VIRTIO_NET_F_MQ, \

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

reviewer
#19 lore raw
In reply to Andrew Melnychenko
Quoted 11 lines · Andrew Melnychenko

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Quoted 4 lines

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Seems like this hasn't been upvoted yet.

https://github.com/oasis-tcs/virtio-spec#use-of-github-issues

Thanks.

Quoted 26 lines

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 18 ++++++++++++++++--
 drivers/net/tun.c               | 15 ++++++++++++++-
 drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
 include/linux/virtio_net.h      | 11 +++++++++++
 include/uapi/linux/if_tun.h     |  3 +++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 66 insertions(+), 7 deletions(-)

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#20 lore raw
Quoted 13 lines · Xuan Zhuo
Quoted 11 lines · Andrew Melnychenko

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Quoted 8 lines
Quoted 4 lines

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Seems like this hasn't been upvoted yet.

https://github.com/oasis-tcs/virtio-spec#use-of-github-issues

Yes, correct. This is a reason why this series of patches is RFC.

Quoted 29 lines

Thanks.

Quoted 26 lines

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 18 ++++++++++++++++--
 drivers/net/tun.c               | 15 ++++++++++++++-
 drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
 include/linux/virtio_net.h      | 11 +++++++++++
 include/uapi/linux/if_tun.h     |  3 +++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 66 insertions(+), 7 deletions(-)

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#21 lore raw

Hi people,
Can you please review this series?

Quoted 17 lines · Yuri Benditovich
Quoted 15 lines · Xuan Zhuo
Quoted 13 lines · Andrew Melnychenko

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

Quoted 38 lines
Quoted 6 lines
Quoted 2 lines

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Seems like this hasn't been upvoted yet.

https://github.com/oasis-tcs/virtio-spec#use-of-github-issues

Yes, correct. This is a reason why this series of patches is RFC.

Quoted 29 lines

Thanks.

Quoted 26 lines

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

 drivers/net/tap.c               | 18 ++++++++++++++++--
 drivers/net/tun.c               | 15 ++++++++++++++-
 drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
 include/linux/virtio_net.h      | 11 +++++++++++
 include/uapi/linux/if_tun.h     |  3 +++
 include/uapi/linux/virtio_net.h |  4 ++++
 6 files changed, 66 insertions(+), 7 deletions(-)

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

maintainer
#22 lore raw
Quoted 2 lines · On Tue, 8 Feb 2022 15:09:21 +0200 Andrew Melnichenko wrote:

Hi people,
Can you please review this series?

Adding Willem, he might be interested.

#23 lore raw
In reply to Andrew Melnichenko
Quoted 2 lines · Andrew Melnichenko

Hi people,
Can you please review this series?

Are there any performance number to demonstrate the difference?

Thanks

Quoted 45 lines
Quoted 42 lines · Yuri Benditovich
Quoted 12 lines · Xuan Zhuo
Quoted 11 lines · Andrew Melnychenko

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Quoted 7 lines
Quoted 4 lines

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Seems like this hasn't been upvoted yet.

https://github.com/oasis-tcs/virtio-spec#use-of-github-issues

Yes, correct. This is a reason why this series of patches is RFC.

Quoted 20 lines

Thanks.

Quoted 18 lines

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

  drivers/net/tap.c               | 18 ++++++++++++++++--
  drivers/net/tun.c               | 15 ++++++++++++++-
  drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
  include/linux/virtio_net.h      | 11 +++++++++++
  include/uapi/linux/if_tun.h     |  3 +++
  include/uapi/linux/virtio_net.h |  4 ++++
  6 files changed, 66 insertions(+), 7 deletions(-)
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

#24 lore raw

Hi all,

Quoted 11 lines · Jason Wang
Quoted 2 lines · Andrew Melnichenko

Hi people,
Can you please review this series?

Are there any performance number to demonstrate the difference?

Thanks

Yeah, I've used udpgso_bench from Linux to test.
Here are some numbers:

Sending packets with size 10000

Without USO:

```
$ ./udpgso_bench_tx -4 -D 192.168.15.1 -s 10000 -S 1000
random: crng init done
random: 7 urandom warning(s) missed due to ratelimiting
udp tx:     36 MB/s     3863 calls/s   3863 msg/s
udp tx:     32 MB/s     3360 calls/s   3360 msg/s
udp tx:     31 MB/s     3340 calls/s   3340 msg/s
udp tx:     31 MB/s     3353 calls/s   3353 msg/s
udp tx:     32 MB/s     3359 calls/s   3359 msg/s
udp tx:     32 MB/s     3370 calls/s   3370 msg/s
```

With USO:

```
$ ./udpgso_bench_tx -4 -D 192.168.15.1 -s 10000 -S 1000
random: crng init done
random: 7 urandom warning(s) missed due to ratelimiting
udp tx:    120 MB/s    12596 calls/s  12596 msg/s
udp tx:    122 MB/s    12885 calls/s  12885 msg/s
udp tx:    120 MB/s    12667 calls/s  12667 msg/s
udp tx:    123 MB/s    12969 calls/s  12969 msg/s
udp tx:    116 MB/s    12232 calls/s  12232 msg/s
udp tx:    108 MB/s    11389 calls/s  11389 msg/s
```
Quoted 54 lines
Quoted 53 lines
Quoted 49 lines · Yuri Benditovich
Quoted 12 lines · Xuan Zhuo
Quoted 11 lines · Andrew Melnychenko

Added new offloads for TUN devices TUN_F_USO4 and TUN_F_USO6. Technically they enable NETIF_F_GSO_UDP_L4
(and only if USO4 & USO6 are set simultaneously). It allows to transmission of large UDP packets.

Different features USO4 and USO6 are required for qemu where Windows guests can enable disable USO receives for IPv4 and IPv6 separately.
On the other side, Linux can't really differentiate USO4 and USO6, for now. For now, to enable USO for TUN it requires enabling USO4 and USO6 together. In the future, there would be a mechanism to control UDP_L4 GSO separately.

Quoted 7 lines
Quoted 4 lines

Test it WIP Qemu https://github.com/daynix/qemu/tree/Dev_USOv2

New types for VirtioNet already on mailing:
https://lists.oasis-open.org/archives/virtio-comment/202110/msg00010.html

Seems like this hasn't been upvoted yet.

https://github.com/oasis-tcs/virtio-spec#use-of-github-issues

Yes, correct. This is a reason why this series of patches is RFC.

Quoted 27 lines

Thanks.

Quoted 25 lines

Also, there is a known issue with transmitting packages between two guests. Without hacks with skb's GSO - packages are still segmented on the host's postrouting.

Andrew Melnychenko (5):
uapi/linux/if_tun.h: Added new ioctl for tun/tap. driver/net/tun: Added features for USO. uapi/linux/virtio_net.h: Added USO types. linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. drivers/net/virtio_net.c: Added USO support.

  drivers/net/tap.c               | 18 ++++++++++++++++--
  drivers/net/tun.c               | 15 ++++++++++++++-
  drivers/net/virtio_net.c        | 22 ++++++++++++++++++----
  include/linux/virtio_net.h      | 11 +++++++++++
  include/uapi/linux/if_tun.h     |  3 +++
  include/uapi/linux/virtio_net.h |  4 ++++
  6 files changed, 66 insertions(+), 7 deletions(-)

--
2.34.1

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization