From patchwork Thu Mar 10 05:46:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775931 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 7A726C433F5 for ; Thu, 10 Mar 2022 05:47:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239635AbiCJFsQ (ORCPT ); Thu, 10 Mar 2022 00:48:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234788AbiCJFsK (ORCPT ); Thu, 10 Mar 2022 00:48:10 -0500 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F69AF957C for ; Wed, 9 Mar 2022 21:47:10 -0800 (PST) Received: by mail-pl1-x62c.google.com with SMTP id r12so3934510pla.1 for ; Wed, 09 Mar 2022 21:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YrYyHNdzE/bZgTw4/T1DAouhykqpGbQHdq//8INO1ZY=; b=G2OWFJBcSGzie4ZKrS5oi3Bm7hXuQH+HQbukbMQtaw0recZKHC0BrSKUlc+aGlpZjt 6pPCxSDSsOjau3NO3pHx59Bm+yR+gERGn7c6Vr6JAnQ5hjuEnhRz6K/HPM9QZ7B0e0cz lU7Soz3ZDOywdoGC10RAr+XXLVN1eti/PUQKFTtLQ925fBbEa3SUtkU10nf0TqNgarOc EZROsFvCnsnTa05dSnLxBsdV93pr7ksJHIqRunbNRPv0LYHLSCgaS4exEUrHJ4zCvbxS xAibBoDQOWblVs7rbjGRskx1CvEWMhApm/pjiCwIwEBxXvrqjRlbnvqwAziDKUasswBC 3uqQ== 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=YrYyHNdzE/bZgTw4/T1DAouhykqpGbQHdq//8INO1ZY=; b=CDw+3lDkCSwVL9kywcoHeceNeDO3rVC2ZuP2h09ZoiNLLY4UEUMKUnH5pidLjhCLh3 J4J4fs68s3sYrurNxABMp2dkfRUc6212uxElMhIZkK7DnVIG4qx0ej3EVDzymLhDB1WO Jard4DLdS059GsEP10hSrVMjax3H7yRflRO9RFdR+ywrn//9M0hkACp6TBLabh0EJaeK 0Zskas+d9NBPTOsQaKi1cQgK+6vGf6nh65Qm1fKvadstmKnQuMJXfJjU6jNUUvzVfbdp GOl9ONNJs9F+21AWlshM20VT2OGlKVfIVZcM6fBgXOhSpeGY84o2rcoicB574LIEdGIl 2J0w== X-Gm-Message-State: AOAM533hvPwFbLGNBfO2WmxSFylFPxpNH6t3rn7OPRI8qWedLdu7zsn+ 62smehpm+p5APjkMCpwbr0A= X-Google-Smtp-Source: ABdhPJxQsm4zfbnwfjPiaD3DFOUiSyXy1gAOcsrGwqOujXWmIMs8cN1vtinOB78dCz39Rodnb1O2OQ== X-Received: by 2002:a17:90a:fa95:b0:1bc:509f:c668 with SMTP id cu21-20020a17090afa9500b001bc509fc668mr14219281pjb.189.1646891229940; Wed, 09 Mar 2022 21:47:09 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:09 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 01/14] net: add netdev->tso_ipv6_max_size attribute Date: Wed, 9 Mar 2022 21:46:50 -0800 Message-Id: <20220310054703.849899-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Some NIC (or virtual devices) are LSOv2 compatible. BIG TCP plans using the large LSOv2 feature for IPv6. New netlink attribute IFLA_TSO_IPV6_MAX_SIZE is defined. Drivers should use netif_set_tso_ipv6_max_size() to advertize their limit. Unchanged drivers are not allowing big TSO packets to be sent. Signed-off-by: Eric Dumazet --- include/linux/netdevice.h | 10 ++++++++++ include/uapi/linux/if_link.h | 1 + net/core/dev.c | 2 ++ net/core/rtnetlink.c | 3 +++ tools/include/uapi/linux/if_link.h | 1 + 5 files changed, 17 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 29a850a8d4604bb2ac43b582595f301aaa96a0bc..61db67222c47664c179b6a5d3b6f15fdf8a02bdd 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1951,6 +1951,7 @@ enum netdev_ml_priv_type { * @dev_registered_tracker: tracker for reference held while * registered * @offload_xstats_l3: L3 HW stats for this netdevice. + * @tso_ipv6_max_size: Maximum size of IPv6 TSO packets (driver/NIC limit) * * FIXME: cleanup struct net_device such that network protocol info * moves out. @@ -2289,6 +2290,7 @@ struct net_device { netdevice_tracker watchdog_dev_tracker; netdevice_tracker dev_registered_tracker; struct rtnl_hw_stats64 *offload_xstats_l3; + unsigned int tso_ipv6_max_size; }; #define to_net_dev(d) container_of(d, struct net_device, dev) @@ -4888,6 +4890,14 @@ static inline void netif_set_gro_max_size(struct net_device *dev, WRITE_ONCE(dev->gro_max_size, size); } +/* Used by drivers to give their hardware/firmware limit for LSOv2 packets */ +static inline void netif_set_tso_ipv6_max_size(struct net_device *dev, + unsigned int size) +{ + dev->tso_ipv6_max_size = size; +} + + static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol, int pulled_hlen, u16 mac_offset, int mac_len) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index ddca20357e7e89b5f204b3117ff3838735535470..c8af031b692e52690a2760e9d79c9462185e2fc9 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -363,6 +363,7 @@ enum { IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, + IFLA_TSO_IPV6_MAX_SIZE, __IFLA_MAX }; diff --git a/net/core/dev.c b/net/core/dev.c index ba69ddf85af6b4543caa91f314caf54794a3a02a..de28f634c18a65d1948a96db5678d38e9c871b1f 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10467,6 +10467,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->gso_max_size = GSO_MAX_SIZE; dev->gso_max_segs = GSO_MAX_SEGS; dev->gro_max_size = GRO_MAX_SIZE; + dev->tso_ipv6_max_size = GSO_MAX_SIZE; + dev->upper_level = 1; dev->lower_level = 1; #ifdef CONFIG_LOCKDEP diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a759f9e0a8476538fb41311113daed998a7193fd..ab51b18cdb5d46b87d4a11d2f66a68968ba737d6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1027,6 +1027,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_GSO_MAX_SEGS */ + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */ + nla_total_size(4) /* IFLA_GRO_MAX_SIZE */ + + nla_total_size(4) /* IFLA_TSO_IPV6_MAX_SIZE */ + nla_total_size(1) /* IFLA_OPERSTATE */ + nla_total_size(1) /* IFLA_LINKMODE */ + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ @@ -1732,6 +1733,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_u32(skb, IFLA_GSO_MAX_SEGS, dev->gso_max_segs) || nla_put_u32(skb, IFLA_GSO_MAX_SIZE, dev->gso_max_size) || nla_put_u32(skb, IFLA_GRO_MAX_SIZE, dev->gro_max_size) || + nla_put_u32(skb, IFLA_TSO_IPV6_MAX_SIZE, dev->tso_ipv6_max_size) || #ifdef CONFIG_RPS nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || #endif @@ -1885,6 +1887,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_NEW_IFINDEX] = NLA_POLICY_MIN(NLA_S32, 1), [IFLA_PARENT_DEV_NAME] = { .type = NLA_NUL_STRING }, [IFLA_GRO_MAX_SIZE] = { .type = NLA_U32 }, + [IFLA_TSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index e1ba2d51b717b7ac7f06e94ac9791cf4c8a5ab6f..441615c39f0a24eeeb6e27b4ca88031bcc234cf8 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -348,6 +348,7 @@ enum { IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, + IFLA_TSO_IPV6_MAX_SIZE, __IFLA_MAX }; From patchwork Thu Mar 10 05:46:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775932 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 D9F84C433F5 for ; Thu, 10 Mar 2022 05:47:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239629AbiCJFsS (ORCPT ); Thu, 10 Mar 2022 00:48:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239632AbiCJFsN (ORCPT ); Thu, 10 Mar 2022 00:48:13 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9199E12D925 for ; Wed, 9 Mar 2022 21:47:12 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 132so3850037pga.5 for ; Wed, 09 Mar 2022 21:47:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aZb7kcMo/qp1+g9aKTO8DmohalD7S1ZpngVnhiOiWtk=; b=JOjQlztX3idGGkodHMDu04IHRY2OqJTqjcWGoZouWZvUO6Zs5Cq4Yi/F3rJNioEi9J nMklkSCeU2HpqHg6JcltV61bOLaTCt/F62IIdDylEH0+f4Cm+Wh73AIZVjVAFCLgnW3W 2+B/RlW0e441GjGUr0lU/LdGHRt9R1ptMLY8Qygg5HRRcI54+rT7STbFmaH6X662KL8x rCJXrKCLN7ICvPownXllgNhT+DncAm3ilGacLsCrPrcAQskmds9t8lL/1/mX6tVkhBD6 YZSGvJzE9BqXXcTR3HIonJekODD5hR8dN0qdcTDwhxqCCb2IaoUx7k4dWeBxQtiXD/bB Rc6Q== 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=aZb7kcMo/qp1+g9aKTO8DmohalD7S1ZpngVnhiOiWtk=; b=AkXZO2MGazij185weFlZ7P+otcPVCMHnToMwPBlhp8TnX1tX+WPYtURLRKK+thnVR9 xuZ1eCTUmY3ckLNJJiFKLz3IpcuHZJZ0dq0waX5/CBQCljpK5F4oITc+e08jJuAWMEMj xYkA3o44D553P8NOPkupQGTREWwcOr+gUdyWm+dI9vgNK9Xq9upNG2Nc5ACAfsCgxwRs Haiwi7bLrE+xGl51gEA2xi5sYkMItXmXWwdOQBcrwMLYr6KE4hM7EKwZk6yev2TITzBM NLA69cGB9gvU6EkZTFrFrV1BRx86o2rDFYktX0Kjd04GSEDW+QUaXVmKcGry9joFZ5Zv 1PIQ== X-Gm-Message-State: AOAM531i08haOmMvf6B/CyXGb/Lvn23C1glAfnsJ7ndSiV69onYGlIHJ 1jsUlJ83w1Wpp7LZS393MpQ= X-Google-Smtp-Source: ABdhPJx7fhYR0jNbSBIXelC9rqIAD0zTwPtBj9GJomz4+wXFi68+DKqjDlqT9e3l3qh3tDamEolMAw== X-Received: by 2002:a63:5024:0:b0:380:83f7:1603 with SMTP id e36-20020a635024000000b0038083f71603mr2640061pgb.289.1646891232049; Wed, 09 Mar 2022 21:47:12 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:11 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 02/14] ipv6: add dev->gso_ipv6_max_size Date: Wed, 9 Mar 2022 21:46:51 -0800 Message-Id: <20220310054703.849899-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Coco Li This enable TCP stack to build TSO packets bigger than 64KB if the driver is LSOv2 compatible. This patch introduces new variable gso_ipv6_max_size that is modifiable through ip link. ip link set dev eth0 gso_ipv6_max_size 185000 User input is capped by driver limit (tso_ipv6_max_size) added in previous patch. Signed-off-by: Coco Li Signed-off-by: Eric Dumazet --- include/linux/netdevice.h | 12 ++++++++++++ include/uapi/linux/if_link.h | 1 + net/core/dev.c | 1 + net/core/rtnetlink.c | 15 +++++++++++++++ net/core/sock.c | 6 ++++++ tools/include/uapi/linux/if_link.h | 1 + 6 files changed, 36 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 61db67222c47664c179b6a5d3b6f15fdf8a02bdd..9ed348d8b6f1195514c3b5f85fbe2c45b3fa997f 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1952,6 +1952,7 @@ enum netdev_ml_priv_type { * registered * @offload_xstats_l3: L3 HW stats for this netdevice. * @tso_ipv6_max_size: Maximum size of IPv6 TSO packets (driver/NIC limit) + * @gso_ipv6_max_size: Maximum size of IPv6 GSO packets (user/admin limit) * * FIXME: cleanup struct net_device such that network protocol info * moves out. @@ -2291,6 +2292,7 @@ struct net_device { netdevice_tracker dev_registered_tracker; struct rtnl_hw_stats64 *offload_xstats_l3; unsigned int tso_ipv6_max_size; + unsigned int gso_ipv6_max_size; }; #define to_net_dev(d) container_of(d, struct net_device, dev) @@ -4874,6 +4876,10 @@ static inline void netif_set_gso_max_size(struct net_device *dev, { /* dev->gso_max_size is read locklessly from sk_setup_caps() */ WRITE_ONCE(dev->gso_max_size, size); + + /* legacy drivers want to lower gso_max_size, regardless of family. */ + size = min(size, dev->gso_ipv6_max_size); + WRITE_ONCE(dev->gso_ipv6_max_size, size); } static inline void netif_set_gso_max_segs(struct net_device *dev, @@ -4897,6 +4903,12 @@ static inline void netif_set_tso_ipv6_max_size(struct net_device *dev, dev->tso_ipv6_max_size = size; } +static inline void netif_set_gso_ipv6_max_size(struct net_device *dev, + unsigned int size) +{ + size = min(size, dev->tso_ipv6_max_size); + WRITE_ONCE(dev->gso_ipv6_max_size, size); +} static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol, int pulled_hlen, u16 mac_offset, diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index c8af031b692e52690a2760e9d79c9462185e2fc9..048a9c848a3a39596b6c3135553fdfb9a1fe37d2 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -364,6 +364,7 @@ enum { IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, IFLA_TSO_IPV6_MAX_SIZE, + IFLA_GSO_IPV6_MAX_SIZE, __IFLA_MAX }; diff --git a/net/core/dev.c b/net/core/dev.c index de28f634c18a65d1948a96db5678d38e9c871b1f..87f8b8cb39a61c8f5a444e3b341a97ba0a4c06d9 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10468,6 +10468,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->gso_max_segs = GSO_MAX_SEGS; dev->gro_max_size = GRO_MAX_SIZE; dev->tso_ipv6_max_size = GSO_MAX_SIZE; + dev->gso_ipv6_max_size = GSO_MAX_SIZE; dev->upper_level = 1; dev->lower_level = 1; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index ab51b18cdb5d46b87d4a11d2f66a68968ba737d6..172de404c595c89e30651a091242a75be8f786b7 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1028,6 +1028,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_GSO_MAX_SIZE */ + nla_total_size(4) /* IFLA_GRO_MAX_SIZE */ + nla_total_size(4) /* IFLA_TSO_IPV6_MAX_SIZE */ + + nla_total_size(4) /* IFLA_GSO_IPV6_MAX_SIZE */ + nla_total_size(1) /* IFLA_OPERSTATE */ + nla_total_size(1) /* IFLA_LINKMODE */ + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ @@ -1734,6 +1735,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_u32(skb, IFLA_GSO_MAX_SIZE, dev->gso_max_size) || nla_put_u32(skb, IFLA_GRO_MAX_SIZE, dev->gro_max_size) || nla_put_u32(skb, IFLA_TSO_IPV6_MAX_SIZE, dev->tso_ipv6_max_size) || + nla_put_u32(skb, IFLA_GSO_IPV6_MAX_SIZE, dev->gso_ipv6_max_size) || #ifdef CONFIG_RPS nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || #endif @@ -1888,6 +1890,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_PARENT_DEV_NAME] = { .type = NLA_NUL_STRING }, [IFLA_GRO_MAX_SIZE] = { .type = NLA_U32 }, [IFLA_TSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, + [IFLA_GSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { @@ -2774,6 +2777,15 @@ static int do_setlink(const struct sk_buff *skb, } } + if (tb[IFLA_GSO_IPV6_MAX_SIZE]) { + u32 max_size = nla_get_u32(tb[IFLA_GSO_IPV6_MAX_SIZE]); + + if (dev->gso_ipv6_max_size ^ max_size) { + netif_set_gso_ipv6_max_size(dev, max_size); + status |= DO_SETLINK_MODIFIED; + } + } + if (tb[IFLA_GSO_MAX_SEGS]) { u32 max_segs = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]); @@ -3249,6 +3261,9 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, netif_set_gso_max_segs(dev, nla_get_u32(tb[IFLA_GSO_MAX_SEGS])); if (tb[IFLA_GRO_MAX_SIZE]) netif_set_gro_max_size(dev, nla_get_u32(tb[IFLA_GRO_MAX_SIZE])); + if (tb[IFLA_GSO_IPV6_MAX_SIZE]) + netif_set_gso_ipv6_max_size(dev, + nla_get_u32(tb[IFLA_GSO_IPV6_MAX_SIZE])); return dev; } diff --git a/net/core/sock.c b/net/core/sock.c index 1180a0cb01104561befa1f96deb71f36efcf12da..e0858e82bc386eb2779a0d6af6063b2078e6ea7b 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2279,6 +2279,12 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) sk->sk_route_caps |= NETIF_F_SG | NETIF_F_HW_CSUM; /* pairs with the WRITE_ONCE() in netif_set_gso_max_size() */ sk->sk_gso_max_size = READ_ONCE(dst->dev->gso_max_size); +#if IS_ENABLED(CONFIG_IPV6) + if (sk->sk_family == AF_INET6 && + sk_is_tcp(sk) && + !ipv6_addr_v4mapped(&sk->sk_v6_rcv_saddr)) + sk->sk_gso_max_size = READ_ONCE(dst->dev->gso_ipv6_max_size); +#endif sk->sk_gso_max_size -= (MAX_TCP_HEADER + 1); /* pairs with the WRITE_ONCE() in netif_set_gso_max_segs() */ max_segs = max_t(u32, READ_ONCE(dst->dev->gso_max_segs), 1); diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index 441615c39f0a24eeeb6e27b4ca88031bcc234cf8..e40cd575607872d3bff3bc1971df8c6426290562 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -349,6 +349,7 @@ enum { IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, IFLA_TSO_IPV6_MAX_SIZE, + IFLA_GSO_IPV6_MAX_SIZE, __IFLA_MAX }; From patchwork Thu Mar 10 05:46:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775933 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 97929C433EF for ; Thu, 10 Mar 2022 05:47:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238622AbiCJFsV (ORCPT ); Thu, 10 Mar 2022 00:48:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239633AbiCJFsP (ORCPT ); Thu, 10 Mar 2022 00:48:15 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6499312D080 for ; Wed, 9 Mar 2022 21:47:14 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id m11-20020a17090a7f8b00b001beef6143a8so4282718pjl.4 for ; Wed, 09 Mar 2022 21:47:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=KFD2Eu7ySwZixX0vecWolWD4u1kH+iPN2NO5nEy2DUo=; b=kX8Uz1h+qJ7YQxiHFEjIu9tofBKnPDZEn0fFxXex5jMsx3frJSrhIDiqn/hSPpU8V2 ZPUMtcCSIH/UVrGwnLLOsu5yiz9PwpK9IaCFuB/HZmEGBOskVDvf84LAhyWAp9AWB444 Qx+Bu9mKrx0vEDcW2vZIqFJ3Aj5s7i6aUgcTREEjoJp9QQU0rQaLFct+ISFdxYWF3j63 ilER4BU73oSYS2JZqrVZj250Q9wJzHTFdoY1nc/B8iHYADMfiTkcT+4YgoLBTMrr60hy cVDmyY/thuwI9x0tNYl1d8hZyTfD2D6uOpjajzCdmYZExVrAyTOV2ZUmebdotFwsfq3j QflQ== 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=KFD2Eu7ySwZixX0vecWolWD4u1kH+iPN2NO5nEy2DUo=; b=UbjzVzMd8u4srSJlIH923g1mhtaymSSI3arhV0e2s9FqWwAPzvcgvvs6SZP85oXb3W dJfZvyaQd2QuCCvQtrXAWW0fCOYcMLRetAutTb6x/HmLae9Dx3+wI2kHlFzJ+oSzjSRR INKrma/nM6pp/ZGcVsDaNfTPNo6l74MVGbUtMK9Qo9efKLIHaCyhS6/uCdnVNbexAkF6 m8dgtqmvWWTzqvsfOT5pxb7YK9Mh//nfEYPox8TGCSzT/snyjrBHoymLB9Hdw4UzFr9b ArzrJTQEmGaJq3P2ymW/p9HgoeyH0CwPjwiBndSY3xFLvmar5zEccbLMHKR4tYgWak3J ffXg== X-Gm-Message-State: AOAM533afhfDKD551fk8gsI5k/M0euPGcCkNHhSBh92w91iv7GTCEr4S pDlFf26DRhsmmfVTOG8X10o= X-Google-Smtp-Source: ABdhPJxOMB79QKOHWSCyjW5SD3gpX3AIh5p0Fd61HQrg15zleuc4DbBgfTRA0TgclHZuqx6HuDelIg== X-Received: by 2002:a17:90a:e614:b0:1bf:53e6:46a5 with SMTP id j20-20020a17090ae61400b001bf53e646a5mr14450907pjy.161.1646891233923; Wed, 09 Mar 2022 21:47:13 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:13 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 03/14] tcp_cubic: make hystart_ack_delay() aware of BIG TCP Date: Wed, 9 Mar 2022 21:46:52 -0800 Message-Id: <20220310054703.849899-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet hystart_ack_delay() had the assumption that a TSO packet would not be bigger than GSO_MAX_SIZE. This will no longer be true. We should use sk->sk_gso_max_size instead. This reduces chances of spurious Hystart ACK train detections. Signed-off-by: Eric Dumazet --- net/ipv4/tcp_cubic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_cubic.c b/net/ipv4/tcp_cubic.c index 24d562dd62254d6e50dd08236f8967400d81e1ea..dfc9dc951b7404776b2246c38273fbadf03c39fd 100644 --- a/net/ipv4/tcp_cubic.c +++ b/net/ipv4/tcp_cubic.c @@ -372,7 +372,7 @@ static void cubictcp_state(struct sock *sk, u8 new_state) * We apply another 100% factor because @rate is doubled at this point. * We cap the cushion to 1ms. */ -static u32 hystart_ack_delay(struct sock *sk) +static u32 hystart_ack_delay(const struct sock *sk) { unsigned long rate; @@ -380,7 +380,7 @@ static u32 hystart_ack_delay(struct sock *sk) if (!rate) return 0; return min_t(u64, USEC_PER_MSEC, - div64_ul((u64)GSO_MAX_SIZE * 4 * USEC_PER_SEC, rate)); + div64_ul((u64)sk->sk_gso_max_size * 4 * USEC_PER_SEC, rate)); } static void hystart_update(struct sock *sk, u32 delay) From patchwork Thu Mar 10 05:46:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775934 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 CCF5FC433FE for ; Thu, 10 Mar 2022 05:47:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239647AbiCJFsY (ORCPT ); Thu, 10 Mar 2022 00:48:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238058AbiCJFsQ (ORCPT ); Thu, 10 Mar 2022 00:48:16 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711C8F957C for ; Wed, 9 Mar 2022 21:47:16 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id g19so4206119pfc.9 for ; Wed, 09 Mar 2022 21:47:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zmMmAv7X/GTOQMp14Z492/H8MoM1ZZZ0aZt3DTBRw6M=; b=E9I5eo+3RT0CJNCXM9CAdllkH0tAi6tyLnbvxTs23YsV4DPhWjDMgCxZEK+42THR+l ZAM3wnw0NxTaZsn4sXXBIKwkVWMsv5mxArv8mWig004vQMHcGGQtQH8V+ejqYet0iUt+ 0ZvW0uJiQJrRjuutenQN4uu1ndkBk1ELOqb6B+NOuBLFRZJjY8m+fLZsI3CBgdJPbp08 7dJ0EipajhJstmlIHf4ZJ5uwxYMKMbQeD/VoZZFMio4chZPpCHjyKkaYm/e0hduFeGVj sQc90cdHI827uhvcNCqQsSAFUy95QuhQlRNEHSTxCHCYacbaXqD6U20sRjnE+WlXrZbf FPbg== 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=zmMmAv7X/GTOQMp14Z492/H8MoM1ZZZ0aZt3DTBRw6M=; b=K3/Je1BA9P3XhajRsPj6p/4PsxXSGNoUl2ph6HGvMsxi2aH3UtFNqg/c0e41Db6kxS fML6ilLkFhWr3FcjTYzJ6qmxr4qPuQex5jnByxQETJ38qXPPvBIhvFwLyXGDVVPhoaeP BEUPJWuzxEJl3VU+2Bfk5DQoSLvVXbtSkh1JYjZFRL0MGu7XliT9IQqI1pqo3l0qM1zt WH4N2gliTlpEUTI+qn8EUXfvqSizAyc0c9LFUymNz/+bsFkCdE7IbNST0RGeja7SORWc qHuWHunHXednRAEu9ee8V6jVxSsfyICv65fN1CBVWGKHbm/KkAX2ZvmUQZ02/KX89sSW iVBQ== X-Gm-Message-State: AOAM530KePZIAAh6X4zWL5OitqLmy2HeLcfMqcpjk103R/P3QJMwQTaa Rq2q29YnWktZFRP7l5tfPMQ= X-Google-Smtp-Source: ABdhPJwMWQbzt0m3NdWwmkiES1J/WrNeje5u6KGzd/X4PO/12aP+hlO4Pt2cJ7O2PSnE1uEo9HuFbQ== X-Received: by 2002:a63:82c3:0:b0:37c:7976:4dc2 with SMTP id w186-20020a6382c3000000b0037c79764dc2mr2738663pgd.477.1646891235958; Wed, 09 Mar 2022 21:47:15 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:15 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 04/14] ipv6: add struct hop_jumbo_hdr definition Date: Wed, 9 Mar 2022 21:46:53 -0800 Message-Id: <20220310054703.849899-5-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Following patches will need to add and remove local IPv6 jumbogram options to enable BIG TCP. Signed-off-by: Eric Dumazet --- include/net/ipv6.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 213612f1680c7c39f4c07f0c05b4e6cf34a7878e..63d019953c47ea03d3b723a58c25e83c249489a9 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -151,6 +151,17 @@ struct frag_hdr { __be32 identification; }; +/* + * Jumbo payload option, as described in RFC 2675 2. + */ +struct hop_jumbo_hdr { + u8 nexthdr; + u8 hdrlen; + u8 tlv_type; /* IPV6_TLV_JUMBO, 0xC2 */ + u8 tlv_len; /* 4 */ + __be32 jumbo_payload_len; +}; + #define IP6_MF 0x0001 #define IP6_OFFSET 0xFFF8 From patchwork Thu Mar 10 05:46:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775935 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 9749CC433F5 for ; Thu, 10 Mar 2022 05:47:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239651AbiCJFs0 (ORCPT ); Thu, 10 Mar 2022 00:48:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239636AbiCJFsS (ORCPT ); Thu, 10 Mar 2022 00:48:18 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A42F957C for ; Wed, 9 Mar 2022 21:47:18 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id 132so3850217pga.5 for ; Wed, 09 Mar 2022 21:47:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WarTF79sMF9Xn0mTSt/aSUNBEE1Q4B+hWX/sa1IOapE=; b=FnhORxPJsZtiDhe4i3M84qF6hNu4q54JxjK3HKH6aJKkF27L2NInWZWZLwqUT0pxFD 24gceujrYjnMDk6/7+ktZLkg7VMFXrYMqZG+NJW+s0D74FMuxZvMce/yv14VDDgeMWXs BIyJOLc9bsarXJ6OkzBBQkGoB+h2yLScHLcXt9jYyE65zeeYWGNvlyf78Y2ydUaAsqNh HNmAHLb9e+KE5I6UL3CQYHM5wT4MMcwY+q8mBItVfWM+dCfMq3Xgnmi4mwQ6/+9DxABD be/7FqR7hvuP/U32Rh9Y1wU31sT6A107E6VbPuhJfrj3zP5+WPmp3WEy57buqYLi9eJl 2LLw== 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=WarTF79sMF9Xn0mTSt/aSUNBEE1Q4B+hWX/sa1IOapE=; b=wI1zZcyoGd6r6WwkBLfTqLrOBLO0dJhjM6fLiGisxPOpZZuMlcHaY6aLdPL7RTchzy zK5THM+yOI9+8tlTt6HUEKA4tXRTDU6WWiGYWLFuiLC459xnkx8dN+duW58TWdmcIGR6 qa9JE1ZISADc4E1M8tnMx4NFkCO0NKwn2SRbsvYLQwDYY2lys23fyKanftDoDJQg/a+C t4OHX9RlBaCaI2p7XfZYwzIh8QaikJbMBjp3uqK45vmsnEns8eySf/50txojBEg0Obac EQmowBhZk9yrqHQswrIHZ69E9074Zc26iXgVFFy4dQXLwOEAQ3ygK/OtT8je4Zfz0jeU ldhQ== X-Gm-Message-State: AOAM532qi/62Z8MKgeWoIyuMDks/qTLnQHPfPRN8SpcA0uXXihNmWhpD q++BiAxHdE891feXk6jqJ7Q= X-Google-Smtp-Source: ABdhPJwjUd8makr3FYAa4X8DYRDQIh241S/+nW985N+7Njc524fy9OhIK6iyD4DPRvf71Zx058m96Q== X-Received: by 2002:a05:6a00:230f:b0:4f4:13a9:9a53 with SMTP id h15-20020a056a00230f00b004f413a99a53mr3430329pfh.11.1646891238060; Wed, 09 Mar 2022 21:47:18 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:17 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 05/14] ipv6/gso: remove temporary HBH/jumbo header Date: Wed, 9 Mar 2022 21:46:54 -0800 Message-Id: <20220310054703.849899-6-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet ipv6 tcp and gro stacks will soon be able to build big TCP packets, with an added temporary Hop By Hop header. If GSO is involved for these large packets, we need to remove the temporary HBH header before segmentation happens. v2: perform HBH removal from ipv6_gso_segment() instead of skb_segment() (Alexander feedback) Signed-off-by: Eric Dumazet --- include/net/ipv6.h | 33 +++++++++++++++++++++++++++++++++ net/ipv6/ip6_offload.c | 24 +++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/include/net/ipv6.h b/include/net/ipv6.h index 63d019953c47ea03d3b723a58c25e83c249489a9..b6df0314aa02dd1c4094620145ccb24da7195b2b 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h @@ -467,6 +467,39 @@ bool ipv6_opt_accepted(const struct sock *sk, const struct sk_buff *skb, struct ipv6_txoptions *ipv6_update_options(struct sock *sk, struct ipv6_txoptions *opt); +/* This helper is specialized for BIG TCP needs. + * It assumes the hop_jumbo_hdr will immediately follow the IPV6 header. + * It assumes headers are already in skb->head. + * Returns 0, or IPPROTO_TCP if a BIG TCP packet is there. + */ +static inline int ipv6_has_hopopt_jumbo(const struct sk_buff *skb) +{ + const struct hop_jumbo_hdr *jhdr; + const struct ipv6hdr *nhdr; + + if (likely(skb->len <= GRO_MAX_SIZE)) + return 0; + + if (skb->protocol != htons(ETH_P_IPV6)) + return 0; + + if (skb_network_offset(skb) + + sizeof(struct ipv6hdr) + + sizeof(struct hop_jumbo_hdr) > skb_headlen(skb)) + return 0; + + nhdr = ipv6_hdr(skb); + + if (nhdr->nexthdr != NEXTHDR_HOP) + return 0; + + jhdr = (const struct hop_jumbo_hdr *) (nhdr + 1); + if (jhdr->tlv_type != IPV6_TLV_JUMBO || jhdr->hdrlen != 0 || + jhdr->nexthdr != IPPROTO_TCP) + return 0; + return jhdr->nexthdr; +} + static inline bool ipv6_accept_ra(struct inet6_dev *idev) { /* If forwarding is enabled, RA are not accepted unless the special diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index c4fc03c1ac99dbecd92e2b47b2db65374197434d..a6a6c1539c28d242ef8c35fcd5ce900512ce912d 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -77,7 +77,7 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, struct sk_buff *segs = ERR_PTR(-EINVAL); struct ipv6hdr *ipv6h; const struct net_offload *ops; - int proto; + int proto, nexthdr; struct frag_hdr *fptr; unsigned int payload_len; u8 *prevhdr; @@ -87,6 +87,28 @@ static struct sk_buff *ipv6_gso_segment(struct sk_buff *skb, bool gso_partial; skb_reset_network_header(skb); + nexthdr = ipv6_has_hopopt_jumbo(skb); + if (nexthdr) { + const int hophdr_len = sizeof(struct hop_jumbo_hdr); + int err; + + err = skb_cow_head(skb, 0); + if (err < 0) + return ERR_PTR(err); + + /* remove the HBH header. + * Layout: [Ethernet header][IPv6 header][HBH][TCP header] + */ + memmove(skb_mac_header(skb) + hophdr_len, + skb_mac_header(skb), + ETH_HLEN + sizeof(struct ipv6hdr)); + skb->data += hophdr_len; + skb->len -= hophdr_len; + skb->network_header += hophdr_len; + skb->mac_header += hophdr_len; + ipv6h = (struct ipv6hdr *)skb->data; + ipv6h->nexthdr = nexthdr; + } nhoff = skb_network_header(skb) - skb_mac_header(skb); if (unlikely(!pskb_may_pull(skb, sizeof(*ipv6h)))) goto out; From patchwork Thu Mar 10 05:46:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775936 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 37E03C433F5 for ; Thu, 10 Mar 2022 05:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239652AbiCJFs1 (ORCPT ); Thu, 10 Mar 2022 00:48:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239639AbiCJFsV (ORCPT ); Thu, 10 Mar 2022 00:48:21 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5053912E140 for ; Wed, 9 Mar 2022 21:47:20 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id q29so2871867pgn.7 for ; Wed, 09 Mar 2022 21:47:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bhvBzCoyUH5Q2UW9eaBJZ/pUOhsdMx7Q/qA4TYp9tCg=; b=Zp2FfWQMfm5g/+uCf2O371WkLZ8jkEvOzFp+CYjQnoQLv1DmpYpCrOR1xZ7lpeb07n roNXJTfiKGNrl10F3vP93yxx/vMyRfvK+D81XFWu1leSzfV4Oy2LL0U17b+PLhP79bZ2 JQ7ogkzkFKKr8+Xe0vA9FP52OZC0xOs5OHc5H9/xfrYfOLcA2yFK/0URu56orTCLTXJI +czr8KNyY+f60+muIcqW3S5hyrgdK50NvfBa6ESCPhWgBcGueLdxTj4qThoSFzTpmcOu u0ThVN2w8gOHUyVtM0zZ1vZaQZ3NlHq82roKYc1GEsU+2b47cs8zN3UqSLfYsfs1DfRA 72zg== 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=bhvBzCoyUH5Q2UW9eaBJZ/pUOhsdMx7Q/qA4TYp9tCg=; b=0wIWhaHD4RDKYwD0cAfXAT6RQUDbNb25W4/SeLQjJzQpnZt/yI+PtnNzse0g2CGJh/ +x6o1WhaLpbpBkeuhi3RqgwV+FP9jtjrl+Ut5EWq2mV/iE27UDyR4lMfBsPYOjoE7L0Z f+69aCN2Xg3IuMdpidXLoFhrPuewKZsJQKT8pmCbyZfV+yvNSPp13j8MeisZZSjPVYrD 4Ldxc5+rQ/zvmD1hSBUQqilZfDiafLfnLES5qIuupcrVhM/IjgBwT6sVdaK9OAJk6I8J NQdHfY+gWkRBkTrrdpBPw1xwEae7QANeJqQMpLTqOwuKoDomvohd7l5e7eR+WPEjOcFc 8xdw== X-Gm-Message-State: AOAM53261OTOIHaXQptF8vajXGwcbTY4PdQ3rQ5MFVaQ5EjG0LI5crtK ziLMkVS3kF4XJTYfn8wz6NE= X-Google-Smtp-Source: ABdhPJyo59yV9HvctnugOVjsaaOEYm+oPkw2SDpIWhDHl/tQiv2qS7xJrtb5Ig0q0M4YigMriBWu1w== X-Received: by 2002:a62:1d48:0:b0:4f6:b805:4bad with SMTP id d69-20020a621d48000000b004f6b8054badmr3362132pfd.67.1646891240226; Wed, 09 Mar 2022 21:47:20 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:19 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 06/14] ipv6/gro: insert temporary HBH/jumbo header Date: Wed, 9 Mar 2022 21:46:55 -0800 Message-Id: <20220310054703.849899-7-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Following patch will add GRO_IPV6_MAX_SIZE, allowing gro to build BIG TCP ipv6 packets (bigger than 64K). This patch changes ipv6_gro_complete() to insert a HBH/jumbo header so that resulting packet can go through IPv6/TCP stacks. Signed-off-by: Eric Dumazet --- net/ipv6/ip6_offload.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index a6a6c1539c28d242ef8c35fcd5ce900512ce912d..d12dba2dd5354dbb79bb80df4038dec2544cddeb 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -342,15 +342,43 @@ static struct sk_buff *ip4ip6_gro_receive(struct list_head *head, INDIRECT_CALLABLE_SCOPE int ipv6_gro_complete(struct sk_buff *skb, int nhoff) { const struct net_offload *ops; - struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + nhoff); + struct ipv6hdr *iph; int err = -ENOSYS; + u32 payload_len; if (skb->encapsulation) { skb_set_inner_protocol(skb, cpu_to_be16(ETH_P_IPV6)); skb_set_inner_network_header(skb, nhoff); } - iph->payload_len = htons(skb->len - nhoff - sizeof(*iph)); + payload_len = skb->len - nhoff - sizeof(*iph); + if (unlikely(payload_len > IPV6_MAXPLEN)) { + struct hop_jumbo_hdr *hop_jumbo; + int hoplen = sizeof(*hop_jumbo); + + /* Move network header left */ + memmove(skb_mac_header(skb) - hoplen, skb_mac_header(skb), + skb->transport_header - skb->mac_header); + skb->data -= hoplen; + skb->len += hoplen; + skb->mac_header -= hoplen; + skb->network_header -= hoplen; + iph = (struct ipv6hdr *)(skb->data + nhoff); + hop_jumbo = (struct hop_jumbo_hdr *)(iph + 1); + + /* Build hop-by-hop options */ + hop_jumbo->nexthdr = iph->nexthdr; + hop_jumbo->hdrlen = 0; + hop_jumbo->tlv_type = IPV6_TLV_JUMBO; + hop_jumbo->tlv_len = 4; + hop_jumbo->jumbo_payload_len = htonl(payload_len + hoplen); + + iph->nexthdr = NEXTHDR_HOP; + iph->payload_len = 0; + } else { + iph = (struct ipv6hdr *)(skb->data + nhoff); + iph->payload_len = htons(payload_len); + } nhoff += sizeof(*iph) + ipv6_exthdrs_len(iph, &ops); if (WARN_ON(!ops || !ops->callbacks.gro_complete)) From patchwork Thu Mar 10 05:46:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775937 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 A4857C433F5 for ; Thu, 10 Mar 2022 05:47:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239637AbiCJFsm (ORCPT ); Thu, 10 Mar 2022 00:48:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239646AbiCJFsX (ORCPT ); Thu, 10 Mar 2022 00:48:23 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A729B12E148 for ; Wed, 9 Mar 2022 21:47:22 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id o26so3841756pgb.8 for ; Wed, 09 Mar 2022 21:47:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eo3id4mltdS6nMy0F8ZyU5fXOpJVIISYbsPHwatxSno=; b=j11Puk6hcPGnQFLogjNiZEDsaooFUewQEz6ZaONpcZ8aCCW0vLujPCsILDMoHQgctV cpFIKAznuFJcRCab6kRqqfbjXWq0488l89ntnIIBTt0kCKbZ02ycWFLhysZZuMA8XSwq It95DIOiYFBQB2zm4nqMkHoQ6OTVnHX0D2Maw+TbqoeXX1b+EDugzzCSzBt4u7IodOZy iYof4+SJ8quWUaRQcHQYctKrnjoyzpz1te9e9aRwPFWCk7rbWqUHcbnP13HV1la9r8Wa Quto96hARc4fdXG/vqRGLpILXX695xG/mkL3Cri+Q1+1yUIs40qgAoBkl+HACSQWa3yy zclA== 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=Eo3id4mltdS6nMy0F8ZyU5fXOpJVIISYbsPHwatxSno=; b=pIxCe6ifoCvKx+d1l8MaO2ORlvjlKFN7/UZegjMi5tx2+gYmxHW2c844ONglYCXSAm 1Yoailzk+Nmg/h397seEz8pBu4+D2os39YBVaB+XFNf3ffo8LPJvEeQDgBw2fa3yuqmE JlynhYkMQ81Eg6py1zGHYGdx/ksFhkNbluZO0QMHK6r07grmEsxrJkSBTHbcEOt4F6es Es88VcQPFkZIgMpBl82uqG8JnsCdBCB0xb4tLRjNtzuTLG6popr/7BYFz549cisYmrV6 WC+Y238GCUiXAZe1B2yYKguRichhWYDcBWP83p74S2jmAZ9BqUA8+kO+hOtVktQyYRP9 5/rw== X-Gm-Message-State: AOAM5304gPPR6O7Nn0L8HV0EV+F92VIJ4Xs5HJ+0941FbYfT0zvoxj1k qnogsQjhA6z9G1pmBFRX+aQ= X-Google-Smtp-Source: ABdhPJwO14p+YV4a+W3Lnn8VMmJwpThdT6kDtKqNRn7m0VmOkAkqsSCp4088/UWXf9YXT1u8z6Wcaw== X-Received: by 2002:a05:6a00:1687:b0:4e1:45d:3ded with SMTP id k7-20020a056a00168700b004e1045d3dedmr3185637pfc.0.1646891242147; Wed, 09 Mar 2022 21:47:22 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:21 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 07/14] ipv6: add GRO_IPV6_MAX_SIZE Date: Wed, 9 Mar 2022 21:46:56 -0800 Message-Id: <20220310054703.849899-8-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Coco Li Enable GRO to have IPv6 specific limit for max packet size. This patch introduces new dev->gro_ipv6_max_size that is modifiable through ip link. ip link set dev eth0 gro_ipv6_max_size 185000 Note that this value is only considered if bigger than gro_max_size, and for non encapsulated TCP/ipv6 packets. Signed-off-by: Coco Li Signed-off-by: Eric Dumazet --- include/linux/netdevice.h | 10 ++++++++++ include/uapi/linux/if_link.h | 1 + net/core/dev.c | 1 + net/core/gro.c | 20 ++++++++++++++++++-- net/core/rtnetlink.c | 15 +++++++++++++++ tools/include/uapi/linux/if_link.h | 1 + 6 files changed, 46 insertions(+), 2 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 9ed348d8b6f1195514c3b5f85fbe2c45b3fa997f..771440f6f8a8fa6cdadd398be8f2bacb4841138c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1944,6 +1944,8 @@ enum netdev_ml_priv_type { * keep a list of interfaces to be deleted. * @gro_max_size: Maximum size of aggregated packet in generic * receive offload (GRO) + * @gro_ipv6_max_size: Maximum size of aggregated packet in generic + * receive offload (GRO), for IPv6 * * @dev_addr_shadow: Copy of @dev_addr to catch direct writes. * @linkwatch_dev_tracker: refcount tracker used by linkwatch. @@ -2140,6 +2142,7 @@ struct net_device { int napi_defer_hard_irqs; #define GRO_MAX_SIZE 65536 unsigned int gro_max_size; + unsigned int gro_ipv6_max_size; rx_handler_func_t __rcu *rx_handler; void __rcu *rx_handler_data; @@ -4910,6 +4913,13 @@ static inline void netif_set_gso_ipv6_max_size(struct net_device *dev, WRITE_ONCE(dev->gso_ipv6_max_size, size); } +static inline void netif_set_gro_ipv6_max_size(struct net_device *dev, + unsigned int size) +{ + /* This pairs with the READ_ONCE() in skb_gro_receive() */ + WRITE_ONCE(dev->gro_ipv6_max_size, size); +} + static inline void skb_gso_error_unwind(struct sk_buff *skb, __be16 protocol, int pulled_hlen, u16 mac_offset, int mac_len) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 048a9c848a3a39596b6c3135553fdfb9a1fe37d2..9baa084fe2c6762b05029c4692cfd9c4646bb916 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -365,6 +365,7 @@ enum { IFLA_GRO_MAX_SIZE, IFLA_TSO_IPV6_MAX_SIZE, IFLA_GSO_IPV6_MAX_SIZE, + IFLA_GRO_IPV6_MAX_SIZE, __IFLA_MAX }; diff --git a/net/core/dev.c b/net/core/dev.c index 87f8b8cb39a61c8f5a444e3b341a97ba0a4c06d9..9921cee9c20d2bc396ef1f4d783ac01604b1e8be 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10469,6 +10469,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->gro_max_size = GRO_MAX_SIZE; dev->tso_ipv6_max_size = GSO_MAX_SIZE; dev->gso_ipv6_max_size = GSO_MAX_SIZE; + dev->gro_ipv6_max_size = GRO_MAX_SIZE; dev->upper_level = 1; dev->lower_level = 1; diff --git a/net/core/gro.c b/net/core/gro.c index ee5e7e889d8bdd8db18715afc7bb6c1c759c9c23..f795393a883b08d71bfcfbd2d897e1ddcddf6fce 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -136,11 +136,27 @@ int skb_gro_receive(struct sk_buff *p, struct sk_buff *skb) unsigned int new_truesize; struct sk_buff *lp; + if (unlikely(NAPI_GRO_CB(skb)->flush)) + return -E2BIG; + /* pairs with WRITE_ONCE() in netif_set_gro_max_size() */ gro_max_size = READ_ONCE(p->dev->gro_max_size); - if (unlikely(p->len + len >= gro_max_size || NAPI_GRO_CB(skb)->flush)) - return -E2BIG; + if (unlikely(p->len + len >= gro_max_size)) { + /* pairs with WRITE_ONCE() in netif_set_gro_ipv6_max_size() */ + unsigned int gro6_max_size = READ_ONCE(p->dev->gro_ipv6_max_size); + + if (gro6_max_size > gro_max_size && + p->protocol == htons(ETH_P_IPV6) && + skb_headroom(p) >= sizeof(struct hop_jumbo_hdr) && + ipv6_hdr(p)->nexthdr == IPPROTO_TCP && + !p->encapsulation) + gro_max_size = gro6_max_size; + + if (p->len + len >= gro_max_size) + return -E2BIG; + } + lp = NAPI_GRO_CB(p)->last; pinfo = skb_shinfo(lp); diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 172de404c595c89e30651a091242a75be8f786b7..39c5a9fb792df3992b4e7177f4dfeba2553eaa08 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1029,6 +1029,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_GRO_MAX_SIZE */ + nla_total_size(4) /* IFLA_TSO_IPV6_MAX_SIZE */ + nla_total_size(4) /* IFLA_GSO_IPV6_MAX_SIZE */ + + nla_total_size(4) /* IFLA_GRO_IPV6_MAX_SIZE */ + nla_total_size(1) /* IFLA_OPERSTATE */ + nla_total_size(1) /* IFLA_LINKMODE */ + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ @@ -1736,6 +1737,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_u32(skb, IFLA_GRO_MAX_SIZE, dev->gro_max_size) || nla_put_u32(skb, IFLA_TSO_IPV6_MAX_SIZE, dev->tso_ipv6_max_size) || nla_put_u32(skb, IFLA_GSO_IPV6_MAX_SIZE, dev->gso_ipv6_max_size) || + nla_put_u32(skb, IFLA_GRO_IPV6_MAX_SIZE, dev->gro_ipv6_max_size) || #ifdef CONFIG_RPS nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || #endif @@ -1891,6 +1893,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_GRO_MAX_SIZE] = { .type = NLA_U32 }, [IFLA_TSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, [IFLA_GSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, + [IFLA_GRO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { @@ -2786,6 +2789,15 @@ static int do_setlink(const struct sk_buff *skb, } } + if (tb[IFLA_GRO_IPV6_MAX_SIZE]) { + u32 max_size = nla_get_u32(tb[IFLA_GRO_IPV6_MAX_SIZE]); + + if (dev->gro_ipv6_max_size ^ max_size) { + netif_set_gro_ipv6_max_size(dev, max_size); + status |= DO_SETLINK_MODIFIED; + } + } + if (tb[IFLA_GSO_MAX_SEGS]) { u32 max_segs = nla_get_u32(tb[IFLA_GSO_MAX_SEGS]); @@ -3264,6 +3276,9 @@ struct net_device *rtnl_create_link(struct net *net, const char *ifname, if (tb[IFLA_GSO_IPV6_MAX_SIZE]) netif_set_gso_ipv6_max_size(dev, nla_get_u32(tb[IFLA_GSO_IPV6_MAX_SIZE])); + if (tb[IFLA_GRO_IPV6_MAX_SIZE]) + netif_set_gro_ipv6_max_size(dev, + nla_get_u32(tb[IFLA_GRO_IPV6_MAX_SIZE])); return dev; } diff --git a/tools/include/uapi/linux/if_link.h b/tools/include/uapi/linux/if_link.h index e40cd575607872d3bff3bc1971df8c6426290562..567008925a8be6900aa048c7ebb12684b2eebb4b 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -350,6 +350,7 @@ enum { IFLA_GRO_MAX_SIZE, IFLA_TSO_IPV6_MAX_SIZE, IFLA_GSO_IPV6_MAX_SIZE, + IFLA_GRO_IPV6_MAX_SIZE, __IFLA_MAX }; From patchwork Thu Mar 10 05:46:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775938 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 C7FEEC433F5 for ; Thu, 10 Mar 2022 05:47:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236134AbiCJFso (ORCPT ); Thu, 10 Mar 2022 00:48:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239648AbiCJFsZ (ORCPT ); Thu, 10 Mar 2022 00:48:25 -0500 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CC2F12D933 for ; Wed, 9 Mar 2022 21:47:24 -0800 (PST) Received: by mail-pl1-x631.google.com with SMTP id z3so3932769plg.8 for ; Wed, 09 Mar 2022 21:47:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Eo6Ay78UtfJaj+pFT4IeJlC6FzfAL4dcL6hsPGiyVns=; b=UngQJA1Qwd2nbsl3K8eXkwGV/ZmMqwDoKMwsYodWXvVaq7BzAQ4n464ZJ68CgwG55K YdsLaqrUjvhfRpA4j9hQdw/Anfn9IAj8nVEu4KzW06QI0B6/9zRF/Xr+e9X006ZbLY9O 0fQc2RTWcG9YQM7RI0UR/CwOSnEXqaiUzSGSymivDQqVyll3Doojq8oRJg7YdlpiaTD4 DArgWJOjdzsG2YUpseALrHWiOofkYTT4rYQZyVhsUdOS3h9hMLds62O92RHvU5h1r+bX FhHAILcFlxUeKO3YThZIGuca8eiG9nO72sVJVF/OW9KTHoCPO6bdEVHzIhC1uKzU0oRl koQw== 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=Eo6Ay78UtfJaj+pFT4IeJlC6FzfAL4dcL6hsPGiyVns=; b=FHI5z+rZ4yQBk5BndUIkMEHd+hlY6Aw/hmmcRBKqzii8YVMNPRmEjFweOX8fTc3Y0D ziBsfy9w4N3i2Ekhs4/YMkSgwVRc8FaQaTSIjsYlQs4FligLwC5DE7eBknBVvBwAa8V/ I4e18KrqRHyRBqEOyZODCwd3F+EWTDpR6RXAkl9CWiKHtt4Eu8xjbQ3uwmVUJ2QZ3Ikf 8bDKYRNAi2EjzUUKwQZ+M9UqCjke0QRIEtxTsFzp+XDbKR35pwV2aHQOvi/SGwKFXv/D frGjIautNdbE1vaGlmjsQF+hWJXfZsB8QhBWrDbzeGSrHI02Aeos+8vGgR4gji2KgboI uKHA== X-Gm-Message-State: AOAM530/riCQxdDDXAppqCUm6KarfHrwY1SC1iqbRYgyXy7uQiIQG0TQ 9h+LqQE4RcwpcxqFtgjJs2k= X-Google-Smtp-Source: ABdhPJwvg0lyFA28nm+Q910n6d0Nlca1VENlt7y7d1mE26lYw/7wDAtxV6XUdJFHS5EgiiSOUSAMTw== X-Received: by 2002:a17:902:7895:b0:14b:6b63:b3fa with SMTP id q21-20020a170902789500b0014b6b63b3famr3210121pll.156.1646891244148; Wed, 09 Mar 2022 21:47:24 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:23 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 08/14] ipv6: Add hop-by-hop header to jumbograms in ip6_output Date: Wed, 9 Mar 2022 21:46:57 -0800 Message-Id: <20220310054703.849899-9-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Coco Li Instead of simply forcing a 0 payload_len in IPv6 header, implement RFC 2675 and insert a custom extension header. Note that only TCP stack is currently potentially generating jumbograms, and that this extension header is purely local, it wont be sent on a physical link. This is needed so that packet capture (tcpdump and friends) can properly dissect these large packets. Signed-off-by: Coco Li Signed-off-by: Eric Dumazet --- include/linux/ipv6.h | 1 + net/ipv6/ip6_output.c | 22 ++++++++++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index 16870f86c74d3d1f5dfb7edac1e7db85f1ef6755..93b273db1c9926aba4199f486ce90778311916f5 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -144,6 +144,7 @@ struct inet6_skb_parm { #define IP6SKB_L3SLAVE 64 #define IP6SKB_JUMBOGRAM 128 #define IP6SKB_SEG6 256 +#define IP6SKB_FAKEJUMBO 512 }; #if defined(CONFIG_NET_L3_MASTER_DEV) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index e69fac576970a9b85fb68aa02822c0e2df67e1a2..941ceff83b616cec11c6bb7ccaf81bc041f8d9cc 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -180,7 +180,9 @@ static int __ip6_finish_output(struct net *net, struct sock *sk, struct sk_buff #endif mtu = ip6_skb_dst_mtu(skb); - if (skb_is_gso(skb) && !skb_gso_validate_network_len(skb, mtu)) + if (skb_is_gso(skb) && + !(IP6CB(skb)->flags & IP6SKB_FAKEJUMBO) && + !skb_gso_validate_network_len(skb, mtu)) return ip6_finish_output_gso_slowpath_drop(net, sk, skb, mtu); if ((skb->len > mtu && !skb_is_gso(skb)) || @@ -251,6 +253,8 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, struct dst_entry *dst = skb_dst(skb); struct net_device *dev = dst->dev; struct inet6_dev *idev = ip6_dst_idev(dst); + struct hop_jumbo_hdr *hop_jumbo; + int hoplen = sizeof(*hop_jumbo); unsigned int head_room; struct ipv6hdr *hdr; u8 proto = fl6->flowi6_proto; @@ -258,7 +262,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, int hlimit = -1; u32 mtu; - head_room = sizeof(struct ipv6hdr) + LL_RESERVED_SPACE(dev); + head_room = sizeof(struct ipv6hdr) + hoplen + LL_RESERVED_SPACE(dev); if (opt) head_room += opt->opt_nflen + opt->opt_flen; @@ -281,6 +285,20 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6, &fl6->saddr); } + if (unlikely(seg_len > IPV6_MAXPLEN)) { + hop_jumbo = skb_push(skb, hoplen); + + hop_jumbo->nexthdr = proto; + hop_jumbo->hdrlen = 0; + hop_jumbo->tlv_type = IPV6_TLV_JUMBO; + hop_jumbo->tlv_len = 4; + hop_jumbo->jumbo_payload_len = htonl(seg_len + hoplen); + + proto = IPPROTO_HOPOPTS; + seg_len = 0; + IP6CB(skb)->flags |= IP6SKB_FAKEJUMBO; + } + skb_push(skb, sizeof(struct ipv6hdr)); skb_reset_network_header(skb); hdr = ipv6_hdr(skb); From patchwork Thu Mar 10 05:46:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775939 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 849F3C433EF for ; Thu, 10 Mar 2022 05:47:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239669AbiCJFss (ORCPT ); Thu, 10 Mar 2022 00:48:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239653AbiCJFsk (ORCPT ); Thu, 10 Mar 2022 00:48:40 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFC212E15B for ; Wed, 9 Mar 2022 21:47:26 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id o8so3838057pgf.9 for ; Wed, 09 Mar 2022 21:47:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=m3R0BhiqPxOZEoq0u9oSqVsOJdu8BSFsUrtrIwkGaQ4=; b=TBfw11vSot0Hi/7+ztT9sVNbY5catDW8bLxFdhEr4bwXID1RHyhEKEd3g9+2J3O+3n U9FEJ5AC6vcm6hkkS64/rvjyxXekfrn5rrvNbrDY8GHbRDrHFzaGbZaQwGg20Vg9q1ae YD6Iddt7RgmWHMqa8jV5kQ6u8yqdsPRFJXG1UEwPp4g5pdx97D4OMx1efyNLMr3Ej+YJ Bd1sv3j1sGYay7DnQj1XHI+aHlrquLgLiuukXEOAsZSdHrV9dVRIMZa0ToZBdhV8q3j7 XnOZB/COrwFIybZjt4cJ0QUiTC349N2IFi/Cx7vTPDdPVyw8H+Nmud6kqpX+I5Lzwvdw nu0g== 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=m3R0BhiqPxOZEoq0u9oSqVsOJdu8BSFsUrtrIwkGaQ4=; b=eayJJci7DtkrUO5O3ix51FzIqTOcGfgMQtuibBotZWNLrkDceMWnHFuuL2Q/i1mGHE HBkQrCKDqBWinbw+mOd1hqXtoEz4x84ncw288j4DqWRDTbargO1rIt0U+MJFJ5uYlxv+ yf0u/KSEjuaRPXhNX4yHqIHNqKIDaceM3vav1i63G+ZVCiBU4llkzjNFuQVQzunoLXLc EgKjz+rpVHT3roa+1KdJZonl+5tkMPi2coRdZAZXaXl5yOevNcG+5X+aDKJl6/jeMQyc p5Ce8D0ZvOTfZosrmhnUOslsJX+zao9jCbBhgs8iK3Tr4q65xHGjxl2AfExLge6qqS9R cceQ== X-Gm-Message-State: AOAM532gQcjQZEvnBy/kiuNag513fQZALprVvvCVA071TeY8x/oa7OH3 FVQFWqLnIrbTCHjw4SeV1Jk= X-Google-Smtp-Source: ABdhPJxUVT4/zlEQUKZgRghRIX7QXByTYt0mfxeLpiCly0BJ1Rqb0+kdEZH7tONOGgtx0xBMuNy7zQ== X-Received: by 2002:aa7:9730:0:b0:4f6:d6ee:cc0b with SMTP id k16-20020aa79730000000b004f6d6eecc0bmr3340200pfg.41.1646891245940; Wed, 09 Mar 2022 21:47:25 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:25 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 09/14] net: loopback: enable BIG TCP packets Date: Wed, 9 Mar 2022 21:46:58 -0800 Message-Id: <20220310054703.849899-10-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Set the driver limit to 512 KB per TSO ipv6 packet. This allows the admin/user to set a GSO ipv6 limit up to this value. Tested: ip link set dev lo gso_ipv6_max_size 200000 netperf -H ::1 -t TCP_RR -l 100 -- -r 80000,80000 & tcpdump shows : 18:28:42.962116 IP6 ::1 > ::1: HBH 40051 > 63780: Flags [P.], seq 3626480001:3626560001, ack 3626560001, win 17743, options [nop,nop,TS val 3771179265 ecr 3771179265], length 80000 18:28:42.962138 IP6 ::1.63780 > ::1.40051: Flags [.], ack 3626560001, win 17743, options [nop,nop,TS val 3771179265 ecr 3771179265], length 0 18:28:42.962152 IP6 ::1 > ::1: HBH 63780 > 40051: Flags [P.], seq 3626560001:3626640001, ack 3626560001, win 17743, options [nop,nop,TS val 3771179265 ecr 3771179265], length 80000 18:28:42.962157 IP6 ::1.40051 > ::1.63780: Flags [.], ack 3626640001, win 17743, options [nop,nop,TS val 3771179265 ecr 3771179265], length 0 18:28:42.962180 IP6 ::1 > ::1: HBH 40051 > 63780: Flags [P.], seq 3626560001:3626640001, ack 3626640001, win 17743, options [nop,nop,TS val 3771179265 ecr 3771179265], length 80000 18:28:42.962214 IP6 ::1.63780 > ::1.40051: Flags [.], ack 3626640001, win 17743, options [nop,nop,TS val 3771179266 ecr 3771179265], length 0 18:28:42.962228 IP6 ::1 > ::1: HBH 63780 > 40051: Flags [P.], seq 3626640001:3626720001, ack 3626640001, win 17743, options [nop,nop,TS val 3771179266 ecr 3771179265], length 80000 18:28:42.962233 IP6 ::1.40051 > ::1.63780: Flags [.], ack 3626720001, win 17743, options [nop,nop,TS val 3771179266 ecr 3771179266], length 0 Signed-off-by: Eric Dumazet --- drivers/net/loopback.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index 720394c0639b20a2fd6262e4ee9d5813c02802f1..9c21d18f0aa75a310ac600081b450f6312ff16fc 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c @@ -191,6 +191,8 @@ static void gen_lo_setup(struct net_device *dev, dev->netdev_ops = dev_ops; dev->needs_free_netdev = true; dev->priv_destructor = dev_destructor; + + netif_set_tso_ipv6_max_size(dev, 512 * 1024); } /* The loopback device is special. There is only one instance From patchwork Thu Mar 10 05:46:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775940 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 08871C433FE for ; Thu, 10 Mar 2022 05:47:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239639AbiCJFsu (ORCPT ); Thu, 10 Mar 2022 00:48:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239660AbiCJFsl (ORCPT ); Thu, 10 Mar 2022 00:48:41 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2262312E169 for ; Wed, 9 Mar 2022 21:47:28 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id p17so3923945plo.9 for ; Wed, 09 Mar 2022 21:47:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5aBQM8wNOxbvrRsNnfmdlVwJl6wi5pr+JOyZvAg1e78=; b=NKmd7RPcJOLxKP4oaFt1g8b9YAgP8ZNOfHhYNev+d7+7HGlTWgDnoDaWFVECdOoLU/ z1CJCg4zo/TWDTBeu7ihQkto1semeJOh6kvbiC0x+rBzBcCzglsTdi8qROFbQNrUWLi1 /7uff6FCCyyIjRtPl2iUV/LPITC86E0qEBQyys3Hj96XLA7Opn/IUW9Uj+KxCUolzayl 6VMeVBU4JGzcXYTxMulfg9MmmMVr3pFbvZ0mgS9woSnQbFlosSz0U0CqGJtpcGc+oeN3 gp4HdfKKJoFa8Jmrm11US6od/4rxyLTtvQIrpLz7BbSp4cXTxyZk9ZeVlKTIqSutYUlX 0UnQ== 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=5aBQM8wNOxbvrRsNnfmdlVwJl6wi5pr+JOyZvAg1e78=; b=0cIGBZkCLTa+8NBiZ85+hkX0fsbVrOS2/j7dobuOjHOaAwCVThnWoG2M7bmh3o4Dk7 Ty90O67aZopBqlRp5/uGXsOxddkccmjsk9B4COVtbatmvW3BWLEWuMvmDg6R1lRUq44K JawMRdkvWM9IEbnLTGkPADPDciAYd4Ru73yb9PAE/v5uUDT1DQaU8AxkdeE/ieZoKaQD ycujorsPPevR6INhhO8z5Gni2EBNg1zLedMy+IbU0fj9xplEpnAcNXPOXEMEGVbuC2TK 03HbL5wj0q32BGi3/9x6llrUm4J9Uuh29H898FLHx+8bev8+dVoPZv3UAhkc1DcXe+I4 dEWA== X-Gm-Message-State: AOAM533qIbRq1zNUNLvA1w4hTc3Og/R8QsCDUZDqAhUCpoXnVUJFVy25 fEwsVfjyJm4JZhf6PzOO8to= X-Google-Smtp-Source: ABdhPJwwb5IrdvL1ddhIYEqhZdPq1csF+PgUXvixWiCDDx/N4oRwXxH0iuJdyTLUIq3ZVzccRvcRAg== X-Received: by 2002:a17:902:e80d:b0:151:e043:a2c3 with SMTP id u13-20020a170902e80d00b00151e043a2c3mr3379261plg.64.1646891247961; Wed, 09 Mar 2022 21:47:27 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:27 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 10/14] bonding: update dev->tso_ipv6_max_size Date: Wed, 9 Mar 2022 21:46:59 -0800 Message-Id: <20220310054703.849899-11-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Use the minimal value found in the set of lower devices. Signed-off-by: Eric Dumazet --- drivers/net/bonding/bond_main.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 55e0ba2a163d0d9c17fdaf47a49d7a2190959651..357188c1f00e6e3919740adb6369d75712fc4e64 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1420,6 +1420,7 @@ static void bond_compute_features(struct bonding *bond) struct slave *slave; unsigned short max_hard_header_len = ETH_HLEN; unsigned int gso_max_size = GSO_MAX_SIZE; + unsigned int tso_ipv6_max_size = ~0U; u16 gso_max_segs = GSO_MAX_SEGS; if (!bond_has_slaves(bond)) @@ -1450,6 +1451,7 @@ static void bond_compute_features(struct bonding *bond) max_hard_header_len = slave->dev->hard_header_len; gso_max_size = min(gso_max_size, slave->dev->gso_max_size); + tso_ipv6_max_size = min(tso_ipv6_max_size, slave->dev->tso_ipv6_max_size); gso_max_segs = min(gso_max_segs, slave->dev->gso_max_segs); } bond_dev->hard_header_len = max_hard_header_len; @@ -1465,6 +1467,7 @@ static void bond_compute_features(struct bonding *bond) bond_dev->mpls_features = mpls_features; netif_set_gso_max_segs(bond_dev, gso_max_segs); netif_set_gso_max_size(bond_dev, gso_max_size); + netif_set_tso_ipv6_max_size(bond_dev, tso_ipv6_max_size); bond_dev->priv_flags &= ~IFF_XMIT_DST_RELEASE; if ((bond_dev->priv_flags & IFF_XMIT_DST_RELEASE_PERM) && From patchwork Thu Mar 10 05:47:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775941 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 A15B7C433F5 for ; Thu, 10 Mar 2022 05:47:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239667AbiCJFsv (ORCPT ); Thu, 10 Mar 2022 00:48:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239668AbiCJFsl (ORCPT ); Thu, 10 Mar 2022 00:48:41 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F99912E160 for ; Wed, 9 Mar 2022 21:47:30 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id mm23-20020a17090b359700b001bfceefd8c6so1071254pjb.3 for ; Wed, 09 Mar 2022 21:47:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gtAHZRigkzO4a1Jgu5OwYx4SbI+nNslUCVxlgRRzKWg=; b=HlSyzdDLZIO8ckhDwEJvl1HNqb2NPFL+6Dv7TwtDxt8sPTVOvUGuSZTk11CbbmHFXh mpNUKHAQBPR9Y+S8TAzarcRibOV3NJrTmc4M3g9uUL7hDECyJSdkcKl395tsLenlj6xS u9i/tKxpjGJTQR1sWQiOpeL6xR/ewMO/hqv1iFSwaE0wzm1ZusRiTQRaapa/CIYoZENt vDiDe7bCwrgH3SVMFqPYkVJEAmY5tXUcKnpVv4iamVxioChL842eH+eCF97XhjrY9xiR 9HVSCrQuEY0i9JZtnIJ1hESVKUj+lm59aQlbcHaKlUYzxGqs7RrddL5wbyWjvpaWEe0X fz9g== 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=gtAHZRigkzO4a1Jgu5OwYx4SbI+nNslUCVxlgRRzKWg=; b=P4sK7rgPcSdWwcbyPgX261wvk5hxJBqpHhqne23rW94l+EfzjTITczQ4nFzfjYk1cW mZgCbpljnkNFNuqfYFG/yM9ijK1sQxiPzHl2z7wYr68Ef2q7K1kjJImdpZbRHz8AIBqg 23Ne4ix3ocgi0pUo4qGVMvTqsiNIQEtU3JSptF1RD60o7zlOwZ8RTi9mf4rHRhgjUrrj PKrI73GqnNNq3tDn9B7Uo6jDsiMGhzhQ3lrfj2v1RWhZVAtP6A3rNXMzij/ZDCjpBdpd ilY10MYhcDDtVSWW4FsiAnXRsRAWwpUoaKZl8ZZdgLT+IinILuxuXGc0rcA5cRZidG3z dQqg== X-Gm-Message-State: AOAM5310GWrT2ODmuxWfdSMROZbtE+bOL81DxoTgVwRBviRTmXgxv5Ym LUq2OdtknUV59fBSFo3G9n8= X-Google-Smtp-Source: ABdhPJw+y1YOSdrOqLUyZmcQ5CdKNvJXYnhKlWT+pUeE8GuBeCxzgi/qNbSI3RnMXooOwdFiZLww3Q== X-Received: by 2002:a17:902:d643:b0:151:6f2c:cfb4 with SMTP id y3-20020a170902d64300b001516f2ccfb4mr3287650plh.120.1646891249818; Wed, 09 Mar 2022 21:47:29 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:29 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 11/14] macvlan: enable BIG TCP Packets Date: Wed, 9 Mar 2022 21:47:00 -0800 Message-Id: <20220310054703.849899-12-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Inherit tso_ipv6_max_size from lower device. Signed-off-by: Eric Dumazet --- drivers/net/macvlan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c index 33753a2fde292f8f415eefe957d09be5db1c4d55..0a41228d4efabb6bcd36bc954cecb9fe3626b63a 100644 --- a/drivers/net/macvlan.c +++ b/drivers/net/macvlan.c @@ -902,6 +902,7 @@ static int macvlan_init(struct net_device *dev) dev->hw_enc_features |= dev->features; netif_set_gso_max_size(dev, lowerdev->gso_max_size); netif_set_gso_max_segs(dev, lowerdev->gso_max_segs); + netif_set_tso_ipv6_max_size(dev, lowerdev->tso_ipv6_max_size); dev->hard_header_len = lowerdev->hard_header_len; macvlan_set_lockdep_class(dev); From patchwork Thu Mar 10 05:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775942 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 8C4DDC433EF for ; Thu, 10 Mar 2022 05:47:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239675AbiCJFsx (ORCPT ); Thu, 10 Mar 2022 00:48:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239674AbiCJFsl (ORCPT ); Thu, 10 Mar 2022 00:48:41 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 098D125E85 for ; Wed, 9 Mar 2022 21:47:32 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id e3so4157506pjm.5 for ; Wed, 09 Mar 2022 21:47:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=34jEWn3KlsSJ9jeDwhLaeV4mw//NGL1b1oh39nIT+68=; b=HSFju2DIjxuFBSl+u4Rc/cC0pBMAXqdgdPgQ/NNJ7pqYz0wzWPGHtODWrZBcG/SoiH T1bHNNWFLDalnNd4s0N7cPC4s38pG/eNyk/wg5F8PuPne07TaI/ugayP7TpDRPm4TK24 EvOht/HY4PGPwxAGBgbjko3wr+eh6pY6+r3OfBE8paXVDee33Aua1o7GWPTszskEerW7 4MeSdtGyJglUzI8nxWCvX/CKEXUZDo3p7M2FBAvZyVUX2Gf4O6ZUNsWgMh7z092mgpGe bKlfQv3gu1IOyVYx709PcEzPHUegY/wr2hEpOLkM+Eib8YVY1FKpWltjg76cUnJoXZwB fa8w== 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=34jEWn3KlsSJ9jeDwhLaeV4mw//NGL1b1oh39nIT+68=; b=PMuSj+1FTDAxRskREC3EyRSD74pmlrpVV3w7Y2h2eVNlidQ1Xv2erR3atq4UxeOMH3 CaF7AlEV2HQtqbtb98uZ0qLMUyS8JhgebWhS3+xU1AxeR/BCIG1DF+8o5UKksft8Bcox vaKJUnIVn9WYGTpHa4nF/QS8532LoIJUs/C7wuRYssiPXnHSFRhYnYSVa9LSNM1IjFsa 7mwjtCptVmydzQpV7WuHH3i7nP4n0Vj/pYH37XjYaAcll2e+/aO7lzjfVXPmz3EjFbgn RsswVAZGVSNb3P+gczPCG4WLHGHtATgwMpXh8QEARgIqWsT5nz4AEMBhTmetvRmyBqU8 mTxw== X-Gm-Message-State: AOAM532632d5WmztLTL5XdaIpz1HYcAy2Pjxb39FcIzZtx3DHs8rz/kX mgSWQe/BosNTe42ya5Q68BY= X-Google-Smtp-Source: ABdhPJxWgpmE8m45RPMFv5vX7pJVtnyfOR/SkqcM7PohfX5VWYyo7Np8JNROAoCk958poflcgOCBqA== X-Received: by 2002:a17:903:2345:b0:153:1b5:6834 with SMTP id c5-20020a170903234500b0015301b56834mr3348151plh.123.1646891251620; Wed, 09 Mar 2022 21:47:31 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:31 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 12/14] ipvlan: enable BIG TCP Packets Date: Wed, 9 Mar 2022 21:47:01 -0800 Message-Id: <20220310054703.849899-13-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Coco Li Inherit tso_ipv6_max_size from physical device. Tested: eth0 tso_ipv6_max_size is set to 524288 ip link add link eth0 name ipvl1 type ipvlan ip -d link show ipvl1 10: ipvl1@eth0:... ipvlan mode l3 bridge addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 gro_max_size 65536 gso_ipv6_max_size 65535 tso_ipv6_max_size 524288 gro_ipv6_max_size 65536 Signed-off-by: Coco Li Signed-off-by: Eric Dumazet --- drivers/net/ipvlan/ipvlan_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 696e245f6d009d4d5d4a9c3523e4aa1e5d0f8bb6..4de30df25f19b32a78a06d18c99e94662307b7fb 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -141,6 +141,7 @@ static int ipvlan_init(struct net_device *dev) dev->hw_enc_features |= dev->features; netif_set_gso_max_size(dev, phy_dev->gso_max_size); netif_set_gso_max_segs(dev, phy_dev->gso_max_segs); + netif_set_tso_ipv6_max_size(dev, phy_dev->tso_ipv6_max_size); dev->hard_header_len = phy_dev->hard_header_len; netdev_lockdep_set_classes(dev); From patchwork Thu Mar 10 05:47:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775943 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 34D26C433F5 for ; Thu, 10 Mar 2022 05:47:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239679AbiCJFsy (ORCPT ); Thu, 10 Mar 2022 00:48:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239673AbiCJFsl (ORCPT ); Thu, 10 Mar 2022 00:48:41 -0500 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 099DD27FED for ; Wed, 9 Mar 2022 21:47:33 -0800 (PST) Received: by mail-pg1-x52c.google.com with SMTP id o23so3815963pgk.13 for ; Wed, 09 Mar 2022 21:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2qkUWOSjFuJ3SYVMEm+07IQm8DqN/HrdudaxPS5fN9M=; b=m3bPEg5eKAeooeOjFmNBwjk7keCAEpxfefNsBnogmisIHwsPJlMBAW/dzyazILi406 yBZGsv3NjhMgeTyUidmAy2msISDet67M0216xnrzWjiYmGokS53FlrUQP7AvW3/FOGvl GGG85vjVawddBY91/qyRK1pkSUZtIUGIxetbNeNMWifz8Kkk/OMCXnpAarhdnKP8zzWX 8p+dz9Bx7We8VCEDFuUBx/qwYMqBgi2sQAon6L1TDVNG4dCOPrY+Xfsnp4YFdLPeczSj 1uuN2PlbtCh+oaMlcANoJzFwPG9fwGnF4fTMbXIudhc59W59V9u9/O1ccPm269om/qFl HitQ== 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=2qkUWOSjFuJ3SYVMEm+07IQm8DqN/HrdudaxPS5fN9M=; b=uXfqreWYllRpaGJm1e7UZUpV8aE/cHrPWMmNHy1ba5toiOcRGSh5v5ADazUAccCqrb /2Bthg8f+1VJDSRe0I5WScsNiMQ6BeYPx+liWp6dTIflrv0e7Hu4X6WvrQ57N/yuAYFZ PldUhdzzKZBiiTNzx5ZV+klRujYxtJOPL3NE407YB6vMFVdNLaAVWHK6ays5my7H9Ysl xdOb8uILVFs3hsIyiReIipIETntEIY2qtOOp2ogafckgKt6MaJqlGL83+MRVYKUFP4ii VdxT4wkGEfPlSNIwbE67T2x0bWfAkQONNmb3X7r6myNrpDjBJEpSxZNfC7Ggb9c97ZNB Yt0A== X-Gm-Message-State: AOAM533tKLo1KcPJNZY41Dux1uHYJDNJmXRc7Jzk1N6+ICawv4MxiLbS ebok1mvXq2toIZI2wcZMC+KbvNEK3tM= X-Google-Smtp-Source: ABdhPJzAuULemzrVoep+YYZ0f/WgaXl9/e7jy2lgp4iC+Kktq8P/u7ZU9KVyhj2t1RSd/eZqPJZrHg== X-Received: by 2002:aa7:8889:0:b0:4f7:7283:e378 with SMTP id z9-20020aa78889000000b004f77283e378mr2041198pfe.36.1646891253383; Wed, 09 Mar 2022 21:47:33 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:33 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet , Tariq Toukan Subject: [PATCH v4 net-next 13/14] mlx4: support BIG TCP packets Date: Wed, 9 Mar 2022 21:47:02 -0800 Message-Id: <20220310054703.849899-14-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet mlx4 supports LSOv2 just fine. IPv6 stack inserts a temporary Hop-by-Hop header with JUMBO TLV for big packets. We need to ignore the HBH header when populating TX descriptor. Tested: Before: (not enabling bigger TSO/GRO packets) ip link set dev eth0 gso_ipv6_max_size 65536 gro_ipv6_max_size 65536 netperf -H lpaa18 -t TCP_RR -T2,2 -l 10 -Cc -- -r 70000,70000 MIGRATED TCP REQUEST/RESPONSE TEST from ::0 (::) port 0 AF_INET6 to lpaa18.prod.google.com () port 0 AF_INET6 : first burst 0 : cpu bind Local /Remote Socket Size Request Resp. Elapsed Trans. CPU CPU S.dem S.dem Send Recv Size Size Time Rate local remote local remote bytes bytes bytes bytes secs. per sec % S % S us/Tr us/Tr 262144 540000 70000 70000 10.00 6591.45 0.86 1.34 62.490 97.446 262144 540000 After: (enabling bigger TSO/GRO packets) ip link set dev eth0 gso_ipv6_max_size 185000 gro_ipv6_max_size 185000 netperf -H lpaa18 -t TCP_RR -T2,2 -l 10 -Cc -- -r 70000,70000 MIGRATED TCP REQUEST/RESPONSE TEST from ::0 (::) port 0 AF_INET6 to lpaa18.prod.google.com () port 0 AF_INET6 : first burst 0 : cpu bind Local /Remote Socket Size Request Resp. Elapsed Trans. CPU CPU S.dem S.dem Send Recv Size Size Time Rate local remote local remote bytes bytes bytes bytes secs. per sec % S % S us/Tr us/Tr 262144 540000 70000 70000 10.00 8383.95 0.95 1.01 54.432 57.584 262144 540000 Signed-off-by: Eric Dumazet Reviewed-by: Tariq Toukan --- .../net/ethernet/mellanox/mlx4/en_netdev.c | 3 ++ drivers/net/ethernet/mellanox/mlx4/en_tx.c | 47 +++++++++++++++---- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index c61dc7ae0c056a4dbcf24297549f6b1b5cc25d92..76cb93f5e5240c54f6f4c57e39739376206b4f34 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -3417,6 +3417,9 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, dev->min_mtu = ETH_MIN_MTU; dev->max_mtu = priv->max_mtu; + /* supports LSOv2 packets, 512KB limit has been tested. */ + netif_set_tso_ipv6_max_size(dev, 512 * 1024); + mdev->pndev[port] = dev; mdev->upper[port] = NULL; diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 817f4154b86d599cd593876ec83529051d95fe2f..c89b3e8094e7d8cfb11aaa6cc4ad63bf3ad5934e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -44,6 +44,7 @@ #include #include #include +#include #include "mlx4_en.h" @@ -635,19 +636,28 @@ static int get_real_size(const struct sk_buff *skb, struct net_device *dev, int *lso_header_size, bool *inline_ok, - void **pfrag) + void **pfrag, + int *hopbyhop) { struct mlx4_en_priv *priv = netdev_priv(dev); int real_size; if (shinfo->gso_size) { *inline_ok = false; - if (skb->encapsulation) + *hopbyhop = 0; + if (skb->encapsulation) { *lso_header_size = (skb_inner_transport_header(skb) - skb->data) + inner_tcp_hdrlen(skb); - else + } else { + /* Detects large IPV6 TCP packets and prepares for removal of + * HBH header that has been pushed by ip6_xmit(), + * mainly so that tcpdump can dissect them. + */ + if (ipv6_has_hopopt_jumbo(skb)) + *hopbyhop = sizeof(struct hop_jumbo_hdr); *lso_header_size = skb_transport_offset(skb) + tcp_hdrlen(skb); + } real_size = CTRL_SIZE + shinfo->nr_frags * DS_SIZE + - ALIGN(*lso_header_size + 4, DS_SIZE); + ALIGN(*lso_header_size - *hopbyhop + 4, DS_SIZE); if (unlikely(*lso_header_size != skb_headlen(skb))) { /* We add a segment for the skb linear buffer only if * it contains data */ @@ -874,6 +884,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) int desc_size; int real_size; u32 index, bf_index; + struct ipv6hdr *h6; __be32 op_own; int lso_header_size; void *fragptr = NULL; @@ -882,6 +893,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) bool stop_queue; bool inline_ok; u8 data_offset; + int hopbyhop; bool bf_ok; tx_ind = skb_get_queue_mapping(skb); @@ -891,7 +903,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) goto tx_drop; real_size = get_real_size(skb, shinfo, dev, &lso_header_size, - &inline_ok, &fragptr); + &inline_ok, &fragptr, &hopbyhop); if (unlikely(!real_size)) goto tx_drop_count; @@ -944,7 +956,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) data = &tx_desc->data; data_offset = offsetof(struct mlx4_en_tx_desc, data); } else { - int lso_align = ALIGN(lso_header_size + 4, DS_SIZE); + int lso_align = ALIGN(lso_header_size - hopbyhop + 4, DS_SIZE); data = (void *)&tx_desc->lso + lso_align; data_offset = offsetof(struct mlx4_en_tx_desc, lso) + lso_align; @@ -1009,14 +1021,31 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ((ring->prod & ring->size) ? cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0); + lso_header_size -= hopbyhop; /* Fill in the LSO prefix */ tx_desc->lso.mss_hdr_size = cpu_to_be32( shinfo->gso_size << 16 | lso_header_size); - /* Copy headers; - * note that we already verified that it is linear */ - memcpy(tx_desc->lso.header, skb->data, lso_header_size); + if (unlikely(hopbyhop)) { + /* remove the HBH header. + * Layout: [Ethernet header][IPv6 header][HBH][TCP header] + */ + memcpy(tx_desc->lso.header, skb->data, ETH_HLEN + sizeof(*h6)); + h6 = (struct ipv6hdr *)((char *)tx_desc->lso.header + ETH_HLEN); + h6->nexthdr = IPPROTO_TCP; + /* Copy the TCP header after the IPv6 one */ + memcpy(h6 + 1, + skb->data + ETH_HLEN + sizeof(*h6) + + sizeof(struct hop_jumbo_hdr), + tcp_hdrlen(skb)); + /* Leave ipv6 payload_len set to 0, as LSO v2 specs request. */ + } else { + /* Copy headers; + * note that we already verified that it is linear + */ + memcpy(tx_desc->lso.header, skb->data, lso_header_size); + } ring->tso_packets++; i = shinfo->gso_segs; From patchwork Thu Mar 10 05:47:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12775944 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 50D74C433F5 for ; Thu, 10 Mar 2022 05:48:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239688AbiCJFs4 (ORCPT ); Thu, 10 Mar 2022 00:48:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239681AbiCJFsl (ORCPT ); Thu, 10 Mar 2022 00:48:41 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82BA3CA70 for ; Wed, 9 Mar 2022 21:47:35 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id o8so3838274pgf.9 for ; Wed, 09 Mar 2022 21:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/ta3iqMA4WzHqEbaAaLOao4IgZivqre/Ol8LyM26FpA=; b=iMYQE5x+V3RM6tZJRIU3VEQN16QxYnNrD+Be882hKV4GsSc0ZXoNSHXIwDY8bVFPk8 TEHXtXFMWX94whvf1Sjc2/E7v5UVBgqBqrGRXmgPGeXsQooVmpo5HyvU1JXhthx5B6b9 jh/DgJ6wnd3aRgPBVc4WZIMqQaB++r9q9McmHBgxueTPjGrrzEMZxuUSeu+iCKNpcxuN 51Hrw5B8BAXg0uZkF40IQUn4tLQZnu1EumqoEYKZqrSmCtP+Kd0fQPH0LFlne9uPSvY8 SCQ3Ts3yTAUw0YQ/1g6OJFaeRYXIK+2g2w405eporwZYL+20ti/9n6rCfUwX0vWFUX95 dr0w== 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=/ta3iqMA4WzHqEbaAaLOao4IgZivqre/Ol8LyM26FpA=; b=7Sl6YjH3xIZ4oUkwi/BDFOxJ1JkCOibMGtFjEgoNizbg7cK7POrKEhji/r/Owd7HMT r2WYIWX1mlIwBdvYUVTwYNpQh7MH/cohtubPTK6zOU9hsF3V7KnobOATmzXnuUoXFPz1 su6TsECBSDD0tvb3TMxzPJuVbG77P2PN6BbJsVGIgykgg4eIVnGGZy0UOerjqySuPcQx jtGBZu8o9vAlLbKDBA1VDZlfZzqX4wvsnsRMzwfKXMW7rFwUCSoqA/s7SroEBOfB0Qax iAv7wZ0YNbK/nDT2KorG2jenOQcTn9ZNglciPE2mCKqXAE25XdkbwwEAdTA29SEF411Z 8iVQ== X-Gm-Message-State: AOAM531gUIOEgw3apJYWWFGp0Wg/Bq+G7FVVnSSkC0Gqk25zsoS+ldx+ x0NYLZBoXMWB0I+g3Exl0Oo= X-Google-Smtp-Source: ABdhPJxP+MfBWjLLexW3/PQS9WJUTMQCbNxjUkjijqga+pq3h36Xpr6ymwrqTITVKsUD5TT/Q/5hOg== X-Received: by 2002:a65:6746:0:b0:377:16e2:33a2 with SMTP id c6-20020a656746000000b0037716e233a2mr2731663pgu.47.1646891255167; Wed, 09 Mar 2022 21:47:35 -0800 (PST) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:c6c7:6f77:9634:183c]) by smtp.gmail.com with ESMTPSA id 16-20020a056a00073000b004dfe2217090sm5270779pfm.200.2022.03.09.21.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Mar 2022 21:47:34 -0800 (PST) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski Cc: netdev , Alexander Duyck , Coco Li , Eric Dumazet , Eric Dumazet , Tariq Toukan , Saeed Mahameed , Leon Romanovsky Subject: [PATCH v4 net-next 14/14] mlx5: support BIG TCP packets Date: Wed, 9 Mar 2022 21:47:03 -0800 Message-Id: <20220310054703.849899-15-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.35.1.616.g0bdcbb4464-goog In-Reply-To: <20220310054703.849899-1-eric.dumazet@gmail.com> References: <20220310054703.849899-1-eric.dumazet@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Coco Li mlx5 supports LSOv2. IPv6 gro/tcp stacks insert a temporary Hop-by-Hop header with JUMBO TLV for big packets. We need to ignore/skip this HBH header when populating TX descriptor. Note that ipv6_has_hopopt_jumbo() only recognizes very specific packet layout, thus mlx5e_sq_xmit_wqe() is taking care of this layout only. v2: clear hopbyhop in mlx5e_tx_get_gso_ihs() v4: fix compile error for CONFIG_MLX5_CORE_IPOIB=y Signed-off-by: Coco Li Signed-off-by: Eric Dumazet Reviewed-by: Tariq Toukan Cc: Saeed Mahameed Cc: Leon Romanovsky --- .../net/ethernet/mellanox/mlx5/core/en_main.c | 1 + .../net/ethernet/mellanox/mlx5/core/en_tx.c | 84 +++++++++++++++---- 2 files changed, 69 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index b2ed2f6d4a9208aebfd17fd0c503cd1e37c39ee1..1e51ce1d74486392a26568852c5068fe9047296d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4910,6 +4910,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->priv_flags |= IFF_UNICAST_FLT; + netif_set_tso_ipv6_max_size(netdev, 512 * 1024); mlx5e_set_netdev_dev_addr(netdev); mlx5e_ipsec_build_netdev(priv); mlx5e_tls_build_netdev(priv); diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c index 2dc48406cd08d21ff94f665cd61ab9227f351215..b4fc45ba1b347fb9ad0f46b9c091cc45e4d3d84f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tx.c @@ -40,6 +40,7 @@ #include "en_accel/en_accel.h" #include "en_accel/ipsec_rxtx.h" #include "en/ptp.h" +#include static void mlx5e_dma_unmap_wqe_err(struct mlx5e_txqsq *sq, u8 num_dma) { @@ -130,23 +131,32 @@ mlx5e_txwqe_build_eseg_csum(struct mlx5e_txqsq *sq, struct sk_buff *skb, sq->stats->csum_none++; } +/* Returns the number of header bytes that we plan + * to inline later in the transmit descriptor + */ static inline u16 -mlx5e_tx_get_gso_ihs(struct mlx5e_txqsq *sq, struct sk_buff *skb) +mlx5e_tx_get_gso_ihs(struct mlx5e_txqsq *sq, struct sk_buff *skb, int *hopbyhop) { struct mlx5e_sq_stats *stats = sq->stats; u16 ihs; + *hopbyhop = 0; if (skb->encapsulation) { ihs = skb_inner_transport_offset(skb) + inner_tcp_hdrlen(skb); stats->tso_inner_packets++; stats->tso_inner_bytes += skb->len - ihs; } else { - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { ihs = skb_transport_offset(skb) + sizeof(struct udphdr); - else + } else { ihs = skb_transport_offset(skb) + tcp_hdrlen(skb); + if (ipv6_has_hopopt_jumbo(skb)) { + *hopbyhop = sizeof(struct hop_jumbo_hdr); + ihs -= sizeof(struct hop_jumbo_hdr); + } + } stats->tso_packets++; - stats->tso_bytes += skb->len - ihs; + stats->tso_bytes += skb->len - ihs - *hopbyhop; } return ihs; @@ -208,6 +218,7 @@ struct mlx5e_tx_attr { __be16 mss; u16 insz; u8 opcode; + u8 hopbyhop; }; struct mlx5e_tx_wqe_attr { @@ -244,14 +255,16 @@ static void mlx5e_sq_xmit_prepare(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct mlx5e_sq_stats *stats = sq->stats; if (skb_is_gso(skb)) { - u16 ihs = mlx5e_tx_get_gso_ihs(sq, skb); + int hopbyhop; + u16 ihs = mlx5e_tx_get_gso_ihs(sq, skb, &hopbyhop); *attr = (struct mlx5e_tx_attr) { .opcode = MLX5_OPCODE_LSO, .mss = cpu_to_be16(skb_shinfo(skb)->gso_size), .ihs = ihs, .num_bytes = skb->len + (skb_shinfo(skb)->gso_segs - 1) * ihs, - .headlen = skb_headlen(skb) - ihs, + .headlen = skb_headlen(skb) - ihs - hopbyhop, + .hopbyhop = hopbyhop, }; stats->packets += skb_shinfo(skb)->gso_segs; @@ -365,7 +378,8 @@ mlx5e_sq_xmit_wqe(struct mlx5e_txqsq *sq, struct sk_buff *skb, struct mlx5_wqe_eth_seg *eseg; struct mlx5_wqe_data_seg *dseg; struct mlx5e_tx_wqe_info *wi; - + u16 ihs = attr->ihs; + struct ipv6hdr *h6; struct mlx5e_sq_stats *stats = sq->stats; int num_dma; @@ -379,15 +393,36 @@ mlx5e_sq_xmit_wqe(struct mlx5e_txqsq *sq, struct sk_buff *skb, eseg->mss = attr->mss; - if (attr->ihs) { - if (skb_vlan_tag_present(skb)) { - eseg->inline_hdr.sz |= cpu_to_be16(attr->ihs + VLAN_HLEN); - mlx5e_insert_vlan(eseg->inline_hdr.start, skb, attr->ihs); + if (ihs) { + u8 *start = eseg->inline_hdr.start; + + if (unlikely(attr->hopbyhop)) { + /* remove the HBH header. + * Layout: [Ethernet header][IPv6 header][HBH][TCP header] + */ + if (skb_vlan_tag_present(skb)) { + mlx5e_insert_vlan(start, skb, ETH_HLEN + sizeof(*h6)); + ihs += VLAN_HLEN; + h6 = (struct ipv6hdr *)(start + sizeof(struct vlan_ethhdr)); + } else { + memcpy(start, skb->data, ETH_HLEN + sizeof(*h6)); + h6 = (struct ipv6hdr *)(start + ETH_HLEN); + } + h6->nexthdr = IPPROTO_TCP; + /* Copy the TCP header after the IPv6 one */ + memcpy(h6 + 1, + skb->data + ETH_HLEN + sizeof(*h6) + + sizeof(struct hop_jumbo_hdr), + tcp_hdrlen(skb)); + /* Leave ipv6 payload_len set to 0, as LSO v2 specs request. */ + } else if (skb_vlan_tag_present(skb)) { + mlx5e_insert_vlan(start, skb, ihs); + ihs += VLAN_HLEN; stats->added_vlan_packets++; } else { - eseg->inline_hdr.sz |= cpu_to_be16(attr->ihs); - memcpy(eseg->inline_hdr.start, skb->data, attr->ihs); + memcpy(start, skb->data, ihs); } + eseg->inline_hdr.sz |= cpu_to_be16(ihs); dseg += wqe_attr->ds_cnt_inl; } else if (skb_vlan_tag_present(skb)) { eseg->insert.type = cpu_to_be16(MLX5_ETH_WQE_INSERT_VLAN); @@ -398,7 +433,7 @@ mlx5e_sq_xmit_wqe(struct mlx5e_txqsq *sq, struct sk_buff *skb, } dseg += wqe_attr->ds_cnt_ids; - num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb->data + attr->ihs, + num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb->data + attr->ihs + attr->hopbyhop, attr->headlen, dseg); if (unlikely(num_dma < 0)) goto err_drop; @@ -918,12 +953,29 @@ void mlx5i_sq_xmit(struct mlx5e_txqsq *sq, struct sk_buff *skb, eseg->mss = attr.mss; if (attr.ihs) { - memcpy(eseg->inline_hdr.start, skb->data, attr.ihs); + if (unlikely(attr.hopbyhop)) { + struct ipv6hdr *h6; + + /* remove the HBH header. + * Layout: [Ethernet header][IPv6 header][HBH][TCP header] + */ + memcpy(eseg->inline_hdr.start, skb->data, ETH_HLEN + sizeof(*h6)); + h6 = (struct ipv6hdr *)((char *)eseg->inline_hdr.start + ETH_HLEN); + h6->nexthdr = IPPROTO_TCP; + /* Copy the TCP header after the IPv6 one */ + memcpy(h6 + 1, + skb->data + ETH_HLEN + sizeof(*h6) + + sizeof(struct hop_jumbo_hdr), + tcp_hdrlen(skb)); + /* Leave ipv6 payload_len set to 0, as LSO v2 specs request. */ + } else { + memcpy(eseg->inline_hdr.start, skb->data, attr.ihs); + } eseg->inline_hdr.sz = cpu_to_be16(attr.ihs); dseg += wqe_attr.ds_cnt_inl; } - num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb->data + attr.ihs, + num_dma = mlx5e_txwqe_build_dsegs(sq, skb, skb->data + attr.ihs + attr.hopbyhop, attr.headlen, dseg); if (unlikely(num_dma < 0)) goto err_drop;