uas.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __USB_UAS_H__
  3. #define __USB_UAS_H__
  4. #include <scsi/scsi.h>
  5. #include <scsi/scsi_cmnd.h>
  6. /* Common header for all IUs */
  7. struct iu {
  8. __u8 iu_id;
  9. __u8 rsvd1;
  10. __be16 tag;
  11. } __attribute__((__packed__));
  12. enum {
  13. IU_ID_COMMAND = 0x01,
  14. IU_ID_STATUS = 0x03,
  15. IU_ID_RESPONSE = 0x04,
  16. IU_ID_TASK_MGMT = 0x05,
  17. IU_ID_READ_READY = 0x06,
  18. IU_ID_WRITE_READY = 0x07,
  19. };
  20. enum {
  21. TMF_ABORT_TASK = 0x01,
  22. TMF_ABORT_TASK_SET = 0x02,
  23. TMF_CLEAR_TASK_SET = 0x04,
  24. TMF_LOGICAL_UNIT_RESET = 0x08,
  25. TMF_I_T_NEXUS_RESET = 0x10,
  26. TMF_CLEAR_ACA = 0x40,
  27. TMF_QUERY_TASK = 0x80,
  28. TMF_QUERY_TASK_SET = 0x81,
  29. TMF_QUERY_ASYNC_EVENT = 0x82,
  30. };
  31. enum {
  32. RC_TMF_COMPLETE = 0x00,
  33. RC_INVALID_INFO_UNIT = 0x02,
  34. RC_TMF_NOT_SUPPORTED = 0x04,
  35. RC_TMF_FAILED = 0x05,
  36. RC_TMF_SUCCEEDED = 0x08,
  37. RC_INCORRECT_LUN = 0x09,
  38. RC_OVERLAPPED_TAG = 0x0a,
  39. };
  40. struct command_iu {
  41. __u8 iu_id;
  42. __u8 rsvd1;
  43. __be16 tag;
  44. __u8 prio_attr;
  45. __u8 rsvd5;
  46. __u8 len;
  47. __u8 rsvd7;
  48. struct scsi_lun lun;
  49. __u8 cdb[16]; /* XXX: Overflow-checking tools may misunderstand */
  50. } __attribute__((__packed__));
  51. struct task_mgmt_iu {
  52. __u8 iu_id;
  53. __u8 rsvd1;
  54. __be16 tag;
  55. __u8 function;
  56. __u8 rsvd2;
  57. __be16 task_tag;
  58. struct scsi_lun lun;
  59. } __attribute__((__packed__));
  60. /*
  61. * Also used for the Read Ready and Write Ready IUs since they have the
  62. * same first four bytes
  63. */
  64. struct sense_iu {
  65. __u8 iu_id;
  66. __u8 rsvd1;
  67. __be16 tag;
  68. __be16 status_qual;
  69. __u8 status;
  70. __u8 rsvd7[7];
  71. __be16 len;
  72. __u8 sense[SCSI_SENSE_BUFFERSIZE];
  73. } __attribute__((__packed__));
  74. struct response_iu {
  75. __u8 iu_id;
  76. __u8 rsvd1;
  77. __be16 tag;
  78. __u8 add_response_info[3];
  79. __u8 response_code;
  80. } __attribute__((__packed__));
  81. struct usb_pipe_usage_descriptor {
  82. __u8 bLength;
  83. __u8 bDescriptorType;
  84. __u8 bPipeID;
  85. __u8 Reserved;
  86. } __attribute__((__packed__));
  87. enum {
  88. CMD_PIPE_ID = 1,
  89. STATUS_PIPE_ID = 2,
  90. DATA_IN_PIPE_ID = 3,
  91. DATA_OUT_PIPE_ID = 4,
  92. UAS_SIMPLE_TAG = 0,
  93. UAS_HEAD_TAG = 1,
  94. UAS_ORDERED_TAG = 2,
  95. UAS_ACA = 4,
  96. };
  97. #endif