diff mbox series

[[RFC,v3,12/12] virtio: feature vhost-net support for packed ring

Message ID 1539266915-15216-13-git-send-email-wexu@redhat.com (mailing list archive)
State New, archived
Headers show
Series packed ring virtio-net userspace backend support | expand

Commit Message

Wei Xu Oct. 11, 2018, 2:08 p.m. UTC
From: Wei Xu <wexu@redhat.com>

(cherry picked from commit 305a2c4640c15c5717245067ab937fd10f478ee6)
Signed-off-by: Wei Xu <wexu@redhat.com>
(cherry picked from commit 46476dae6f44c6fef8802a4a0ac7d0d79fe399e3)
Signed-off-by: Wei Xu <wexu@redhat.com>
---
 hw/virtio/vhost.c          | 3 +++
 hw/virtio/virtio.c         | 4 ++++
 include/hw/virtio/virtio.h | 1 +
 3 files changed, 8 insertions(+)

Comments

Jason Wang Oct. 15, 2018, 7:50 a.m. UTC | #1
On 2018年10月11日 22:08, wexu@redhat.com wrote:
> From: Wei Xu <wexu@redhat.com>
>
> (cherry picked from commit 305a2c4640c15c5717245067ab937fd10f478ee6)
> Signed-off-by: Wei Xu <wexu@redhat.com>
> (cherry picked from commit 46476dae6f44c6fef8802a4a0ac7d0d79fe399e3)
> Signed-off-by: Wei Xu <wexu@redhat.com>

The cherry-pick tag looks odd.

> ---
>   hw/virtio/vhost.c          | 3 +++
>   hw/virtio/virtio.c         | 4 ++++
>   include/hw/virtio/virtio.h | 1 +
>   3 files changed, 8 insertions(+)
>
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 9df2da3..de06d55 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -974,6 +974,9 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
>       }
>   
>       state.num = virtio_queue_get_last_avail_idx(vdev, idx);
> +    if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> +        state.num |= ((int)virtio_queue_packed_get_wc(vdev, idx)) << 31;
> +    }

We decide to use bit 15 instead.

And please refer the recent discussion for the agreement.

Thanks

>       r = dev->vhost_ops->vhost_set_vring_base(dev, &state);
>       if (r) {
>           VHOST_OPS_DEBUG("vhost_set_vring_base failed");
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index 1d25776..2a90163 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -2894,6 +2894,10 @@ void virtio_init(VirtIODevice *vdev, const char *name,
>       vdev->use_guest_notifier_mask = true;
>   }
>   
> +bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n)
> +{
> +    return vdev->vq[n].avail_wrap_counter;
> +}
>   hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
>   {
>       return vdev->vq[n].vring.desc;
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 9af8839..0bb3be5 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -295,6 +295,7 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
>                                                   VirtIOHandleAIOOutput handle_output);
>   VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
>   VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
> +bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n);
>   
>   static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)
>   {
Wei Xu Oct. 15, 2018, 8:11 a.m. UTC | #2
On Mon, Oct 15, 2018 at 03:50:21PM +0800, Jason Wang wrote:
> 
> 
> On 2018年10月11日 22:08, wexu@redhat.com wrote:
> >From: Wei Xu <wexu@redhat.com>
> >
> >(cherry picked from commit 305a2c4640c15c5717245067ab937fd10f478ee6)
> >Signed-off-by: Wei Xu <wexu@redhat.com>
> >(cherry picked from commit 46476dae6f44c6fef8802a4a0ac7d0d79fe399e3)
> >Signed-off-by: Wei Xu <wexu@redhat.com>
> 
> The cherry-pick tag looks odd.

My bad.

> 
> >---
> >  hw/virtio/vhost.c          | 3 +++
> >  hw/virtio/virtio.c         | 4 ++++
> >  include/hw/virtio/virtio.h | 1 +
> >  3 files changed, 8 insertions(+)
> >
> >diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> >index 9df2da3..de06d55 100644
> >--- a/hw/virtio/vhost.c
> >+++ b/hw/virtio/vhost.c
> >@@ -974,6 +974,9 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
> >      }
> >      state.num = virtio_queue_get_last_avail_idx(vdev, idx);
> >+    if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> >+        state.num |= ((int)virtio_queue_packed_get_wc(vdev, idx)) << 31;
> >+    }
> 
> We decide to use bit 15 instead.
> 
> And please refer the recent discussion for the agreement.

OK.

