srp.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. /*
  2. * Copyright (c) 2005 Cisco Systems. All rights reserved.
  3. *
  4. * This software is available to you under a choice of one of two
  5. * licenses. You may choose to be licensed under the terms of the GNU
  6. * General Public License (GPL) Version 2, available from the file
  7. * COPYING in the main directory of this source tree, or the
  8. * OpenIB.org BSD license below:
  9. *
  10. * Redistribution and use in source and binary forms, with or
  11. * without modification, are permitted provided that the following
  12. * conditions are met:
  13. *
  14. * - Redistributions of source code must retain the above
  15. * copyright notice, this list of conditions and the following
  16. * disclaimer.
  17. *
  18. * - Redistributions in binary form must reproduce the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer in the documentation and/or other materials
  21. * provided with the distribution.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  24. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  25. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  26. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  27. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  28. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  29. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  30. * SOFTWARE.
  31. *
  32. */
  33. #ifndef SCSI_SRP_H
  34. #define SCSI_SRP_H
  35. /*
  36. * Structures and constants for the SCSI RDMA Protocol (SRP) as
  37. * defined by the INCITS T10 committee. This file was written using
  38. * draft Revision 16a of the SRP standard.
  39. */
  40. enum {
  41. SRP_LOGIN_REQ = 0x00,
  42. SRP_TSK_MGMT = 0x01,
  43. SRP_CMD = 0x02,
  44. SRP_I_LOGOUT = 0x03,
  45. SRP_LOGIN_RSP = 0xc0,
  46. SRP_RSP = 0xc1,
  47. SRP_LOGIN_REJ = 0xc2,
  48. SRP_T_LOGOUT = 0x80,
  49. SRP_CRED_REQ = 0x81,
  50. SRP_AER_REQ = 0x82,
  51. SRP_CRED_RSP = 0x41,
  52. SRP_AER_RSP = 0x42
  53. };
  54. enum {
  55. SRP_BUF_FORMAT_DIRECT = 1 << 1,
  56. SRP_BUF_FORMAT_INDIRECT = 1 << 2
  57. };
  58. enum {
  59. SRP_NO_DATA_DESC = 0,
  60. SRP_DATA_DESC_DIRECT = 1,
  61. SRP_DATA_DESC_INDIRECT = 2
  62. };
  63. enum {
  64. SRP_TSK_ABORT_TASK = 0x01,
  65. SRP_TSK_ABORT_TASK_SET = 0x02,
  66. SRP_TSK_CLEAR_TASK_SET = 0x04,
  67. SRP_TSK_LUN_RESET = 0x08,
  68. SRP_TSK_CLEAR_ACA = 0x40
  69. };
  70. enum srp_login_rej_reason {
  71. SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
  72. SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
  73. SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
  74. SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
  75. SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
  76. SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
  77. SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
  78. };
  79. enum {
  80. SRP_REV10_IB_IO_CLASS = 0xff00,
  81. SRP_REV16A_IB_IO_CLASS = 0x0100
  82. };
  83. enum {
  84. SRP_TSK_MGMT_COMPLETE = 0x00,
  85. SRP_TSK_MGMT_FIELDS_INVALID = 0x02,
  86. SRP_TSK_MGMT_NOT_SUPPORTED = 0x04,
  87. SRP_TSK_MGMT_FAILED = 0x05
  88. };
  89. struct srp_direct_buf {
  90. uint64_t va;
  91. uint32_t key;
  92. uint32_t len;
  93. };
  94. /*
  95. * We need the packed attribute because the SRP spec puts the list of
  96. * descriptors at an offset of 20, which is not aligned to the size of
  97. * struct srp_direct_buf. The whole structure must be packed to avoid
  98. * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
  99. */
  100. struct srp_indirect_buf {
  101. struct srp_direct_buf table_desc;
  102. uint32_t len;
  103. struct srp_direct_buf desc_list[0];
  104. } QEMU_PACKED;
  105. enum {
  106. SRP_MULTICHAN_SINGLE = 0,
  107. SRP_MULTICHAN_MULTI = 1
  108. };
  109. struct srp_login_req {
  110. uint8_t opcode;
  111. uint8_t reserved1[7];
  112. uint64_t tag;
  113. uint32_t req_it_iu_len;
  114. uint8_t reserved2[4];
  115. uint16_t req_buf_fmt;
  116. uint8_t req_flags;
  117. uint8_t reserved3[5];
  118. uint8_t initiator_port_id[16];
  119. uint8_t target_port_id[16];
  120. };
  121. /*
  122. * The SRP spec defines the size of the LOGIN_RSP structure to be 52
  123. * bytes, so it needs to be packed to avoid having it padded to 56
  124. * bytes on 64-bit architectures.
  125. */
  126. struct srp_login_rsp {
  127. uint8_t opcode;
  128. uint8_t reserved1[3];
  129. uint32_t req_lim_delta;
  130. uint64_t tag;
  131. uint32_t max_it_iu_len;
  132. uint32_t max_ti_iu_len;
  133. uint16_t buf_fmt;
  134. uint8_t rsp_flags;
  135. uint8_t reserved2[25];
  136. } QEMU_PACKED;
  137. struct srp_login_rej {
  138. uint8_t opcode;
  139. uint8_t reserved1[3];
  140. uint32_t reason;
  141. uint64_t tag;
  142. uint8_t reserved2[8];
  143. uint16_t buf_fmt;
  144. uint8_t reserved3[6];
  145. };
  146. struct srp_i_logout {
  147. uint8_t opcode;
  148. uint8_t reserved[7];
  149. uint64_t tag;
  150. };
  151. struct srp_t_logout {
  152. uint8_t opcode;
  153. uint8_t sol_not;
  154. uint8_t reserved[2];
  155. uint32_t reason;
  156. uint64_t tag;
  157. };
  158. /*
  159. * We need the packed attribute because the SRP spec only aligns the
  160. * 8-byte LUN field to 4 bytes.
  161. */
  162. struct srp_tsk_mgmt {
  163. uint8_t opcode;
  164. uint8_t sol_not;
  165. uint8_t reserved1[6];
  166. uint64_t tag;
  167. uint8_t reserved2[4];
  168. uint64_t lun;
  169. uint8_t reserved3[2];
  170. uint8_t tsk_mgmt_func;
  171. uint8_t reserved4;
  172. uint64_t task_tag;
  173. uint8_t reserved5[8];
  174. } QEMU_PACKED;
  175. /*
  176. * We need the packed attribute because the SRP spec only aligns the
  177. * 8-byte LUN field to 4 bytes.
  178. */
  179. struct srp_cmd {
  180. uint8_t opcode;
  181. uint8_t sol_not;
  182. uint8_t reserved1[3];
  183. uint8_t buf_fmt;
  184. uint8_t data_out_desc_cnt;
  185. uint8_t data_in_desc_cnt;
  186. uint64_t tag;
  187. uint8_t reserved2[4];
  188. uint64_t lun;
  189. uint8_t reserved3;
  190. uint8_t task_attr;
  191. uint8_t reserved4;
  192. uint8_t add_cdb_len;
  193. uint8_t cdb[16];
  194. uint8_t add_data[0];
  195. } QEMU_PACKED;
  196. enum {
  197. SRP_RSP_FLAG_RSPVALID = 1 << 0,
  198. SRP_RSP_FLAG_SNSVALID = 1 << 1,
  199. SRP_RSP_FLAG_DOOVER = 1 << 2,
  200. SRP_RSP_FLAG_DOUNDER = 1 << 3,
  201. SRP_RSP_FLAG_DIOVER = 1 << 4,
  202. SRP_RSP_FLAG_DIUNDER = 1 << 5
  203. };
  204. /*
  205. * The SRP spec defines the size of the RSP structure to be 36 bytes,
  206. * so it needs to be packed to avoid having it padded to 40 bytes on
  207. * 64-bit architectures.
  208. */
  209. struct srp_rsp {
  210. uint8_t opcode;
  211. uint8_t sol_not;
  212. uint8_t reserved1[2];
  213. uint32_t req_lim_delta;
  214. uint64_t tag;
  215. uint8_t reserved2[2];
  216. uint8_t flags;
  217. uint8_t status;
  218. uint32_t data_out_res_cnt;
  219. uint32_t data_in_res_cnt;
  220. uint32_t sense_data_len;
  221. uint32_t resp_data_len;
  222. uint8_t data[0];
  223. } QEMU_PACKED;
  224. #endif /* SCSI_SRP_H */