From patchwork Tue Nov 22 19:32:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coco Li X-Patchwork-Id: 24530 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2405152wrr; Tue, 22 Nov 2022 11:40:40 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Y8LiXg2dyKp9z4icDWqXJjSR8jGXDzTe5RbghCUFPxiZooHfZqpWOZ3MVwhas5R4PVi97 X-Received: by 2002:a17:906:774e:b0:782:55de:4fcf with SMTP id o14-20020a170906774e00b0078255de4fcfmr20949117ejn.85.1669146040153; Tue, 22 Nov 2022 11:40:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669146040; cv=none; d=google.com; s=arc-20160816; b=C4IzIs79boRPTF6PY/lU3tSZCsVjVWDjl3gimG2n3qE1vxI0or2W5Y/tHSY86AuJj9 lvnv/Fi+hCp3QizyVfcw0aSDs1y9TLQ3AcTn/pbU4+yz2X2cGM07vInqZPFfPUpqUgBV XJpt4TPNO8JFFU9/9gBQWT45xm8orEgrS5a6R6XMUhLy4OyHmb58yA+0w01L0gxU08xM eirIy7QIx14pOIhoYbjaZAgknidyJ+i89LAFcXh2UnHlNgFGm94Qlkr8xt5It/3k8BXy 8gIJhc2ikFpEQqWvcQv6GqiQ0uy+xhOIvELU+VtoIrH3Y7+XQIfMD2WgZV79gjQpblmP Eq7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=N4Pb5W255LH0BWY4yuGbMLQMKFxJAPzH0I4oKHVGlwI=; b=mpsxgL4J7jH1V90MXsCgIR25TFLK7ajfoilM0OWi7h3Ssa7Osh/3LwVIExVemVNrCR 6qyZyHVKyufejLkHCi+CuJ/JJHZdGnD4qkFEbjrqvEIB+1r4yJbL4j/YDbdOJ1oQHHK7 cp5Z5xb1HWChGasCk+qbq3T7bBhoX4S3pRtixgfhM1WeFvETtwngBcJZOPHOFlM33Re7 bRbAQ4ET8VDgRqCHe9EBmwMt2EU+lwodlqxMY3NkDNrqWnCS/A7P8A3jFCK7yVCCOhZs 09ARoMH8MMNxAgSF4dtMROQGSG9pv1P4iZ0CEmdeaczOum1doyu81DyGaWirEYfzjEkJ 2zlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=rG8Z0Vfw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd10-20020a170907968a00b007830f14fffesi14265068ejc.375.2022.11.22.11.40.16; Tue, 22 Nov 2022 11:40:40 -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=@google.com header.s=20210112 header.b=rG8Z0Vfw; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234626AbiKVTd2 (ORCPT + 99 others); Tue, 22 Nov 2022 14:33:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234830AbiKVTdE (ORCPT ); Tue, 22 Nov 2022 14:33:04 -0500 Received: from mail-pl1-x64a.google.com (mail-pl1-x64a.google.com [IPv6:2607:f8b0:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AE8B1F2D3 for ; Tue, 22 Nov 2022 11:32:51 -0800 (PST) Received: by mail-pl1-x64a.google.com with SMTP id u6-20020a170903124600b00188cd4769bcso12174612plh.0 for ; Tue, 22 Nov 2022 11:32:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=N4Pb5W255LH0BWY4yuGbMLQMKFxJAPzH0I4oKHVGlwI=; b=rG8Z0VfwaA61bPZeGe5CnP8ilpFBvhTqlF9lTA6QpM53rohJc2wzAw7rs1GQZW+NEv RLWLFEJhfvjgk5RbgXqLj58WpJioOScTUo8jdDGop2H5QOtDBWju/w7GfldL1KQnuH+l PuB6BmbX81PIYU7z0tKY2wbl/4rPYVu3PedIbk4oZgIXnLCNEfxYxBRLjdjn2pI1pQJG az8cFasXy0LoGu8oiPGcvsZyccvAbo3ftp8Rxl8viuaU6Ti8i91/Oy//HMFGJjLWNDrD QtdgFE0FLx2dPwPNoRl5SdCCwfUfsRmyqW56AIBGr6vVUb8+gBKn1amV8CZPUjCXvtLD v41g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=N4Pb5W255LH0BWY4yuGbMLQMKFxJAPzH0I4oKHVGlwI=; b=20o+olvYcCx8HHVRnBWj2oEpsIyaDYw1gbRftEChfhW4cer6bBMYHFOtcZyFNy6+m7 3QcSGbu4csh71PYd1zxEThhI6rKAQRF13gs3fLO05hVBV1zTCtimnExOEdIqvDAxnXR3 2nJ4xSaOANvdpvQWrQoK5DxmSTrSlbTMTWmuq976glq+KYogAk9pXLo4SMWR1lGyO9GA 4nEE5Hw0c3TOCMLz9MT6BZ86IZ4hMqNj6nNpOfvNWdK9GBC7zsPUCRCgD5vRAwSIcQbR j9ujBzQvqMNr4umCz9eLQAe3NGH9U1PlKpM2gwlCL4owzd4dhpSrdoAx7tTOsGsyjR5h W1GQ== X-Gm-Message-State: ANoB5pk6+RGMX6WPSbEcsn2f0KqcIU8T4kTHb6pXRUkMAce6Q5SAkzzS vvv5V/ZCWro51ETRuzL6kilT43/RtN02kSE= X-Received: from lixiaoyan-desktop.svl.corp.google.com ([2620:15c:2c4:201:d85f:1168:cf63:556b]) (user=lixiaoyan job=sendgmr) by 2002:a17:902:a989:b0:188:d6c7:e7b7 with SMTP id bh9-20020a170902a98900b00188d6c7e7b7mr5323760plb.16.1669145571058; Tue, 22 Nov 2022 11:32:51 -0800 (PST) Date: Tue, 22 Nov 2022 11:32:38 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221122193239.3159985-1-lixiaoyan@google.com> Subject: [PATCH net-next 1/2] IPv6/GRO: generic helper to remove temporary HBH/jumbo header in driver From: Coco Li To: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michael Chan Cc: linux-kernel@vger.kernel.org, Coco Li X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750226478241079809?= X-GMAIL-MSGID: =?utf-8?q?1750226478241079809?= IPv6/TCP and GRO stacks can build big TCP packets with an added temporary Hop By Hop header. Is GSO is not involved, then the temporary header needs to be removed in the driver. This patch provides a generic helper for drivers that need to modify their headers in place. Signed-off-by: Coco Li --- include/net/ipv6.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index d383c895592a..a11d58c85c05 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -500,6 +500,39 @@ static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb) return jhdr->nexthdr; } +/* Return 0 if HBH header is successfully removed + * Or if HBH removal is unnecessary (packet is not big TCP) + * Return error to indicate dropping the packet + */ +static inline int ipv6_hopopt_jumbo_remove(struct sk_buff *skb) +{ + const int hophdr_len = sizeof(struct hop_jumbo_hdr); + int nexthdr = ipv6_has_hopopt_jumbo(skb); + struct ipv6hdr *h6; + + if (!nexthdr) + return 0; + + if (skb_cow_head(skb, 0)) + return -1; + + /* Remove the HBH header. + * Layout: [Ethernet header][IPv6 header][HBH][L4 Header] + */ + memmove(skb->data + hophdr_len, + skb->data, + ETH_HLEN + sizeof(struct ipv6hdr)); + + skb->data += hophdr_len; + skb->len -= hophdr_len; + skb->network_header += hophdr_len; + + h6 = ipv6_hdr(skb); + h6->nexthdr = nexthdr; + + return 0; +} + static inline bool ipv6_accept_ra(struct inet6_dev *idev) { /* If forwarding is enabled, RA are not accepted unless the special From patchwork Tue Nov 22 19:32:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Coco Li X-Patchwork-Id: 24535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2411378wrr; Tue, 22 Nov 2022 11:58:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5qPbSWEjsIMWp34pAj6QA25OvH4kw+X8SJSQ9cr7C5hphV+cr7+W+F8Son9Th+00ymPJdf X-Received: by 2002:a63:d48:0:b0:474:6739:6a09 with SMTP id 8-20020a630d48000000b0047467396a09mr11610350pgn.292.1669147116940; Tue, 22 Nov 2022 11:58:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669147116; cv=none; d=google.com; s=arc-20160816; b=dhGXoqNBfacbY6SDSyyzVopP5erEQ4o8x048LG93IniwE2Pgweo671l2sVL08HPqjm YO86jP+1HZp40y2lrUDg41S8rV3MiOeasl9gbTgjzEpbqjdDt6JPQ9mIOOpHg6LXzEaB dM0c4bluP/qtMAkS9+SWzdrnzEFS2QUJ0RidIyC5piIFiyR6LZps+r8GEKnJwJWMXeox DNn3uD3trvtbwFbM05bxpBNul8E1P74JnZ8MHgvr/qoZOInxGaWsqPQ40m7JlBoW5mfK xw2pbl79fG36qMIoXYhB5g5Y2W9CeDkBVo/5+uCf5ZvTSysG0bZs4QbI8dn9A7g4zQNq EEPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:dkim-signature; bh=NW0Mw/qHQ9FIGEA+rYwuphRFxEn0u6CmWZPIH+7Q52E=; b=kAmo00Li05VqJLQIHD0DDgyHDN2xfkX53XblQWUBm+74zwNhmP8Ad7s4AarP2XH9DQ ZEpYVotBsvBlaqrS+Eg+wySkynmOnZFTWfNSKOHEnCwdqfv0kc9ZH+io5Z0HHEr2vxQ2 00JyZCENb/46wojVROpf2p47QqRcV/vmQB5UZUFbulPvtg94OOwJe2PdZVmbux6djCuU BBzdFqmSXEhqcOyWuYQ8vEexFLyoZtwIb+87w1xUnpK2vbWR4tsYji9/YRPfS1cBT28I jK/OMzFB85obyhyyeKtYBL9UCdqMJ1Abd/hVGXJGn+q0kSFT6rZBkdOgslCNzmRaGzNU /omw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=WRPvZ4wP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pc10-20020a17090b3b8a00b002187b07b835si14343868pjb.52.2022.11.22.11.58.23; Tue, 22 Nov 2022 11:58:36 -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=@google.com header.s=20210112 header.b=WRPvZ4wP; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233443AbiKVT6P (ORCPT + 99 others); Tue, 22 Nov 2022 14:58:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43546 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232689AbiKVT6L (ORCPT ); Tue, 22 Nov 2022 14:58:11 -0500 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [IPv6:2607:f8b0:4864:20::114a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 478B62338C for ; Tue, 22 Nov 2022 11:58:06 -0800 (PST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-3a1cfadbcbaso62731957b3.23 for ; Tue, 22 Nov 2022 11:58:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=NW0Mw/qHQ9FIGEA+rYwuphRFxEn0u6CmWZPIH+7Q52E=; b=WRPvZ4wPW3a3gPE25QfY5FbQTs4oV7y90ry376Wn2mRUOvOP/z+i/MUN5ChborZs44 WbqVuEY1M0h9xbB3TLjGbdtxYlnxHPifZ2dMBtWHRv/Yvk+mvuHLDsM37icIe5ErjCnZ mNWiwC+RkIOJiwzosAgkycpQgi3Cqg1sJjl9u324v/8Dgnys6205OpofRDj1DvzYSX6r 3OIcR0nuvLx3JExExXq8McNOVs3d1Bx8y2ukK1U6kPDrS8es6DQSR4CrhQ+VNhylWFQo /4Q14hWqvjpM82tfV5+MMY/I3eQwlsI6IkX1P0XQl/Jykpqb+c1ssNb9+Dv51J9Xw65J fCWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NW0Mw/qHQ9FIGEA+rYwuphRFxEn0u6CmWZPIH+7Q52E=; b=e6NsNwB35RgR7W17V/8wHtcWqoKPXcitagqLwh3aGtmLy/F82JACFfHf5qnZ+DR2bE BLHfQ29OzCqx6msoeJYTxYtaw63nn651EF+n6liw3RcxlNJ0cU2zR8LFTXxm78luyahL xfMOVbgMTaU0BeVS7YHHdLh3McRzg2nRuIdPpnU+tQXYS8PejWqIhNFnn21mdKyIkPtG iJjcwVWcdmxL02mG/E4A27fJj90fPgdAL4nlxxiesdWrTq8M3J+2hIUx8+XJCsJtKzZl mUH/pQp9rZCWvg64EJtsgL7cjCy2iyGoX08FL3aiKEHIr7/x+AxKtYfyvnYQ18yvwo8b Tkxg== X-Gm-Message-State: ANoB5pk9gG6C0m73xx4mPtFurW3wSMROGAo8+6iQb7RsuUHfW6G9EXhX cCmBwGj6JYXPGMIEQTfYlktDqjup2bk4sBo= X-Received: from lixiaoyan-desktop.svl.corp.google.com ([2620:15c:2c4:201:d85f:1168:cf63:556b]) (user=lixiaoyan job=sendgmr) by 2002:a81:c5:0:b0:392:f16a:23e3 with SMTP id 188-20020a8100c5000000b00392f16a23e3mr5ywa.57.1669147085558; Tue, 22 Nov 2022 11:58:05 -0800 (PST) Date: Tue, 22 Nov 2022 11:32:39 -0800 In-Reply-To: <20221122193239.3159985-1-lixiaoyan@google.com> Mime-Version: 1.0 References: <20221122193239.3159985-1-lixiaoyan@google.com> X-Mailer: git-send-email 2.38.1.584.g0f3c55d4c2-goog Message-ID: <20221122193239.3159985-2-lixiaoyan@google.com> Subject: [PATCH net-next 2/2] bnxt: Use generic HBH removal helper in tx path From: Coco Li To: "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Michael Chan Cc: linux-kernel@vger.kernel.org, Coco Li X-Spam-Status: No, score=-8.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,HK_RANDOM_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750227607043522180?= X-GMAIL-MSGID: =?utf-8?q?1750227607043522180?= Eric Dumazet implemented Big TCP that allowed bigger TSO/GRO packet sizes for IPv6 traffic. See patch series: 'commit 89527be8d8d6 ("net: add IFLA_TSO_{MAX_SIZE|SEGS} attributes")' This reduces the number of packets traversing the networking stack and should usually improves performance. However, it also inserts a temporary Hop-by-hop IPv6 extension header. Using the HBH header removal method in the previous path, the extra header be removed in bnxt drivers to allow it to send big TCP packets (bigger TSO packets) as well. If bnxt folks could help with testing this patch on the driver (as I don't have access to one) that would be wonderful. Thank you! Tested: Compiled locally To further test functional correctness, update the GSO/GRO limit on the physical NIC: ip link set eth0 gso_max_size 181000 ip link set eth0 gro_max_size 181000 Note that if there are bonding or ipvan devices on top of the physical NIC, their GSO sizes need to be updated as well. Then, IPv6/TCP packets with sizes larger than 64k can be observed. Signed-off-by: Coco Li --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 0fe164b42c5d..2bfa5e9fb179 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -389,6 +389,9 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_BUSY; } + if (unlikely(ipv6_hopopt_jumbo_remove(skb))) + goto tx_free; + length = skb->len; len = skb_headlen(skb); last_frag = skb_shinfo(skb)->nr_frags; @@ -13657,6 +13660,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) dev->features &= ~NETIF_F_LRO; dev->priv_flags |= IFF_UNICAST_FLT; + netif_set_tso_max_size(dev, GSO_MAX_SIZE); #ifdef CONFIG_BNXT_SRIOV init_waitqueue_head(&bp->sriov_cfg_wait); #endif