]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netmem: add niov->type attribute to distinguish different net_iov types
authorMina Almasry <almasrymina@google.com>
Thu, 8 May 2025 00:48:21 +0000 (00:48 +0000)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 13 May 2025 09:12:48 +0000 (11:12 +0200)
Later patches in the series adds TX net_iovs where there is no pp
associated, so we can't rely on niov->pp->mp_ops to tell what is the
type of the net_iov.

Add a type enum to the net_iov which tells us the net_iov type.

Signed-off-by: Mina Almasry <almasrymina@google.com>
Link: https://patch.msgid.link/20250508004830.4100853-2-almasrymina@google.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
include/net/netmem.h
io_uring/zcrx.c
net/core/devmem.c

index c61d5b21e7b42a6974b45f19f3da225616db7321..973fdbcfef38bed4752cfd03f17f6ecdde1768e2 100644 (file)
@@ -20,8 +20,17 @@ DECLARE_STATIC_KEY_FALSE(page_pool_mem_providers);
  */
 #define NET_IOV 0x01UL
 
+enum net_iov_type {
+       NET_IOV_DMABUF,
+       NET_IOV_IOURING,
+
+       /* Force size to unsigned long to make the NET_IOV_ASSERTS below pass.
+        */
+       NET_IOV_MAX = ULONG_MAX
+};
+
 struct net_iov {
-       unsigned long __unused_padding;
+       enum net_iov_type type;
        unsigned long pp_magic;
        struct page_pool *pp;
        struct net_iov_area *owner;
index fe86606b9f304d8e0f954fefbd1a12eb63ea0c2b..a07ad38935c861c8b9329dcd2a882c0c7fad396b 100644 (file)
@@ -259,6 +259,7 @@ static int io_zcrx_create_area(struct io_zcrx_ifq *ifq,
                niov->owner = &area->nia;
                area->freelist[i] = i;
                atomic_set(&area->user_refs[i], 0);
+               niov->type = NET_IOV_IOURING;
        }
 
        area->free_count = nr_iovs;
index 6e27a47d04935436fb7ee68a422734154a55bf99..f5c3a7e6dbb7b51c1ef7a0a967a89e3b3e527fcb 100644 (file)
@@ -30,7 +30,7 @@ static const struct memory_provider_ops dmabuf_devmem_ops;
 
 bool net_is_devmem_iov(struct net_iov *niov)
 {
-       return niov->pp->mp_ops == &dmabuf_devmem_ops;
+       return niov->type == NET_IOV_DMABUF;
 }
 
 static void net_devmem_dmabuf_free_chunk_owner(struct gen_pool *genpool,
@@ -266,6 +266,7 @@ net_devmem_bind_dmabuf(struct net_device *dev, unsigned int dmabuf_fd,
 
                for (i = 0; i < owner->area.num_niovs; i++) {
                        niov = &owner->area.niovs[i];
+                       niov->type = NET_IOV_DMABUF;
                        niov->owner = &owner->area;
                        page_pool_set_dma_addr_netmem(net_iov_to_netmem(niov),
                                                      net_devmem_get_dma_addr(niov));