From patchwork Fri May 6 15:30:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841316 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 0420EC4332F for ; Fri, 6 May 2022 15:31:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442928AbiEFPf1 (ORCPT ); Fri, 6 May 2022 11:35:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1389935AbiEFPfM (ORCPT ); Fri, 6 May 2022 11:35:12 -0400 Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5824F6EB33 for ; Fri, 6 May 2022 08:31:01 -0700 (PDT) Received: by mail-pf1-x435.google.com with SMTP id y41so1716809pfw.12 for ; Fri, 06 May 2022 08:31:01 -0700 (PDT) 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=0KByvAI5wxmwml/sN2uj4dXiTldcv8jjd6Op43vG4IA=; b=gQDypQHtGeKSJvagm83TuAtm+wvSmdcRwIACkAvhFfZI2XhmS1c4SC7K3YfuW9zYpm ZAsNEx78fHMSHZYOtN/EOqPWw6XtmX79dFzNcGcTHcbN0oaNu+KOEPbcubdbajFpLOQ5 RZOlNQnS+IV9H4ynX0MilDW371vPYrSJgV/WUqEBe9t55AxzervJPW1RwmCLjUOkaFB/ XRfi/TvZK0yJ3FMUkNj532r469GTEAi4j/1v416IbdbxbAFbsPsduoIEGL5epTQLd9Kf af9qxPYOkH9JrKknggTEJeUmHEcNUwt0hYpCAQtPfUvL7OAtYx2sB7UtgXFP42riHVRh NLSg== 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=0KByvAI5wxmwml/sN2uj4dXiTldcv8jjd6Op43vG4IA=; b=zzAsAWj2OhgUTw21UGL8fMONEw9OqKKmQsm5uDsNcpEiBSaNE6VlekCQyy2EDru41T 6y2xEMVYg1z9qY4J+WNwMxLQeBOzGIZFd2aJHmCNe6Pp1arClxTrQc8hffqeuGZL4UXV Wuy4nqVeV4NFXXaM9RKHeljrdA3xed2M4HrHpe8JJlMaFBLmccDsAr2OvDn0G9LBBCsz LdGokqOPW54EgUu/1EXwLDLrJJqp3Rbwpu4AbvDxAkbdxhRrR0TOOh19RXxcl2KmvgZV +q8tz80Xn56T5SPsPMQZVK71rwszeq0a4mk80e0NeITwH+VB3wrcvGyYQi2Fpkyn2Waa Omvw== X-Gm-Message-State: AOAM5306bRkxyHPb0tqMpPpTw3qQCZ8uZtVQ4rnpYIWR+9bryOay0V9P P9BMCnNHHcZq7obFUxPg/UA= X-Google-Smtp-Source: ABdhPJwltwIZDoRmWEG8YSmgILq4BsIsdYs/vzma8+s6M6lQjLp3kJQiAfJ3ctdz4x8EnzjbUk6i/w== X-Received: by 2002:a63:af42:0:b0:39d:942c:504b with SMTP id s2-20020a63af42000000b0039d942c504bmr3289825pgo.453.1651851060659; Fri, 06 May 2022 08:31:00 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.30.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:00 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 01/12] net: add IFLA_TSO_{MAX_SIZE|SEGS} attributes Date: Fri, 6 May 2022 08:30:37 -0700 Message-Id: <20220506153048.3695721-2-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 New netlink attributes IFLA_TSO_MAX_SIZE and IFLA_TSO_MAX_SEGS are used to report to user-space the device TSO limits. ip -d link sh dev eth1 ... tso_max_size 65536 tso_max_segs 65535 Signed-off-by: Eric Dumazet --- include/uapi/linux/if_link.h | 2 ++ net/core/rtnetlink.c | 6 ++++++ tools/include/uapi/linux/if_link.h | 2 ++ 3 files changed, 10 insertions(+) diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index d1e600816b82c2e73c3e0684c66ddf9841a75b04..5f58dcfe2787f308bb2aa5777cca0816dd32bbb9 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -368,6 +368,8 @@ enum { IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, + IFLA_TSO_MAX_SIZE, + IFLA_TSO_MAX_SEGS, __IFLA_MAX }; diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index e6d4b9272995b7a9b9f83b8868845222f4785edf..512ed661204e0c66c8dcfaddc3001500d10f63ab 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1064,6 +1064,8 @@ 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_MAX_SIZE */ + + nla_total_size(4) /* IFLA_TSO_MAX_SEGS */ + nla_total_size(1) /* IFLA_OPERSTATE */ + nla_total_size(1) /* IFLA_LINKMODE */ + nla_total_size(4) /* IFLA_CARRIER_CHANGES */ @@ -1769,6 +1771,8 @@ 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_MAX_SIZE, dev->tso_max_size) || + nla_put_u32(skb, IFLA_TSO_MAX_SEGS, dev->tso_max_segs) || #ifdef CONFIG_RPS nla_put_u32(skb, IFLA_NUM_RX_QUEUES, dev->num_rx_queues) || #endif @@ -1922,6 +1926,8 @@ 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_MAX_SIZE] = { .type = NLA_REJECT }, + [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT }, }; 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..b339bf2196ca160ed3040615ae624b9a028562fb 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -348,6 +348,8 @@ enum { IFLA_PARENT_DEV_NAME, IFLA_PARENT_DEV_BUS_NAME, IFLA_GRO_MAX_SIZE, + IFLA_TSO_MAX_SIZE, + IFLA_TSO_MAX_SEGS, __IFLA_MAX }; From patchwork Fri May 6 15:30:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841314 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 8925AC433EF for ; Fri, 6 May 2022 15:31:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443021AbiEFPfV (ORCPT ); Fri, 6 May 2022 11:35:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379239AbiEFPfO (ORCPT ); Fri, 6 May 2022 11:35:14 -0400 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 CAC576EC50 for ; Fri, 6 May 2022 08:31:04 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id v10so6374010pgl.11 for ; Fri, 06 May 2022 08:31:04 -0700 (PDT) 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=Ajs8Qst8iYNToP8OwD94MfSLvH2ZbhrQ/Qlzg71j/1Q=; b=dnXo6r8sEYyMpPfqcoZyl5kc+1Yaq+49FpD5qcI/kHnt8tkht5T5129RxUYfrQ9flM vLp77CX9u43iGghOFfpUAOdZr/u2hd+UaDolgYZlfQlA3NLoztOdNaHiw+e+6hBA3y3q ByIeyUs3uciapvuRkZoJQXwLuKEC3PEbuvZy1Vb0IF2jPp/9uoW6x+YrCCCxC3EBzfYe jGu+/mNox5WAS9Bztov5a+3fBzfO50wAvMe6NJ8CXLvZ0+8l659Uoo1AFHQBbrtY/fSF vpBUxb0iMqA31svcrF2kd/efoQ9MxyF9Fus1xuxeir9O0z6e+hg8g7cN9n0NbgPe89lJ cTgw== 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=Ajs8Qst8iYNToP8OwD94MfSLvH2ZbhrQ/Qlzg71j/1Q=; b=4ogThgzqnNgfI1ydIKAj5Ktm69fxNUYXyYxxRGtR+4OU3ZXpMLbKi2OwczZsZfHK3i tFqSvOnKmfhBqyueyHN4liFDdaw3rRUhYTn3o/hOhFudqRJcmjO82Zgbgqo4P3F/4vpC N5k430AsxrCXfYstpCCX5qjzN2e6wK3Wxo24g5NVyXXsWc9LVMA/WNNQDBXTJP5YXthG YzRiAZg89w3+St3AtoDFrW7/l6AwKSeDIIPnhzgP15ygyruKp5ypF0u6jbjfO6WyLI91 xA6yyUYFeaINLXEyEvYvFqrmXr/vEebZ6a7yVZeV1iEm90JIUA73+L2c7T1GO785eJiL gslg== X-Gm-Message-State: AOAM531eVmZ/1/0aBxUvxFKtQ88Dx7dL7aHch9RomAW+/6rys0m0aJCG SaQiWQMcWKL6DRbOfDc7zVQ= X-Google-Smtp-Source: ABdhPJzEQGfUwekktQmxzWdJzUUrKLe5aGNP6Ig97x26SXXYLd7llK8HpVsnQGDRBRGXsa9db8LT8Q== X-Received: by 2002:a65:6794:0:b0:3c1:922b:2b1e with SMTP id e20-20020a656794000000b003c1922b2b1emr3225027pgr.370.1651851063806; Fri, 06 May 2022 08:31:03 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:03 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 02/12] ipv6: add IFLA_GSO_IPV6_MAX_SIZE Date: Fri, 6 May 2022 08:30:38 -0700 Message-Id: <20220506153048.3695721-3-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 enables ipv6/TCP stacks 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_max_size) Signed-off-by: Coco Li Signed-off-by: Eric Dumazet --- include/linux/netdevice.h | 2 ++ include/uapi/linux/if_link.h | 1 + net/core/dev.c | 2 ++ net/core/rtnetlink.c | 23 +++++++++++++++++++++++ net/core/sock.c | 8 ++++++++ tools/include/uapi/linux/if_link.h | 1 + 6 files changed, 37 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 8cf0ac616cb9b7279e643cf6630f42c807742244..47f413dac12e901700045f4b73d47ecdca0f4f3c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1917,6 +1917,7 @@ enum netdev_ml_priv_type { * @rtnl_link_ops: Rtnl_link_ops * * @gso_max_size: Maximum size of generic segmentation offload + * @gso_ipv6_max_size: Maximum size of IPv6 GSO packets (user/admin limit) * @tso_max_size: Device (as in HW) limit on the max TSO request size * @gso_max_segs: Maximum number of segments that can be passed to the * NIC for GSO @@ -2264,6 +2265,7 @@ struct net_device { /* for setting kernel sock attribute on TCP connection setup */ #define GSO_MAX_SIZE 65536 unsigned int gso_max_size; + unsigned int gso_ipv6_max_size; #define TSO_LEGACY_MAX_SIZE 65536 #define TSO_MAX_SIZE UINT_MAX unsigned int tso_max_size; diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index 5f58dcfe2787f308bb2aa5777cca0816dd32bbb9..aa05fc9cc23f4ccf92f4cbba57f43472749cd42a 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -370,6 +370,7 @@ enum { IFLA_GRO_MAX_SIZE, IFLA_TSO_MAX_SIZE, IFLA_TSO_MAX_SEGS, + IFLA_GSO_IPV6_MAX_SIZE, __IFLA_MAX }; diff --git a/net/core/dev.c b/net/core/dev.c index f036ccb61da4da3ffc52c4f2402427054b831e8a..aa8757215b2a9f14683f95086732668eb99a875b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10607,6 +10607,8 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->gro_max_size = GRO_MAX_SIZE; dev->tso_max_size = TSO_LEGACY_MAX_SIZE; dev->tso_max_segs = TSO_MAX_SEGS; + dev->gso_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 512ed661204e0c66c8dcfaddc3001500d10f63ab..847cf80f81754451e5f220f846db734a7625695b 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1066,6 +1066,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_MAX_SIZE */ + nla_total_size(4) /* IFLA_TSO_MAX_SEGS */ + + 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 */ @@ -1773,6 +1774,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_MAX_SIZE, dev->tso_max_size) || nla_put_u32(skb, IFLA_TSO_MAX_SEGS, dev->tso_max_segs) || + 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 @@ -1928,6 +1930,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_GRO_MAX_SIZE] = { .type = NLA_U32 }, [IFLA_TSO_MAX_SIZE] = { .type = NLA_REJECT }, [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT }, + [IFLA_GSO_IPV6_MAX_SIZE] = { .type = NLA_U32 }, }; static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = { @@ -2644,6 +2647,14 @@ static int do_set_proto_down(struct net_device *dev, return 0; } +static void netif_set_gso_ipv6_max_size(struct net_device *dev, + unsigned int size) +{ + size = min(size, dev->tso_max_size); + /* Paired with READ_ONCE() in sk_setup_caps() */ + WRITE_ONCE(dev->gso_ipv6_max_size, size); +} + #define DO_SETLINK_MODIFIED 0x01 /* notify flag means notify + modified. */ #define DO_SETLINK_NOTIFY 0x03 @@ -2820,6 +2831,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]); @@ -3283,6 +3303,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 6b287eb5427b32865d25fc22122fefeff3a4ccf5..4a29c3bf6b95f76280d8e32e903a0916322d5c4f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2312,6 +2312,14 @@ 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)) { + /* Paired with WRITE_ONCE() in netif_set_gso_ipv6_max_size() */ + 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 b339bf2196ca160ed3040615ae624b9a028562fb..443eddd285f37198566fa1357f0d394ec5270ab9 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_MAX_SIZE, IFLA_TSO_MAX_SEGS, + IFLA_GSO_IPV6_MAX_SIZE, __IFLA_MAX }; From patchwork Fri May 6 15:30:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841315 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 F17EDC433F5 for ; Fri, 6 May 2022 15:31:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389422AbiEFPfX (ORCPT ); Fri, 6 May 2022 11:35:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443058AbiEFPfP (ORCPT ); Fri, 6 May 2022 11:35:15 -0400 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 E5DEA6EC5A for ; Fri, 6 May 2022 08:31:06 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id g184so3893640pgc.1 for ; Fri, 06 May 2022 08:31:06 -0700 (PDT) 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=VfIc2hwKs3WKU/LwfhuXIfUteFdkMbyV5rtiOsdfl00=; b=N8SjvDENK8SjrJCHxFsP3T30ghh+vtcnhhF0urPrC+SuJgUByt5nq9ZfZqlSFjW64b tl3iUdsjrvyREKnl06PzwtI+kaP7lwas7rBnMiSbT3uwAi3AKzGYvXsq0/Q7vVY9SbsY 5cWyki7K9e8G51WWxFkrmSBDAkMjzC6sI6xCDSXw+atR8vuDl1mg+vpOKFZZ4+PnXd7q CFuva4NekKSyyYK1fQp+sXAIeKtV9QR/jLdTaOBTDgWl83oYXwFQqCU186crj94pWLbC dH5jUIw7sIAPzGUwb+4zuxIGuT3wgNmqTOA4N4JBKNodeCq27WvVtbLtUqI9rRzso0+Z 6eRA== 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=VfIc2hwKs3WKU/LwfhuXIfUteFdkMbyV5rtiOsdfl00=; b=B81pZLwP6LSxF6l4EJ1TmoPGvYYOn9QIMx/Zm7rEQIjWGXP3OXpfm0UZes1sJVy2yK J/exX+uZB0Ss33zpkPt/9pnZ+FTYq5syZkWMZgxqq45WgRmVnsjHeyDl1sE3jDioCROK loxSy7r14TPyd0X726frNxtifY8Svos1EiNcMb63m3hvjo5gJGNmButEyHPezOR/WQxe xXAh8WJR9yECdmxdlpWZQ0g5CR17jp3nhU6CtmeFDwq7dmfs1iNCrTi8kyhpG3/+THut WO93FKpowWH6u3ukq9XtjFKVhb2eo9MEfrj9CDqV/Sgpv1hK7Cd6ZxkBsxe5KaWk8xfe wuuQ== X-Gm-Message-State: AOAM532wgWH/wZfTN1wqjvtWWNF8hjJsK7o4bvyuxOgkYbUexUWs1bDm OswK9Uj7h28T7c/f9vlL2x8= X-Google-Smtp-Source: ABdhPJy0KNTyX5eih2R0lEhYwmH5XE5Hr5GOfqM+KlTdA7s2l43SHAoOI7qr0IbqsRN2oU2B0oN7+A== X-Received: by 2002:a63:1b1f:0:b0:3c1:bb2a:3afb with SMTP id b31-20020a631b1f000000b003c1bb2a3afbmr3175752pgb.596.1651851066510; Fri, 06 May 2022 08:31:06 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:06 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 03/12] tcp_cubic: make hystart_ack_delay() aware of BIG TCP Date: Fri, 6 May 2022 08:30:39 -0700 Message-Id: <20220506153048.3695721-4-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 b0918839bee7cf0264ec3bbcdfc1417daa86d197..68178e7280ce24c26a48e48a51518d759e4d1718 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 Fri May 6 15:30:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841318 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 3BEB8C433FE for ; Fri, 6 May 2022 15:31:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442947AbiEFPff (ORCPT ); Fri, 6 May 2022 11:35:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442937AbiEFPfQ (ORCPT ); Fri, 6 May 2022 11:35:16 -0400 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 7E43B6EC71 for ; Fri, 6 May 2022 08:31:09 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id a191so6403508pge.2 for ; Fri, 06 May 2022 08:31:09 -0700 (PDT) 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=Kdkb9iJD2Cf92mUwdfbtRZPbJe3zJ/RvlmfMXNxr0ow=; b=BbQAApVltlUz38H+FD9UfNocvzYbc2lnKvRFDdAYntx5DQ6S28pl58E0a/FO3Dl3nv /2lTlAi6T4ztizG+gVEIZtc9pmi+/3Pq3oGW63sumsvrRbSK0Az+3/8tQ4bKA6g1dMu4 4rUjHP8xiboqHAvJ3Mwa6rgxowZlSgk+F+ibvi4Zt/VIVH1g+b3IyEhMMPkL1r80akRi a9WSBdAwxHIHi4GSYywdxNdms0kQrNfBZsGdVVd9dPr+fXS52UgOlW3py+D0Pv4DqdWJ Aj8ehHQgVrbXLrK2KW8j8VcFSJJi/q5u6Jw9aPu7KbRf3Cds2VTbXv8kDymdxStVjqPP ToMg== 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=Kdkb9iJD2Cf92mUwdfbtRZPbJe3zJ/RvlmfMXNxr0ow=; b=nQRl/LsQcthxuwYrhtor4LbYk9peKs50FzfnwQpd0rYV2uBmxxi2Xzf6Dw6/vnLmrH YsBg4XFeYVsZbMsvqKMU8FvAgxQCXGHr1zWER6E4ag2Uoh4qErQTO6eZj0uDymq800vX 7GdQBvrxmQSLueay3Wi0QkaetKagR0LEDSHNzcoVHwD4en7rVRFrqQmy72tnvTcmpZje H1LVFB9/r9k+woD8rnLOZwhTtTRFa1TmmXYqG71TatA+UejcPssekkA2cTSDYvD4WMC1 XV2K+2Wqq3OE7Z5F+kCBe25xaDlsLhTFlFZJX4o+XPD6RUH8kmcIeA23GBl8F4DHAqOJ GoJQ== X-Gm-Message-State: AOAM532NBqMg9uRhgklZYehPf8E9hv/xogPLx0raUiAdNrVSpb3c/fVq tK14S5rNT6SwblPe2i8R0oo= X-Google-Smtp-Source: ABdhPJxcVmgpZtZgbJfldL47UAkDVJ5vuoMK8UowsK0tDhjtuwODnjc461RgdJRJG5ekNwPk4K70ZA== X-Received: by 2002:a63:2bc4:0:b0:3ab:1d76:64db with SMTP id r187-20020a632bc4000000b003ab1d7664dbmr3096089pgr.508.1651851068898; Fri, 06 May 2022 08:31:08 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:08 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 04/12] ipv6: add struct hop_jumbo_hdr definition Date: Fri, 6 May 2022 08:30:40 -0700 Message-Id: <20220506153048.3695721-5-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 Fri May 6 15:30:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841317 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 A6697C433F5 for ; Fri, 6 May 2022 15:31:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442946AbiEFPfd (ORCPT ); Fri, 6 May 2022 11:35:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443118AbiEFPfR (ORCPT ); Fri, 6 May 2022 11:35:17 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4F3A6D4C0 for ; Fri, 6 May 2022 08:31:11 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id l11so823235pgt.13 for ; Fri, 06 May 2022 08:31:11 -0700 (PDT) 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=vouoEdwTH20px730Nji3ldDgd4hnD+bR+BzxtMCTNyw=; b=QWX9NmZ/yT63lVHOtdKaKfnuxNcxPxgqHg8Cg2jlCtX4W+h4PR8/AzIvPX69414Y3S 8MaC0dmZJ32OAR/U0jiyjFKfZfbeG3x2FjFMLjwyyx1fQbq1lRe1V3myRQJp4enNvMwE 1QCeknkh1mAHabHQ1pk0vW0N273TgeCSx7qI56iL9fAUCZ/fSfiM6aQeewXgm+mLLQj/ MkfR2ra5vzk6JcLW+8e4hXlSMcNKjus+BKyUXsl4lsIO4hOr4COGQMZEpl79JEoaorMg qaZFKt/j2TLYq5Rc097eTLSCEBA1uZpSoJopyR9cjqM2dOaVyYxUss7aivwH5NFjhLL1 HD9g== 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=vouoEdwTH20px730Nji3ldDgd4hnD+bR+BzxtMCTNyw=; b=4PWgk/D8zjw1dPmieeD2tmwNgiVxmJVk5mhvTIJmBkNO8OhYkbkfFT90YibqcdjEhc NKMVtWJclR+/4dKBSURd2mHIoeQZ0MJp/H37pXZuwtPrO5AgHdpM+J8xoY88OhPwvXah z+gHlX5oi22G1FrMoVEuworFLBp4F0WtGLOqyAztLJObrgLb4rjgLYZXycTC3VLlTuuV dxXPgwDhFpuluy86Vg/uMp0cI8vlrpx1L7DaME29nc9Nfc+bahKOEnYiqm/eBDIPG67u 2NMuVKbgb46Xqn9SwxQ/pxe6O6Diab7ySH9wVAbQUdOo53MgqdxEE3u9vXu1rOw2GAfa j+WA== X-Gm-Message-State: AOAM530vHAHlplXP3Ms6WsMNkJVpl7zk+hbEgX+/Az0GSez0xLupJNkp oavuPnUWV2l+1iB6WGAFCCA= X-Google-Smtp-Source: ABdhPJxVXqocudIzy/RBvlTjD9/OCerr2tiy9ZvnJfZ67WP36GemBKzXDfpGCiQqGTqUOtp6oMvtqA== X-Received: by 2002:aa7:82d9:0:b0:4fa:2c7f:41e with SMTP id f25-20020aa782d9000000b004fa2c7f041emr3862295pfn.1.1651851071341; Fri, 06 May 2022 08:31:11 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:10 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 05/12] ipv6/gso: remove temporary HBH/jumbo header Date: Fri, 6 May 2022 08:30:41 -0700 Message-Id: <20220506153048.3695721-6-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 Fri May 6 15:30:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841319 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 612E7C433EF for ; Fri, 6 May 2022 15:32:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442994AbiEFPfu (ORCPT ); Fri, 6 May 2022 11:35:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443130AbiEFPfS (ORCPT ); Fri, 6 May 2022 11:35:18 -0400 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 D41F26D959 for ; Fri, 6 May 2022 08:31:13 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id g184so3893640pgc.1 for ; Fri, 06 May 2022 08:31:13 -0700 (PDT) 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=Vu77qaZ+HoKgSEeugLbfMjppTn8NfczBDAHApl4hhmA=; b=bXn4PUn0Y3pz/6Gm/tOFudd5qOKFZ9TkcABYCptw//ifw2Jx/tBOi9P8X6D4DTGS5A iT/A216Z0+cgr0Eqjgzv+RXAHxZXKvpLHb5/qPV8xDvIrGHHTSE/pyljUoDyr6BgJeeZ FZjLGjqiivUE1NS8Ix9R5ngOyUny6+rLhHfjsbEv84KY2vegOw5KYhOaTG/VXiTXQ9JL nG///ogWn1wSoskTtTnO1Fsk9dCJQk5RsgIZXq7uIngIPbTtH/UvMKShAEFzdWDKtzTG Ysolaz0vyOTmGHuA6+Ng6YBqPfLViL9vFGSnB2KuUiuZ1leX0esHWkFlyKvxPhgA8LTE uO4g== 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=Vu77qaZ+HoKgSEeugLbfMjppTn8NfczBDAHApl4hhmA=; b=UAIRYfteda4n5hkQB7HG4Fi6TSZbpOgTNcmS5FCBzZDi7aVmp3mN5tY8JDVnKQ8Yy6 WePy4d/UiLyl3O9qe6CU445sIaQXWlElnaVZ9NRL0PjxmUxYsn+nthfI6BqQSVboKWTr bf5YW+wLPjP3d6tqCeg9cDhLHfkQeM4GZJrmP/FxLOGeM58cosonCktwVjeanqydtY+H UPdVXpP9wb3ThfibzmKrjb9DYf9dIAqqnGwqyHDmV97IS3/d1ZuAR7n0I8GMQ+s+8FTp CFhvmUe7HpWXmLoBhaSEqBCUrSsBUd54465GpRcDp92jCukKzWypOOzQxMRE0r6zGBp8 uyKw== X-Gm-Message-State: AOAM530PR3SrKafLwivHMNcah7xfADht4uDXSgCKhhDooXGRK3jFIVES uw3z/WEBS1XmMotg+g7GVF0= X-Google-Smtp-Source: ABdhPJwf+bG+r17ZRY7lMQNj2EDX3XbSx3sRus+3fA8w2qxA3byR+2bQ1dzj7aAYbCVxd7IeQSxSCQ== X-Received: by 2002:a05:6a00:140f:b0:4e0:6995:9c48 with SMTP id l15-20020a056a00140f00b004e069959c48mr4130083pfu.59.1651851073489; Fri, 06 May 2022 08:31:13 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:13 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 06/12] ipv6/gro: insert temporary HBH/jumbo header Date: Fri, 6 May 2022 08:30:42 -0700 Message-Id: <20220506153048.3695721-7-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 Fri May 6 15:30:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841320 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 84FC4C433FE for ; Fri, 6 May 2022 15:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443013AbiEFPfw (ORCPT ); Fri, 6 May 2022 11:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443142AbiEFPfS (ORCPT ); Fri, 6 May 2022 11:35:18 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A6AB6D96C for ; Fri, 6 May 2022 08:31:16 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id p6so7334972pjm.1 for ; Fri, 06 May 2022 08:31:16 -0700 (PDT) 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=0zLeWpNxSFVZ8VibuyqKCuhzPs7ZM+V0HJsd6yRZBis=; b=VXu/SBMOgWC+Q3nuCXeqJPC8ZUuRhS6bBm7L1XYYv0xAiBLrDAzXjwsAHXFcfXXbKZ a4Bm3Uz8AYvI1vVSbcR8JFZYrIopRdK7G6OoR0tla1aTg+Ws90kRnwGyfrXy+GbpX27L WNYxm6HrLRu2TqQj57RR2wbxCJ2difZ0ef+I6jsGE/R9YTsxikphVdiHfNBqVxlmG7ei hATt4b60zaY4AQe2BJqhRFzKhpTKVdQIEk75Kknf/3FoeKDYp0sjChaJ7izanbpbTjDd dc9P20lADu0eOND6ozYhazlJU1A6lB6MHST1/m0gpIlEgovO910HjsoeRxBC/9ntozrV 8NxA== 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=0zLeWpNxSFVZ8VibuyqKCuhzPs7ZM+V0HJsd6yRZBis=; b=4TpB7i4hb9OQpajeTU2HNlLLPWxLGWtMm8ZBta9YrcmCb2dnBMhKTdFT65cYcE7EVr UNtn07Azg8E0h4Aa8JQXH7vfzt/JcS0hqDh5s0MrPflCsShRw68ZyOAuGn3zWtHCdfjv zPTD1x5upLHj1DjM9po/6Xm8C6e8bKmuhr+Cu/0TDzmWV/LYGL3TR/jsykrTNg3B3MVA NOUXfV+Fc1i0H76lRMguO8QLjb0UAk29NhKC04RzeGeVLs80/QNcdnm43ZqxUDRL2f9Q FgRAMoDa4CyjRvqX70ymNOuyuiQoCy5pD9N1lmM8nsJ/kA3Jt0zR1OeQU/avsg3baD67 bvxA== X-Gm-Message-State: AOAM532rBPI80SX4a3n7BMPNvWSndycZQjjMC3p9jIV1tgtqMcd44l4b 5dWMiSrtlyaikq6LTE/qdfg= X-Google-Smtp-Source: ABdhPJzgV1HsN0APRqM7wCXBFeBvZz625Dq1X0mMfzjGeusoga/TL8Uv8E9QvjcQPgHneSvaQhOgMA== X-Received: by 2002:a17:90b:17c5:b0:1dc:e0a6:340b with SMTP id me5-20020a17090b17c500b001dce0a6340bmr2823580pjb.34.1651851076018; Fri, 06 May 2022 08:31:16 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:15 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 07/12] ipv6: add IFLA_GRO_IPV6_MAX_SIZE Date: Fri, 6 May 2022 08:30:43 -0700 Message-Id: <20220506153048.3695721-8-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 | 3 +++ include/uapi/linux/if_link.h | 1 + net/core/dev.c | 1 + net/core/gro.c | 20 ++++++++++++++++++-- net/core/rtnetlink.c | 22 ++++++++++++++++++++++ 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 47f413dac12e901700045f4b73d47ecdca0f4f3c..df12c9843d94cb847e0ce5ba1b3b36bde7d476ed 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -1962,6 +1962,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. @@ -2154,6 +2156,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; diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h index aa05fc9cc23f4ccf92f4cbba57f43472749cd42a..9ece3a391105c171057cc491c1458ee8a45e07e0 100644 --- a/include/uapi/linux/if_link.h +++ b/include/uapi/linux/if_link.h @@ -371,6 +371,7 @@ enum { IFLA_TSO_MAX_SIZE, IFLA_TSO_MAX_SEGS, 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 aa8757215b2a9f14683f95086732668eb99a875b..582b7fe052a6fb06437f95bd6a451b79e188cc57 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10608,6 +10608,7 @@ struct net_device *alloc_netdev_mqs(int sizeof_priv, const char *name, dev->tso_max_size = TSO_LEGACY_MAX_SIZE; dev->tso_max_segs = TSO_MAX_SEGS; 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 78110edf5d4b36d2fa6f8a2676096efe0112aa0e..8b35403dd7e909a8d7df591d952a4600c13f360b 100644 --- a/net/core/gro.c +++ b/net/core/gro.c @@ -161,11 +161,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 847cf80f81754451e5f220f846db734a7625695b..5fa3ff835aaf6601c31458ec88e88837d353eabd 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1067,6 +1067,7 @@ static noinline size_t if_nlmsg_size(const struct net_device *dev, + nla_total_size(4) /* IFLA_TSO_MAX_SIZE */ + nla_total_size(4) /* IFLA_TSO_MAX_SEGS */ + 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 */ @@ -1775,6 +1776,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, nla_put_u32(skb, IFLA_TSO_MAX_SIZE, dev->tso_max_size) || nla_put_u32(skb, IFLA_TSO_MAX_SEGS, dev->tso_max_segs) || 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 @@ -1931,6 +1933,7 @@ static const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_TSO_MAX_SIZE] = { .type = NLA_REJECT }, [IFLA_TSO_MAX_SEGS] = { .type = NLA_REJECT }, [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] = { @@ -2655,6 +2658,13 @@ static void netif_set_gso_ipv6_max_size(struct net_device *dev, WRITE_ONCE(dev->gso_ipv6_max_size, size); } +static 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); +} + #define DO_SETLINK_MODIFIED 0x01 /* notify flag means notify + modified. */ #define DO_SETLINK_NOTIFY 0x03 @@ -2840,6 +2850,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]); @@ -3306,6 +3325,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 443eddd285f37198566fa1357f0d394ec5270ab9..5aead1be6b99623fb6ffd31cfcfd44976eb8794f 100644 --- a/tools/include/uapi/linux/if_link.h +++ b/tools/include/uapi/linux/if_link.h @@ -351,6 +351,7 @@ enum { IFLA_TSO_MAX_SIZE, IFLA_TSO_MAX_SEGS, IFLA_GSO_IPV6_MAX_SIZE, + IFLA_GRO_IPV6_MAX_SIZE, __IFLA_MAX }; From patchwork Fri May 6 15:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841324 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 E8B6BC433FE for ; Fri, 6 May 2022 15:32:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442893AbiEFPgE (ORCPT ); Fri, 6 May 2022 11:36:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443147AbiEFPfU (ORCPT ); Fri, 6 May 2022 11:35:20 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF026D97F for ; Fri, 6 May 2022 08:31:18 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id i1so7765686plg.7 for ; Fri, 06 May 2022 08:31:18 -0700 (PDT) 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=3plY4QYEdjKGAPxIOu4e/4uq96gqixpA+zmKua8m2bA=; b=quDOkcghthEodUSf5oGrRLiHKEbtXNsGwqWROtrRUGR9bpoeCVbaizXn5myjD+ryaX ZpBbmQhfTAE+zGqijt7Rr5soHjELkEFcZyAFYrFzoF1wa2YSrij3jssdVFK7ApTSrN0F 8qwkWGrul2TktsFyLrVeS24EpUzHWB5aMT4hyDW/+zuRwvSeGB/luVTVc/LvQLf8Hjzh gBvP7j/MdSc6gTG4HwOgXXvK46UQpPC9kYvQPDuuo5Wyl+h9KJslGR/hPYQCZeTmGvm5 xHP/Cr1L6zQrgSuiequdt+hG+g7cbHkZ8NZ4Pij/CRkfpJJowJUSQ2UbhOjbBdJbxov/ ebxQ== 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=3plY4QYEdjKGAPxIOu4e/4uq96gqixpA+zmKua8m2bA=; b=TnrDvzU1pkIDPbL1kJxfcXnr9gcp5WE+gkWqjihSbaWEn5a+SpUpDMqcUhBkDXEB2j 5rtdbOpnUhL6RiaXUZdh7qTDvk4+iOFON+GkoPBKXPpgwQfbHTdkaQbGByW/5kXn68Fg C96PqzOhBvqu83qJ8WkUPeu5t/7VYhYG3uU6rs8UO3a8Y30odrtelxP339J7NWzBmw9s VljQ05VO8lATYEIrvsicUkf4Gy3cIcGE6zUgkp3/6w9PJs71cv+WU6Ua1xzmb2yVn3aB YpcBPPHJ0wbtuFMmav2X4t+0dSchO3tI2lAY3sJ2NTAqAidjAeGgEg/x6Qiee4vpcEm3 NMTw== X-Gm-Message-State: AOAM531J/Of6s4I9YT64atJ++TCljT/fSKbYRg3CI5NagAjw9IHLrELD leLSt4qcNSm4/j2FWF8oFJXiktf9FrE= X-Google-Smtp-Source: ABdhPJwYAKKrlOvCFNTzeSsuUIPlBWBzjxT20y+a92z9pZJy8x/5IjfAuXcfxPzOz9nY115ALvymGQ== X-Received: by 2002:a17:902:8608:b0:158:c532:d8b2 with SMTP id f8-20020a170902860800b00158c532d8b2mr4242639plo.46.1651851078124; Fri, 06 May 2022 08:31:18 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:17 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 08/12] ipv6: Add hop-by-hop header to jumbograms in ip6_output Date: Fri, 6 May 2022 08:30:44 -0700 Message-Id: <20220506153048.3695721-9-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 ec5ca392eaa31e83a022b1124fae6b607ba168cd..38c8203d52cbf39e523c43fe630a7b184b9991aa 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h @@ -145,6 +145,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 afa5bd4ad167c4a40878f33773d43be85e89c32f..4081b12a01ff22ecf94a6490aef0665808407a6e 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -182,7 +182,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)) || @@ -252,6 +254,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; @@ -259,7 +263,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; @@ -282,6 +286,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 Fri May 6 15:30:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841323 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 C04EAC433EF for ; Fri, 6 May 2022 15:32:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379604AbiEFPgC (ORCPT ); Fri, 6 May 2022 11:36:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442986AbiEFPf3 (ORCPT ); Fri, 6 May 2022 11:35:29 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A0E6E8D6 for ; Fri, 6 May 2022 08:31:21 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id n18so7776403plg.5 for ; Fri, 06 May 2022 08:31:21 -0700 (PDT) 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=V+KJgJWC/mZzQ1xI2xAF94ZgqLkHsDJA4L2W1AotAhQ=; b=EEDm61/uLum5dW3PKEQD+dtsH7CvHTMJEVpZi4tdMofKeQHSOU4qazS+I0NhqqA5bX VENF7gjSm9t79yNHnuDAuh1qTwvufH1B4XVSkLU1YwCYx5acj5y2C7ga5Zz11iXVbm1p Q+bCWnRhZdJnd3s25KCM/Bh8f/KgaWjbkgmnhDTHESKkTMQpssbsPBDkzROiAnMgovKe KV63dOmjFS0VL+MKiOllSq2r0zPocpgZYhzTyx8M3TcqspqC4KbR0v2tOAUl1k1GhjUu m9QY4Cxt1ihd+aw8FhuDf2XamR1OWeJ7yGT4Y7mjUjoYquxClajnsvFRh3BxNAB7GX5N /0HQ== 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=V+KJgJWC/mZzQ1xI2xAF94ZgqLkHsDJA4L2W1AotAhQ=; b=AEkHyNLEstm1aJZ62jjE9XmB/yyZekbVMDfBQRERu+rYqQ0CvBIUO1pfgjZxwXniXT dTlsiGuENSbR8EnQoVThQVHLxRywY+sGEYkPfqA8ZhtTGamKhh/D4e4XKfEIaOPdeVw6 /vD44DO0eu4pXZo+LkCp/+SRapJHaE1k3Yqhl/Ap3Zyu/Xi0ZrAvQi8Dry9seUdFVhR0 vIt5DQVoIUi57YECa6JtMSpGHlIr4HONSgv8tVcJ/5TjmOBs0PzQCts/P7rFpxzXT4l4 AVjDjmrVdPQ5+DVRO1GeGxloK7yTQwYjfRPH/sZvJRfmyeSYz9xRhKz6Dzc/MBbS8FM3 SscA== X-Gm-Message-State: AOAM530sRWgnFb67HmpfG1mrSGgsPpxDtdhztszlQS+9myxqXt94/ZDY R2Xt3sn2PA1RpIG5Qjpz0KqAhBgGeAM= X-Google-Smtp-Source: ABdhPJzB159EEAJZ+RXe8VhZdIg/qhI/qnbzccMKPkAuwNmFuiorUIOip30U6Cy5pTxrAtflcaP+kg== X-Received: by 2002:a17:902:b78c:b0:15d:2431:a806 with SMTP id e12-20020a170902b78c00b0015d2431a806mr4210960pls.77.1651851080826; Fri, 06 May 2022 08:31:20 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:20 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 09/12] net: loopback: enable BIG TCP packets Date: Fri, 6 May 2022 08:30:45 -0700 Message-Id: <20220506153048.3695721-10-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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..f504dd0817092d63f0e929500ec49cfdda562c4b 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_max_size(dev, 512 * 1024); } /* The loopback device is special. There is only one instance From patchwork Fri May 6 15:30:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841321 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 9AF76C433EF for ; Fri, 6 May 2022 15:32:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346346AbiEFPf4 (ORCPT ); Fri, 6 May 2022 11:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442941AbiEFPfa (ORCPT ); Fri, 6 May 2022 11:35:30 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB53A6D397 for ; Fri, 6 May 2022 08:31:22 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id p6so7334972pjm.1 for ; Fri, 06 May 2022 08:31:22 -0700 (PDT) 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=/P9EWKSxN2uCXkVodpKaHqSst+cMbWDBm9KaQ/M+xK8=; b=TOonhpbWODRKCjtHXI++ZqipYfxS00shKPb04NrNXXWvgjy3rTJYBegCjhhLMyAIFp /PvLUTUOBVOsqNhyBskQ4evyGGTEsAQTSExEMShKM7R3TIE6gOj2wsV7tY6AYsKLUxkY MSkj7DkxgqcdabNUi81eignY3Uy7dcDYo8jOESh/7CGhN8BJnh1hQiee10jz33TLaF9B /MowMLwG03bkrpniuv/n2r44dRCrAEdoFOIP5X3JojT76MowYGnYQLRKrBTLEJRF/ocY WVyVVaQRA4B75dAV0+4hm0Gfn7AoPs6kwQ33G2J4EHvQSGsc3W4k5UcOPhuClqWRvCqU jK+g== 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=/P9EWKSxN2uCXkVodpKaHqSst+cMbWDBm9KaQ/M+xK8=; b=dPjoOJBRKHOm/j9Uzwvx6chold4kC+WkY8rPXg9DfwPOiAaEu8TSjNLvc+NzaoOE4N cIQCgX5aSqwQ2vBvyiphWkc/+WLRoucuVZ1tmG5dzgs2Uql4QZ2D2p09Z9ViHazlm60W WgtDrWHStj9BYAZHWXjqhy51ozFhKz1qUM+YGxULvMjinPXSD076ky/7wL74nj7XU8rx 1VdqiUnG8dEfKba52+0ShX53cTnut+18vIJrK242ufcmpD7Xr8P2oYE2W3t76rJoptEb SOScr3habAICkFk71jHHkQ0uc5Z+3f0oxCSHVdaYNCPtoFZXa8Ktd1TLk9PozRszbLwT BJTA== X-Gm-Message-State: AOAM533L+GBXzt/+BVxff/d0MlNiCQixzHcxbGp3SfSw9SZNYAGdy11y TbMZ6vGbgxuul3H7YmxBdx0= X-Google-Smtp-Source: ABdhPJxOr+r7UUWXXdqgmZbRIWTCPD1mM3ksalB9WQ9vOlTVqANHMBkrrxflD7bkZ44p3PAqybWiZQ== X-Received: by 2002:a17:902:d2d1:b0:15e:9b06:28b3 with SMTP id n17-20020a170902d2d100b0015e9b0628b3mr4284761plc.148.1651851082514; Fri, 06 May 2022 08:31:22 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:22 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet Subject: [PATCH v4 net-next 10/12] veth: enable BIG TCP packets Date: Fri, 6 May 2022 08:30:46 -0700 Message-Id: <20220506153048.3695721-11-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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. ip link set dev veth10 gso_ipv6_max_size 200000 Signed-off-by: Eric Dumazet --- drivers/net/veth.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/veth.c b/drivers/net/veth.c index f474e79a774580e4cb67da44b5f0c796c3ce8abb..989248b0f0c64349494a54735bb5abac66a42a93 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c @@ -1647,6 +1647,7 @@ static void veth_setup(struct net_device *dev) dev->hw_features = VETH_FEATURES; dev->hw_enc_features = VETH_FEATURES; dev->mpls_features = NETIF_F_HW_CSUM | NETIF_F_GSO_SOFTWARE; + netif_set_tso_max_size(dev, 512 * 1024); } /* From patchwork Fri May 6 15:30:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841322 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 BE2ABC433F5 for ; Fri, 6 May 2022 15:32:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348091AbiEFPf6 (ORCPT ); Fri, 6 May 2022 11:35:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442977AbiEFPfa (ORCPT ); Fri, 6 May 2022 11:35:30 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62D1BCD4 for ; Fri, 6 May 2022 08:31:25 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id n18so7776403plg.5 for ; Fri, 06 May 2022 08:31:25 -0700 (PDT) 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=WgRfS5eb2UyF5K8/N83Xr3Ox3vMkX6iH80CNtDNa3dI=; b=EuMvEYS38IW/YIBdqIat08G8QJ27R6CLGyn3o3qQEnfzhcAh+X5MXSy2pnQAaOULFE 5YGjxXSjtpK0J/n8eo8fjZaxhn4m/gF25w4a5n7s33bzi0ikbL2HL3oQnSBNku4m9g0r vuNVGqZ27r2CXj7rRAPWB/Y/8HhUkw6iwC8Jk/iuo72psYzH0zxMx2x0y77JRfvSIPP0 cA4BLjpq+oFbjwvU3A3cQMmnwzEvF4FLNIoCIsu4Nk6DRG3Z/2zaHEygFvHUWBYIc651 HEoUKf7h7b/0dG/+hPFVOSd4OOawYthbg7cmcR9arFu1luEzEPwBcZJRkMTXT4KCSpgN VzOA== 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=WgRfS5eb2UyF5K8/N83Xr3Ox3vMkX6iH80CNtDNa3dI=; b=IW55TgeLJibPzfoRHXA+LetiuWo6x/ndnSn8h85q8Olg3UyjkR44fEhqOTrao0erSb idbsETIVeTV90K6Z8QoO+kg5P9mtLemDl7iKoX/cwhc59CK4QhhntOZ/5tWmVP+FAZi1 7JOAqMf9ltDjQOFSafnyJ4UReJeNcHWI1V/i+c826Uarj2siJ3UlmtPmOZQfmJZ/pggn bHdhkuVliG05af8YKwFr6yJqQjA3QWzod6obqB6G8/wQrj8PeikXo2S+Ek2OmII0SPKS M2rbPGBoMzc/J2OpPzwBXPJEY89cp/qouhyT2lWvaJ0Um2YTpJmJGPWj2z1ujwUFYIuR rqlg== X-Gm-Message-State: AOAM533Km7HpyIJXazGMNvYVwgt6sdbo+7del3xw3Mjaa3HUzNPRvEsg o1Jj1BonDzCG2D+pp1OauGU= X-Google-Smtp-Source: ABdhPJyMO5kr7iAqKL64ezpyODgCplGhGtbVIkE5jMEtzOQGbgdVYDP5yuJXWY4NQtEJ5lnqi0olDg== X-Received: by 2002:a17:902:c947:b0:15e:b73a:63d1 with SMTP id i7-20020a170902c94700b0015eb73a63d1mr4285122pla.67.1651851085064; Fri, 06 May 2022 08:31:25 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:24 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet , Tariq Toukan Subject: [PATCH v4 net-next 11/12] mlx4: support BIG TCP packets Date: Fri, 6 May 2022 08:30:47 -0700 Message-Id: <20220506153048.3695721-12-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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..e9b854c563ab7cf7a5f037b65d7f734577369f52 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_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 f777151d226fb601f52366850f8c86358e214032..af3b2b59a2a6940a2839b277815ec7c3b4af1008 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "mlx4_en.h" @@ -634,19 +635,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 */ @@ -873,6 +883,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; @@ -881,6 +892,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); @@ -890,7 +902,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; @@ -943,7 +955,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; @@ -1008,14 +1020,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 Fri May 6 15:30:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12841325 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 1C1DCC433F5 for ; Fri, 6 May 2022 15:32:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1442986AbiEFPgT (ORCPT ); Fri, 6 May 2022 11:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442972AbiEFPft (ORCPT ); Fri, 6 May 2022 11:35:49 -0400 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3974B84C for ; Fri, 6 May 2022 08:31:27 -0700 (PDT) Received: by mail-pg1-x531.google.com with SMTP id q76so6369985pgq.10 for ; Fri, 06 May 2022 08:31:27 -0700 (PDT) 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=okmO0o4zFF9RG3+3SPFXl3A+UQViu/6B/8NuQ9OH0bc=; b=JnMEI0pl25ASCbXJi1ssfnng0O3j1qf3il97b2x9ZYWCG5vdFy+RscSr8vuyquz1XY hGAvmzILWi+fBiTQWlujRoROpmY0JDwKkEgL0h6wVglEN5hjg8Oa5CjQI4Oo4hpgD2Ua Ez/XCRvPBL44Fsn1GK3wWM2O+UEY0a4T1bi3FGcpewqrtgb4cVfX9v5Zonh4Sw030+W/ phYM4cFlD4zXgrSzdfcIHtIp3tNXUOJd2LH4wfopppaSXkrJtldcbJgFwc6+aOI8wJwo tG0BawZG8gzFABeHs+Z6I1Z4ZMZRF13FF/eSFcTLAuzelXmlm+H+uMVGSO8Xqc30d5wv 7lHQ== 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=okmO0o4zFF9RG3+3SPFXl3A+UQViu/6B/8NuQ9OH0bc=; b=zNamtZxFue/YJs8b5BXtugwnoj8KT1jtIarh9xnAJspTvh12jCS2vsoq09ehWrL1RA jGX4Yu5aOEccqsyzwGt7kNCQhqXSDF+Ttwh+T5TSZoH71tgrpFDuEtO5HlKahfhjZUls cLU+zqgvmpRRsZmc+Z8lJxlDAAHHAAVszacb5qA3RdPoN99Qx3XgGdHDVtD3Neg3iOTX Cz7iyCHd2QDZpBnhBUlh79rB/u0/QPgzagX/smpnW6Hg/4nm9scVGZtNakZSFDL6ViRb yvOmJXARyYcvoRyB93z7kLUCur5Kz6PzvpSgQlAK08H2JV7ymO/rM4yj7xv3Br6bZ8BG ZQaA== X-Gm-Message-State: AOAM530k/Tii6j8HAaZkcWevE9Vm0d/nw3kydB0jA3w9SNj3eVMHhqMl yfyyfK2mgUrGGNDCk95i1sM= X-Google-Smtp-Source: ABdhPJz0F2ZTnSD+DUf8BUlntQHU2x5PUcFX/VUN57hJGq2MiJhe535xYW6knqmx1EtWdD5Qb0kI8w== X-Received: by 2002:a63:1907:0:b0:39d:4f3:6dd8 with SMTP id z7-20020a631907000000b0039d04f36dd8mr3171056pgl.447.1651851087314; Fri, 06 May 2022 08:31:27 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:709e:d3d8:321b:df52]) by smtp.gmail.com with ESMTPSA id w4-20020a170902d70400b0015e8d4eb1bfsm1918612ply.9.2022.05.06.08.31.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 May 2022 08:31:26 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Coco Li , Eric Dumazet , Eric Dumazet , Tariq Toukan , Saeed Mahameed , Leon Romanovsky Subject: [PATCH v4 net-next 12/12] mlx5: support BIG TCP packets Date: Fri, 6 May 2022 08:30:48 -0700 Message-Id: <20220506153048.3695721-13-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog In-Reply-To: <20220506153048.3695721-1-eric.dumazet@gmail.com> References: <20220506153048.3695721-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 d27986869b8ba070d1a4f8bcdc7e14ab54ae984e..226825410a1aa55b5b7941a7389a78abdb800521 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -4920,6 +4920,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) netdev->priv_flags |= IFF_UNICAST_FLT; + netif_set_tso_max_size(netdev, 512 * 1024); mlx5e_set_netdev_dev_addr(netdev); mlx5e_ipsec_build_netdev(priv); mlx5e_ktls_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;