Merge branch 'rc-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
[linux/fpc-iii.git] / include / scsi / scsi_tcq.h
blob4416b1026189c182bb75fbc5f677f587007522a7
1 #ifndef _SCSI_SCSI_TCQ_H
2 #define _SCSI_SCSI_TCQ_H
4 #include <linux/blkdev.h>
5 #include <scsi/scsi_cmnd.h>
6 #include <scsi/scsi_device.h>
7 #include <scsi/scsi_host.h>
9 #define SCSI_NO_TAG (-1) /* identify no tag in use */
12 #ifdef CONFIG_BLOCK
13 /**
14 * scsi_host_find_tag - find the tagged command by host
15 * @shost: pointer to scsi_host
16 * @tag: tag
18 * Note: for devices using multiple hardware queues tag must have been
19 * generated by blk_mq_unique_tag().
20 **/
21 static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
22 int tag)
24 struct request *req = NULL;
26 if (tag == SCSI_NO_TAG)
27 return NULL;
29 if (shost_use_blk_mq(shost)) {
30 u16 hwq = blk_mq_unique_tag_to_hwq(tag);
32 if (hwq < shost->tag_set.nr_hw_queues) {
33 req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
34 blk_mq_unique_tag_to_tag(tag));
36 } else {
37 req = blk_map_queue_find_tag(shost->bqt, tag);
40 if (!req)
41 return NULL;
42 return req->special;
45 #endif /* CONFIG_BLOCK */
46 #endif /* _SCSI_SCSI_TCQ_H */