Re: [PATCH net-next v1 08/19] virtio_net: sq support premapped mode

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 20 Oct 2023 14:50:52 +0800, Jason Wang <jasowang@xxxxxxxxxx> wrote:
> On Mon, Oct 16, 2023 at 8:01 PM Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx> wrote:
> >
> > If the xsk is enabling, the xsk tx will share the send queue.
> > But the xsk requires that the send queue use the premapped mode.
> > So the send queue must support premapped mode.
> >
> > Signed-off-by: Xuan Zhuo <xuanzhuo@xxxxxxxxxxxxxxxxx>
> > ---
> >  drivers/net/virtio/main.c       | 108 ++++++++++++++++++++++++++++----
> >  drivers/net/virtio/virtio_net.h |  54 +++++++++++++++-
> >  2 files changed, 149 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/net/virtio/main.c b/drivers/net/virtio/main.c
> > index 8da84ea9bcbe..02d27101fef1 100644
> > --- a/drivers/net/virtio/main.c
> > +++ b/drivers/net/virtio/main.c
> > @@ -514,20 +514,104 @@ static void *virtnet_rq_alloc(struct virtnet_rq *rq, u32 size, gfp_t gfp)
> >         return buf;
> >  }
> >
> > -static void virtnet_rq_set_premapped(struct virtnet_info *vi)
> > +static int virtnet_sq_set_premapped(struct virtnet_sq *sq)
> >  {
> > -       int i;
> > +       struct virtnet_sq_dma *d;
> > +       int err, size, i;
> >
> > -       /* disable for big mode */
> > -       if (!vi->mergeable_rx_bufs && vi->big_packets)
> > -               return;
>
> Not specific to this patch but any plan to fix the big mode?
>


For big, we should make it support XDP and do dma first.


>
> > +       size = virtqueue_get_vring_size(sq->vq);
> > +
> > +       size += MAX_SKB_FRAGS + 2;
> > +
> > +       sq->dmainfo.head = kcalloc(size, sizeof(*sq->dmainfo.head), GFP_KERNEL);
> > +       if (!sq->dmainfo.head)
> > +               return -ENOMEM;
> > +
> > +       err = virtqueue_set_dma_premapped(sq->vq);
> > +       if (err) {
> > +               kfree(sq->dmainfo.head);
> > +               return err;
> > +       }
> > +
> > +       sq->dmainfo.free = NULL;
> > +

[...]

> > +
> > +               d->addr = sg->dma_address;
> > +               d->len = sg->length;
> > +
> > +               d->next = head;
> > +               head = d;
>
> It's really a pity that we need to duplicate those DMA metata twice.
> Could we invent a new API to just fetch it from the virtio core?

Actually, I posted that patch.

Consider this is pushing to net-next. We can do that on top.


>
> > +       }
> > +
> > +       head->data = data;
> > +
> > +       return (void *)((unsigned long)head | ((unsigned long)data & VIRTIO_XMIT_DATA_MASK));
>
> If we packed everything into dmainfo, we can leave the type (XDP vs
> skb) there to avoid trick like packing it into the pointer here?

Yes. But if the virtio has not _ACCESS_PLATFORM, the driver will
has not the DMA meta data.

Thanks.


>
> Thanks
>





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux