scsi_tcq.h 1005 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #ifndef _SCSI_SCSI_TCQ_H
  2. #define _SCSI_SCSI_TCQ_H
  3. #include <linux/blkdev.h>
  4. #include <scsi/scsi_cmnd.h>
  5. #include <scsi/scsi_device.h>
  6. #include <scsi/scsi_host.h>
  7. #define SCSI_NO_TAG (-1) /* identify no tag in use */
  8. #ifdef CONFIG_BLOCK
  9. /**
  10. * scsi_host_find_tag - find the tagged command by host
  11. * @shost: pointer to scsi_host
  12. * @tag: tag
  13. *
  14. * Note: for devices using multiple hardware queues tag must have been
  15. * generated by blk_mq_unique_tag().
  16. **/
  17. static inline struct scsi_cmnd *scsi_host_find_tag(struct Scsi_Host *shost,
  18. int tag)
  19. {
  20. struct request *req = NULL;
  21. if (tag == SCSI_NO_TAG)
  22. return NULL;
  23. if (shost_use_blk_mq(shost)) {
  24. u16 hwq = blk_mq_unique_tag_to_hwq(tag);
  25. if (hwq < shost->tag_set.nr_hw_queues) {
  26. req = blk_mq_tag_to_rq(shost->tag_set.tags[hwq],
  27. blk_mq_unique_tag_to_tag(tag));
  28. }
  29. } else {
  30. req = blk_map_queue_find_tag(shost->bqt, tag);
  31. }
  32. if (!req)
  33. return NULL;
  34. return req->special;
  35. }
  36. #endif /* CONFIG_BLOCK */
  37. #endif /* _SCSI_SCSI_TCQ_H */