scsi_bsg_fc.h 7.9 KB

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