Thread (22 messages) 22 messages, 3 authors, 2024-02-14

Re: [RFC PATCH net-next v5 05/14] netdev: netdevice devmem allocator

From: Mina Almasry <hidden>
Date: 2024-02-13 20:01:55
Also in: bpf, dri-devel, linux-alpha, linux-arch, linux-doc, linux-kselftest, linux-media, linux-mips, linux-trace-kernel, lkml, sparclinux

On Tue, Feb 13, 2024 at 5:24 AM Pavel Begunkov [off-list ref] wrote:
On 12/18/23 02:40, Mina Almasry wrote:
quoted
Implement netdev devmem allocator. The allocator takes a given struct
netdev_dmabuf_binding as input and allocates net_iov from that
binding.

The allocation simply delegates to the binding's genpool for the
allocation logic and wraps the returned memory region in a net_iov
struct.

Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: Kaiyuan Zhang <redacted>
Signed-off-by: Mina Almasry <redacted>

---

v1:
- Rename devmem -> dmabuf (David).

---
  include/net/devmem.h | 12 ++++++++++++
  include/net/netmem.h | 26 ++++++++++++++++++++++++++
  net/core/dev.c       | 38 ++++++++++++++++++++++++++++++++++++++
  3 files changed, 76 insertions(+)
...
quoted
diff --git a/include/net/netmem.h b/include/net/netmem.h
index 45eb42d9990b..7fce2efc8707 100644
--- a/include/net/netmem.h
+++ b/include/net/netmem.h
@@ -14,8 +14,34 @@

  struct net_iov {
      struct dmabuf_genpool_chunk_owner *owner;
+     unsigned long dma_addr;
  };

+static inline struct dmabuf_genpool_chunk_owner *
+net_iov_owner(const struct net_iov *niov)
+{
+     return niov->owner;
+}
+
+static inline unsigned int net_iov_idx(const struct net_iov *niov)
+{
+     return niov - net_iov_owner(niov)->niovs;
+}
+
+static inline dma_addr_t net_iov_dma_addr(const struct net_iov *niov)
+{
+     struct dmabuf_genpool_chunk_owner *owner = net_iov_owner(niov);
+
+     return owner->base_dma_addr +
+            ((dma_addr_t)net_iov_idx(niov) << PAGE_SHIFT);
Looks like it should have been niov->dma_addr
Yes, indeed. Thanks for catching.
quoted
+}
+
+static inline struct netdev_dmabuf_binding *
+net_iov_binding(const struct net_iov *niov)
+{
+     return net_iov_owner(niov)->binding;
+}
+
  /* netmem */

  struct netmem {
...

--
Pavel Begunkov


-- 
Thanks,
Mina
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help