From patchwork Tue Jan 25 08:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 12723462 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18464C43219 for ; Tue, 25 Jan 2022 09:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1456004AbiAYJH6 (ORCPT ); Tue, 25 Jan 2022 04:07:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45982 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455315AbiAYJEH (ORCPT ); Tue, 25 Jan 2022 04:04:07 -0500 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 489D0C061345 for ; Tue, 25 Jan 2022 00:47:23 -0800 (PST) Received: by mail-lj1-x231.google.com with SMTP id z20so4900766ljo.6 for ; Tue, 25 Jan 2022 00:47:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=k43NlouVQB8hM1beYosBs1yb2iePFVYZFONuMP14vSM=; b=zp0RDdvCCfDNZfHZsadkx2auxVmRnOOpvABVv9a1MtModBQsy/um51GjHOd7t53C2N tA/G2rMzpf9wWg761k/ef2SUVbbzAlVs+mozPmJjymGAUK5aAiwRQfO9lqwGVxuK5otI Pl1RMPJRJoo69MW/tkfnBcf3JEn0aqVRkjuYH7BCr0Pg+c0rglS3vio4S6gl7bQ3UGaX 1nscK/FwgBv2TA0EsI+2kfdGD0JEbkH1eUyfkEWgAx/EtxIiGFnJMBxIBmnpy6KBN84l tTtoY8j5IXK9nVZT2/cuCoUN70rFwtLCwgB0kS14UaLp/KVsdxFJ+fsZKbwvjAtdn1Ll DoMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=k43NlouVQB8hM1beYosBs1yb2iePFVYZFONuMP14vSM=; b=rNcMiVc4wqbBKgBgRk578Q2dkcF+ioCslTEbYc7dq3z+KBUq89a3bh1wIXGeLgG/mf dX7zTND5+bkEWAf8QE1Yb/a9zVCb2/9qsRHsduXhbVTyLf2yHcf53b9IMe4IEudMuXa2 PlqtyIBoLBaTnTD2KPJsalAVPLzNKU3NK6R6eF1CSxAtcnYrwZkil3GLrJo5wzofOQpL A1EDuNeAheumY5GNY3Q0hmK5aipSzClkyvo6UieTV++t7laC8ygeQnZy3S2MPA49h+mx UdE7ZeLu4LzZ8r3/6p9/8MdKsI0Ps3D89u9ZmFwggP/U3MdHXR0/DNRnIjCrMdWn0agW Bxqg== X-Gm-Message-State: AOAM5321i4qkCygCjemFgw5y8HK1P/eABZgRHhKkNFJETTu1TT1F9oIN hh2MDWl/MwV9rHXcjWK2EdKRkA== X-Google-Smtp-Source: ABdhPJyYp87wYisP2/l1MxOBncqSB6zBTz6Bvqiipiw7V7kXabqJmsZ2TUeV3tPNrW20SUDhl6kxAg== X-Received: by 2002:a2e:b914:: with SMTP id b20mr13735990ljb.6.1643100441653; Tue, 25 Jan 2022 00:47:21 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q5sm1418944lfe.279.2022.01.25.00.47.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 00:47:21 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, kuba@kernel.org, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yuri.benditovich@daynix.com, yan@daynix.com Subject: [RFC PATCH 1/5] uapi/linux/if_tun.h: Added new ioctl for tun/tap. Date: Tue, 25 Jan 2022 10:46:58 +0200 Message-Id: <20220125084702.3636253-2-andrew@daynix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125084702.3636253-1-andrew@daynix.com> References: <20220125084702.3636253-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 From patchwork Tue Jan 25 08:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 12723461 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08086C4167B for ; Tue, 25 Jan 2022 09:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1455935AbiAYJHy (ORCPT ); Tue, 25 Jan 2022 04:07:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455317AbiAYJEH (ORCPT ); Tue, 25 Jan 2022 04:04:07 -0500 Received: from mail-lj1-x236.google.com (mail-lj1-x236.google.com [IPv6:2a00:1450:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F3CCC061347 for ; Tue, 25 Jan 2022 00:47:24 -0800 (PST) Received: by mail-lj1-x236.google.com with SMTP id z7so11378735ljj.4 for ; Tue, 25 Jan 2022 00:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dl66e2A4mF2Qyvn7/VEBHhQt84ZUbQKV7qGHfbulC4U=; b=Gsrzm15/kayF28SoC7sRkEvuny/rjuR0K2X1Z7cSFVnnayBUfiP4EzS1A2SOjEc6Hh C7NTMRcc88pn/KoPjs2YMzKWjRjxmLg0jXOGRjhWVct3Tl0qq1V+JEFL75IbM/JUmsAM tdrhqfsQXJCR4egAsQInQ8ZLP4VBZf3T+/bTepIzfgGapjSy+Jo9RjHYdxGOCkEOjvFf 7GZXD2q/iwvTy3FaLt/ZtdI8FpA7ZZInUvR4qxCp0oTiIr2xfzOySbV8bMt607oC1SfJ 7DsCIcTW0+tQfr3RglcbTYg/Mljf71FeLFk4M675o6azUTmUSWS9oipD0pox74oQEFRr JN7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dl66e2A4mF2Qyvn7/VEBHhQt84ZUbQKV7qGHfbulC4U=; b=tk0Q4/C8tQ4BX2ZiHpnoolJakigQSlqamqCDHFXVHbdQSV13uomZCtIWiC2PSOAgw9 xnNoiPbAhgiTe2Ck6jqgfThr2R8dBJl8zYU73kMiA6hQYINh0ASguG7gT1ru9XRIIy8r DhV+qOu1EuyrLyyHBShHdv/4vqqK6oX7n6yNEXg1Uds5OAtnWOyDOkmOr5xPRajmFCy2 nmxLPhkczZh+VehLjCXQsZz2EBVBP9itU0KyFVMvtIOGLFvI1kLWviu9r7SiaiOcVBSp gGaQGKrrCWteAW31jJ5X0BgyWa33Owo3yv5OuWiOIBdn4Wxx/lfcuctHQngMBMwFWAgn gxGA== X-Gm-Message-State: AOAM530vZUlGtOk+qyUDL4PVuI06Yd0occ/qpuY2+GdRYuxR8XG4d4Oc aGjjWRVB00aGsLUpI8sbE5NuxQ== X-Google-Smtp-Source: ABdhPJzCfueNt7EGxpjgAvt/Euq5JGSCE+aooEIdd/EgvAx3MMRVq/2nZFYCCNX0MnqsmbFtQII1ig== X-Received: by 2002:a05:651c:210c:: with SMTP id a12mr14427072ljq.285.1643100442603; Tue, 25 Jan 2022 00:47:22 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q5sm1418944lfe.279.2022.01.25.00.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 00:47:22 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, kuba@kernel.org, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yuri.benditovich@daynix.com, yan@daynix.com Subject: [RFC PATCH 2/5] driver/net/tun: Added features for USO. Date: Tue, 25 Jan 2022 10:46:59 +0200 Message-Id: <20220125084702.3636253-3-andrew@daynix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125084702.3636253-1-andrew@daynix.com> References: <20220125084702.3636253-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC 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 --- 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 */ From patchwork Tue Jan 25 08:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 12723483 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 956ADC433FE for ; Tue, 25 Jan 2022 09:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345429AbiAYJIJ (ORCPT ); Tue, 25 Jan 2022 04:08:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455335AbiAYJE0 (ORCPT ); Tue, 25 Jan 2022 04:04:26 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F85C061353 for ; Tue, 25 Jan 2022 00:47:25 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id z7so11378798ljj.4 for ; Tue, 25 Jan 2022 00:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UtVU5Ioannj5lFzXA15MNhoL0jZF5uZA66JN5wY/VHo=; b=z1PVhkYnURa8uk4TdLAjmi4ey/+drh7NOxm8j5ND/n779yDew1YHn/TF1jSwclCBNz aExTGYGyghejwUs2hNWH+nYD08V+6xE6xa9k3FvihZgFRyQhDqgUNyWRjKuGBUU2UwEH q/SMJMs8GRd06V8oHMqLFnZsM74NV2Oc7IRvEkxixGzFVkyyLU8O7n5ef0vSET7gfXuv Eaqko63J/8AeudSImrul4ef25S9Vtr6a4tHVIoxmzTvfuHzDeiBXBZXsB9SEbGiDs703 ChOXRRz2i7aT/wwqwgOrbR6ziolJ3xFET6e8Y6A2aFvx09YMk8ZoqJ7T6/usZsZeU/1C nFUQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=UtVU5Ioannj5lFzXA15MNhoL0jZF5uZA66JN5wY/VHo=; b=3tpStKIjTUwzHXu4XWuhqHosYkeL6reI56rkCvxv6DniYEq+Y1gtnC7HHOnEDfkruK q4AESHUFkor9+oXzv7UfVpeBN+jomREoUe2x//nHyZLirn5VM4kObVir/qwy93twwMnT +WPL2ItcSjWvSXH766MNKTMJeHOmKdfSRy0JRH81wVpKuSPuFax9+6DLiQIN4lix2OzE iJ4OTIVWKkjCQSsUQlLHsTKpDOA7Svl6m2eI3wNUvxYnxq65h452eMt6CaR2PaB6N0fr 0AwwncsZlTkzRHtCPKmuljomX/Q4T+dJIw8cUVajLzLZGr8TCYEm+HriGgzV8GvVf1iy Iwgw== X-Gm-Message-State: AOAM531jODhYI64NcNx+5E0bUahnEEMtdNZSIU8J7FwjisWbkTYIrsOJ +Ky5+iCxNwnnyR8lMDDkZydPkA== X-Google-Smtp-Source: ABdhPJwyonKvuxlj8x8ao+iZgQDBoPXfdR2ybG7ru6rdG/cLdX4fw/FgGqWs+2hNx2lMu2DLvmkRLA== X-Received: by 2002:a2e:9654:: with SMTP id z20mr14066133ljh.526.1643100443571; Tue, 25 Jan 2022 00:47:23 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q5sm1418944lfe.279.2022.01.25.00.47.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 00:47:23 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, kuba@kernel.org, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yuri.benditovich@daynix.com, yan@daynix.com Subject: [RFC PATCH 3/5] uapi/linux/virtio_net.h: Added USO types. Date: Tue, 25 Jan 2022 10:47:00 +0200 Message-Id: <20220125084702.3636253-4-andrew@daynix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125084702.3636253-1-andrew@daynix.com> References: <20220125084702.3636253-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC 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 --- 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 */ From patchwork Tue Jan 25 08:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 12723482 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7FB45C433EF for ; Tue, 25 Jan 2022 09:08:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1456026AbiAYJIB (ORCPT ); Tue, 25 Jan 2022 04:08:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455339AbiAYJE0 (ORCPT ); Tue, 25 Jan 2022 04:04:26 -0500 Received: from mail-lj1-x229.google.com (mail-lj1-x229.google.com [IPv6:2a00:1450:4864:20::229]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15D01C061359 for ; Tue, 25 Jan 2022 00:47:26 -0800 (PST) Received: by mail-lj1-x229.google.com with SMTP id a25so11788634lji.9 for ; Tue, 25 Jan 2022 00:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=baQ+umQNqHWDum1lpPhk7WW3HA5LDWS+YAun2KSlxoM=; b=wDBHF7w/TMCb+hQit42vS3t/lC2517uJvPUBhXqfdal8jFWSxDixIdeHImw94pMhB9 W/f5jjHcIoSKzFZPwx0UyQRx1HbhvsrRTy9LNxD8iZoa251NscFVFZuAEscBM6N3hDsQ NnH2t8ECcNwthNO5DibTwt2kykb16IQ9DGEpoSY/KR5Am9y5CTGEvxZQXL/mauiXRIBU Qc21Vx3CCtxwjUFB5Iou22VHPZ1ostv8ol7NyHBmJQcMOTSFKVW2gJuEknM5jSEe0H1m 9TNftXM0SRofdK18MnBocE0I8NruSmiIE4gm+emYaz4cUNijLiUedvW8GyyzRlA8BEsg X8fQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=baQ+umQNqHWDum1lpPhk7WW3HA5LDWS+YAun2KSlxoM=; b=UJt/MQVUgSLfw8weKs64q9stDsZrZdciK/MX1YirfdY76kaUhWwDGI3Lbl6cf5jcXH P29pZzwCFTEbGWxAam9t4xuKomj7m1CHoGADzcg0PL8neflxeaAzP+S7F/Zxn572nLpo 4fBS7ywOEhS2Kr1BHT146r+gxwXxfQGolPOyGD4U1t6k8Uvt3q4XxHsmg3vvDsCjdNYU U8DWQBmEkHee1tkj2prLBxCL4FJ/rZCUsQ/r5FV9YRtn3A/cR1O+trjw3SvjIlBOIWAX HUA7vtmUQhL4a+88m6nqVCdH1kUjsUFUpYuGhNBlhcY+hQeXZ3P2/0VqR2NEQkJ+3LMF 0YHA== X-Gm-Message-State: AOAM533qM3PU27hu5r2QYUHRve4PDbYh4bMgHhY3SCUEI+74xXEUC78P /xhRGCitx+Jao074E3rjS2VQhg== X-Google-Smtp-Source: ABdhPJxwoXFjwGNabYMY+I6uihGStNKdiHmxSD+sVeV0Up4jOraro+EZiNLGhfeRiUwhmTKg6Qqrhw== X-Received: by 2002:a2e:7f10:: with SMTP id a16mr14008651ljd.48.1643100444520; Tue, 25 Jan 2022 00:47:24 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q5sm1418944lfe.279.2022.01.25.00.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 00:47:24 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, kuba@kernel.org, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yuri.benditovich@daynix.com, yan@daynix.com Subject: [RFC PATCH 4/5] linux/virtio_net.h: Added Support for GSO_UDP_L4 offload. Date: Tue, 25 Jan 2022 10:47:01 +0200 Message-Id: <20220125084702.3636253-5-andrew@daynix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125084702.3636253-1-andrew@daynix.com> References: <20220125084702.3636253-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-State: RFC Now, it's possible to convert vnet packets from/to skb. Signed-off-by: Andrew Melnychenko --- 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) From patchwork Tue Jan 25 08:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Melnichenko X-Patchwork-Id: 12723464 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27F37C4167E for ; Tue, 25 Jan 2022 09:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1456015AbiAYJH7 (ORCPT ); Tue, 25 Jan 2022 04:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1455342AbiAYJE0 (ORCPT ); Tue, 25 Jan 2022 04:04:26 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 135D8C06135F for ; Tue, 25 Jan 2022 00:47:27 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id b9so6249715lfq.6 for ; Tue, 25 Jan 2022 00:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KADXDwPSZzBNJZyGOf6/RaxmVEZ0dcQMEj4ph2LZrIA=; b=E5N6rnfpLVuomzpKv7B2iO6tqIya1+zMB7j6sPn5f/I6ggTAaJqoDqBHwysCe4g6D6 FFcao7hF04BWqCwu9s+U+g3GORW4cq8dmt4RqSXNaDPnA329ZI81GDO8lKVEe11XmxoQ qdqv+GI8VdBE3edikJPt8xXPZZ59+BR55A+ZXBmrAZ/XtcgN0qouXrcIbmYQCfYJ1juM 58JkfDeW2VsEdCxdU5Z8THlgm7GFAZOYY3Sv9b4Htj2gMJgKUTQkszP8lSJ24EnW4P4X GRkuYMYKrVRlJjnYxt6ud7UUwMM80YzgH3LH9zlOS/Gbh1c2aXETX6oG4qZtSPzLk19N KCZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=KADXDwPSZzBNJZyGOf6/RaxmVEZ0dcQMEj4ph2LZrIA=; b=PA/0GZHNt7inrYJD9f5szc0LjxIriE9n6we7fjX3Q7fxJ2H3EPSxtzDOq6Y1PoXjhY 0Sq7gqDC/i0x8mN94/5ypTreidfDQ8Qm3+WtQpjLlSLoUR76gnpc46mmKperwBOpo6+T ckzGm8fccsaNUI4rkkrLLMh/2t9QjeIp4grSweHI0zevwlaGnIdmbLbtW1Q9Tq51LLll 70o7V5W3HGkBZobWwUgKwdvzEAiqdXTbh2cGmqc/YcweWXWNk6dFHTHQT69hNFZsFXVp GiljHSh8pNpZlbWYvj3uPPXsmQAjGLVnvov72McMoAEsaDkQhJ1oioadVOTCkLpHJVoL 3G8Q== X-Gm-Message-State: AOAM530srx+W18CGDTE6vxWQGPEmHrWGpXXJw8HOVAagt1tBRGzz+f+f olEhl3kEPrVILbjm9Y2sEIqz8w== X-Google-Smtp-Source: ABdhPJxBOpDCi+HD+W7m+aCE1uJ74rL4NmI8ow4BsEsaN6ZHzn0gSv57q1zh/Uyab4PWRk17uBBwWA== X-Received: by 2002:a05:6512:3d0a:: with SMTP id d10mr2796243lfv.472.1643100445460; Tue, 25 Jan 2022 00:47:25 -0800 (PST) Received: from navi.cosmonova.net.ua ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id q5sm1418944lfe.279.2022.01.25.00.47.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 00:47:25 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, kuba@kernel.org, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yuri.benditovich@daynix.com, yan@daynix.com Subject: [RFC PATCH 5/5] drivers/net/virtio_net.c: Added USO support. Date: Tue, 25 Jan 2022 10:47:02 +0200 Message-Id: <20220125084702.3636253-6-andrew@daynix.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220125084702.3636253-1-andrew@daynix.com> References: <20220125084702.3636253-1-andrew@daynix.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Now, it possible to enable GSO_UDP_L4("tx-udp-segmentation") for VirtioNet. Signed-off-by: Andrew Melnychenko --- 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, \