Subject: Re: [PATCH net-next v3 1/8] net: convert netmem_tx flag to enum

From: Stanislav Fomichev <[email-masked]>
Date: Fri, 8 May 2026 07:56:42 -0700

On 05/07, Bobby Eshleman wrote:
> From: Bobby Eshleman <[email-masked]>
> 
> Devices that support netmem TX previously set dev->netmem_tx = true.
> This was checked in validate_xmit_unreadable_skb() to drop unreadable
> skbs (skbs with dmabuf-backed frags) before they reach drivers that
> would mishandle them or devices that would not have the iommu mappings
> for them.
> 
> A subsequent patch will introduce a third state for virtual devices
> that forward unreadable skbs without ever performing DMA on them. To
> prepare for that, convert the boolean dev->netmem_tx into an enum:
> 
> NETMEM_TX_NONE   - no netmem TX support (drop unreadable skbs)
> NETMEM_TX_DMA    - full support, device does DMA
> 
> Update the existing NIC drivers (bnxt, gve, mlx5, fbnic) and the
> validators in net/core to use the new enum. No functional change.
> 
> Acked-by: Harshitha Ramamurthy <[email-masked]>
> Signed-off-by: Bobby Eshleman <[email-masked]>
> ---
> Changes in v3:
> - Split NO_DMA changes into subsequent commit (Jakub)
> - Move !netdev->netmem_tx -> netdev->netmem_tx ==
>   NETMEM_TX_NONE conversions to this patch (Jakub)
> 
> Changes in v2:
> - Squash driver conversion patches (2-5) into patch 1 (Jakub)
> ---
>  Documentation/networking/netmem.rst                    | 5 ++++-
>  Documentation/translations/zh_CN/networking/netmem.rst | 4 +++-
>  drivers/net/ethernet/broadcom/bnxt/bnxt.c              | 2 +-
>  drivers/net/ethernet/google/gve/gve_main.c             | 2 +-
>  drivers/net/ethernet/mellanox/mlx5/core/en_main.c      | 2 +-
>  drivers/net/ethernet/meta/fbnic/fbnic_netdev.c         | 2 +-
>  include/linux/netdevice.h                              | 8 +++++++-
>  net/core/dev.c                                         | 2 +-
>  net/core/netdev-genl.c                                 | 2 +-
>  9 files changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/Documentation/networking/netmem.rst b/Documentation/networking/netmem.rst
> index b63aded46337..5ccadba4f373 100644
> --- a/Documentation/networking/netmem.rst
> +++ b/Documentation/networking/netmem.rst
> @@ -95,4 +95,7 @@ Driver TX Requirements
>     netdev@, or reach out to the maintainers and/or [email-masked] for
>     help adding the netmem API.
>  
> -2. Driver should declare support by setting `netdev->netmem_tx = true`
> +2. Driver should declare support by setting `netdev->netmem_tx` to the
> +   appropriate mode:
> +
> +   - `NETMEM_TX_DMA`: for physical devices that perform DMA.
> diff --git a/Documentation/translations/zh_CN/networking/netmem.rst b/Documentation/translations/zh_CN/networking/netmem.rst
> index fe351a240f02..9c84423b7528 100644
> --- a/Documentation/translations/zh_CN/networking/netmem.rst
> +++ b/Documentation/translations/zh_CN/networking/netmem.rst
> @@ -89,4 +89,6 @@ dma-mapping API 去处理。
>  使用某个还不存在的 netmem API，你可以自行添加并提交到 netdev@，也可以联系维护
>  人员或者发送邮件至 [email-masked] 寻求帮助。
>  
> -2. 驱动程序应通过设置 netdev->netmem_tx = true 来表明自身支持 netmem 功能。
> +2. 驱动程序应将 `netdev->netmem_tx` 设置为适当的模式：
> +
> +   - `NETMEM_TX_DMA`：适用于执行 DMA 的物理设备。
> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> index 8c55874f44ca..ed9c22dc4a5a 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
> @@ -17120,7 +17120,7 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>  	dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops_unsupp;
>  	if (BNXT_SUPPORTS_QUEUE_API(bp))
>  		dev->queue_mgmt_ops = &bnxt_queue_mgmt_ops;
> -	dev->netmem_tx = true;
> +	dev->netmem_tx = NETMEM_TX_DMA;
>  
>  	rc = register_netdev(dev);
>  	if (rc)
> diff --git a/drivers/net/ethernet/google/gve/gve_main.c b/drivers/net/ethernet/google/gve/gve_main.c
> index 424d973c97f2..dd2b8f087163 100644
> --- a/drivers/net/ethernet/google/gve/gve_main.c
> +++ b/drivers/net/ethernet/google/gve/gve_main.c
> @@ -2894,7 +2894,7 @@ static int gve_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>  		goto abort_with_wq;
>  
>  	if (!gve_is_gqi(priv) && !gve_is_qpl(priv))
> -		dev->netmem_tx = true;
> +		dev->netmem_tx = NETMEM_TX_DMA;
>  
>  	err = register_netdev(dev);
>  	if (err)
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 5a46870c4b74..fc49aae38807 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -5924,7 +5924,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
>  
>  	netdev->priv_flags       |= IFF_UNICAST_FLT;
>  
> -	netdev->netmem_tx = true;
> +	netdev->netmem_tx = NETMEM_TX_DMA;
>  
>  	netif_set_tso_max_size(netdev, GSO_MAX_SIZE);
>  	mlx5e_set_xdp_feature(priv);
> diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
> index c406a3b56b37..138e522ef9b9 100644
> --- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
> +++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
> @@ -752,7 +752,7 @@ struct net_device *fbnic_netdev_alloc(struct fbnic_dev *fbd)
>  	netdev->netdev_ops = &fbnic_netdev_ops;
>  	netdev->stat_ops = &fbnic_stat_ops;
>  	netdev->queue_mgmt_ops = &fbnic_queue_mgmt_ops;
> -	netdev->netmem_tx = true;
> +	netdev->netmem_tx = NETMEM_TX_DMA;
>  
>  	fbnic_set_ethtool_ops(netdev);
>  
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 0e1e581efc5a..580bccb118a0 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -1788,6 +1788,11 @@ enum netdev_stat_type {
>  	NETDEV_PCPU_STAT_DSTATS, /* struct pcpu_dstats */
>  };
>  
> +enum netmem_tx_mode {
> +	NETMEM_TX_NONE,		/* no netmem TX support */
> +	NETMEM_TX_DMA,		/* DMA-capable netmem TX (real HW) */
> +};
> +
>  enum netdev_reg_state {
>  	NETREG_UNINITIALIZED = 0,
>  	NETREG_REGISTERED,	/* completed register_netdevice */
> @@ -1809,7 +1814,8 @@ enum netdev_reg_state {
>   *	@lltx:		device supports lockless Tx. Deprecated for real HW
>   *			drivers. Mainly used by logical interfaces, such as
>   *			bonding and tunnels
> - *	@netmem_tx:	device support netmem_tx.
> + *	@netmem_tx:	device netmem TX mode (NETMEM_TX_NONE or
> + *			NETMEM_TX_DMA).

nit: if you happen to repost, listing enum values here seems too much?

"device netmem TX mode" should be enough

Acked-by: Stanislav Fomichev <[email-masked]>