mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
net: convert netmem_tx flag to enum
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 <hramamurthy@google.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Signed-off-by: Bobby Eshleman <bobbyeshleman@meta.com> Link: https://patch.msgid.link/20260514-tcp-dm-netkit-v5-1-408c59b91e66@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
f79a0466a4
commit
7d3ab852dc
|
|
@ -95,4 +95,7 @@ Driver TX Requirements
|
|||
netdev@, or reach out to the maintainers and/or almasrymina@google.com 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.
|
||||
|
|
|
|||
|
|
@ -89,4 +89,6 @@ dma-mapping API 去处理。
|
|||
使用某个还不存在的 netmem API,你可以自行添加并提交到 netdev@,也可以联系维护
|
||||
人员或者发送邮件至 almasrymina@google.com 寻求帮助。
|
||||
|
||||
2. 驱动程序应通过设置 netdev->netmem_tx = true 来表明自身支持 netmem 功能。
|
||||
2. 驱动程序应将 `netdev->netmem_tx` 设置为适当的模式:
|
||||
|
||||
- `NETMEM_TX_DMA`:适用于执行 DMA 的物理设备。
|
||||
|
|
|
|||
|
|
@ -17123,7 +17123,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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -5963,7 +5963,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);
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1794,6 +1794,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 */
|
||||
|
|
@ -1815,7 +1820,7 @@ 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
|
||||
*
|
||||
* @name: This is the first field of the "visible" part of this structure
|
||||
* (i.e. as seen by users in the "Space.c" file). It is the name
|
||||
|
|
|
|||
|
|
@ -3996,7 +3996,7 @@ static struct sk_buff *validate_xmit_unreadable_skb(struct sk_buff *skb,
|
|||
if (likely(skb_frags_readable(skb)))
|
||||
goto out;
|
||||
|
||||
if (!dev->netmem_tx)
|
||||
if (dev->netmem_tx == NETMEM_TX_NONE)
|
||||
goto out_free;
|
||||
|
||||
shinfo = skb_shinfo(skb);
|
||||
|
|
|
|||
|
|
@ -1164,7 +1164,7 @@ int netdev_nl_bind_tx_doit(struct sk_buff *skb, struct genl_info *info)
|
|||
goto err_unlock_netdev;
|
||||
}
|
||||
|
||||
if (!netdev->netmem_tx) {
|
||||
if (netdev->netmem_tx == NETMEM_TX_NONE) {
|
||||
err = -EOPNOTSUPP;
|
||||
NL_SET_ERR_MSG(info->extack,
|
||||
"Driver does not support netmem TX");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user