netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tariq Toukan <ttoukan.linux@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <edumazet@google.com>,
	Coco Li <lixiaoyan@google.com>,
	Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>,
	Tariq Toukan <tariqt@nvidia.com>
Subject: Re: [PATCH net-next 15/15] mlx5: support BIG TCP packets
Date: Thu, 3 Feb 2022 09:27:46 +0200	[thread overview]
Message-ID: <3ec9a7cb-433c-41b3-f918-8b5746092482@gmail.com> (raw)
In-Reply-To: <20220203015140.3022854-16-eric.dumazet@gmail.com>

Hi,

Thanks for your patch!

On 2/3/2022 3:51 AM, Eric Dumazet wrote:
> From: Coco Li <lixiaoyan@google.com>
> 
> 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.
> 
> Signed-off-by: Coco Li <lixiaoyan@google.com>
> Signed-off-by: Eric Dumazet <edumazet@google.com>
> Cc: Saeed Mahameed <saeedm@nvidia.com>
> Cc: Leon Romanovsky <leon@kernel.org>
> ---
>   .../net/ethernet/mellanox/mlx5/core/en_main.c |  1 +
>   .../net/ethernet/mellanox/mlx5/core/en_tx.c   | 81 +++++++++++++++----
>   2 files changed, 65 insertions(+), 17 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index bf80fb6124499fc4e6a0310ab92c91159b4ccbbb..1c4ce90e5d0f5186c402137b744258ff4ce6a348 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -4888,6 +4888,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 7fd33b356cc8d191413e8259acd0b26b3ebd6ba9..fc945bd8219dcb69950b1840bb492649c8749976 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 <net/ipv6.h>
>   
>   static void mlx5e_dma_unmap_wqe_err(struct mlx5e_txqsq *sq, u8 num_dma)
>   {
> @@ -241,8 +242,11 @@ 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;
> @@ -252,15 +256,18 @@ mlx5e_tx_get_gso_ihs(struct mlx5e_txqsq *sq, struct sk_buff *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 {
> +			if (ipv6_has_hopopt_jumbo(skb))
> +				*hopbyhop = sizeof(struct hop_jumbo_hdr);
>   			ihs = skb_transport_offset(skb) + tcp_hdrlen(skb);
> +		}
>   		stats->tso_packets++;
> -		stats->tso_bytes += skb->len - ihs;
> +		stats->tso_bytes += skb->len - ihs - *hopbyhop;

AFAIU, *hopbyhop is already accounted inside ihs, why decrement it once 
more?

Probably it'd be cleaner to assign/fix both ihs and hopbyhop under 
ipv6_has_hopopt_jumbo branch():

		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_bytes += skb->len - ihs - *hopbyhop;
...
		return ihs;

>   	}
>   
> -	return ihs;
> +	return ihs - *hopbyhop;
>   }
>   
>   static inline int
> @@ -319,6 +326,7 @@ struct mlx5e_tx_attr {
>   	__be16 mss;
>   	u16 insz;
>   	u8 opcode;
> +	u8 hopbyhop;
>   };
>   
>   struct mlx5e_tx_wqe_attr {
> @@ -355,14 +363,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;

missing init to zero. mlx5e_tx_get_gso_ihs() doesn't always write to it.

> +		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;
> @@ -476,7 +486,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;
>   
> @@ -490,15 +501,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. */

You are not using ihs when preparing the inline part of the descriptor, 
so this might yield a mismatch between ihs and the sum of the sizes 
you're copying above. Is there a guarantee that this won't happen?

> +		} 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);
> @@ -509,7 +541,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;
> @@ -1016,12 +1048,27 @@ 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)) {
> +			/* 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;

  reply	other threads:[~2022-02-03  7:27 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03  1:51 [PATCH net-next 00/15] tcp: BIG TCP implementation Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 01/15] net: add netdev->tso_ipv6_max_size attribute Eric Dumazet
2022-02-03 16:34   ` Jakub Kicinski
2022-02-03 16:56     ` Eric Dumazet
2022-02-03 18:58       ` Jakub Kicinski
2022-02-03 19:12         ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 02/15] ipv6: add dev->gso_ipv6_max_size Eric Dumazet
2022-02-03  8:57   ` Paolo Abeni
2022-02-03 15:34     ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 03/15] tcp_cubic: make hystart_ack_delay() aware of BIG TCP Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 04/15] ipv6: add struct hop_jumbo_hdr definition Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 05/15] ipv6/gso: remove temporary HBH/jumbo header Eric Dumazet
2022-02-03 18:53   ` Alexander H Duyck
2022-02-03 19:17     ` Eric Dumazet
2022-02-03 19:45       ` Alexander Duyck
2022-02-03 19:59         ` Eric Dumazet
2022-02-03 21:08           ` Alexander H Duyck
2022-02-03 21:41             ` Eric Dumazet
2022-02-04  0:05               ` Alexander Duyck
2022-02-04  0:27                 ` Eric Dumazet
2022-02-04  1:14                   ` Eric Dumazet
2022-02-04  1:48                     ` Eric Dumazet
2022-02-04  2:15                       ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 06/15] ipv6/gro: insert " Eric Dumazet
2022-02-03  9:19   ` Paolo Abeni
2022-02-03 15:48     ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 07/15] ipv6: add GRO_IPV6_MAX_SIZE Eric Dumazet
2022-02-03  2:18   ` Eric Dumazet
2022-02-03 10:44   ` Paolo Abeni
2022-02-03  1:51 ` [PATCH net-next 08/15] ipv6: Add hop-by-hop header to jumbograms in ip6_output Eric Dumazet
2022-02-03  9:07   ` Paolo Abeni
2022-02-03 16:31     ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 09/15] net: increase MAX_SKB_FRAGS Eric Dumazet
2022-02-03  5:02   ` kernel test robot
2022-02-03  5:20     ` Eric Dumazet
2022-02-03  5:31       ` Jakub Kicinski
2022-02-03  6:35         ` Eric Dumazet
2022-02-03  5:23   ` kernel test robot
2022-02-03  5:43   ` kernel test robot
2022-02-03 16:01   ` Paolo Abeni
2022-02-03 17:26   ` Alexander H Duyck
2022-02-03 17:34     ` Eric Dumazet
2022-02-03 17:56       ` Alexander Duyck
2022-02-03 19:18         ` Jakub Kicinski
2022-02-03 19:20           ` Eric Dumazet
2022-02-03 19:54             ` Eric Dumazet
2022-02-04 10:18         ` David Laight
2022-02-04 15:46           ` Alexander Duyck
2022-02-03  1:51 ` [PATCH net-next 10/15] net: loopback: enable BIG TCP packets Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 11/15] bonding: update dev->tso_ipv6_max_size Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 12/15] macvlan: enable BIG TCP Packets Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 13/15] ipvlan: " Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 14/15] mlx4: support BIG TCP packets Eric Dumazet
2022-02-03 13:04   ` Tariq Toukan
2022-02-03 15:54     ` Eric Dumazet
2022-02-03  1:51 ` [PATCH net-next 15/15] mlx5: " Eric Dumazet
2022-02-03  7:27   ` Tariq Toukan [this message]
2022-02-04  4:03   ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ec9a7cb-433c-41b3-f918-8b5746092482@gmail.com \
    --to=ttoukan.linux@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=lixiaoyan@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    --cc=tariqt@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).