All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/5] TUN/VirtioNet USO features support.
@ 2022-01-25  8:46 Andrew Melnychenko
  2022-01-25  8:46 ` [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap Andrew Melnychenko
                   ` (5 more replies)
  0 siblings, 6 replies; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:46 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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(-)

-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
@ 2022-01-25  8:46 ` Andrew Melnychenko
  2022-02-09  4:25   ` Jason Wang
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:46 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/if_tun.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
index 454ae31b93c7..07680fae6e18 100644
--- a/include/uapi/linux/if_tun.h
+++ b/include/uapi/linux/if_tun.h
@@ -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
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
  2022-01-25  8:46 ` [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap Andrew Melnychenko
@ 2022-01-25  8:46 ` Andrew Melnychenko
  2022-01-25 13:42     ` kernel test robot
                     ` (2 more replies)
  2022-01-25  8:47 ` [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types Andrew Melnychenko
                   ` (3 subsequent siblings)
  5 siblings, 3 replies; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:46 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/tap.c | 18 ++++++++++++++++--
 drivers/net/tun.c | 15 ++++++++++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 8e3a28ba6b28..82d742ba78b1 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -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);
diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index fed85447701a..4f2105d1e6f1 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -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 */
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
  2022-01-25  8:46 ` [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap Andrew Melnychenko
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
@ 2022-01-25  8:47 ` Andrew Melnychenko
  2022-02-09  4:41   ` Jason Wang
  2022-01-25  8:47 ` [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload Andrew Melnychenko
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:47 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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.

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/uapi/linux/virtio_net.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
index 3f55a4215f11..620addc5767b 100644
--- a/include/uapi/linux/virtio_net.h
+++ b/include/uapi/linux/virtio_net.h
@@ -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 */
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
                   ` (2 preceding siblings ...)
  2022-01-25  8:47 ` [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types Andrew Melnychenko
@ 2022-01-25  8:47 ` Andrew Melnychenko
  2022-02-09  4:42   ` Jason Wang
  2022-01-25  8:47 ` [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support Andrew Melnychenko
  2022-01-26  7:52 ` [RFC PATCH 0/5] TUN/VirtioNet USO features support Xuan Zhuo
  5 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:47 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 include/linux/virtio_net.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index a960de68ac69..9311d41d0a81 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -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)
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
                   ` (3 preceding siblings ...)
  2022-01-25  8:47 ` [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload Andrew Melnychenko
@ 2022-01-25  8:47 ` Andrew Melnychenko
  2022-02-09  4:44   ` Jason Wang
  2022-01-26  7:52 ` [RFC PATCH 0/5] TUN/VirtioNet USO features support Xuan Zhuo
  5 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnychenko @ 2022-01-25  8:47 UTC (permalink / raw)
  To: davem, kuba, mst, jasowang, netdev, linux-kernel, virtualization
  Cc: yan, yuri.benditovich

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

Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
---
 drivers/net/virtio_net.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index a801ea40908f..a45eee022be4 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -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, \
-- 
2.34.1

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
@ 2022-01-25 13:42     ` kernel test robot
  2022-01-25 15:14   ` kernel test robot
  2022-02-09  4:39   ` Jason Wang
  2 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2022-01-25 13:42 UTC (permalink / raw)
  To: Andrew Melnychenko; +Cc: llvm, kbuild-all

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@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
Reported-by: kernel test robot <lkp@intel.com>

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@lists.01.org

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
@ 2022-01-25 13:42     ` kernel test robot
  0 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2022-01-25 13:42 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 5705 bytes --]

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
Reported-by: kernel test robot <lkp@intel.com>

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
  2022-01-25 13:42     ` kernel test robot
@ 2022-01-25 15:14   ` kernel test robot
  2022-02-09  4:39   ` Jason Wang
  2 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2022-01-25 15:14 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 4285 bytes --]

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
Reported-by: kernel test robot <lkp@intel.com>

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 0/5] TUN/VirtioNet USO features support.
  2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
                   ` (4 preceding siblings ...)
  2022-01-25  8:47 ` [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support Andrew Melnychenko
@ 2022-01-26  7:52 ` Xuan Zhuo
  2022-01-26  8:32   ` Yuri Benditovich
  5 siblings, 1 reply; 27+ messages in thread
From: Xuan Zhuo @ 2022-01-26  7:52 UTC (permalink / raw)
  To: Andrew Melnychenko
  Cc: mst, netdev, linux-kernel, virtualization, yuri.benditovich, yan,
	kuba, davem

On Tue, 25 Jan 2022 10:46:57 +0200, Andrew Melnychenko <andrew@daynix.com> wrote:
> 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

Seems like this hasn't been upvoted yet.

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

Thanks.

>
> 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
> Virtualization@lists.linux-foundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/virtualization
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 0/5] TUN/VirtioNet USO features support.
  2022-01-26  7:52 ` [RFC PATCH 0/5] TUN/VirtioNet USO features support Xuan Zhuo
@ 2022-01-26  8:32   ` Yuri Benditovich
  2022-02-08 13:09     ` Andrew Melnichenko
  0 siblings, 1 reply; 27+ messages in thread
From: Yuri Benditovich @ 2022-01-26  8:32 UTC (permalink / raw)
  To: Xuan Zhuo
  Cc: Andrew Melnychenko, Michael S . Tsirkin, Network Development,
	LKML, virtualization, Yan Vugenfirer, Jakub Kicinski,
	David S. Miller

On Wed, Jan 26, 2022 at 9:54 AM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> On Tue, 25 Jan 2022 10:46:57 +0200, Andrew Melnychenko <andrew@daynix.com> wrote:
> > 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
>
> 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.

>
> Thanks.
>
> >
> > 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
> > Virtualization@lists.linux-foundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/virtualization
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
@ 2022-01-27  7:21 ` Dan Carpenter
  2022-01-25 15:14   ` kernel test robot
  2022-02-09  4:39   ` Jason Wang
  2 siblings, 0 replies; 27+ messages in thread
