diff mbox series

[RFC,03/10] virtio: Add virtio_queue_get_idx

Message ID 20210129205415.876290-4-eperezma@redhat.com (mailing list archive)
State New, archived
Headers show
Series vDPA shadow virtqueue - notifications forwarding | expand

Commit Message

Eugenio Perez Martin Jan. 29, 2021, 8:54 p.m. UTC
Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 include/hw/virtio/virtio.h | 2 ++
 hw/virtio/virtio.c         | 5 +++++
 2 files changed, 7 insertions(+)

Comments

Jason Wang Feb. 1, 2021, 6:10 a.m. UTC | #1
On 2021/1/30 上午4:54, Eugenio Pérez wrote:
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>   include/hw/virtio/virtio.h | 2 ++
>   hw/virtio/virtio.c         | 5 +++++
>   2 files changed, 7 insertions(+)
>
> diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> index 9988c6d5c9..9013c03424 100644
> --- a/include/hw/virtio/virtio.h
> +++ b/include/hw/virtio/virtio.h
> @@ -399,6 +399,8 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev)
>       return unlikely(vdev->disabled || vdev->broken);
>   }
>   
> +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq);
> +
>   bool virtio_legacy_allowed(VirtIODevice *vdev);
>   bool virtio_legacy_check_disabled(VirtIODevice *vdev);
>   
> diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> index ebb780fb42..3d14b0ef74 100644
> --- a/hw/virtio/virtio.c
> +++ b/hw/virtio/virtio.c
> @@ -500,6 +500,11 @@ void virtio_queue_set_notification(VirtQueue *vq, int enable)
>       }
>   }
>   
> +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq)
> +{
> +    return vq - vdev->vq;
> +}


It looks to me we had a dedicated index stored in VirtQueue: 
vq->queue_index.

Thanks


> +
>   int virtio_queue_ready(VirtQueue *vq)
>   {
>       return vq->vring.avail != 0;
Eugenio Perez Martin Feb. 1, 2021, 7:20 a.m. UTC | #2
On Mon, Feb 1, 2021 at 7:10 AM Jason Wang <jasowang@redhat.com> wrote:
>
>
> On 2021/1/30 上午4:54, Eugenio Pérez wrote:
> > Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> > ---
> >   include/hw/virtio/virtio.h | 2 ++
> >   hw/virtio/virtio.c         | 5 +++++
> >   2 files changed, 7 insertions(+)
> >
> > diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
> > index 9988c6d5c9..9013c03424 100644
> > --- a/include/hw/virtio/virtio.h
> > +++ b/include/hw/virtio/virtio.h
> > @@ -399,6 +399,8 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev)
> >       return unlikely(vdev->disabled || vdev->broken);
> >   }
> >
> > +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq);
> > +
> >   bool virtio_legacy_allowed(VirtIODevice *vdev);
> >   bool virtio_legacy_check_disabled(VirtIODevice *vdev);
> >
> > diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
> > index ebb780fb42..3d14b0ef74 100644
> > --- a/hw/virtio/virtio.c
> > +++ b/hw/virtio/virtio.c
> > @@ -500,6 +500,11 @@ void virtio_queue_set_notification(VirtQueue *vq, int enable)
> >       }
> >   }
> >
> > +unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq)
> > +{
> > +    return vq - vdev->vq;
> > +}
>
>
> It looks to me we had a dedicated index stored in VirtQueue:
> vq->queue_index.
>

You are right, I don't know why but missed it! It will be used in the
next series.

Thanks!

> Thanks
>
>
> > +
> >   int virtio_queue_ready(VirtQueue *vq)
> >   {
> >       return vq->vring.avail != 0;
>
diff mbox series

Patch

diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h
index 9988c6d5c9..9013c03424 100644
--- a/include/hw/virtio/virtio.h
+++ b/include/hw/virtio/virtio.h
@@ -399,6 +399,8 @@  static inline bool virtio_device_disabled(VirtIODevice *vdev)
     return unlikely(vdev->disabled || vdev->broken);
 }
 
+unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq);
+
 bool virtio_legacy_allowed(VirtIODevice *vdev);
 bool virtio_legacy_check_disabled(VirtIODevice *vdev);
 
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index ebb780fb42..3d14b0ef74 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -500,6 +500,11 @@  void virtio_queue_set_notification(VirtQueue *vq, int enable)
     }
 }
 
+unsigned virtio_queue_get_idx(const VirtIODevice *vdev, const VirtQueue *vq)
+{
+    return vq - vdev->vq;
+}
+
 int virtio_queue_ready(VirtQueue *vq)
 {
     return vq->vring.avail != 0;