Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _SCSI_SCSI_TCQ_H
0003 #define _SCSI_SCSI_TCQ_H
0004 
0005 #include <linux/blkdev.h>
0006 #include <scsi/scsi_cmnd.h>
0007 #include <scsi/scsi_device.h>
0008 #include <scsi/scsi_host.h>
0009 
0010 #define SCSI_NO_TAG (-1)    /* identify no tag in use */
0011 
0012 
0013 #ifdef CONFIG_BLOCK
0014 /**
0015  * scsi_host_find_tag - find the tagged command by host
0016  * @shost:  pointer to scsi_host
0017  * @tag:    tag
0018  *
0019  * Note: for devices using multiple hardware queues tag must have been
0020  * generated by blk_mq_unique_tag().
0021  **/
0022 static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
0023         int tag)
0024 {
0025     struct request *req = NULL;
0026     u16 hwq;
0027 
0028     if (tag == SCSI_NO_TAG)
0029         return NULL;
0030 
0031     hwq = blk_mq_unique_tag_to_hwq(tag);
0032     if (hwq < shost->tag_set.nr_hw_queues) {
0033         req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
0034                     blk_mq_unique_tag_to_tag(tag));
0035     }
0036 
0037     if (!req || !blk_mq_request_started(req))
0038         return NULL;
0039     return blk_mq_rq_to_pdu(req);
0040 }
0041 
0042 #endif /* CONFIG_BLOCK */
0043 #endif /* _SCSI_SCSI_TCQ_H */