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

Mina Almasry
2024-02-13T20:01:55Z

On Tue, Feb 13, 2024 at 5:24 AM Pavel Begunkov <asml.silence@gmail.com> wrote:
>
> On 12/18/23 02:40, Mina Almasry wrote:
> > 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 <kaiyuanz@google.com>
> > Signed-off-by: Mina Almasry <almasrymina@google.com>
> >
> > ---
> >
> > 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(+)
> >
> ...
> > 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.

> > +}
> > +
> > +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