scsi_bsg_fc.h 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. /*
  2. * FC Transport BSG Interface
  3. *
  4. * Copyright (C) 2008 James Smart, Emulex Corporation
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. */
  21. #ifndef SCSI_BSG_FC_H
  22. #define SCSI_BSG_FC_H
  23. /*
  24. * This file intended to be included by both kernel and user space
  25. */
  26. /*
  27. * FC Transport SGIO v4 BSG Message Support
  28. */
  29. /* Default BSG request timeout (in seconds) */
  30. #define FC_DEFAULT_BSG_TIMEOUT (10 * HZ)
  31. /*
  32. * Request Message Codes supported by the FC Transport
  33. */
  34. /* define the class masks for the message codes */
  35. #define FC_BSG_CLS_MASK 0xF0000000 /* find object class */
  36. #define FC_BSG_HST_MASK 0x80000000 /* fc host class */
  37. #define FC_BSG_RPT_MASK 0x40000000 /* fc rport class */
  38. /* fc_host Message Codes */
  39. #define FC_BSG_HST_ADD_RPORT (FC_BSG_HST_MASK | 0x00000001)
  40. #define FC_BSG_HST_DEL_RPORT (FC_BSG_HST_MASK | 0x00000002)
  41. #define FC_BSG_HST_ELS_NOLOGIN (FC_BSG_HST_MASK | 0x00000003)
  42. #define FC_BSG_HST_CT (FC_BSG_HST_MASK | 0x00000004)
  43. #define FC_BSG_HST_VENDOR (FC_BSG_HST_MASK | 0x000000FF)
  44. /* fc_rport Message Codes */
  45. #define FC_BSG_RPT_ELS (FC_BSG_RPT_MASK | 0x00000001)
  46. #define FC_BSG_RPT_CT (FC_BSG_RPT_MASK | 0x00000002)
  47. /*
  48. * FC Address Identifiers in Message Structures :
  49. *
  50. * Whenever a command payload contains a FC Address Identifier
  51. * (aka port_id), the value is effectively in big-endian
  52. * order, thus the array elements are decoded as follows:
  53. * element [0] is bits 23:16 of the FC Address Identifier
  54. * element [1] is bits 15:8 of the FC Address Identifier
  55. * element [2] is bits 7:0 of the FC Address Identifier
  56. */
  57. /*
  58. * FC Host Messages
  59. */
  60. /* FC_BSG_HST_ADDR_PORT : */
  61. /* Request:
  62. * This message requests the FC host to login to the remote port
  63. * at the specified N_Port_Id. The remote port is to be enumerated
  64. * with the transport upon completion of the login.
  65. */
  66. struct fc_bsg_host_add_rport {
  67. uint8_t reserved;
  68. /* FC Address Identier of the remote port to login to */
  69. uint8_t port_id[3];
  70. };
  71. /* Response:
  72. * There is no additional response data - fc_bsg_reply->result is sufficient
  73. */
  74. /* FC_BSG_HST_DEL_RPORT : */
  75. /* Request:
  76. * This message requests the FC host to remove an enumerated
  77. * remote port and to terminate the login to it.
  78. *
  79. * Note: The driver is free to reject this request if it desires to
  80. * remain logged in with the remote port.
  81. */
  82. struct fc_bsg_host_del_rport {
  83. uint8_t reserved;
  84. /* FC Address Identier of the remote port to logout of */
  85. uint8_t port_id[3];
  86. };
  87. /* Response:
  88. * There is no additional response data - fc_bsg_reply->result is sufficient
  89. */
  90. /* FC_BSG_HST_ELS_NOLOGIN : */
  91. /* Request:
  92. * This message requests the FC_Host to send an ELS to a specific
  93. * N_Port_ID. The host does not need to log into the remote port,
  94. * nor does it need to enumerate the rport for further traffic
  95. * (although, the FC host is free to do so if it desires).
  96. */
  97. struct fc_bsg_host_els {
  98. /*
  99. * ELS Command Code being sent (must be the same as byte 0
  100. * of the payload)
  101. */
  102. uint8_t command_code;
  103. /* FC Address Identier of the remote port to send the ELS to */
  104. uint8_t port_id[3];
  105. };
  106. /* Response:
  107. */
  108. /* fc_bsg_ctels_reply->status values */
  109. #define FC_CTELS_STATUS_OK 0x00000000
  110. #define FC_CTELS_STATUS_REJECT 0x00000001
  111. #define FC_CTELS_STATUS_P_RJT 0x00000002
  112. #define FC_CTELS_STATUS_F_RJT 0x00000003
  113. #define FC_CTELS_STATUS_P_BSY 0x00000004
  114. #define FC_CTELS_STATUS_F_BSY 0x00000006
  115. struct fc_bsg_ctels_reply {
  116. /*
  117. * Note: An ELS LS_RJT may be reported in 2 ways:
  118. * a) A status of FC_CTELS_STATUS_OK is returned. The caller
  119. * is to look into the ELS receive payload to determine
  120. * LS_ACC or LS_RJT (by contents of word 0). The reject
  121. * data will be in word 1.
  122. * b) A status of FC_CTELS_STATUS_REJECT is returned, The
  123. * rjt_data field will contain valid data.
  124. *
  125. * Note: ELS LS_ACC is determined by an FC_CTELS_STATUS_OK, and
  126. * the receive payload word 0 indicates LS_ACC
  127. * (e.g. value is 0x02xxxxxx).
  128. *
  129. * Note: Similarly, a CT Reject may be reported in 2 ways:
  130. * a) A status of FC_CTELS_STATUS_OK is returned. The caller
  131. * is to look into the CT receive payload to determine
  132. * Accept or Reject (by contents of word 2). The reject
  133. * data will be in word 3.
  134. * b) A status of FC_CTELS_STATUS_REJECT is returned, The
  135. * rjt_data field will contain valid data.
  136. *
  137. * Note: x_RJT/BSY status will indicae that the rjt_data field
  138. * is valid and contains the reason/explanation values.
  139. */
  140. uint32_t status; /* See FC_CTELS_STATUS_xxx */
  141. /* valid if status is not FC_CTELS_STATUS_OK */
  142. struct {
  143. uint8_t action; /* fragment_id for CT REJECT */
  144. uint8_t reason_code;
  145. uint8_t reason_explanation;
  146. uint8_t vendor_unique;
  147. } rjt_data;
  148. };
  149. /* FC_BSG_HST_CT : */
  150. /* Request:
  151. * This message requests that a CT Request be performed with the
  152. * indicated N_Port_ID. The driver is responsible for logging in with
  153. * the fabric and/or N_Port_ID, etc as per FC rules. This request does
  154. * not mandate that the driver must enumerate the destination in the
  155. * transport. The driver is allowed to decide whether to enumerate it,
  156. * and whether to tear it down after the request.
  157. */
  158. struct fc_bsg_host_ct {
  159. uint8_t reserved;
  160. /* FC Address Identier of the remote port to send the ELS to */
  161. uint8_t port_id[3];
  162. /*
  163. * We need words 0-2 of the generic preamble for the LLD's
  164. */
  165. uint32_t preamble_word0; /* revision & IN_ID */
  166. uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
  167. uint32_t preamble_word2; /* Cmd Code, Max Size */
  168. };
  169. /* Response:
  170. *
  171. * The reply structure is an fc_bsg_ctels_reply structure
  172. */
  173. /* FC_BSG_HST_VENDOR : */
  174. /* Request:
  175. * Note: When specifying vendor_id, be sure to read the Vendor Type and ID
  176. * formatting requirements specified in scsi_netlink.h
  177. */
  178. struct fc_bsg_host_vendor {
  179. /*
  180. * Identifies the vendor that the message is formatted for. This
  181. * should be the recipient of the message.
  182. */
  183. uint64_t vendor_id;
  184. /* start of vendor command area */
  185. uint32_t vendor_cmd[0];
  186. };
  187. /* Response:
  188. */
  189. struct fc_bsg_host_vendor_reply {
  190. /* start of vendor response area */
  191. uint32_t vendor_rsp[0];
  192. };
  193. /*
  194. * FC Remote Port Messages
  195. */
  196. /* FC_BSG_RPT_ELS : */
  197. /* Request:
  198. * This message requests that an ELS be performed with the rport.
  199. */
  200. struct fc_bsg_rport_els {
  201. /*
  202. * ELS Command Code being sent (must be the same as
  203. * byte 0 of the payload)
  204. */
  205. uint8_t els_code;
  206. };
  207. /* Response:
  208. *
  209. * The reply structure is an fc_bsg_ctels_reply structure
  210. */
  211. /* FC_BSG_RPT_CT : */
  212. /* Request:
  213. * This message requests that a CT Request be performed with the rport.
  214. */
  215. struct fc_bsg_rport_ct {
  216. /*
  217. * We need words 0-2 of the generic preamble for the LLD's
  218. */
  219. uint32_t preamble_word0; /* revision & IN_ID */
  220. uint32_t preamble_word1; /* GS_Type, GS_SubType, Options, Rsvd */
  221. uint32_t preamble_word2; /* Cmd Code, Max Size */
  222. };
  223. /* Response:
  224. *
  225. * The reply structure is an fc_bsg_ctels_reply structure
  226. */
  227. /* request (CDB) structure of the sg_io_v4 */
  228. struct fc_bsg_request {
  229. uint32_t msgcode;
  230. union {
  231. struct fc_bsg_host_add_rport h_addrport;
  232. struct fc_bsg_host_del_rport h_delrport;
  233. struct fc_bsg_host_els h_els;
  234. struct fc_bsg_host_ct h_ct;
  235. struct fc_bsg_host_vendor h_vendor;
  236. struct fc_bsg_rport_els r_els;
  237. struct fc_bsg_rport_ct r_ct;
  238. } rqst_data;
  239. } __attribute__((packed));
  240. /* response (request sense data) structure of the sg_io_v4 */
  241. struct fc_bsg_reply {
  242. /*
  243. * The completion result. Result exists in two forms:
  244. * if negative, it is an -Exxx system errno value. There will
  245. * be no further reply information supplied.
  246. * else, it's the 4-byte scsi error result, with driver, host,
  247. * msg and status fields. The per-msgcode reply structure
  248. * will contain valid data.
  249. */
  250. uint32_t result;
  251. /* If there was reply_payload, how much was recevied ? */
  252. uint32_t reply_payload_rcv_len;
  253. union {
  254. struct fc_bsg_host_vendor_reply vendor_reply;
  255. struct fc_bsg_ctels_reply ctels_reply;
  256. } reply_data;
  257. };
  258. #endif /* SCSI_BSG_FC_H */