mbox series

[v2,0/9] virtio: support advance DMA

Message ID 20220224110402.108161-1-xuanzhuo@linux.alibaba.com (mailing list archive)
Headers show
Series virtio: support advance DMA | expand

Message

Xuan Zhuo Feb. 24, 2022, 11:03 a.m. UTC
virtqueue_add() only supports virtual addresses, dma is completed in
virtqueue_add().

In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
it is necessary for us to support passing the DMA address to virtqueue_add().

v2:
    1. rename predma -> premapped
    2. virtio net xdp tx use virtio dma api

v1:
   1. All sgs requested at one time are required to be unified PREDMA, and several
      of them are not supported to be PREDMA
   2. virtio_dma_map() is removed from this patch set and will be submitted
      together with the next time AF_XDP supports virtio dma
   3. Added patch #2 #3 to remove the check for flags when performing unmap
      indirect desc

Xuan Zhuo (9):
  virtio_ring: rename vring_unmap_state_packed() to
    vring_unmap_extra_packed()
  virtio_ring: remove flags check for unmap split indirect desc
  virtio_ring: remove flags check for unmap packed indirect desc
  virtio_ring: virtqueue_add() support premapped
  virtio_ring: split: virtqueue_add_split() support premapped
  virtio_ring: packed: virtqueue_add_packed() support premapped
  virtio_ring: add api virtio_dma_map() for advance dma
  virtio_ring: introduce virtqueue_add_outbuf_premapped()
  virtio_net: xdp xmit use virtio dma api

 drivers/net/virtio_net.c     |  42 +++++-
 drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
 include/linux/virtio.h       |  12 ++
 3 files changed, 254 insertions(+), 80 deletions(-)

--
2.31.0

Comments

Michael S. Tsirkin March 30, 2022, 6:33 a.m. UTC | #1
On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> virtqueue_add() only supports virtual addresses, dma is completed in
> virtqueue_add().
> 
> In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> it is necessary for us to support passing the DMA address to virtqueue_add().

I picked up a couple of patches. Others are waiting for some acks
(Jason?) and improved commit logs for documentation.

Thanks!

> v2:
>     1. rename predma -> premapped
>     2. virtio net xdp tx use virtio dma api
> 
> v1:
>    1. All sgs requested at one time are required to be unified PREDMA, and several
>       of them are not supported to be PREDMA
>    2. virtio_dma_map() is removed from this patch set and will be submitted
>       together with the next time AF_XDP supports virtio dma
>    3. Added patch #2 #3 to remove the check for flags when performing unmap
>       indirect desc
> 
> Xuan Zhuo (9):
>   virtio_ring: rename vring_unmap_state_packed() to
>     vring_unmap_extra_packed()
>   virtio_ring: remove flags check for unmap split indirect desc
>   virtio_ring: remove flags check for unmap packed indirect desc
>   virtio_ring: virtqueue_add() support premapped
>   virtio_ring: split: virtqueue_add_split() support premapped
>   virtio_ring: packed: virtqueue_add_packed() support premapped
>   virtio_ring: add api virtio_dma_map() for advance dma
>   virtio_ring: introduce virtqueue_add_outbuf_premapped()
>   virtio_net: xdp xmit use virtio dma api
> 
>  drivers/net/virtio_net.c     |  42 +++++-
>  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
>  include/linux/virtio.h       |  12 ++
>  3 files changed, 254 insertions(+), 80 deletions(-)
> 
> --
> 2.31.0
Jason Wang March 30, 2022, 6:56 a.m. UTC | #2
On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
>
> On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > virtqueue_add() only supports virtual addresses, dma is completed in
> > virtqueue_add().
> >
> > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > it is necessary for us to support passing the DMA address to virtqueue_add().
>
> I picked up a couple of patches. Others are waiting for some acks
> (Jason?) and improved commit logs for documentation.

I will review them.

Thanks

