On Tue, Mar 22, 2022 at 3:41 AM Harold Huang <baymaxhu...@gmail.com> wrote:
>
> On Fri, Mar 18, 2022 at 11:33 PM David Marchand
> <david.march...@redhat.com> wrote:
> >
> > DPDK based dp-packets points to data buffers that can't be expanded
> > dynamically.
> > Their layout is as follows:
> > - a 128 bytes headroom chosen at DPDK build time (RTE_PKTMBUF_HEADROOM),
> > - a maximum size chosen at mempool creation,
> >
> > In some usecases though (like encapsulating with multiple tunnels),
> > a 128 bytes headroom is too short.
> >
> > Dynamically allocate buffers in DPDK memory and make use of DPDK
> > external buffers API (previously used for userspace TSO).
> >
> > Signed-off-by: David Marchand <david.march...@redhat.com>
> > ---
> >  lib/dp-packet.c   | 17 ++++++++++++++++-
> >  lib/netdev-dpdk.c | 47 +++++++++++++++++++++++++++++++++++------------
> >  lib/netdev-dpdk.h |  3 +++
> >  3 files changed, 54 insertions(+), 13 deletions(-)
> >
> > diff --git a/lib/dp-packet.c b/lib/dp-packet.c
> > index 35c72542a2..07fa67b1a1 100644
> > --- a/lib/dp-packet.c
> > +++ b/lib/dp-packet.c
> > @@ -250,8 +250,23 @@ dp_packet_resize(struct dp_packet *b, size_t 
> > new_headroom, size_t new_tailroom)
> >      new_allocated = new_headroom + dp_packet_size(b) + new_tailroom;
> >
> >      switch (b->source) {
> > -    case DPBUF_DPDK:
> > +    case DPBUF_DPDK: {
> > +#ifdef DPDK_NETDEV
> > +        uint32_t buf_len;
> > +
> > +        buf_len = new_allocated;
> > +        new_base = netdev_dpdk_extbuf_allocate(&buf_len);
> > +        if (!new_base) {
> > +            out_of_memory();
> > +        }
> > +        ovs_assert(buf_len <= UINT16_MAX);
> > +        dp_packet_copy__(b, new_base, new_headroom, new_tailroom);
> > +        netdev_dpdk_extbuf_replace(b, new_base, buf_len);
>
> It seems that this is the first example in dp-packet.c to use the APIs
> in netdev-dpdk.c. Why not move them to dp-packet.c directly?

This is not the first time this approach is taken.

lib/dp-packet.c:            free_dpdk_buf((struct dp_packet*) b);
lib/dp-packet.h:            free_dpdk_buf((struct dp_packet*) b);
lib/netdev-dpdk.c:free_dpdk_buf(struct dp_packet *p)
lib/netdev-dpdk.h:void free_dpdk_buf(struct dp_packet *);
lib/netdev-dpdk.h:free_dpdk_buf(struct dp_packet *buf OVS_UNUSED)

I prefer to keep DPDK related bits in netdev-dpdk.c.
dp-packet does not have to know about external buffers and having all
code about external buffers in a single file is easier to
tracker/understand.


-- 
David Marchand

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to