Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1028213iob; Fri, 13 May 2022 20:12:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzivspQaS2DOGFv4QPrinRGdbiMUsi4g+IraOohTRltxzTyhYPNC7mbctQ2goFPq+p0zSyu X-Received: by 2002:a05:600c:2c4b:b0:394:36d4:e0ee with SMTP id r11-20020a05600c2c4b00b0039436d4e0eemr18081108wmg.28.1652497958978; Fri, 13 May 2022 20:12:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652497958; cv=none; d=google.com; s=arc-20160816; b=ocLkF9PxUuciD+eZv5rTA3h9xRckApOsi/Fp/cJP8g/aFOJZB3JXERWZ4Y0RCSaz9p 69UP//jPuAPwgBLNpoKx+zEuGM/Et5z65QTMS6zaBKVK8uhPj1G4YoLD1Y8na+f3LE9v CwHCpNwJ77zSHqwe9eeN0IB7E7sFLOfzPhrPsNViCJJ0S1GyJt6j1n2lBY+P1QDwAwNJ /JCDyIxxLTP93c9xAaTnTS7kjhzl9gajBYW6p4ZnoyeKMUiyQAXDA68VAZbsLQ6+QbwP xOICgX1WWUtgBMCAl9oCD+Nrjnu4JwtRgmDzZgkSL7RQ2rgJfJvvqtkdqHAlGeNGq2S8 pA6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vWGmhmweV+dNU5jtCxsxI3a+Zh1xPCMPOBO82/gmlT8=; b=mZuMFTuUI0D9eHS62x/RP+/ucrIEWxjz8zBBGeBPYix89Q82jdySNwl7xvInH6USZf DOomr6HALcQwzoxa5IYSC6Lhm3CSxjVxGCxIl1FvUMbovg6taKrh4p+rl6Oe+AwCxfgX ZkTAt1z/uAfvjB2N4oJRK46VHCx7lDmu+GcTQzz1qFEXvFck0yxN2qCNEtsjtQWm6qDw VSnRrOay3npA6TvHUqAuTNgnUklwn02yj1yw6fGnKvShOMLrvKzH/6D5y7PAUXTkvc/A 9IJlaKPLz3jjZYzxwP+YUMTl9yrICLvPDfslWNDXW7kb5ATylA6GM/lyVz9lJS1YO14d Uqwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=LKUD1yC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id m10-20020a7bca4a000000b003943e0a24c1si3603854wml.174.2022.05.13.20.12.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 20:12:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=LKUD1yC3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 9A0263D3074; Fri, 13 May 2022 16:52:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1353301AbiELLdc (ORCPT + 99 others); Thu, 12 May 2022 07:33:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353245AbiELLdZ (ORCPT ); Thu, 12 May 2022 07:33:25 -0400 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 84E021D0404 for ; Thu, 12 May 2022 04:33:22 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id t25so8493035lfg.7 for ; Thu, 12 May 2022 04:33:22 -0700 (PDT) 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=vWGmhmweV+dNU5jtCxsxI3a+Zh1xPCMPOBO82/gmlT8=; b=LKUD1yC32xjbxmkSjCnpvuGV+8W7U4BU65WpHJE3jq3pkQpn1jtn6WIi0hBwFbvO1H A9TSVFsVVQfZbvcjeW13k4cH6GFbrI5hb0Z4djPSZd1N6bBC67YPH452ep4LQwsk0WV8 y2YzdhmWiMSLQZFLeedNKlvsJGIR0oAkoC9fTPqx1xNStO2xj0HGxgNgfWCkuf0BTSfB zhM0kGiyzLSCjeiQgbzY7bjCBK+FcgdMsz0UnP4Zgpjnb4SOX3/4bMiKLkJGKbXTrlDO KzFWIsuWwK6BVT0/jE4YaTxGKFY00f6wvNeNPO/Rek5sOuC08PXqLalP/n9r+2F1I/L+ TFPg== 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=vWGmhmweV+dNU5jtCxsxI3a+Zh1xPCMPOBO82/gmlT8=; b=s4nSyAfycj5gtmgfOVHClCthQyUTYwHymllJXioig7JzSuOmzd8kaI60XCMqQWCsQr MhdWYU7ExLp2O9ZoxJ5u6I8c3gXgBaXfoT/N92ecg2UYTu3ffikiWJQ8oiG0fu3DaxBH aq5XTtU0pdzRdp4cvjpjgH8uw51fHyKbjE2DuK7uaI+OpKud2NZPTB266bq95braUJQ9 FPkyAO4pQi4SfN+wpHJjarrfBCtHYy/xRJM38Q5bA95gm/e5ZtjAqw0fyYib0xOYJw3b yTkOy80oSfc9fiVxhM+KAa46VKLSfsNlhatzr7IzV4U1b8ukbFymZLfyfJUuCNgXqMrd tcMQ== X-Gm-Message-State: AOAM531d+osgBYzHB/zae5AdF1VbIUIHcZkaWC5SzKLSYbyXEF89cRHQ DYgEy1YxOI6p0d4imtzUjO+v6Q== X-Received: by 2002:a05:6512:3e17:b0:473:205d:a3d5 with SMTP id i23-20020a0565123e1700b00473205da3d5mr23770800lfv.80.1652355200800; Thu, 12 May 2022 04:33:20 -0700 (PDT) Received: from localhost.localdomain (host-188-190-49-235.la.net.ua. [188.190.49.235]) by smtp.gmail.com with ESMTPSA id r29-20020ac25a5d000000b0047255d211a6sm741758lfn.213.2022.05.12.04.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 May 2022 04:33:20 -0700 (PDT) From: Andrew Melnychenko To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mst@redhat.com, jasowang@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: yan@daynix.com, yuri.benditovich@daynix.com Subject: [RFC PATCH v2 2/5] driver/net/tun: Added features for USO. Date: Thu, 12 May 2022 14:23:44 +0300 Message-Id: <20220512112347.18717-3-andrew@daynix.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220512112347.18717-1-andrew@daynix.com> References: <20220512112347.18717-1-andrew@daynix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Added support for USO4 and USO6. 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 | 10 ++++++++-- drivers/net/tun.c | 8 +++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/net/tap.c b/drivers/net/tap.c index c3d42062559d..eae7c2c13713 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -955,6 +955,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 @@ -965,7 +969,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; @@ -1089,7 +1094,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(); diff --git a/drivers/net/tun.c b/drivers/net/tun.c index dbe4c0a4be2c..ecad1bdee717 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; @@ -2861,6 +2861,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 -- 2.35.1