1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2016 Christoph Hellwig.
5 #include <linux/device.h>
6 #include <linux/blk-mq-virtio.h>
7 #include <linux/virtio_config.h>
8 #include <linux/module.h>
12 * blk_mq_virtio_map_queues - provide a default queue mapping for virtio device
13 * @qmap: CPU to hardware queue map.
14 * @vdev: virtio device to provide a mapping for.
15 * @first_vec: first interrupt vectors to use for queues (usually 0)
17 * This function assumes the virtio device @vdev has at least as many available
18 * interrupt vectors as @set has queues. It will then query the vector
19 * corresponding to each queue for it's affinity mask and built queue mapping
20 * that maps a queue to the CPUs that have irq affinity for the corresponding
23 void blk_mq_virtio_map_queues(struct blk_mq_queue_map
*qmap
,
24 struct virtio_device
*vdev
, int first_vec
)
26 const struct cpumask
*mask
;
27 unsigned int queue
, cpu
;
29 if (!vdev
->config
->get_vq_affinity
)
32 for (queue
= 0; queue
< qmap
->nr_queues
; queue
++) {
33 mask
= vdev
->config
->get_vq_affinity(vdev
, first_vec
+ queue
);
37 for_each_cpu(cpu
, mask
)
38 qmap
->mq_map
[cpu
] = qmap
->queue_offset
+ queue
;
44 blk_mq_map_queues(qmap
);
46 EXPORT_SYMBOL_GPL(blk_mq_virtio_map_queues
);