public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Tariq Toukan <tariqt@nvidia.com>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>
Cc: Saeed Mahameed <saeedm@nvidia.com>,
	Leon Romanovsky <leon@kernel.org>, Mark Bloch <mbloch@nvidia.com>,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	linux-kernel@vger.kernel.org, Gal Pressman <gal@nvidia.com>,
	Moshe Shemesh <moshe@nvidia.com>,
	Cosmin Ratiu <cratiu@nvidia.com>,
	Dragos Tatulea <dtatulea@nvidia.com>
Subject: Re: [PATCH net-next 3/3] net/mlx5e: SHAMPO, Switch to header memcpy
Date: Thu, 15 Jan 2026 15:46:36 +0100	[thread overview]
Message-ID: <f6e226ff-8b6c-486e-96f2-024c420751ab@redhat.com> (raw)
In-Reply-To: <1768224129-1600265-4-git-send-email-tariqt@nvidia.com>

On 1/12/26 2:22 PM, Tariq Toukan wrote:
> @@ -1292,15 +1065,41 @@ static void mlx5e_shampo_update_ipv6_udp_hdr(struct mlx5e_rq *rq, struct ipv6hdr
>  	skb_shinfo(skb)->gso_type |= SKB_GSO_UDP_L4;
>  }
>  
> +static inline u32 mlx5e_shampo_get_header_offset(int header_index)

Is the above really needed to get this function inlined? Perhaps you
could use a macro insted of a function? 'static inline' in c files
should be avoided.

> +{
> +	return (header_index & (MLX5E_SHAMPO_WQ_HEADER_PER_PAGE - 1)) *
> +	       BIT(MLX5E_SHAMPO_LOG_HEADER_ENTRY_SIZE);
> +}
> +
> +static void *mlx5e_shampo_get_hdr(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
> +				  int len)
> +{
> +	struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
> +	u32 head_offset, header_index, di_index;
> +	struct mlx5e_dma_info *di;
> +
> +	header_index = mlx5e_shampo_get_cqe_header_index(rq, cqe);
> +	head_offset = mlx5e_shampo_get_header_offset(header_index);
> +	di_index = header_index >> MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE;
> +	di = &shampo->hd_buf_pages[di_index];
> +
> +	dma_sync_single_range_for_cpu(rq->pdev, di->addr, head_offset,
> +				      len, rq->buff.map_dir);
> +
> +	return page_address(di->page) + head_offset;
> +}
> +
>  static void mlx5e_shampo_update_fin_psh_flags(struct mlx5e_rq *rq, struct mlx5_cqe64 *cqe,
>  					      struct tcphdr *skb_tcp_hd)
>  {
> -	u16 header_index = mlx5e_shampo_get_cqe_header_index(rq, cqe);
> +	int nhoff = ETH_HLEN + rq->hw_gro_data->fk.control.thoff;
> +	int len = nhoff + sizeof(struct tcphdr);
>  	struct tcphdr *last_tcp_hd;
>  	void *last_hd_addr;
>  
> -	last_hd_addr = mlx5e_shampo_get_packet_hd(rq, header_index);
> -	last_tcp_hd =  last_hd_addr + ETH_HLEN + rq->hw_gro_data->fk.control.thoff;
> +	last_hd_addr = mlx5e_shampo_get_hdr(rq, cqe, len);
> +	last_tcp_hd = (struct tcphdr *)(last_hd_addr + nhoff);
> +
>  	tcp_flag_word(skb_tcp_hd) |= tcp_flag_word(last_tcp_hd) & (TCP_FLAG_FIN | TCP_FLAG_PSH);
>  }
>  
> @@ -2299,52 +2098,29 @@ static struct sk_buff *
>  mlx5e_skb_from_cqe_shampo(struct mlx5e_rq *rq, struct mlx5e_mpw_info *wi,
>  			  struct mlx5_cqe64 *cqe, u16 header_index)
>  {
> -	struct mlx5e_frag_page *frag_page = mlx5e_shampo_hd_to_frag_page(rq, header_index);
> -	u16 head_offset = mlx5e_shampo_hd_offset(rq, header_index);
>  	struct mlx5e_shampo_hd *shampo = rq->mpwqe.shampo;
>  	u16 head_size = cqe->shampo.header_size;
> -	u16 rx_headroom = rq->buff.headroom;
> -	struct sk_buff *skb = NULL;
> -	dma_addr_t page_dma_addr;
> -	dma_addr_t dma_addr;
> -	void *hdr, *data;
> -	u32 frag_size;
> -
> -	page_dma_addr = page_pool_get_dma_addr_netmem(frag_page->netmem);
> -	dma_addr = page_dma_addr + head_offset;
> +	struct mlx5e_dma_info *di;
> +	u32 head_offset, di_index;
> +	struct sk_buff *skb;
> +	int len;
>  
> -	hdr		= netmem_address(frag_page->netmem) + head_offset;
> -	data		= hdr + rx_headroom;
> -	frag_size	= MLX5_SKB_FRAG_SZ(rx_headroom + head_size);
> +	len = ALIGN(head_size, sizeof(long));
> +	skb = napi_alloc_skb(rq->cq.napi, len);
> +	if (unlikely(!skb)) {
> +		rq->stats->buff_alloc_err++;
> +		return NULL;
> +	}
>  
> -	if (likely(frag_size <= BIT(shampo->log_hd_entry_size))) {
> -		/* build SKB around header */
> -		dma_sync_single_range_for_cpu(rq->pdev, dma_addr, 0, frag_size, rq->buff.map_dir);
> -		net_prefetchw(hdr);
> -		net_prefetch(data);
> -		skb = mlx5e_build_linear_skb(rq, hdr, frag_size, rx_headroom, head_size, 0);
> -		if (unlikely(!skb))
> -			return NULL;
> +	net_prefetchw(skb->data);
>  
> -		frag_page->frags++;
> -	} else {
> -		/* allocate SKB and copy header for large header */
> -		rq->stats->gro_large_hds++;
> -		skb = napi_alloc_skb(rq->cq.napi,
> -				     ALIGN(head_size, sizeof(long)));
> -		if (unlikely(!skb)) {
> -			rq->stats->buff_alloc_err++;
> -			return NULL;
> -		}
> +	head_offset = mlx5e_shampo_get_header_offset(header_index);
> +	di_index = header_index >> MLX5E_SHAMPO_LOG_WQ_HEADER_PER_PAGE;
> +	di = &shampo->hd_buf_pages[di_index];

The above 3 statement are repeated verbatim in mlx5e_shampo_get_hdr();
perhaps you could factor out a common helper.

/P


  reply	other threads:[~2026-01-15 14:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 13:22 [PATCH net-next 0/3] net/mlx5e: RX datapath enhancements Tariq Toukan
2026-01-12 13:22 ` [PATCH net-next 1/3] net/mlx5e: RX, Drop oversized packets in non-linear mode Tariq Toukan
2026-01-15 14:41   ` Paolo Abeni
2026-01-12 13:22 ` [PATCH net-next 2/3] net/mlx5e: SHAMPO, Improve allocation recovery Tariq Toukan
2026-01-12 13:22 ` [PATCH net-next 3/3] net/mlx5e: SHAMPO, Switch to header memcpy Tariq Toukan
2026-01-15 14:46   ` Paolo Abeni [this message]
2026-01-15 13:57 ` [PATCH net-next 0/3] net/mlx5e: RX datapath enhancements Simon Horman

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=f6e226ff-8b6c-486e-96f2-024c420751ab@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dtatulea@nvidia.com \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=mbloch@nvidia.com \
    --cc=moshe@nvidia.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