>
> Thanks!
>
> > v2:
> >     1. rename predma -> premapped
> >     2. virtio net xdp tx use virtio dma api
> >
> > v1:
> >    1. All sgs requested at one time are required to be unified PREDMA, and several
> >       of them are not supported to be PREDMA
> >    2. virtio_dma_map() is removed from this patch set and will be submitted
> >       together with the next time AF_XDP supports virtio dma
> >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> >       indirect desc
> >
> > Xuan Zhuo (9):
> >   virtio_ring: rename vring_unmap_state_packed() to
> >     vring_unmap_extra_packed()
> >   virtio_ring: remove flags check for unmap split indirect desc
> >   virtio_ring: remove flags check for unmap packed indirect desc
> >   virtio_ring: virtqueue_add() support premapped
> >   virtio_ring: split: virtqueue_add_split() support premapped
> >   virtio_ring: packed: virtqueue_add_packed() support premapped
> >   virtio_ring: add api virtio_dma_map() for advance dma
> >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> >   virtio_net: xdp xmit use virtio dma api
> >
> >  drivers/net/virtio_net.c     |  42 +++++-
> >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> >  include/linux/virtio.h       |  12 ++
> >  3 files changed, 254 insertions(+), 80 deletions(-)
> >
> > --
> > 2.31.0
>
Xuan Zhuo March 30, 2022, 6:58 a.m. UTC | #3
On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> >
> > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > virtqueue_add().
> > >
> > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > it is necessary for us to support passing the DMA address to virtqueue_add().
> >
> > I picked up a couple of patches. Others are waiting for some acks
> > (Jason?) and improved commit logs for documentation.
>
> I will review them.

hi, the core code of premapped, I will merge it into 'virtio pci support
VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
after resize.

Thanks.


>
> Thanks
>
> >
> > Thanks!
> >
> > > v2:
> > >     1. rename predma -> premapped
> > >     2. virtio net xdp tx use virtio dma api
> > >
> > > v1:
> > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > >       of them are not supported to be PREDMA
> > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > >       together with the next time AF_XDP supports virtio dma
> > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > >       indirect desc
> > >
> > > Xuan Zhuo (9):
> > >   virtio_ring: rename vring_unmap_state_packed() to
> > >     vring_unmap_extra_packed()
> > >   virtio_ring: remove flags check for unmap split indirect desc
> > >   virtio_ring: remove flags check for unmap packed indirect desc
> > >   virtio_ring: virtqueue_add() support premapped
> > >   virtio_ring: split: virtqueue_add_split() support premapped
> > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > >   virtio_ring: add api virtio_dma_map() for advance dma
> > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > >   virtio_net: xdp xmit use virtio dma api
> > >
> > >  drivers/net/virtio_net.c     |  42 +++++-
> > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > >  include/linux/virtio.h       |  12 ++
> > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > >
> > > --
> > > 2.31.0
> >
>
Jason Wang March 30, 2022, 8:38 a.m. UTC | #4
On Wed, Mar 30, 2022 at 2:59 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
>
> On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > >
> > > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > > virtqueue_add().
> > > >
> > > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > > it is necessary for us to support passing the DMA address to virtqueue_add().
> > >
> > > I picked up a couple of patches. Others are waiting for some acks
> > > (Jason?) and improved commit logs for documentation.
> >
> > I will review them.
>
> hi, the core code of premapped, I will merge it into 'virtio pci support
> VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
> after resize.

I still prefer not to do that.

We can make rest work for resize first and add pre mapping on top. It
will simplify the review.

Thanks

>
> Thanks.
>
>
> >
> > Thanks
> >
> > >
> > > Thanks!
> > >
> > > > v2:
> > > >     1. rename predma -> premapped
> > > >     2. virtio net xdp tx use virtio dma api
> > > >
> > > > v1:
> > > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > > >       of them are not supported to be PREDMA
> > > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > > >       together with the next time AF_XDP supports virtio dma
> > > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > > >       indirect desc
> > > >
> > > > Xuan Zhuo (9):
> > > >   virtio_ring: rename vring_unmap_state_packed() to
> > > >     vring_unmap_extra_packed()
> > > >   virtio_ring: remove flags check for unmap split indirect desc
> > > >   virtio_ring: remove flags check for unmap packed indirect desc
> > > >   virtio_ring: virtqueue_add() support premapped
> > > >   virtio_ring: split: virtqueue_add_split() support premapped
> > > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > > >   virtio_ring: add api virtio_dma_map() for advance dma
> > > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > > >   virtio_net: xdp xmit use virtio dma api
> > > >
> > > >  drivers/net/virtio_net.c     |  42 +++++-
> > > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > > >  include/linux/virtio.h       |  12 ++
> > > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > > >
> > > > --
> > > > 2.31.0
> > >
> >
>
Xuan Zhuo March 30, 2022, 9:03 a.m. UTC | #5
On Wed, 30 Mar 2022 16:38:18 +0800, Jason Wang <jasowang@redhat.com> wrote:
> On Wed, Mar 30, 2022 at 2:59 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> >
> > On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > >
> > > > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > > > virtqueue_add().
> > > > >
> > > > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > > > it is necessary for us to support passing the DMA address to virtqueue_add().
> > > >
> > > > I picked up a couple of patches. Others are waiting for some acks
> > > > (Jason?) and improved commit logs for documentation.
> > >
> > > I will review them.
> >
> > hi, the core code of premapped, I will merge it into 'virtio pci support
> > VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
> > after resize.
>
> I still prefer not to do that.
>
> We can make rest work for resize first and add pre mapping on top. It
> will simplify the review.

Yes, I am also worried about the review problem, the number of my local resize
patch has reached 44 (including reuse bufs).

hi, Michael, can we implement resize on top of v8 first? (drop unused bufs directly)

Then we implement premmapd and reuse the bufs after resize.

We need to get the address (DMA address) and len from the reset ring and submit
it to the new vq through virtqueue_add(). So let virtqueue_add() support
premapped first.

Thanks.


>
> Thanks
>
> >
> > Thanks.
> >
> >
> > >
> > > Thanks
> > >
> > > >
> > > > Thanks!
> > > >
> > > > > v2:
> > > > >     1. rename predma -> premapped
> > > > >     2. virtio net xdp tx use virtio dma api
> > > > >
> > > > > v1:
> > > > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > > > >       of them are not supported to be PREDMA
> > > > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > > > >       together with the next time AF_XDP supports virtio dma
> > > > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > > > >       indirect desc
> > > > >
> > > > > Xuan Zhuo (9):
> > > > >   virtio_ring: rename vring_unmap_state_packed() to
> > > > >     vring_unmap_extra_packed()
> > > > >   virtio_ring: remove flags check for unmap split indirect desc
> > > > >   virtio_ring: remove flags check for unmap packed indirect desc
> > > > >   virtio_ring: virtqueue_add() support premapped
> > > > >   virtio_ring: split: virtqueue_add_split() support premapped
> > > > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > > > >   virtio_ring: add api virtio_dma_map() for advance dma
> > > > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > > > >   virtio_net: xdp xmit use virtio dma api
> > > > >
> > > > >  drivers/net/virtio_net.c     |  42 +++++-
> > > > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > > > >  include/linux/virtio.h       |  12 ++
> > > > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > > > >
> > > > > --
> > > > > 2.31.0
> > > >
> > >
> >
>
Michael S. Tsirkin March 30, 2022, 10:51 a.m. UTC | #6
On Wed, Mar 30, 2022 at 05:03:32PM +0800, Xuan Zhuo wrote:
> On Wed, 30 Mar 2022 16:38:18 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > On Wed, Mar 30, 2022 at 2:59 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> > >
> > > On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > > On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > > >
> > > > > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > > > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > > > > virtqueue_add().
> > > > > >
> > > > > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > > > > it is necessary for us to support passing the DMA address to virtqueue_add().
> > > > >
> > > > > I picked up a couple of patches. Others are waiting for some acks
> > > > > (Jason?) and improved commit logs for documentation.
> > > >
> > > > I will review them.
> > >
> > > hi, the core code of premapped, I will merge it into 'virtio pci support
> > > VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
> > > after resize.
> >
> > I still prefer not to do that.
> >
> > We can make rest work for resize first and add pre mapping on top. It
> > will simplify the review.
> 
> Yes, I am also worried about the review problem, the number of my local resize
> patch has reached 44 (including reuse bufs).
> 
> hi, Michael, can we implement resize on top of v8 first? (drop unused bufs directly)
> 
> Then we implement premmapd and reuse the bufs after resize.
> 
> We need to get the address (DMA address) and len from the reset ring and submit
> it to the new vq through virtqueue_add(). So let virtqueue_add() support
> premapped first.
> 
> Thanks.