From: kernel test robot @ 2022-01-26 23:48 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 7287 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20220125084702.3636253-3-andrew@daynix.com>
References: <20220125084702.3636253-3-andrew@daynix.com>
TO: Andrew Melnychenko <andrew@daynix.com>

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
:::::: branch date: 2 days ago
:::::: commit date: 2 days ago
config: openrisc-randconfig-m031-20220124 (https://download.01.org/0day-ci/archive/20220127/202201270710.TzXKgCWT-lkp(a)intel.com/config)
compiler: or1k-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/net/tap.c:945 set_offload() warn: compare has higher precedence than mask
drivers/net/tap.c:945 set_offload() warn: add some parenthesis here?

Old smatch warnings:
drivers/net/tap.c:958 set_offload() warn: compare has higher precedence than mask
drivers/net/tap.c:958 set_offload() warn: add some parenthesis here?

vim +945 drivers/net/tap.c

815f236d622721b drivers/net/macvtap.c Jason Wang         2013-06-05  919  
635b8c8ecdd2714 drivers/net/tap.c     Sainath Grandhi    2017-02-10  920  static int set_offload(struct tap_queue *q, unsigned long arg)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  921  {
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  922  	struct tap_dev *tap;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  923  	netdev_features_t features;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  924  	netdev_features_t feature_mask = 0;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  925  
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  926  	tap = rtnl_dereference(q->tap);
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  927  	if (!tap)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  928  		return -ENOLINK;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  929  
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  930  	features = tap->dev->features;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  931  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  932  	if (arg & TUN_F_CSUM) {
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  933  		feature_mask = NETIF_F_HW_CSUM;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  934  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  935  		if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) {
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  936  			if (arg & TUN_F_TSO_ECN)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  937  				feature_mask |= NETIF_F_TSO_ECN;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  938  			if (arg & TUN_F_TSO4)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  939  				feature_mask |= NETIF_F_TSO;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  940  			if (arg & TUN_F_TSO6)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  941  				feature_mask |= NETIF_F_TSO6;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  942  		}
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  943  
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  944  		/* TODO: for now USO4 and USO6 should work simultaneously */
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25 @945  		if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  946  			features |= NETIF_F_GSO_UDP_L4;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  947  	}
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  948  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  949  	/* tun/tap driver inverts the usage for TSO offloads, where
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  950  	 * setting the TSO bit means that the userspace wants to
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  951  	 * accept TSO frames and turning it off means that user space
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  952  	 * does not support TSO.
635b8c8ecdd2714 drivers/net/tap.c     Sainath Grandhi    2017-02-10  953  	 * For tap, we have to invert it to mean the same thing.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  954  	 * When user space turns off TSO, we turn off GSO/LRO so that
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  955  	 * user-space will not receive TSO frames.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  956  	 */
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  957  	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  958  	    feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  959  		features |= RX_OFFLOADS;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  960  	else
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  961  		features &= ~RX_OFFLOADS;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  962  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  963  	/* tap_features are the same as features on tun/tap and
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  964  	 * reflect user expectations.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  965  	 */
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  966  	tap->tap_features = feature_mask;
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  967  	if (tap->update_features)
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  968  		tap->update_features(tap, features);
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  969  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  970  	return 0;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  971  }
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  972  

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
@ 2022-01-27  7:21 ` Dan Carpenter
  0 siblings, 0 replies; 27+ messages in thread
From: Dan Carpenter @ 2022-01-27  7:21 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6544 bytes --]

Hi Andrew,

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: openrisc-randconfig-m031-20220124 (https://download.01.org/0day-ci/archive/20220127/202201270710.TzXKgCWT-lkp(a)intel.com/config)
compiler: or1k-linux-gcc (GCC) 11.2.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/net/tap.c:945 set_offload() warn: compare has higher precedence than mask
drivers/net/tap.c:945 set_offload() warn: add some parenthesis here?

Old smatch warnings:
drivers/net/tap.c:958 set_offload() warn: compare has higher precedence than mask
drivers/net/tap.c:958 set_offload() warn: add some parenthesis here?

vim +945 drivers/net/tap.c

635b8c8ecdd2714 drivers/net/tap.c     Sainath Grandhi    2017-02-10  920  static int set_offload(struct tap_queue *q, unsigned long arg)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  921  {
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  922  	struct tap_dev *tap;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  923  	netdev_features_t features;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  924  	netdev_features_t feature_mask = 0;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  925  
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  926  	tap = rtnl_dereference(q->tap);
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  927  	if (!tap)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  928  		return -ENOLINK;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  929  
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  930  	features = tap->dev->features;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  931  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  932  	if (arg & TUN_F_CSUM) {
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  933  		feature_mask = NETIF_F_HW_CSUM;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  934  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  935  		if (arg & (TUN_F_TSO4 | TUN_F_TSO6)) {
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  936  			if (arg & TUN_F_TSO_ECN)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  937  				feature_mask |= NETIF_F_TSO_ECN;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  938  			if (arg & TUN_F_TSO4)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  939  				feature_mask |= NETIF_F_TSO;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  940  			if (arg & TUN_F_TSO6)
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  941  				feature_mask |= NETIF_F_TSO6;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  942  		}
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  943  
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  944  		/* TODO: for now USO4 and USO6 should work simultaneously */
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25 @945  		if (arg & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))

This is equivalent to if (arg & 1).

3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  946  			features |= NETIF_F_GSO_UDP_L4;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  947  	}
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  948  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  949  	/* tun/tap driver inverts the usage for TSO offloads, where
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  950  	 * setting the TSO bit means that the userspace wants to
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  951  	 * accept TSO frames and turning it off means that user space
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  952  	 * does not support TSO.
635b8c8ecdd2714 drivers/net/tap.c     Sainath Grandhi    2017-02-10  953  	 * For tap, we have to invert it to mean the same thing.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  954  	 * When user space turns off TSO, we turn off GSO/LRO so that
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  955  	 * user-space will not receive TSO frames.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  956  	 */
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  957  	if (feature_mask & (NETIF_F_TSO | NETIF_F_TSO6) ||
3c1c2daa10c8eac drivers/net/tap.c     Andrew Melnychenko 2022-01-25  958  	    feature_mask & (TUN_F_USO4 | TUN_F_USO6) == (TUN_F_USO4 | TUN_F_USO6))

Same same

2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  959  		features |= RX_OFFLOADS;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  960  	else
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  961  		features &= ~RX_OFFLOADS;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  962  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  963  	/* tap_features are the same as features on tun/tap and
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  964  	 * reflect user expectations.
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  965  	 */
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  966  	tap->tap_features = feature_mask;
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  967  	if (tap->update_features)
6fe3faf86757eb7 drivers/net/tap.c     Sainath Grandhi    2017-02-10  968  		tap->update_features(tap, features);
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  969  
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  970  	return 0;
2be5c76794b0e57 drivers/net/macvtap.c Vlad Yasevich      2013-06-25  971  }

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 0/5] TUN/VirtioNet USO features support.
  2022-01-26  8:32   ` Yuri Benditovich
