Commit 6e52fc44 authored by Jason Wang's avatar Jason Wang Committed by Michael S. Tsirkin

virtio-pci-modern: introduce helper for getting queue nums

This patch introduces helper for getting queue num of modern device.
Signed-off-by: default avatarJason Wang <jasowang@redhat.com>
Link: https://lore.kernel.org/r/20210104065503.199631-14-jasowang@redhat.comSigned-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 75658afb
...@@ -292,6 +292,17 @@ static u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev, ...@@ -292,6 +292,17 @@ static u16 vp_modern_get_queue_size(struct virtio_pci_modern_device *mdev,
} }
/*
* vp_modern_get_num_queues - get the number of virtqueues
* @mdev: the modern virtio-pci device
*
* Returns the number of virtqueues
*/
static u16 vp_modern_get_num_queues(struct virtio_pci_modern_device *mdev)
{
return vp_ioread16(&mdev->common->num_queues);
}
/* virtio config->finalize_features() implementation */ /* virtio config->finalize_features() implementation */
static int vp_finalize_features(struct virtio_device *vdev) static int vp_finalize_features(struct virtio_device *vdev)
{ {
...@@ -510,7 +521,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev, ...@@ -510,7 +521,7 @@ static struct virtqueue *setup_vq(struct virtio_pci_device *vp_dev,
u16 num, off; u16 num, off;
int err; int err;
if (index >= vp_ioread16(&cfg->num_queues)) if (index >= vp_modern_get_num_queues(mdev))
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
/* Select the queue we're interested in */ /* Select the queue we're interested in */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment