Re: [PATCH net-next] eth: bnxt: add netmem TX support

Mina Almasry
2025-06-17T20:14:38Z

On Tue, Jun 17, 2025 at 2:45 AM Taehee Yoo <ap420073@gmail.com> wrote:
>
> Use netmem_dma_*() helpers and declare netmem_tx to support netmem TX.
> By this change, all bnxt devices will support the netmem TX.
>
> bnxt_start_xmit() uses memcpy() if a packet is too small. However,

nit: this is slightly inaccurate. memcpy itself is not a problem (via
skb_copy_from_linear_data) is not an issue because I think that's
copying the linear part of the skb. What is really a is
skb_frag_address_safe(). Unreadable skbs have no valid address.

This made me realize that skb_frag_address_safe() is broken :( it
needs this check, similar to skb_frag_address():

```
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index c05057869e08..da03ff71b05e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -3681,7 +3681,12 @@ static inline void *skb_frag_address(const
skb_frag_t *frag)
*/
static inline void *skb_frag_address_safe(const skb_frag_t *frag)
{
- void *ptr = page_address(skb_frag_page(frag));
+ void *ptr;
+
+ if (!skb_frag_page(frag))
+ return NULL;
+
+ ptr = page_address(skb_frag_page(frag));
if (unlikely(!ptr))
return NULL;
```

I guess I'll send this fix to net.

> netmem packets are unreadable, so memcpy() is not allowed.
> It should check whether an skb is readable, and if an SKB is unreadable,
> it is processed by the normal transmission logic.
>
> netmem TX can be tested with ncdevmem.c
>
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>

Seems like a straightforward conversion to using the netmem dma
mapping API. I don't see anything concerning/unusualy.

Acked-by: Mina Almasry <almasrymina@google.com>

--
Thanks,
Mina