Not sure I understand.
So the plan is
- remap
- resize on top
?



> 
> >
> > Thanks
> >
> > >
> > > Thanks.
> > >
> > >
> > > >
> > > > Thanks
> > > >
> > > > >
> > > > > Thanks!
> > > > >
> > > > > > v2:
> > > > > >     1. rename predma -> premapped
> > > > > >     2. virtio net xdp tx use virtio dma api
> > > > > >
> > > > > > v1:
> > > > > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > > > > >       of them are not supported to be PREDMA
> > > > > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > > > > >       together with the next time AF_XDP supports virtio dma
> > > > > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > > > > >       indirect desc
> > > > > >
> > > > > > Xuan Zhuo (9):
> > > > > >   virtio_ring: rename vring_unmap_state_packed() to
> > > > > >     vring_unmap_extra_packed()
> > > > > >   virtio_ring: remove flags check for unmap split indirect desc
> > > > > >   virtio_ring: remove flags check for unmap packed indirect desc
> > > > > >   virtio_ring: virtqueue_add() support premapped
> > > > > >   virtio_ring: split: virtqueue_add_split() support premapped
> > > > > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > > > > >   virtio_ring: add api virtio_dma_map() for advance dma
> > > > > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > > > > >   virtio_net: xdp xmit use virtio dma api
> > > > > >
> > > > > >  drivers/net/virtio_net.c     |  42 +++++-
> > > > > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > > > > >  include/linux/virtio.h       |  12 ++
> > > > > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > > > > >
> > > > > > --
> > > > > > 2.31.0
> > > > >
> > > >
> > >
> >
Xuan Zhuo March 30, 2022, 10:51 a.m. UTC | #7
On Wed, 30 Mar 2022 06:51:03 -0400, "Michael S. Tsirkin" <mst@redhat.com> wrote:
> On Wed, Mar 30, 2022 at 05:03:32PM +0800, Xuan Zhuo wrote:
> > On Wed, 30 Mar 2022 16:38:18 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > On Wed, Mar 30, 2022 at 2:59 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> > > >
> > > > On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > > > On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > > > >
> > > > > > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > > > > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > > > > > virtqueue_add().
> > > > > > >
> > > > > > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > > > > > it is necessary for us to support passing the DMA address to virtqueue_add().
> > > > > >
> > > > > > I picked up a couple of patches. Others are waiting for some acks
> > > > > > (Jason?) and improved commit logs for documentation.
> > > > >
> > > > > I will review them.
> > > >
> > > > hi, the core code of premapped, I will merge it into 'virtio pci support
> > > > VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
> > > > after resize.
> > >
> > > I still prefer not to do that.
> > >
> > > We can make rest work for resize first and add pre mapping on top. It
> > > will simplify the review.
> >
> > Yes, I am also worried about the review problem, the number of my local resize
> > patch has reached 44 (including reuse bufs).
> >
> > hi, Michael, can we implement resize on top of v8 first? (drop unused bufs directly)
> >
> > Then we implement premmapd and reuse the bufs after resize.
> >
> > We need to get the address (DMA address) and len from the reset ring and submit
> > it to the new vq through virtqueue_add(). So let virtqueue_add() support
> > premapped first.
> >
> > Thanks.
>
> Not sure I understand.
> So the plan is
> - remap
> - resize on top
> ?

