Re: [PATCH net-next v7 8/9] net: check for driver support in netmem TX

Paolo Abeni
2025-03-13T10:59:02Z

On 3/8/25 10:40 PM, Mina Almasry wrote:
> We should not enable netmem TX for drivers that don't declare support.
>
> Check for driver netmem TX support during devmem TX binding and fail if
> the driver does not have the functionality.
>
> Check for driver support in validate_xmit_skb as well.
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> Acked-by: Stanislav Fomichev <sdf@fomichev.me>
>
> ---
>
> v5: https://lore.kernel.org/netdev/20250227041209.2031104-8-almasrymina@google.com/
> - Check that the dmabuf mappings belongs to the specific device the TX
> is being sent from (Jakub)
>
> v4:
> - New patch
>
> ---
> net/core/dev.c | 33 +++++++++++++++++++++++++++++++++
> net/core/devmem.h | 6 ++++++
> net/core/netdev-genl.c | 7 +++++++
> 3 files changed, 46 insertions(+)
>
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 1cb134ff7327..5553947123a0 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -3868,10 +3868,43 @@ int skb_csum_hwoffload_help(struct sk_buff *skb,
> }
> EXPORT_SYMBOL(skb_csum_hwoffload_help);
>
> +static struct sk_buff *validate_xmit_unreadable_skb(struct sk_buff *skb,
> + struct net_device *dev)
> +{
> + struct skb_shared_info *shinfo;
> + struct net_iov *niov;
> +
> + if (likely(skb_frags_readable(skb)))
> + goto out;
> +
> + if (likely(!dev->netmem_tx))

Minor nit: I think the above is actually unlikely. The skb is
unreadable: is supposed to be transmitted on a device supporting
netmem_tx, otherwise we are in exceptional/error path.

No need to repost just for this.

Thanks,

Paolo