Re: [PATCH net-next v9 2/8] netmem: introduce utility APIs to use struct netmem_desc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 12, 2025 at 12:59:34PM +0100, Pavel Begunkov wrote:
> On 7/10/25 09:28, Byungchul Park wrote:
> ...> +
> >   static inline struct net_iov *netmem_to_net_iov(netmem_ref netmem)
> >   {
> >       if (netmem_is_net_iov(netmem))
> > @@ -314,6 +340,21 @@ static inline netmem_ref netmem_compound_head(netmem_ref netmem)
> >       return page_to_netmem(compound_head(netmem_to_page(netmem)));
> >   }
> > 
> > +#define nmdesc_to_page(nmdesc)               (_Generic((nmdesc),             \
> > +     const struct netmem_desc * :    (const struct page *)(nmdesc),  \
> > +     struct netmem_desc * :          (struct page *)(nmdesc)))
> 
> Considering that nmdesc is going to be separated from pages and
> accessed through indirection, and back reference to the page is
> not needed (at least for net/), this helper shouldn't even exist.
> And in fact, you don't really use it ...
> > +static inline struct netmem_desc *page_to_nmdesc(struct page *page)
> > +{
> > +     VM_BUG_ON_PAGE(PageTail(page), page);
> > +     return (struct netmem_desc *)page;
> > +}
> > +
> > +static inline void *nmdesc_address(struct netmem_desc *nmdesc)
> > +{
> > +     return page_address(nmdesc_to_page(nmdesc));
> > +}
> 
> ... That's the only caller, and nmdesc_address() is not used, so
> just nuke both of them. This helper doesn't even make sense.
> 
> Please avoid introducing functions that you don't use as a general
> rule.

I'm sorry about making you confused.  I should've included another patch
using the helper like the following.

	Byungchul

---8<---
diff --git a/drivers/net/ethernet/intel/idpf/idpf_txrx.c b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
index cef9dfb877e8..adccc7c8e68f 100644
--- a/drivers/net/ethernet/intel/idpf/idpf_txrx.c
+++ b/drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -3266,7 +3266,7 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 			     struct libeth_fqe *buf, u32 data_len)
 {
 	u32 copy = data_len <= L1_CACHE_BYTES ? data_len : ETH_HLEN;
-	struct page *hdr_page, *buf_page;
+	struct netmem_desc *hdr_nmdesc, *buf_nmdesc;
 	const void *src;
 	void *dst;
 
@@ -3274,10 +3274,10 @@ static u32 idpf_rx_hsplit_wa(const struct libeth_fqe *hdr,
 	    !libeth_rx_sync_for_cpu(buf, copy))
 		return 0;
 
-	hdr_page = __netmem_to_page(hdr->netmem);
-	buf_page = __netmem_to_page(buf->netmem);
-	dst = page_address(hdr_page) + hdr->offset + hdr_page->pp->p.offset;
-	src = page_address(buf_page) + buf->offset + buf_page->pp->p.offset;
+	hdr_nmdesc = __netmem_to_nmdesc(hdr->netmem);
+	buf_nmdesc = __netmem_to_nmdesc(buf->netmem);
+	dst = nmdesc_address(hdr_nmdesc) + hdr->offset + hdr_nmdesc->pp->p.offset;
+	src = nmdesc_address(buf_nmdesc) + buf->offset + buf_nmdesc->pp->p.offset;
 
 	memcpy(dst, src, LARGEST_ALIGN(copy));
 	buf->offset += copy;
--
> > +
> >   /**
> >    * __netmem_address - unsafely get pointer to the memory backing @netmem
> >    * @netmem: netmem reference to get the pointer for
> 
> --
> Pavel Begunkov




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux