Commit b8b4e1a0 authored by Jiri Pirko's avatar Jiri Pirko Committed by Michael S. Tsirkin

virtio_pci: pass vector policy enum to vp_find_one_vq_msix()

Instead of accessing vp_dev->per_vq_vectors, pass vector policy enum
as an argument of vp_find_one_vq_msix() in preparation for another irq
allocation policy.
Signed-off-by: default avatarJiri Pirko <jiri@nvidia.com>
Message-Id: <20240716113552.80599-5-jiri@resnulli.us>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent ef775b26
...@@ -292,11 +292,11 @@ enum vp_vq_vector_policy { ...@@ -292,11 +292,11 @@ enum vp_vq_vector_policy {
VP_VQ_VECTOR_POLICY_SHARED, VP_VQ_VECTOR_POLICY_SHARED,
}; };
static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev, static struct virtqueue *
int queue_idx, vp_find_one_vq_msix(struct virtio_device *vdev, int queue_idx,
vq_callback_t *callback, vq_callback_t *callback, const char *name, bool ctx,
const char *name, bool ctx, int *allocated_vectors,
int *allocated_vectors) enum vp_vq_vector_policy vector_policy)
{ {
struct virtio_pci_device *vp_dev = to_vp_device(vdev); struct virtio_pci_device *vp_dev = to_vp_device(vdev);
struct virtqueue *vq; struct virtqueue *vq;
...@@ -305,7 +305,7 @@ static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev, ...@@ -305,7 +305,7 @@ static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev,
if (!callback) if (!callback)
msix_vec = VIRTIO_MSI_NO_VECTOR; msix_vec = VIRTIO_MSI_NO_VECTOR;
else if (vp_dev->per_vq_vectors) else if (vector_policy == VP_VQ_VECTOR_POLICY_EACH)
msix_vec = (*allocated_vectors)++; msix_vec = (*allocated_vectors)++;
else else
msix_vec = VP_MSIX_VQ_VECTOR; msix_vec = VP_MSIX_VQ_VECTOR;
...@@ -313,7 +313,8 @@ static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev, ...@@ -313,7 +313,8 @@ static struct virtqueue *vp_find_one_vq_msix(struct virtio_device *vdev,
if (IS_ERR(vq)) if (IS_ERR(vq))
return vq; return vq;
if (!vp_dev->per_vq_vectors || msix_vec == VIRTIO_MSI_NO_VECTOR) if (vector_policy == VP_VQ_VECTOR_POLICY_SHARED ||
msix_vec == VIRTIO_MSI_NO_VECTOR)
return vq; return vq;
/* allocate per-vq irq if available and necessary */ /* allocate per-vq irq if available and necessary */
...@@ -374,7 +375,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs, ...@@ -374,7 +375,7 @@ static int vp_find_vqs_msix(struct virtio_device *vdev, unsigned int nvqs,
} }
vqs[i] = vp_find_one_vq_msix(vdev, queue_idx++, vqi->callback, vqs[i] = vp_find_one_vq_msix(vdev, queue_idx++, vqi->callback,
vqi->name, vqi->ctx, vqi->name, vqi->ctx,
&allocated_vectors); &allocated_vectors, vector_policy);
if (IS_ERR(vqs[i])) { if (IS_ERR(vqs[i])) {
err = PTR_ERR(vqs[i]); err = PTR_ERR(vqs[i]);
goto error_find; goto error_find;
......
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