mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
virtio: push out code to vp_avq_index()
To prepare for the follow-up patch to use the code as an op, push out the code that gets admin virtqueue base index and count to a separate helper. Signed-off-by: Jiri Pirko <jiri@nvidia.com> Message-Id: <20240716113552.80599-8-jiri@resnulli.us> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
4199107e39
commit
7e5d9f556e
@ -28,6 +28,21 @@ static u64 vp_get_features(struct virtio_device *vdev)
|
||||
return vp_modern_get_features(&vp_dev->mdev);
|
||||
}
|
||||
|
||||
static int vp_avq_index(struct virtio_device *vdev, u16 *index, u16 *num)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
|
||||
|
||||
*num = 0;
|
||||
if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ))
|
||||
return 0;
|
||||
|
||||
*num = vp_modern_avq_num(&vp_dev->mdev);
|
||||
if (!(*num))
|
||||
return -EINVAL;
|
||||
*index = vp_modern_avq_index(&vp_dev->mdev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool vp_is_avq(struct virtio_device *vdev, unsigned int index)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
|
||||
@ -729,19 +744,15 @@ static bool vp_get_shm_region(struct virtio_device *vdev,
|
||||
static int vp_modern_create_avq(struct virtio_device *vdev)
|
||||
{
|
||||
struct virtio_pci_device *vp_dev = to_vp_device(vdev);
|
||||
struct virtio_pci_admin_vq *avq;
|
||||
struct virtio_pci_admin_vq *avq = &vp_dev->admin_vq;
|
||||
struct virtqueue *vq;
|
||||
u16 admin_q_num;
|
||||
u16 num;
|
||||
int err;
|
||||
|
||||
if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ))
|
||||
return 0;
|
||||
err = vp_avq_index(vdev, &avq->vq_index, &num);
|
||||
if (err || !num)
|
||||
return err;
|
||||
|
||||
admin_q_num = vp_modern_avq_num(&vp_dev->mdev);
|
||||
if (!admin_q_num)
|
||||
return -EINVAL;
|
||||
|
||||
avq = &vp_dev->admin_vq;
|
||||
avq->vq_index = vp_modern_avq_index(&vp_dev->mdev);
|
||||
sprintf(avq->name, "avq.%u", avq->vq_index);
|
||||
vq = vp_dev->setup_vq(vp_dev, &vp_dev->admin_vq.info, avq->vq_index, NULL,
|
||||
avq->name, NULL, VIRTIO_MSI_NO_VECTOR);
|
||||
|
Loading…
Reference in New Issue
Block a user