Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1265969rwb; Thu, 1 Dec 2022 14:59:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vyi7ROb3N0Nutu174vYMHvSHqquQUPrAWp8D5A3z/kAwMpod1bSh+/m8QEle3fA1M6fgK X-Received: by 2002:a17:906:9f13:b0:7bf:661b:6b0e with SMTP id fy19-20020a1709069f1300b007bf661b6b0emr20105191ejc.191.1669935556556; Thu, 01 Dec 2022 14:59:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669935556; cv=none; d=google.com; s=arc-20160816; b=Gbo4Up0wJPwCPXm+5AX4bDLe4Qj7pQkcszNEEI5VRMijTpsf5TcYF/qBJIb+FHGyAv HZO90oPgRqR35KS9uYONTg47eSSq5YwdVCerfj2fAh2mME6omCY3sMAb2DJlA5jgaJxo uSbTcZy4WPvaZMHKYetwdTH+cn/Knvx7ZyvIWeSH+/E67TBqYvs4dHDNwv0l8tnpFSJF yKLiLNWdxneSG8c9WYihUFO0T0N7V/7mZDbBBbB8Ar5K/9FkB9bK19PynmcJLyi6vxSA daVFN+IVDjXJqT84OppytfXHXTxQlsTG8Agy4/eKXvye/is+wPjyF8XEO0bVJZKvpYK9 FjcA== 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=BlO6QTZCwR1RLEDuFRe8THkhQOGpd88LnLO5Y8el1kY=; b=AZgSxxFkWsvmuqv564rmIGyOkwVfqlLHjU5EyqUFihfmruXwsFGHhOFZ7ac87Kkc/s sqUN0zYxxmxkb/kdmQFwq/bLAQ0Gy/w8ZY/V0lutSxC0iEvYq+R4bPAk4hVgQTfNJf5H OfuBInRV/WiqZe0dh41TtDUYq0HW0pIEltS/QKWNmbXhxyJxkYW4Y4nMaW3DSlJVgoQA UDWzaf9p2BNU48XeAgdrKm4U8oJbgL/12Z8Q+xRfV9sRP1qC0uKYAJiaOHXKtKiCaxXf oka+r1/hgk2NMa4K806iQPQ0hvRhMLwoR/adLcHhQkXXggApVgOgicQyz/gXlobUTtWD deeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=OQa+DAdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y15-20020a056402358f00b0046aa94ae407si5145866edc.632.2022.12.01.14.58.56; Thu, 01 Dec 2022 14:59:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@daynix-com.20210112.gappssmtp.com header.s=20210112 header.b=OQa+DAdU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231607AbiLAWtD (ORCPT + 81 others); Thu, 1 Dec 2022 17:49:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231559AbiLAWs4 (ORCPT ); Thu, 1 Dec 2022 17:48:56 -0500 Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4A6E99F62 for ; Thu, 1 Dec 2022 14:48:54 -0800 (PST) Received: by mail-lj1-x230.google.com with SMTP id r8so3539502ljn.8 for ; Thu, 01 Dec 2022 14:48:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BlO6QTZCwR1RLEDuFRe8THkhQOGpd88LnLO5Y8el1kY=; b=OQa+DAdUw25Ne94o8Inx5iCJ59YUCMg+QHfRo6xIu6a4xvMjlsgj5c2yxNNo+UVHxE HeENFmyRRYnS1NoX9sJhjEOFj5+NH0pCOGM4g1y5/p/r6KRF7qzeZEWMkgF6KiVjdQY0 VB+Qqyl8R1w0leOOZ82Mhtoj/85biqpWkIevsh4n7JGId7+6BtCdn1LRtjcrttvpK45S sUk8RqXnMV5eqe3OIi+AHNAUMfAQv3xxUHEMuIHZr5wgOa19b0vfcPEGEebDjTPUjC7/ ckOTciOmLdDcV4kdYI+fCuGBRYCNf0lusxwinAq2I5mZ580SvwR8PTwhEhKr1XuOc2nl ksnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BlO6QTZCwR1RLEDuFRe8THkhQOGpd88LnLO5Y8el1kY=; b=Dro5LYpo+7qu7wFduXtcc5waS4INAzDlE8nt+CMuoBpZLcoHqerYsX96B1Z72mSutm 7es/vLtFAQJl0JVyJCydxp6f+eGuxreTanYGqHHIRf4aouU6VhCB1Jndz8Miapv7Gm8a CATqmgsLrOrJq5TtoGePtr5NlxDZrUuxq+8vkmKSwyVSs0DgpaWjPPy7mOJlJg/vPBEQ cux1y6RHiizpeMdem1YnmVZYIZCW+kI8xkbKRCiTtnrRWC7HyhOYlpXWAjWXmVi04yZG uGMKzeVmxOhl0ZZDo9Jr11F1lXAvaxDU0rq/h/EfdBC/9MkQfBEdtgv/jEWD9lZ1nEYP 7fYw== X-Gm-Message-State: ANoB5plfezTsck+ESM1qC8jlwttOCh3BTz59MYvDvEzX1tOZBuM9yK60 d/p2sUHOn77tbHho3uROfb3Ekg== X-Received: by 2002:a2e:b891:0:b0:277:8df:88a7 with SMTP id r17-20020a2eb891000000b0027708df88a7mr23324289ljp.139.1669934932549; Thu, 01 Dec 2022 14:48:52 -0800 (PST) Received: from localhost.localdomain ([95.67.24.131]) by smtp.gmail.com with ESMTPSA id g7-20020a056512118700b00497ab34bf5asm797573lfr.20.2022.12.01.14.48.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Dec 2022 14:48:52 -0800 (PST) From: Andrew Melnychenko To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mst@redhat.com, jasowang@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, virtualization@lists.linux-foundation.org Cc: devel@daynix.com Subject: [PATCH v4 3/6] driver/net/tun: Added features for USO. Date: Fri, 2 Dec 2022 00:33:29 +0200 Message-Id: <20221201223332.249441-3-andrew@daynix.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221201223332.249441-1-andrew@daynix.com> References: <20221201223332.249441-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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=ham 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 9e75ed3f08ce..a2be1994b389 100644 --- a/drivers/net/tap.c +++ b/drivers/net/tap.c @@ -957,6 +957,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 @@ -967,7 +971,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; @@ -1091,7 +1096,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 24001112c323..a7b9808368d0 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; @@ -2885,6 +2885,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.38.1