@ 2022-02-08 13:09     ` Andrew Melnichenko
  2022-02-09  5:41       ` Jason Wang
  0 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnichenko @ 2022-02-08 13:09 UTC (permalink / raw)
  To: Yuri Benditovich
  Cc: Michael S . Tsirkin, Network Development, LKML, virtualization,
	Yan Vugenfirer, Jakub Kicinski, David S. Miller

Hi people,
Can you please review this series?

On Wed, Jan 26, 2022 at 10:32 AM Yuri Benditovich
<yuri.benditovich@daynix.com> wrote:
>
> On Wed, Jan 26, 2022 at 9:54 AM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> >
> > On Tue, 25 Jan 2022 10:46:57 +0200, Andrew Melnychenko <andrew@daynix.com> wrote:
> > > 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
> >
> > 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.
>
> >
> > Thanks.
> >
> > >
> > > 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
> > > Virtualization@lists.linux-foundation.org
> > > https://lists.linuxfoundation.org/mailman/listinfo/virtualization
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-01-25  8:46 ` [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap Andrew Melnychenko
@ 2022-02-09  4:25   ` Jason Wang
  2022-02-22 13:28     ` Andrew Melnichenko
  0 siblings, 1 reply; 27+ messages in thread
From: Jason Wang @ 2022-02-09  4:25 UTC (permalink / raw)
  To: Andrew Melnychenko, davem, kuba, mst, netdev, linux-kernel,
	virtualization
  Cc: yan, yuri.benditovich


在 2022/1/25 下午4:46, 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


> 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.
>
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>   include/uapi/linux/if_tun.h | 3 +++
>   1 file changed, 3 insertions(+)
>
> diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> index 454ae31b93c7..07680fae6e18 100644
> --- a/include/uapi/linux/if_tun.h
> +++ b/include/uapi/linux/if_tun.h
> @@ -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

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
  2022-01-25 13:42     ` kernel test robot
  2022-01-25 15:14   ` kernel test robot
@ 2022-02-09  4:39   ` Jason Wang
  2022-02-22 13:22     ` Andrew Melnichenko
  2 siblings, 1 reply; 27+ messages in thread
From: Jason Wang @ 2022-02-09  4:39 UTC (permalink / raw)
  To: Andrew Melnychenko, davem, kuba, mst, netdev, linux-kernel,
	virtualization
  Cc: yan, yuri.benditovich


在 2022/1/25 下午4:46, 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.
>
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>   drivers/net/tap.c | 18 ++++++++++++++++--
>   drivers/net/tun.c | 15 ++++++++++++++-
>   2 files changed, 30 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index 8e3a28ba6b28..82d742ba78b1 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -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


>   	}
>   
>   	/* 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);
> diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> index fed85447701a..4f2105d1e6f1 100644
> --- a/drivers/net/tun.c
> +++ b/drivers/net/tun.c
> @@ -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 */

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types.
  2022-01-25  8:47 ` [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types Andrew Melnychenko
@ 2022-02-09  4:41   ` Jason Wang
  2022-02-22 13:14     ` Andrew Melnichenko
  0 siblings, 1 reply; 27+ messages in thread
From: Jason Wang @ 2022-02-09  4:41 UTC (permalink / raw)
  To: Andrew Melnychenko, davem, kuba, mst, netdev, linux-kernel,
	virtualization
  Cc: yan, yuri.benditovich


在 2022/1/25 下午4:47, 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.
>
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>   include/uapi/linux/virtio_net.h | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
> index 3f55a4215f11..620addc5767b 100644
> --- a/include/uapi/linux/virtio_net.h
> +++ b/include/uapi/linux/virtio_net.h
> @@ -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


>   
>   #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
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload.
  2022-01-25  8:47 ` [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload Andrew Melnychenko
@ 2022-02-09  4:42   ` Jason Wang
  0 siblings, 0 replies; 27+ messages in thread
From: Jason Wang @ 2022-02-09  4:42 UTC (permalink / raw)
  To: Andrew Melnychenko, davem, kuba, mst, netdev, linux-kernel,
	virtualization
  Cc: yan, yuri.benditovich


在 2022/1/25 下午4:47, 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


>
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>   include/linux/virtio_net.h | 11 +++++++++++
>   1 file changed, 11 insertions(+)
>
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index a960de68ac69..9311d41d0a81 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
> @@ -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)

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support.
  2022-01-25  8:47 ` [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support Andrew Melnychenko
@ 2022-02-09  4:44   ` Jason Wang
  0 siblings, 0 replies; 27+ messages in thread
