]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/scsi/scsi_tcq.h
Merge branches 'for-4.4/upstream-fixes', 'for-4.5/async-suspend', 'for-4.5/container...
[mirror_ubuntu-artful-kernel.git] / include / scsi / scsi_tcq.h
CommitLineData
1da177e4
LT
1#ifndef _SCSI_SCSI_TCQ_H
2#define _SCSI_SCSI_TCQ_H
3
4#include <linux/blkdev.h>
5#include <scsi/scsi_cmnd.h>
6#include <scsi/scsi_device.h>
86e33a29 7#include <scsi/scsi_host.h>
1da177e4 8
1da177e4
LT
9#define SCSI_NO_TAG (-1) /* identify no tag in use */
10
11
9361401e 12#ifdef CONFIG_BLOCK
f583f492
DS
13/**
14 * scsi_host_find_tag - find the tagged command by host
15 * @shost: pointer to scsi_host
64d513ac 16 * @tag: tag
f583f492 17 *
64d513ac
CH
18 * Note: for devices using multiple hardware queues tag must have been
19 * generated by blk_mq_unique_tag().
f583f492
DS
20 **/
21static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
64d513ac 22 int tag)
f583f492 23{
64d513ac 24 struct request *req = NULL;
f583f492 25
64d513ac
CH
26 if (tag == SCSI_NO_TAG)
27 return NULL;
28
29 if (shost_use_blk_mq(shost)) {
30 u16 hwq = blk_mq_unique_tag_to_hwq(tag);
31
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));
35 }
36 } else {
f583f492 37 req = blk_map_queue_find_tag(shost->bqt, tag);
f583f492 38 }
64d513ac
CH
39
40 if (!req)
41 return NULL;
42 return req->special;
f583f492
DS
43}
44
9361401e 45#endif /* CONFIG_BLOCK */
1da177e4 46#endif /* _SCSI_SCSI_TCQ_H */