#1 resize with drop unused bufs directly
#2 premapped and resize support reuse the unused bufs

This way "premaped" will have a user.

Between #1 and #2, I may submit some code with optimized formatting, because
jason doesn't like my introduction of struct vring_split and struct vring_packed
in #1 for passing parameters between extracted functions.

Thanks.


>
>
>
> >
> > >
> > > Thanks
> > >
> > > >
> > > > Thanks.
> > > >
> > > >
> > > > >
> > > > > Thanks
> > > > >
> > > > > >
> > > > > > Thanks!
> > > > > >
> > > > > > > v2:
> > > > > > >     1. rename predma -> premapped
> > > > > > >     2. virtio net xdp tx use virtio dma api
> > > > > > >
> > > > > > > v1:
> > > > > > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > > > > > >       of them are not supported to be PREDMA
> > > > > > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > > > > > >       together with the next time AF_XDP supports virtio dma
> > > > > > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > > > > > >       indirect desc
> > > > > > >
> > > > > > > Xuan Zhuo (9):
> > > > > > >   virtio_ring: rename vring_unmap_state_packed() to
> > > > > > >     vring_unmap_extra_packed()
> > > > > > >   virtio_ring: remove flags check for unmap split indirect desc
> > > > > > >   virtio_ring: remove flags check for unmap packed indirect desc
> > > > > > >   virtio_ring: virtqueue_add() support premapped
> > > > > > >   virtio_ring: split: virtqueue_add_split() support premapped
> > > > > > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > > > > > >   virtio_ring: add api virtio_dma_map() for advance dma
> > > > > > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > > > > > >   virtio_net: xdp xmit use virtio dma api
> > > > > > >
> > > > > > >  drivers/net/virtio_net.c     |  42 +++++-
> > > > > > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > > > > > >  include/linux/virtio.h       |  12 ++
> > > > > > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > > > > > >
> > > > > > > --
> > > > > > > 2.31.0
> > > > > >
> > > > >
> > > >
> > >
>
Michael S. Tsirkin March 30, 2022, 10:58 a.m. UTC | #8
On Wed, Mar 30, 2022 at 06:51:53PM +0800, Xuan Zhuo wrote:
> On Wed, 30 Mar 2022 06:51:03 -0400, "Michael S. Tsirkin" <mst@redhat.com> wrote:
> > On Wed, Mar 30, 2022 at 05:03:32PM +0800, Xuan Zhuo wrote:
> > > On Wed, 30 Mar 2022 16:38:18 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > > On Wed, Mar 30, 2022 at 2:59 PM Xuan Zhuo <xuanzhuo@linux.alibaba.com> wrote:
> > > > >
> > > > > On Wed, 30 Mar 2022 14:56:17 +0800, Jason Wang <jasowang@redhat.com> wrote:
> > > > > > On Wed, Mar 30, 2022 at 2:34 PM Michael S. Tsirkin <mst@redhat.com> wrote:
> > > > > > >
> > > > > > > On Thu, Feb 24, 2022 at 07:03:53PM +0800, Xuan Zhuo wrote:
> > > > > > > > virtqueue_add() only supports virtual addresses, dma is completed in
> > > > > > > > virtqueue_add().
> > > > > > > >
> > > > > > > > In some scenarios (such as the AF_XDP scenario), DMA is completed in advance, so
> > > > > > > > it is necessary for us to support passing the DMA address to virtqueue_add().
> > > > > > >
> > > > > > > I picked up a couple of patches. Others are waiting for some acks
> > > > > > > (Jason?) and improved commit logs for documentation.
> > > > > >
> > > > > > I will review them.
> > > > >
> > > > > hi, the core code of premapped, I will merge it into 'virtio pci support
> > > > > VIRTIO_F_RING_RESET' because this function will be used when reusing the buffer
> > > > > after resize.
> > > >
> > > > I still prefer not to do that.
> > > >
> > > > We can make rest work for resize first and add pre mapping on top. It
> > > > will simplify the review.
> > >
> > > Yes, I am also worried about the review problem, the number of my local resize
> > > patch has reached 44 (including reuse bufs).
> > >
> > > hi, Michael, can we implement resize on top of v8 first? (drop unused bufs directly)
> > >
> > > Then we implement premmapd and reuse the bufs after resize.
> > >
> > > We need to get the address (DMA address) and len from the reset ring and submit
> > > it to the new vq through virtqueue_add(). So let virtqueue_add() support
> > > premapped first.
> > >
> > > Thanks.
> >
> > Not sure I understand.
> > So the plan is
> > - remap
> > - resize on top
> > ?
> 
> #1 resize with drop unused bufs directly
> #2 premapped and resize support reuse the unused bufs
> 
> This way "premaped" will have a user.
> 
> Between #1 and #2, I may submit some code with optimized formatting, because
> jason doesn't like my introduction of struct vring_split and struct vring_packed
> in #1 for passing parameters between extracted functions.
> 
> Thanks.