From: Jason Wang @ 2022-02-09  4:44 UTC (permalink / raw)
  To: Andrew Melnychenko, davem, kuba, mst, netdev, linux-kernel,
	virtualization
  Cc: yan, yuri.benditovich


在 2022/1/25 下午4:47, Andrew Melnychenko 写道:
> Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet.
>
> Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> ---
>   drivers/net/virtio_net.c | 22 ++++++++++++++++++----
>   1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index a801ea40908f..a45eee022be4 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -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;


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

Thanks


>   
>   	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, \

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 0/5] TUN/VirtioNet USO features support.
  2022-02-08 13:09     ` Andrew Melnichenko
@ 2022-02-09  5:41       ` Jason Wang
  2022-02-22 13:05         ` Andrew Melnichenko
  0 siblings, 1 reply; 27+ messages in thread
From: Jason Wang @ 2022-02-09  5:41 UTC (permalink / raw)
  To: Andrew Melnichenko, Yuri Benditovich
  Cc: Michael S . Tsirkin, Network Development, LKML, virtualization,
	Yan Vugenfirer, Jakub Kicinski, David S. Miller


在 2022/2/8 下午9:09, Andrew Melnichenko 写道:
> Hi people,
> Can you please review this series?


Are there any performance number to demonstrate the difference?

Thanks


>
> On Wed, Jan 26, 2022 at 10:32 AM Yuri Benditovich
> <yuri.benditovich@daynix.com> wrote:
>> On Wed, Jan 26, 2022 at 9:54 AM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>>> On Tue, 25 Jan 2022 10:46:57 +0200, Andrew Melnychenko <andrew@daynix.com> wrote:
>>>> 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
>>> 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.
>>
>>> Thanks.
>>>
>>>> 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
>>>> Virtualization@lists.linux-foundation.org
>>>> https://lists.linuxfoundation.org/mailman/listinfo/virtualization

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 0/5] TUN/VirtioNet USO features support.
  2022-02-09  5:41       ` Jason Wang
@ 2022-02-22 13:05         ` Andrew Melnichenko
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew Melnichenko @ 2022-02-22 13:05 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S . Tsirkin, Network Development, LKML, virtualization,
	Yuri Benditovich, Yan Vugenfirer, Jakub Kicinski, David S. Miller

Hi all,

On Wed, Feb 9, 2022 at 7:41 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/2/8 下午9:09, 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
```


>
> >
> > On Wed, Jan 26, 2022 at 10:32 AM Yuri Benditovich
> > <yuri.benditovich@daynix.com> wrote:
> >> On Wed, Jan 26, 2022 at 9:54 AM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> >>> On Tue, 25 Jan 2022 10:46:57 +0200, Andrew Melnychenko <andrew@daynix.com> wrote:
> >>>> 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
> >>> 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.
> >>
> >>> Thanks.
> >>>
> >>>> 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
> >>>> Virtualization@lists.linux-foundation.org
> >>>> https://lists.linuxfoundation.org/mailman/listinfo/virtualization
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types.
  2022-02-09  4:41   ` Jason Wang
@ 2022-02-22 13:14     ` Andrew Melnichenko
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew Melnichenko @ 2022-02-22 13:14 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, Network Development, LKML, virtualization,
	Yuri Benditovich, Yan Vugenfirer, Jakub Kicinski, David S. Miller

Hi all,



On Wed, Feb 9, 2022 at 6:41 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/25 下午4:47, 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.
> >
> > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > ---
> >   include/uapi/linux/virtio_net.h | 4 ++++
> >   1 file changed, 4 insertions(+)
> >
> > diff --git a/include/uapi/linux/virtio_net.h b/include/uapi/linux/virtio_net.h
> > index 3f55a4215f11..620addc5767b 100644
> > --- a/include/uapi/linux/virtio_net.h
> > +++ b/include/uapi/linux/virtio_net.h
> > @@ -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
>

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.

