diff mbox

[dpdk-dev] vhost: fix dequeue zero copy not work with virtio1

Message ID 1513183856-5639-1-git-send-email-junjie.j.chen@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Yuanhan Liu
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

junjie.j.chen@intel.com Dec. 13, 2017, 4:50 p.m. UTC
This fix dequeue zero copy can not work with Qemu
version >= 2.7. Since from Qemu 2.7 virtio device
use virtio-1 protocol, the zero copy code path
forget to add offset to buffer address.

Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
---
 lib/librte_vhost/virtio_net.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Maxime Coquelin Dec. 13, 2017, 11:12 a.m. UTC | #1
Hi Junjie,

On 12/13/2017 05:50 PM, Junjie Chen wrote:
> This fix dequeue zero copy can not work with Qemu
> version >= 2.7. Since from Qemu 2.7 virtio device
> use virtio-1 protocol, the zero copy code path
> forget to add offset to buffer address.
> 
> Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
> ---
>   lib/librte_vhost/virtio_net.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 6fee16e..79d80f7 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -977,7 +977,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
>   					desc->addr + desc_offset, cpy_len)))) {
>   			cur->data_len = cpy_len;
>   			cur->data_off = 0;
> -			cur->buf_addr = (void *)(uintptr_t)desc_addr;
> +			cur->buf_addr = (void *)(uintptr_t)(desc_addr
> +				+ desc_offset);
>   			cur->buf_iova = hpa;
>   
>   			/*
> 

Thanks for fixing this.

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Maxime
Loftus, Ciara Dec. 15, 2017, 10:33 a.m. UTC | #2
> 

> Hi Junjie,

> 

> On 12/13/2017 05:50 PM, Junjie Chen wrote:

> > This fix dequeue zero copy can not work with Qemu

> > version >= 2.7. Since from Qemu 2.7 virtio device

> > use virtio-1 protocol, the zero copy code path

> > forget to add offset to buffer address.

> >

> > Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>

> > ---

> >   lib/librte_vhost/virtio_net.c | 3 ++-

> >   1 file changed, 2 insertions(+), 1 deletion(-)

> >

> > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c

> > index 6fee16e..79d80f7 100644

> > --- a/lib/librte_vhost/virtio_net.c

> > +++ b/lib/librte_vhost/virtio_net.c

> > @@ -977,7 +977,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct

> vhost_virtqueue *vq,

> >   					desc->addr + desc_offset,

> cpy_len)))) {

> >   			cur->data_len = cpy_len;

> >   			cur->data_off = 0;

> > -			cur->buf_addr = (void *)(uintptr_t)desc_addr;

> > +			cur->buf_addr = (void *)(uintptr_t)(desc_addr

> > +				+ desc_offset);

> >   			cur->buf_iova = hpa;

> >

> >   			/*

> >

> 

> Thanks for fixing this.

> 

> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

> 

> Maxime


Thanks for the fix. Can this be considered for the stable branch?

Thanks,
Ciara
Yuanhan Liu Dec. 15, 2017, 12:48 p.m. UTC | #3
On Fri, Dec 15, 2017 at 10:33:41AM +0000, Loftus, Ciara wrote:
> > 
> > Hi Junjie,
> > 
> > On 12/13/2017 05:50 PM, Junjie Chen wrote:
> > > This fix dequeue zero copy can not work with Qemu
> > > version >= 2.7. Since from Qemu 2.7 virtio device
> > > use virtio-1 protocol, the zero copy code path
> > > forget to add offset to buffer address.
> > >
> > > Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
> > > ---
> > >   lib/librte_vhost/virtio_net.c | 3 ++-
> > >   1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> > > index 6fee16e..79d80f7 100644
> > > --- a/lib/librte_vhost/virtio_net.c
> > > +++ b/lib/librte_vhost/virtio_net.c
> > > @@ -977,7 +977,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct
> > vhost_virtqueue *vq,
> > >   					desc->addr + desc_offset,
> > cpy_len)))) {
> > >   			cur->data_len = cpy_len;
> > >   			cur->data_off = 0;
> > > -			cur->buf_addr = (void *)(uintptr_t)desc_addr;
> > > +			cur->buf_addr = (void *)(uintptr_t)(desc_addr
> > > +				+ desc_offset);
> > >   			cur->buf_iova = hpa;
> > >
> > >   			/*
> > >
> > 
> > Thanks for fixing this.
> > 
> > Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> > 
> > Maxime
> 
> Thanks for the fix. Can this be considered for the stable branch?

Yes, I think so. Applied to dpdk-next-virtio, with

Fixes: b0a985d1f340 ("vhost: add dequeue zero copy")
Cc: stable@dpdk.org

Thanks.

	--yliu
Bing Zhao Dec. 20, 2017, 5:58 a.m. UTC | #4
On 2017/12/15 20:48, Yuanhan Liu wrote:
> On Fri, Dec 15, 2017 at 10:33:41AM +0000, Loftus, Ciara wrote:
> >>
> >> Hi Junjie,
> >>
> >> On 12/13/2017 05:50 PM, Junjie Chen wrote:
> >>> This fix dequeue zero copy can not work with Qemu
> >>> version >= 2.7. Since from Qemu 2.7 virtio device
> >>> use virtio-1 protocol, the zero copy code path
> >>> forget to add offset to buffer address.
> >>>
> >>> Signed-off-by: Junjie Chen <junjie.j.chen@intel.com>
> >>> ---
> >>>    lib/librte_vhost/virtio_net.c | 3 ++-
> >>>    1 file changed, 2 insertions(+), 1 deletion(-)
> >>>
> >>> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> >>> index 6fee16e..79d80f7 100644
> >>> --- a/lib/librte_vhost/virtio_net.c
> >>> +++ b/lib/librte_vhost/virtio_net.c
> >>> @@ -977,7 +977,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct
> >> vhost_virtqueue *vq,
> >>>                        desc->addr + desc_offset,
> >> cpy_len)))) {
> >>>                cur->data_len = cpy_len;
> >>>                cur->data_off = 0;
> >>> -            cur->buf_addr = (void *)(uintptr_t)desc_addr;
> >>> +            cur->buf_addr = (void *)(uintptr_t)(desc_addr
> >>> +                + desc_offset);
> >>>                cur->buf_iova = hpa;
> >>>
> >>>                /*
> >>>
> >>
> >> Thanks for fixing this.
> >>
> >> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> >>
> >> Maxime
> >
> > Thanks for the fix. Can this be considered for the stable branch?
>
> Yes, I think so. Applied to dpdk-next-virtio, with
>
> Fixes: b0a985d1f340 ("vhost: add dequeue zero copy")
> Cc: stable@dpdk.org
>
> Thanks.
>
>     --yliu
>
@Yuanhan & Maxime, sorry to interrupt here. I meet the same issue recently. Could the "cur->data_off" field be used here with the value "desc_offset"? (I don't go through all the code and am a little confused about the "0". Is there any detail description about the "data_off" field?)
Thanks
diff mbox

Patch

diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 6fee16e..79d80f7 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -977,7 +977,8 @@  copy_desc_to_mbuf(struct virtio_net *dev, struct vhost_virtqueue *vq,
 					desc->addr + desc_offset, cpy_len)))) {
 			cur->data_len = cpy_len;
 			cur->data_off = 0;
-			cur->buf_addr = (void *)(uintptr_t)desc_addr;
+			cur->buf_addr = (void *)(uintptr_t)(desc_addr
+				+ desc_offset);
 			cur->buf_iova = hpa;
 
 			/*