So let's start with 1. Direct drop for now is ok.


> 
> >
> >
> >
> > >
> > > >
> > > > Thanks
> > > >
> > > > >
> > > > > Thanks.
> > > > >
> > > > >
> > > > > >
> > > > > > Thanks
> > > > > >
> > > > > > >
> > > > > > > Thanks!
> > > > > > >
> > > > > > > > v2:
> > > > > > > >     1. rename predma -> premapped
> > > > > > > >     2. virtio net xdp tx use virtio dma api
> > > > > > > >
> > > > > > > > v1:
> > > > > > > >    1. All sgs requested at one time are required to be unified PREDMA, and several
> > > > > > > >       of them are not supported to be PREDMA
> > > > > > > >    2. virtio_dma_map() is removed from this patch set and will be submitted
> > > > > > > >       together with the next time AF_XDP supports virtio dma
> > > > > > > >    3. Added patch #2 #3 to remove the check for flags when performing unmap
> > > > > > > >       indirect desc
> > > > > > > >
> > > > > > > > Xuan Zhuo (9):
> > > > > > > >   virtio_ring: rename vring_unmap_state_packed() to
> > > > > > > >     vring_unmap_extra_packed()
> > > > > > > >   virtio_ring: remove flags check for unmap split indirect desc
> > > > > > > >   virtio_ring: remove flags check for unmap packed indirect desc
> > > > > > > >   virtio_ring: virtqueue_add() support premapped
> > > > > > > >   virtio_ring: split: virtqueue_add_split() support premapped
> > > > > > > >   virtio_ring: packed: virtqueue_add_packed() support premapped
> > > > > > > >   virtio_ring: add api virtio_dma_map() for advance dma
> > > > > > > >   virtio_ring: introduce virtqueue_add_outbuf_premapped()
> > > > > > > >   virtio_net: xdp xmit use virtio dma api
> > > > > > > >
> > > > > > > >  drivers/net/virtio_net.c     |  42 +++++-
> > > > > > > >  drivers/virtio/virtio_ring.c | 280 ++++++++++++++++++++++++++---------
> > > > > > > >  include/linux/virtio.h       |  12 ++
> > > > > > > >  3 files changed, 254 insertions(+), 80 deletions(-)
> > > > > > > >
> > > > > > > > --
> > > > > > > > 2.31.0
> > > > > > >
> > > > > >
> > > > >
> > > >
> >