>
> >
> >   #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
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 2/5] driver/net/tun: Added features for USO.
  2022-02-09  4:39   ` Jason Wang
@ 2022-02-22 13:22     ` Andrew Melnichenko
  0 siblings, 0 replies; 27+ messages in thread
From: Andrew Melnichenko @ 2022-02-22 13:22 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, Network Development, LKML, virtualization,
	Yuri Benditovich, Yan Vugenfirer, Jakub Kicinski, David S. Miller

On Wed, Feb 9, 2022 at 6:39 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/25 下午4:46, 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.
> >
> > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > ---
> >   drivers/net/tap.c | 18 ++++++++++++++++--
> >   drivers/net/tun.c | 15 ++++++++++++++-
> >   2 files changed, 30 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> > index 8e3a28ba6b28..82d742ba78b1 100644
> > --- a/drivers/net/tap.c
> > +++ b/drivers/net/tap.c
> > @@ -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
>

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.

>
> >       }
> >
> >       /* 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);
> > diff --git a/drivers/net/tun.c b/drivers/net/tun.c
> > index fed85447701a..4f2105d1e6f1 100644
> > --- a/drivers/net/tun.c
> > +++ b/drivers/net/tun.c
> > @@ -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 */
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-02-09  4:25   ` Jason Wang
@ 2022-02-22 13:28     ` Andrew Melnichenko
  2022-02-23  3:53       ` Jason Wang
  0 siblings, 1 reply; 27+ messages in thread
From: Andrew Melnichenko @ 2022-02-22 13:28 UTC (permalink / raw)
  To: Jason Wang
  Cc: Michael S. Tsirkin, Network Development, LKML, virtualization,
	Yuri Benditovich, Yan Vugenfirer, Jakub Kicinski, David S. Miller

Hi all,

On Wed, Feb 9, 2022 at 6:26 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> 在 2022/1/25 下午4:46, 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
>

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.

>
> > 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.
> >
> > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > ---
> >   include/uapi/linux/if_tun.h | 3 +++
> >   1 file changed, 3 insertions(+)
> >
> > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > index 454ae31b93c7..07680fae6e18 100644
> > --- a/include/uapi/linux/if_tun.h
> > +++ b/include/uapi/linux/if_tun.h
> > @@ -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
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-02-22 13:28     ` Andrew Melnichenko
@ 2022-02-23  3:53       ` Jason Wang
  2022-02-23 13:31         ` Yuri Benditovich
  0 siblings, 1 reply; 27+ messages in thread
From: Jason Wang @ 2022-02-23  3:53 UTC (permalink / raw)
  To: Andrew Melnichenko
  Cc: Michael S. Tsirkin, Network Development, LKML, virtualization,
	Yuri Benditovich, Yan Vugenfirer, Jakub Kicinski, David S. Miller

On Tue, Feb 22, 2022 at 9:28 PM Andrew Melnichenko <andrew@daynix.com> wrote:
>
> Hi all,
>
> On Wed, Feb 9, 2022 at 6:26 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> >
> > 在 2022/1/25 下午4:46, 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
> >
>
> 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.

> 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

>
> >
> > > 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.
> > >
> > > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > > ---
> > >   include/uapi/linux/if_tun.h | 3 +++
> > >   1 file changed, 3 insertions(+)
> > >
> > > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > > index 454ae31b93c7..07680fae6e18 100644
> > > --- a/include/uapi/linux/if_tun.h
> > > +++ b/include/uapi/linux/if_tun.h
> > > @@ -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
> >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-02-23  3:53       ` Jason Wang
@ 2022-02-23 13:31         ` Yuri Benditovich
  2022-02-24  3:33           ` Jason Wang
  0 siblings, 1 reply; 27+ messages in thread
From: Yuri Benditovich @ 2022-02-23 13:31 UTC (permalink / raw)
  To: Jason Wang
  Cc: Andrew Melnichenko, Michael S. Tsirkin, Network Development, LKML,
	virtualization, Yan Vugenfirer, Jakub Kicinski, David S. Miller

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


On Wed, Feb 23, 2022 at 5:53 AM Jason Wang <jasowang@redhat.com> wrote:
>
> On Tue, Feb 22, 2022 at 9:28 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> >
> > Hi all,
> >
> > On Wed, Feb 9, 2022 at 6:26 AM Jason Wang <jasowang@redhat.com> wrote:
> > >
> > >
> > > 在 2022/1/25 下午4:46, 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
> > >
> >
> > 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.
>
> > 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
>
> >
> > >
> > > > 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.
> > > >
> > > > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > > > ---
> > > >   include/uapi/linux/if_tun.h | 3 +++
> > > >   1 file changed, 3 insertions(+)
> > > >
> > > > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > > > index 454ae31b93c7..07680fae6e18 100644
> > > > --- a/include/uapi/linux/if_tun.h
> > > > +++ b/include/uapi/linux/if_tun.h
> > > > @@ -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
> > >
> >
>
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap.
  2022-02-23 13:31         ` Yuri Benditovich
