Provides a function that returns the number of queues that are or will be passed through to a guest when the mdev is attached to a guest. Signed-off-by: Anthony Krowiak --- drivers/s390/crypto/vfio_ap_ops.c | 14 ++++++++++++++ drivers/s390/crypto/vfio_ap_private.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 44b3a1dcc1b3..71d3e2c2e07c 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2098,6 +2098,20 @@ static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count) release_update_locks_for_mdev(matrix_mdev); } +int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix) +{ + unsigned long apid, apqi; + int num_queues = 0; + + lockdep_assert_held(&matrix_dev->mdevs_lock); + + for_each_set_bit_inv(apid, ap_matrix->apm, AP_DEVICES) + for_each_set_bit_inv(apqi, ap_matrix->aqm, AP_DOMAINS) + num_queues++; + + return num_queues; +} + static int vfio_ap_mdev_get_device_info(unsigned long arg) { unsigned long minsz; diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h index 9bff666b0b35..9677e49554d7 100644 --- a/drivers/s390/crypto/vfio_ap_private.h +++ b/drivers/s390/crypto/vfio_ap_private.h @@ -152,6 +152,8 @@ struct vfio_ap_queue { struct work_struct reset_work; }; +int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix); + int vfio_ap_mdev_register(void); void vfio_ap_mdev_unregister(void); -- 2.53.0