summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorMina Almasry <almasrymina@google.com>2025-05-08 00:48:26 +0000
committerPaolo Abeni <pabeni@redhat.com>2025-05-13 11:12:49 +0200
commit383faec0fd64b9bff15eb5f700f023ec35520a96 (patch)
tree24e5909b0ef72a7d59c7f36ba08a063d28a266cc /include/net
parent17af8cc06a5a302f22994e765ddb7268373ad1db (diff)
net: enable driver support for netmem TX
Drivers need to make sure not to pass netmem dma-addrs to the dma-mapping API in order to support netmem TX. Add helpers and netmem_dma_*() helpers that enables special handling of netmem dma-addrs that drivers can use. Document in netmem.rst what drivers need to do to support netmem TX. Signed-off-by: Mina Almasry <almasrymina@google.com> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250508004830.4100853-7-almasrymina@google.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'include/net')
-rw-r--r--include/net/netmem.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/include/net/netmem.h b/include/net/netmem.h
index ecb6b29c93f6..386164fb9c18 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -8,6 +8,7 @@
#ifndef _NET_NETMEM_H
#define _NET_NETMEM_H
+#include <linux/dma-mapping.h>
#include <linux/mm.h>
#include <net/net_debug.h>
@@ -276,4 +277,23 @@ static inline unsigned long netmem_get_dma_addr(netmem_ref netmem)
void get_netmem(netmem_ref netmem);
void put_netmem(netmem_ref netmem);
+#define netmem_dma_unmap_addr_set(NETMEM, PTR, ADDR_NAME, VAL) \
+ do { \
+ if (!netmem_is_net_iov(NETMEM)) \
+ dma_unmap_addr_set(PTR, ADDR_NAME, VAL); \
+ else \
+ dma_unmap_addr_set(PTR, ADDR_NAME, 0); \
+ } while (0)
+
+static inline void netmem_dma_unmap_page_attrs(struct device *dev,
+ dma_addr_t addr, size_t size,
+ enum dma_data_direction dir,
+ unsigned long attrs)
+{
+ if (!addr)
+ return;
+
+ dma_unmap_page_attrs(dev, addr, size, dir, attrs);
+}
+
#endif /* _NET_NETMEM_H */