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 Reviewed-by: Jason J. Herne --- drivers/s390/crypto/vfio_ap_ops.c | 8 ++++++++ drivers/s390/crypto/vfio_ap_private.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index 4db878c18f41..345c52a328ad 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2105,6 +2105,14 @@ static void vfio_ap_mdev_request(struct vfio_device *vdev, unsigned int count) release_update_locks_for_mdev(matrix_mdev); } +unsigned int vfio_ap_mdev_get_num_queues(struct ap_matrix *ap_matrix) +{ + lockdep_assert_held(&matrix_dev->mdevs_lock); + + return bitmap_weight(ap_matrix->apm, AP_DEVICES) * + bitmap_weight(ap_matrix->aqm, AP_DOMAINS); +} + 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..12d7d240addd 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; }; +unsigned 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