srp.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. enum {
  43. SRP_LOGIN_REQ = 0x00,
  44. SRP_TSK_MGMT = 0x01,
  45. SRP_CMD = 0x02,
  46. SRP_I_LOGOUT = 0x03,
  47. SRP_LOGIN_RSP = 0xc0,
  48. SRP_RSP = 0xc1,
  49. SRP_LOGIN_REJ = 0xc2,
  50. SRP_T_LOGOUT = 0x80,
  51. SRP_CRED_REQ = 0x81,
  52. SRP_AER_REQ = 0x82,
  53. SRP_CRED_RSP = 0x41,
  54. SRP_AER_RSP = 0x42
  55. };
  56. enum {
  57. SRP_BUF_FORMAT_DIRECT = 1 << 1,
  58. SRP_BUF_FORMAT_INDIRECT = 1 << 2
  59. };
  60. enum {
  61. SRP_NO_DATA_DESC = 0,
  62. SRP_DATA_DESC_DIRECT = 1,
  63. SRP_DATA_DESC_INDIRECT = 2
  64. };
  65. enum {
  66. SRP_TSK_ABORT_TASK = 0x01,
  67. SRP_TSK_ABORT_TASK_SET = 0x02,
  68. SRP_TSK_CLEAR_TASK_SET = 0x04,
  69. SRP_TSK_LUN_RESET = 0x08,
  70. SRP_TSK_CLEAR_ACA = 0x40
  71. };
  72. enum srp_login_rej_reason {
  73. SRP_LOGIN_REJ_UNABLE_ESTABLISH_CHANNEL = 0x00010000,
  74. SRP_LOGIN_REJ_INSUFFICIENT_RESOURCES = 0x00010001,
  75. SRP_LOGIN_REJ_REQ_IT_IU_LENGTH_TOO_LARGE = 0x00010002,
  76. SRP_LOGIN_REJ_UNABLE_ASSOCIATE_CHANNEL = 0x00010003,
  77. SRP_LOGIN_REJ_UNSUPPORTED_DESCRIPTOR_FMT = 0x00010004,
  78. SRP_LOGIN_REJ_MULTI_CHANNEL_UNSUPPORTED = 0x00010005,
  79. SRP_LOGIN_REJ_CHANNEL_LIMIT_REACHED = 0x00010006
  80. };
  81. struct srp_direct_buf {
  82. __be64 va;
  83. __be32 key;
  84. __be32 len;
  85. };
  86. /*
  87. * We need the packed attribute because the SRP spec puts the list of
  88. * descriptors at an offset of 20, which is not aligned to the size of
  89. * struct srp_direct_buf. The whole structure must be packed to avoid
  90. * having the 20-byte structure padded to 24 bytes on 64-bit architectures.
  91. */
  92. struct srp_indirect_buf {
  93. struct srp_direct_buf table_desc;
  94. __be32 len;
  95. struct srp_direct_buf desc_list[0];
  96. } __attribute__((packed));
  97. enum {
  98. SRP_MULTICHAN_SINGLE = 0,
  99. SRP_MULTICHAN_MULTI = 1
  100. };
  101. struct srp_login_req {
  102. u8 opcode;
  103. u8 reserved1[7];
  104. u64 tag;
  105. __be32 req_it_iu_len;
  106. u8 reserved2[4];
  107. __be16 req_buf_fmt;
  108. u8 req_flags;
  109. u8 reserved3[5];
  110. u8 initiator_port_id[16];
  111. u8 target_port_id[16];
  112. };
  113. /*
  114. * The SRP spec defines the size of the LOGIN_RSP structure to be 52
  115. * bytes, so it needs to be packed to avoid having it padded to 56
  116. * bytes on 64-bit architectures.
  117. */
  118. struct srp_login_rsp {
  119. u8 opcode;
  120. u8 reserved1[3];
  121. __be32 req_lim_delta;
  122. u64 tag;
  123. __be32 max_it_iu_len;
  124. __be32 max_ti_iu_len;
  125. __be16 buf_fmt;
  126. u8 rsp_flags;
  127. u8 reserved2[25];
  128. } __attribute__((packed));
  129. struct srp_login_rej {
  130. u8 opcode;
  131. u8 reserved1[3];
  132. __be32 reason;
  133. u64 tag;
  134. u8 reserved2[8];
  135. __be16 buf_fmt;
  136. u8 reserved3[6];
  137. };
  138. struct srp_i_logout {
  139. u8 opcode;
  140. u8 reserved[7];
  141. u64 tag;
  142. };
  143. struct srp_t_logout {
  144. u8 opcode;
  145. u8 sol_not;
  146. u8 reserved[2];
  147. __be32 reason;
  148. u64 tag;
  149. };
  150. /*
  151. * We need the packed attribute because the SRP spec only aligns the
  152. * 8-byte LUN field to 4 bytes.
  153. */
  154. struct srp_tsk_mgmt {
  155. u8 opcode;
  156. u8 sol_not;
  157. u8 reserved1[6];
  158. u64 tag;
  159. u8 reserved2[4];
  160. __be64 lun __attribute__((packed));
  161. u8 reserved3[2];
  162. u8 tsk_mgmt_func;
  163. u8 reserved4;
  164. u64 task_tag;
  165. u8 reserved5[8];
  166. };
  167. /*
  168. * We need the packed attribute because the SRP spec only aligns the
  169. * 8-byte LUN field to 4 bytes.
  170. */
  171. struct srp_cmd {
  172. u8 opcode;
  173. u8 sol_not;
  174. u8 reserved1[3];
  175. u8 buf_fmt;
  176. u8 data_out_desc_cnt;
  177. u8 data_in_desc_cnt;
  178. u64 tag;
  179. u8 reserved2[4];
  180. __be64 lun __attribute__((packed));
  181. u8 reserved3;
  182. u8 task_attr;
  183. u8 reserved4;
  184. u8 add_cdb_len;
  185. u8 cdb[16];
  186. u8 add_data[0];
  187. };
  188. enum {
  189. SRP_RSP_FLAG_RSPVALID = 1 << 0,
  190. SRP_RSP_FLAG_SNSVALID = 1 << 1,
  191. SRP_RSP_FLAG_DOOVER = 1 << 2,
  192. SRP_RSP_FLAG_DOUNDER = 1 << 3,
  193. SRP_RSP_FLAG_DIOVER = 1 << 4,
  194. SRP_RSP_FLAG_DIUNDER = 1 << 5
  195. };
  196. /*
  197. * The SRP spec defines the size of the RSP structure to be 36 bytes,
  198. * so it needs to be packed to avoid having it padded to 40 bytes on
  199. * 64-bit architectures.
  200. */
  201. struct srp_rsp {
  202. u8 opcode;
  203. u8 sol_not;
  204. u8 reserved1[2];
  205. __be32 req_lim_delta;
  206. u64 tag;
  207. u8 reserved2[2];
  208. u8 flags;
  209. u8 status;
  210. __be32 data_out_res_cnt;
  211. __be32 data_in_res_cnt;
  212. __be32 sense_data_len;
  213. __be32 resp_data_len;
  214. u8 data[0];
  215. } __attribute__((packed));
  216. #endif /* SCSI_SRP_H */