mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-10-31 22:34:33 +01:00
For zerocopy (io_uring, devmem), there is an assumption that the parent device can do DMA. However that is not always the case: - Scalable Function netdevs [1] have the DMA device in the grandparent. - For Multi-PF netdevs [2] queues can be associated to different DMA devices. This patch introduces the a queue based interface for allowing drivers to expose a different DMA device for zerocopy. [1] Documentation/networking/device_drivers/ethernet/mellanox/mlx5/switchdev.rst [2] Documentation/networking/multi-pf-netdev.rst Signed-off-by: Dragos Tatulea <[email protected]> Reviewed-by: Pavel Begunkov <[email protected]> Reviewed-by: Mina Almasry <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
28 lines
761 B
C
28 lines
761 B
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <net/netdev_queues.h>
|
|
|
|
/**
|
|
* netdev_queue_get_dma_dev() - get dma device for zero-copy operations
|
|
* @dev: net_device
|
|
* @idx: queue index
|
|
*
|
|
* Get dma device for zero-copy operations to be used for this queue.
|
|
* When such device is not available or valid, the function will return NULL.
|
|
*
|
|
* Return: Device or NULL on error
|
|
*/
|
|
struct device *netdev_queue_get_dma_dev(struct net_device *dev, int idx)
|
|
{
|
|
const struct netdev_queue_mgmt_ops *queue_ops = dev->queue_mgmt_ops;
|
|
struct device *dma_dev;
|
|
|
|
if (queue_ops && queue_ops->ndo_queue_get_dma_dev)
|
|
dma_dev = queue_ops->ndo_queue_get_dma_dev(dev, idx);
|
|
else
|
|
dma_dev = dev->dev.parent;
|
|
|
|
return dma_dev && dma_dev->dma_mask ? dma_dev : NULL;
|
|
}
|
|
|