Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / include / scsi / scsi_tcq.h
blobe192a0caa8509294de01b851606ebaa3de3145a6
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _SCSI_SCSI_TCQ_H
3 #define _SCSI_SCSI_TCQ_H
5 #include <linux/blkdev.h>
6 #include <scsi/scsi_cmnd.h>
7 #include <scsi/scsi_device.h>
8 #include <scsi/scsi_host.h>
10 #define SCSI_NO_TAG (-1) /* identify no tag in use */
13 #ifdef CONFIG_BLOCK
14 /**
15 * scsi_host_find_tag - find the tagged command by host
16 * @shost: pointer to scsi_host
17 * @tag: tag
19 * Note: for devices using multiple hardware queues tag must have been
20 * generated by blk_mq_unique_tag().
21 **/
22 static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
23 int tag)
25 struct request *req = NULL;
27 if (tag == SCSI_NO_TAG)
28 return NULL;
30 if (shost_use_blk_mq(shost)) {
31 u16 hwq = blk_mq_unique_tag_to_hwq(tag);
33 if (hwq < shost->tag_set.nr_hw_queues) {
34 req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
35 blk_mq_unique_tag_to_tag(tag));
37 } else {
38 req = blk_map_queue_find_tag(shost->bqt, tag);
41 if (!req)
42 return NULL;
43 return blk_mq_rq_to_pdu(req);
46 #endif /* CONFIG_BLOCK */
47 #endif /* _SCSI_SCSI_TCQ_H */