summaryrefslogtreecommitdiff
path: root/net/ethtool
diff options
context:
space:
mode:
authorMina Almasry <almasrymina@google.com>2024-09-10 17:14:47 +0000
committerJakub Kicinski <kuba@kernel.org>2024-09-11 20:44:31 -0700
commit170aafe35cb98e0f3fbacb446ea86389fbce22ea (patch)
tree409d694de09ee93818437df95bc5f49d23031635 /net/ethtool
parent3efd7ab46d0aebc3e567a9846e79a98dbad3291c (diff)
netdev: support binding dma-buf to netdevice
Add a netdev_dmabuf_binding struct which represents the dma-buf-to-netdevice binding. The netlink API will bind the dma-buf to rx queues on the netdevice. On the binding, the dma_buf_attach & dma_buf_map_attachment will occur. The entries in the sg_table from mapping will be inserted into a genpool to make it ready for allocation. The chunks in the genpool are owned by a dmabuf_chunk_owner struct which holds the dma-buf offset of the base of the chunk and the dma_addr of the chunk. Both are needed to use allocations that come from this chunk. We create a new type that represents an allocation from the genpool: net_iov. We setup the net_iov allocation size in the genpool to PAGE_SIZE for simplicity: to match the PAGE_SIZE normally allocated by the page pool and given to the drivers. The user can unbind the dmabuf from the netdevice by closing the netlink socket that established the binding. We do this so that the binding is automatically unbound even if the userspace process crashes. The binding and unbinding leaves an indicator in struct netdev_rx_queue that the given queue is bound, and the binding is actuated by resetting the rx queue using the queue API. The netdev_dmabuf_binding struct is refcounted, and releases its resources only when all the refs are released. Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Kaiyuan Zhang <kaiyuanz@google.com> Signed-off-by: Mina Almasry <almasrymina@google.com> Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> # excluding netlink Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Reviewed-by: Jakub Kicinski <kuba@kernel.org> Link: https://patch.msgid.link/20240910171458.219195-4-almasrymina@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/ethtool')
-rw-r--r--net/ethtool/common.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/net/ethtool/common.c b/net/ethtool/common.c
index 6c245e59bbc1..dd345efa114b 100644
--- a/net/ethtool/common.c
+++ b/net/ethtool/common.c
@@ -655,6 +655,7 @@ int ethtool_check_max_channel(struct net_device *dev,
{
u64 max_rxnfc_in_use;
u32 max_rxfh_in_use;
+ int max_mp_in_use;
/* ensure the new Rx count fits within the configured Rx flow
* indirection table/rxnfc settings
@@ -673,6 +674,13 @@ int ethtool_check_max_channel(struct net_device *dev,
return -EINVAL;
}
+ max_mp_in_use = dev_get_min_mp_channel_count(dev);
+ if (channels.combined_count + channels.rx_count <= max_mp_in_use) {
+ if (info)
+ GENL_SET_ERR_MSG_FMT(info, "requested channel counts are too low for existing memory provider setting (%d)", max_mp_in_use);
+ return -EINVAL;
+ }
+
return 0;
}