srp.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  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. * $Id$
  33. */
  34. #ifndef SCSI_SRP_H
  35. #define SCSI_SRP_H
  36. /*
  37. * Structures and constants for the SCSI RDMA Protocol (SRP) as
  38. * defined by the INCITS T10 committee. This file was written using
  39. * draft Revision 16a of the SRP standard.
  40. */
  41. #include <linux/types.h>
  42. #include <scsi/scsi.h>
  43. enum {
  44. SRP_LOGIN_REQ = 0x00,
  45. SRP_TSK_MGMT = 0x01,
  46. SRP_CMD = 0x02,
  47. SRP_I_LOGOUT = 0x03,
  48. SRP_LOGIN_RSP = 0xc0,
  49. SRP_RSP = 0xc1,
  50. SRP_LOGIN_REJ = 0xc2,
  51. SRP_T_LOGOUT = 0x80,
  52. SRP_CRED_REQ = 0x81,
  53. SRP_AER_REQ = 0x82,
  54. SRP_CRED_RSP = 0x41,
  55. SRP_AER_RSP = 0x42
  56. };
  57. enum {
  58. SRP_BUF_FORMAT_DIRECT = 1 << 1,
  59. SRP_BUF_FORMAT_INDIRECT = 1 << 2
  60. };
  61. enum {
  62. SRP_NO_DATA_DESC = 0,
  63. SRP_DATA_DESC_DIRECT = 1,
  64. SRP_DATA_DESC_INDIRECT = 2,
  65. SRP_DATA_DESC_IMM = 3, /* new in SRP2 */
  66. };
  67. enum {
  68. SRP_TSK_ABORT_TASK = 0x01,
  69. SRP_TSK_ABORT_TASK_SET = 0x02,
  70. SRP_TSK_CLEAR_TASK_SET = 0x04,
  71. SRP_TSK_LUN_RESET = 0x08,
  72. SRP_TSK_CLEAR_ACA = 0x40
  73. };
  74. enum srp_login_rej_reason {
  75. SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
  76. SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
  77. SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
  78. SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
  79. SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
  80. SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
  81. SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
  82. };
  83. enum {
  84. SRP_REV10_IB_IO_CLASS = 0xff00,
  85. SRP_REV16A_IB_IO_CLASS = 0x0100
  86. };
  87. struct srp_direct_buf {
  88. __be64 va;
  89. __be32 key;
  90. __be32 len;
  91. };
  92. /*
  93. * We need the packed attribute because the SRP spec puts the list of
  94. * descriptors at an offset of 20, which is not aligned to the size of
  95. * struct srp_direct_buf. The whole structure must be packed to avoid
  96. * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
  97. */
  98. struct srp_indirect_buf {
  99. struct srp_direct_buf table_desc;
  100. __be32 len;
  101. struct srp_direct_buf desc_list[];
  102. } __attribute__((packed));
  103. /* Immediate data buffer descriptor as defined in SRP2. */
  104. struct srp_imm_buf {
  105. __be32 len;
  106. };
  107. /* srp_login_req.flags */
  108. enum {
  109. SRP_MULTICHAN_SINGLE = 0,
  110. SRP_MULTICHAN_MULTI = 1,
  111. SRP_IMMED_REQUESTED = 0x80, /* new in SRP2 */
  112. };
  113. struct srp_login_req {
  114. u8 opcode;
  115. u8 reserved1[7];
  116. u64 tag;
  117. __be32 req_it_iu_len;
  118. u8 reserved2[4];
  119. __be16 req_buf_fmt;
  120. u8 req_flags;
  121. u8 reserved3[1];
  122. __be16 imm_data_offset; /* new in SRP2 */
  123. u8 reserved4[2];
  124. u8 initiator_port_id[16];
  125. u8 target_port_id[16];
  126. };
  127. /**
  128. * struct srp_login_req_rdma - RDMA/CM login parameters.
  129. *
  130. * RDMA/CM over InfiniBand can only carry 92 - 36 = 56 bytes of private
  131. * data. The %srp_login_req_rdma structure contains the same information as
  132. * %srp_login_req but with the reserved data removed.
  133. */
  134. struct srp_login_req_rdma {
  135. u64 tag;
  136. __be16 req_buf_fmt;
  137. u8 req_flags;
  138. u8 opcode;
  139. __be32 req_it_iu_len;
  140. u8 initiator_port_id[16];
  141. u8 target_port_id[16];
  142. __be16 imm_data_offset;
  143. u8 reserved[6];
  144. };
  145. /* srp_login_rsp.rsp_flags */
  146. enum {
  147. SRP_LOGIN_RSP_MULTICHAN_NO_CHAN = 0x0,
  148. SRP_LOGIN_RSP_MULTICHAN_TERMINATED = 0x1,
  149. SRP_LOGIN_RSP_MULTICHAN_MAINTAINED = 0x2,
  150. SRP_LOGIN_RSP_IMMED_SUPP = 0x80, /* new in SRP2 */
  151. };
  152. /*
  153. * The SRP spec defines the size of the LOGIN_RSP structure to be 52
  154. * bytes, so it needs to be packed to avoid having it padded to 56
  155. * bytes on 64-bit architectures.
  156. */
  157. struct srp_login_rsp {
  158. u8 opcode;
  159. u8 reserved1[3];
  160. __be32 req_lim_delta;
  161. u64 tag;
  162. __be32 max_it_iu_len;
  163. __be32 max_ti_iu_len;
  164. __be16 buf_fmt;
  165. u8 rsp_flags;
  166. u8 reserved2[25];
  167. } __attribute__((packed));
  168. struct srp_login_rej {
  169. u8 opcode;
  170. u8 reserved1[3];
  171. __be32 reason;
  172. u64 tag;
  173. u8 reserved2[8];
  174. __be16 buf_fmt;
  175. u8 reserved3[6];
  176. };
  177. struct srp_i_logout {
  178. u8 opcode;
  179. u8 reserved[7];
  180. u64 tag;
  181. };
  182. struct srp_t_logout {
  183. u8 opcode;
  184. u8 sol_not;
  185. u8 reserved[2];
  186. __be32 reason;
  187. u64 tag;
  188. };
  189. /*
  190. * We need the packed attribute because the SRP spec only aligns the
  191. * 8-byte LUN field to 4 bytes.
  192. */
  193. struct srp_tsk_mgmt {
  194. u8 opcode;
  195. u8 sol_not;
  196. u8 reserved1[6];
  197. u64 tag;
  198. u8 reserved2[4];
  199. struct scsi_lun lun;
  200. u8 reserved3[2];
  201. u8 tsk_mgmt_func;
  202. u8 reserved4;
  203. u64 task_tag;
  204. u8 reserved5[8];
  205. };
  206. /*
  207. * We need the packed attribute because the SRP spec only aligns the
  208. * 8-byte LUN field to 4 bytes.
  209. */
  210. struct srp_cmd {
  211. u8 opcode;
  212. u8 sol_not;
  213. u8 reserved1[3];
  214. u8 buf_fmt;
  215. u8 data_out_desc_cnt;
  216. u8 data_in_desc_cnt;
  217. u64 tag;
  218. u8 reserved2[4];
  219. struct scsi_lun lun;
  220. u8 reserved3;
  221. u8 task_attr;
  222. u8 reserved4;
  223. u8 add_cdb_len;
  224. u8 cdb[16];
  225. u8 add_data[];
  226. };
  227. enum {
  228. SRP_RSP_FLAG_RSPVALID = 1 << 0,
  229. SRP_RSP_FLAG_SNSVALID = 1 << 1,
  230. SRP_RSP_FLAG_DOOVER = 1 << 2,
  231. SRP_RSP_FLAG_DOUNDER = 1 << 3,
  232. SRP_RSP_FLAG_DIOVER = 1 << 4,
  233. SRP_RSP_FLAG_DIUNDER = 1 << 5
  234. };
  235. /*
  236. * The SRP spec defines the size of the RSP structure to be 36 bytes,
  237. * so it needs to be packed to avoid having it padded to 40 bytes on
  238. * 64-bit architectures.
  239. */
  240. struct srp_rsp {
  241. u8 opcode;
  242. u8 sol_not;
  243. u8 reserved1[2];
  244. __be32 req_lim_delta;
  245. u64 tag;
  246. u8 reserved2[2];
  247. u8 flags;
  248. u8 status;
  249. __be32 data_out_res_cnt;
  250. __be32 data_in_res_cnt;
  251. __be32 sense_data_len;
  252. __be32 resp_data_len;
  253. u8 data[];
  254. } __attribute__((packed));
  255. struct srp_cred_req {
  256. u8 opcode;
  257. u8 sol_not;
  258. u8 reserved[2];
  259. __be32 req_lim_delta;
  260. u64 tag;
  261. };
  262. struct srp_cred_rsp {
  263. u8 opcode;
  264. u8 reserved[7];
  265. u64 tag;
  266. };
  267. /*
  268. * The SRP spec defines the fixed portion of the AER_REQ structure to be
  269. * 36 bytes, so it needs to be packed to avoid having it padded to 40 bytes
  270. * on 64-bit architectures.
  271. */
  272. struct srp_aer_req {
  273. u8 opcode;
  274. u8 sol_not;
  275. u8 reserved[2];
  276. __be32 req_lim_delta;
  277. u64 tag;
  278. u32 reserved2;
  279. struct scsi_lun lun;
  280. __be32 sense_data_len;
  281. u32 reserved3;
  282. u8 sense_data[];
  283. } __attribute__((packed));
  284. struct srp_aer_rsp {
  285. u8 opcode;
  286. u8 reserved[7];
  287. u64 tag;
  288. };
  289. #endif /* SCSI_SRP_H */