public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Joe Damato <joe@dama.to>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	andrew+netdev@lunn.ch, michael.chan@broadcom.com,
	pavan.chebbi@broadcom.com, linux-kernel@vger.kernel.org
Subject: Re: [net-next v3 02/12] net: tso: Add tso_dma_map helpers
Date: Thu, 19 Mar 2026 21:34:46 +0200	[thread overview]
Message-ID: <20260319193446.GM352386@unreal> (raw)
In-Reply-To: <abwtsiQhycAgmgjv@devvm20253.cco0.facebook.com>

On Thu, Mar 19, 2026 at 10:09:06AM -0700, Joe Damato wrote:
> On Thu, Mar 19, 2026 at 09:39:59AM +0200, Leon Romanovsky wrote:
> > On Wed, Mar 18, 2026 at 12:13:07PM -0700, Joe Damato wrote:
> > > Adds skb_frag_phys() to skbuff.h, returning the physical address
> > > of a paged fragment's data, which is used by the tso_dma_map helpers
> > > introduced in this commit described below:
> > > 
> > > tso_dma_map_init(): DMA-maps the linear payload region and all frags
> > > upfront. Prefers the DMA IOVA API for a single contiguous mapping with
> > > one IOTLB sync; falls back to per-region dma_map_phys() otherwise.
> > > Returns 0 on success, cleans up partial mappings on failure.
> > > 
> > > tso_dma_map_cleanup(): Handles both IOVA and fallback teardown paths.
> > > 
> > > tso_dma_map_count(): counts how many descriptors the next N bytes of
> > > payload will need. Returns 1 if IOVA is used since the mapping is
> > > contiguous.
> > > 
> > > tso_dma_map_next(): yields the next (dma_addr, chunk_len) pair.
> > > On the IOVA path, each segment is a single contiguous chunk. On the
> > > fallback path, indicates when a chunk starts a new DMA mapping so the
> > > driver can set dma_unmap_len on that descriptor for completion-time
> > > unmapping.
> > > 
> > > Suggested-by: Jakub Kicinski <kuba@kernel.org>
> > > Signed-off-by: Joe Damato <joe@dama.to>
> > > ---
> > >  v3:
> > >    - Added skb_frag_phys helper include/linux/skbuff.h.
> > >    - Added tso_dma_map_use_iova() inline helper in tso.h.
> > >    - Updated the helpers to use the DMA IOVA API and falls back to per-region
> > >      mapping instead.
> > > 
> > >  include/linux/skbuff.h |  11 ++
> > >  include/net/tso.h      |  21 ++++
> > >  net/core/tso.c         | 274 +++++++++++++++++++++++++++++++++++++++++
> > >  3 files changed, 306 insertions(+)
> > > 
> > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> > > index 9cc98f850f1d..d8630eb366c5 100644
> > > --- a/include/linux/skbuff.h
> > > +++ b/include/linux/skbuff.h
> > > @@ -3758,6 +3758,17 @@ static inline void *skb_frag_address_safe(const skb_frag_t *frag)
> > >  	return ptr + skb_frag_off(frag);
> > >  }
> > >  
> > > +/**
> > > + * skb_frag_phys - gets the physical address of the data in a paged fragment
> > > + * @frag: the paged fragment buffer
> > > + *
> > > + * Returns: the physical address of the data within @frag.
> > > + */
> > > +static inline phys_addr_t skb_frag_phys(const skb_frag_t *frag)
> > > +{
> > > +	return page_to_phys(skb_frag_page(frag)) + skb_frag_off(frag);
> > > +}
> > 
> > I skimmed through the patch and it looks generally correct to me. The one
> > thing that disappointed me is this function. It's unfortunate that you
> > have to implement it this way and cannot rely on phys_addr_t directly.
> 
> Thanks for taking a look.
> 
> Would you prefer if I modified this and created a netmem_to_phys() helper
> (page-only for now, but extensible later?) and use that instead?
> 
> Or is this patch acceptable as-is for this series with the understanding that
> it only handles page-backed frags?
> 
> Just want to make sure I'm following what you mean.

It is acceptable as is. I'm just expressing my view about performing so
much translations.

Thanks

> 
> Thanks.
> 

  reply	other threads:[~2026-03-19 19:34 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-18 19:13 [net-next v3 00/12] Add TSO map-once DMA helpers and bnxt SW USO support Joe Damato
2026-03-18 19:13 ` [net-next v3 01/12] net: tso: Introduce tso_dma_map Joe Damato
2026-03-18 19:13 ` [net-next v3 02/12] net: tso: Add tso_dma_map helpers Joe Damato
2026-03-19  7:39   ` Leon Romanovsky
2026-03-19 17:09     ` Joe Damato
2026-03-19 19:34       ` Leon Romanovsky [this message]
2026-03-18 19:13 ` [net-next v3 03/12] net: bnxt: Export bnxt_xmit_get_cfa_action Joe Damato
2026-03-19 11:32   ` Pavan Chebbi
2026-03-18 19:13 ` [net-next v3 04/12] net: bnxt: Add a helper for tx_bd_ext Joe Damato
2026-03-19 11:33   ` Pavan Chebbi
2026-03-18 19:13 ` [net-next v3 05/12] net: bnxt: Use dma_unmap_len for TX completion unmapping Joe Damato
2026-03-19 11:35   ` Pavan Chebbi
2026-03-18 19:13 ` [net-next v3 06/12] net: bnxt: Add TX inline buffer infrastructure Joe Damato
2026-03-18 19:13 ` [net-next v3 07/12] net: bnxt: Add boilerplate GSO code Joe Damato
2026-03-18 19:13 ` [net-next v3 08/12] net: bnxt: Implement software USO Joe Damato
2026-03-19 11:41   ` Pavan Chebbi
2026-03-19 17:12     ` Joe Damato
2026-03-18 19:13 ` [net-next v3 09/12] net: bnxt: Add SW GSO completion and teardown support Joe Damato
2026-03-18 19:13 ` [net-next v3 10/12] net: bnxt: Dispatch to SW USO Joe Damato
2026-03-18 19:13 ` [net-next v3 11/12] net: netdevsim: Add support for " Joe Damato
2026-03-18 19:13 ` [net-next v3 12/12] selftests: drv-net: Add USO test Joe Damato

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=20260319193446.GM352386@unreal \
    --to=leon@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=joe@dama.to \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.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