@ 2022-02-24  3:33           ` Jason Wang
  0 siblings, 0 replies; 27+ messages in thread
From: Jason Wang @ 2022-02-24  3:33 UTC (permalink / raw)
  To: Yuri Benditovich
  Cc: Andrew Melnichenko, Michael S. Tsirkin, Network Development, LKML,
	virtualization, Yan Vugenfirer, Jakub Kicinski, David S. Miller

On Wed, Feb 23, 2022 at 9:31 PM Yuri Benditovich
<yuri.benditovich@daynix.com> wrote:
>
> 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.

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

We can discuss this when qemu patches were sent.

> 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

>
> Thanks
>
>
> On Wed, Feb 23, 2022 at 5:53 AM Jason Wang <jasowang@redhat.com> wrote:
> >
> > On Tue, Feb 22, 2022 at 9:28 PM Andrew Melnichenko <andrew@daynix.com> wrote:
> > >
> > > Hi all,
> > >
> > > On Wed, Feb 9, 2022 at 6:26 AM Jason Wang <jasowang@redhat.com> wrote:
> > > >
> > > >
> > > > 在 2022/1/25 下午4:46, 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
> > > >
> > >
> > > 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.
> >
> > > 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
> >
> > >
> > > >
> > > > > 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.
> > > > >
> > > > > Signed-off-by: Andrew Melnychenko <andrew@daynix.com>
> > > > > ---
> > > > >   include/uapi/linux/if_tun.h | 3 +++
> > > > >   1 file changed, 3 insertions(+)
> > > > >
> > > > > diff --git a/include/uapi/linux/if_tun.h b/include/uapi/linux/if_tun.h
> > > > > index 454ae31b93c7..07680fae6e18 100644
> > > > > --- a/include/uapi/linux/if_tun.h
> > > > > +++ b/include/uapi/linux/if_tun.h
> > > > > @@ -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
> > > >
> > >
> >
>

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2022-02-24  3:34 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-26 23:48 [RFC PATCH 2/5] driver/net/tun: Added features for USO kernel test robot
2022-01-27  7:21 ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2022-01-25  8:46 [RFC PATCH 0/5] TUN/VirtioNet USO features support Andrew Melnychenko
2022-01-25  8:46 ` [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap Andrew Melnychenko
2022-02-09  4:25   ` Jason Wang
2022-02-22 13:28     ` Andrew Melnichenko
2022-02-23  3:53       ` Jason Wang
2022-02-23 13:31         ` Yuri Benditovich
2022-02-24  3:33           ` Jason Wang
2022-01-25  8:46 ` [RFC PATCH 2/5] driver/net/tun: Added features for USO Andrew Melnychenko
2022-01-25 13:42   ` kernel test robot
2022-01-25 13:42     ` kernel test robot
2022-01-25 15:14   ` kernel test robot
2022-02-09  4:39   ` Jason Wang
2022-02-22 13:22     ` Andrew Melnichenko
2022-01-25  8:47 ` [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types Andrew Melnychenko
2022-02-09  4:41   ` Jason Wang
2022-02-22 13:14     ` Andrew Melnichenko
2022-01-25  8:47 ` [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload Andrew Melnychenko
2022-02-09  4:42   ` Jason Wang
2022-01-25  8:47 ` [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support Andrew Melnychenko
2022-02-09  4:44   ` Jason Wang
2022-01-26  7:52 ` [RFC PATCH 0/5] TUN/VirtioNet USO features support Xuan Zhuo
2022-01-26  8:32   ` Yuri Benditovich
2022-02-08 13:09     ` Andrew Melnichenko
2022-02-09  5:41       ` Jason Wang
2022-02-22 13:05         ` Andrew Melnichenko

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.