> 
> Thanks
> 
> >      r = dev->vhost_ops->vhost_set_vring_base(dev, &state);
> >      if (r) {
> >          VHOST_OPS_DEBUG("vhost_set_vring_base failed");
> >diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> >index 1d25776..2a90163 100644
> >--- a/hw/virtio/virtio.c
> >+++ b/hw/virtio/virtio.c
> >@@ -2894,6 +2894,10 @@ void virtio_init(VirtIODevice *vdev, const char *name,
> >      vdev->use_guest_notifier_mask = true;
> >  }
> >+bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n)
> >+{
> >+    return vdev->vq[n].avail_wrap_counter;
> >+}
> >  hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
> >  {
> >      return vdev->vq[n].vring.desc;
> >diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> >index 9af8839..0bb3be5 100644
> >--- a/include/hw/virtio/virtio.h
> >+++ b/include/hw/virtio/virtio.h
> >@@ -295,6 +295,7 @@ void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
> >                                                  VirtIOHandleAIOOutput handle_output);
> >  VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
> >  VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
> >+bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n);
> >  static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)
> >  {
> 
>
Maxime Coquelin Nov. 21, 2018, 1:03 p.m. UTC | #3
Hi Wei,

On 10/11/18 4:08 PM, wexu@redhat.com wrote:
> From: Wei Xu <wexu@redhat.com>
> 
> (cherry picked from commit 305a2c4640c15c5717245067ab937fd10f478ee6)
> Signed-off-by: Wei Xu <wexu@redhat.com>
> (cherry picked from commit 46476dae6f44c6fef8802a4a0ac7d0d79fe399e3)
> Signed-off-by: Wei Xu <wexu@redhat.com>
> ---
>   hw/virtio/vhost.c          | 3 +++
>   hw/virtio/virtio.c         | 4 ++++
>   include/hw/virtio/virtio.h | 1 +
>   3 files changed, 8 insertions(+)
> 
> diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> index 9df2da3..de06d55 100644
> --- a/hw/virtio/vhost.c
> +++ b/hw/virtio/vhost.c
> @@ -974,6 +974,9 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
>       }
>   
>       state.num = virtio_queue_get_last_avail_idx(vdev, idx);
> +    if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> +        state.num |= ((int)virtio_queue_packed_get_wc(vdev, idx)) << 31;

For next version, please note that we agreed to move the wrap counter
value at bit 15. DPDK vhost lib implemented it that way.
Wei Xu Nov. 22, 2018, 3:46 a.m. UTC | #4
On Wed, Nov 21, 2018 at 02:03:59PM +0100, Maxime Coquelin wrote:
> Hi Wei,
> 
> On 10/11/18 4:08 PM, wexu@redhat.com wrote:
> >From: Wei Xu <wexu@redhat.com>
> >
> >(cherry picked from commit 305a2c4640c15c5717245067ab937fd10f478ee6)
> >Signed-off-by: Wei Xu <wexu@redhat.com>
> >(cherry picked from commit 46476dae6f44c6fef8802a4a0ac7d0d79fe399e3)
> >Signed-off-by: Wei Xu <wexu@redhat.com>
> >---
> >  hw/virtio/vhost.c          | 3 +++
> >  hw/virtio/virtio.c         | 4 ++++
> >  include/hw/virtio/virtio.h | 1 +
> >  3 files changed, 8 insertions(+)
> >
> >diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
> >index 9df2da3..de06d55 100644
> >--- a/hw/virtio/vhost.c
> >+++ b/hw/virtio/vhost.c
> >@@ -974,6 +974,9 @@ static int vhost_virtqueue_start(struct vhost_dev *dev,
> >      }
> >      state.num = virtio_queue_get_last_avail_idx(vdev, idx);
> >+    if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
> >+        state.num |= ((int)virtio_queue_packed_get_wc(vdev, idx)) << 31;
> 
> For next version, please note that we agreed to move the wrap counter
> value at bit 15. DPDK vhost lib implemented it that way.

Yes, I have revised it in my next version, thanks for remindering.

>
diff mbox series

Patch

diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 9df2da3..de06d55 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -974,6 +974,9 @@  static int vhost_virtqueue_start(struct vhost_dev *dev,
     }
 
     state.num = virtio_queue_get_last_avail_idx(vdev, idx);
+    if (virtio_vdev_has_feature(vdev, VIRTIO_F_RING_PACKED)) {
+        state.num |= ((int)virtio_queue_packed_get_wc(vdev, idx)) << 31;
+    }
     r = dev->vhost_ops->vhost_set_vring_base(dev, &state);
     if (r) {
         VHOST_OPS_DEBUG("vhost_set_vring_base failed");
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 1d25776..2a90163 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -2894,6 +2894,10 @@  void virtio_init(VirtIODevice *vdev, const char *name,
     vdev->use_guest_notifier_mask = true;
 }
 
+bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n)
+{
+    return vdev->vq[n].avail_wrap_counter;
+}
 hwaddr virtio_queue_get_desc_addr(VirtIODevice *vdev, int n)
 {
     return vdev->vq[n].vring.desc;
diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 9af8839..0bb3be5 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -295,6 +295,7 @@  void virtio_queue_aio_set_host_notifier_handler(VirtQueue *vq, AioContext *ctx,
                                                 VirtIOHandleAIOOutput handle_output);
 VirtQueue *virtio_vector_first_queue(VirtIODevice *vdev, uint16_t vector);
 VirtQueue *virtio_vector_next_queue(VirtQueue *vq);
+bool virtio_queue_packed_get_wc(VirtIODevice *vdev, int n);
 
 static inline void virtio_add_feature(uint64_t *features, unsigned int fbit)
 {