lpfc_bsg.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2010-2015 Emulex. All rights reserved. *
  5. * EMULEX and SLI are trademarks of Emulex. *
  6. * www.emulex.com *
  7. * *
  8. * This program is free software; you can redistribute it and/or *
  9. * modify it under the terms of version 2 of the GNU General *
  10. * Public License as published by the Free Software Foundation. *
  11. * This program is distributed in the hope that it will be useful. *
  12. * ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND *
  13. * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, *
  14. * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
  15. * DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD *
  16. * TO BE LEGALLY INVALID. See the GNU General Public License for *
  17. * more details, a copy of which can be found in the file COPYING *
  18. * included with this package. *
  19. *******************************************************************/
  20. /* bsg definitions
  21. * No pointers to user data are allowed, all application buffers and sizes will
  22. * derived through the bsg interface.
  23. *
  24. * These are the vendor unique structures passed in using the bsg
  25. * FC_BSG_HST_VENDOR message code type.
  26. */
  27. #define LPFC_BSG_VENDOR_SET_CT_EVENT 1
  28. #define LPFC_BSG_VENDOR_GET_CT_EVENT 2
  29. #define LPFC_BSG_VENDOR_SEND_MGMT_RESP 3
  30. #define LPFC_BSG_VENDOR_DIAG_MODE 4
  31. #define LPFC_BSG_VENDOR_DIAG_RUN_LOOPBACK 5
  32. #define LPFC_BSG_VENDOR_GET_MGMT_REV 6
  33. #define LPFC_BSG_VENDOR_MBOX 7
  34. #define LPFC_BSG_VENDOR_MENLO_CMD 8
  35. #define LPFC_BSG_VENDOR_MENLO_DATA 9
  36. #define LPFC_BSG_VENDOR_DIAG_MODE_END 10
  37. #define LPFC_BSG_VENDOR_LINK_DIAG_TEST 11
  38. struct set_ct_event {
  39. uint32_t command;
  40. uint32_t type_mask;
  41. uint32_t ev_req_id;
  42. uint32_t ev_reg_id;
  43. };
  44. struct get_ct_event {
  45. uint32_t command;
  46. uint32_t ev_reg_id;
  47. uint32_t ev_req_id;
  48. };
  49. struct get_ct_event_reply {
  50. uint32_t immed_data;
  51. uint32_t type;
  52. };
  53. struct send_mgmt_resp {
  54. uint32_t command;
  55. uint32_t tag;
  56. };
  57. #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
  58. #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
  59. struct diag_mode_set {
  60. uint32_t command;
  61. uint32_t type;
  62. uint32_t timeout;
  63. };
  64. struct sli4_link_diag {
  65. uint32_t command;
  66. uint32_t timeout;
  67. uint32_t test_id;
  68. uint32_t loops;
  69. uint32_t test_version;
  70. uint32_t error_action;
  71. };
  72. struct diag_mode_test {
  73. uint32_t command;
  74. };
  75. struct diag_status {
  76. uint32_t mbox_status;
  77. uint32_t shdr_status;
  78. uint32_t shdr_add_status;
  79. };
  80. #define LPFC_WWNN_TYPE 0
  81. #define LPFC_WWPN_TYPE 1
  82. struct get_mgmt_rev {
  83. uint32_t command;
  84. };
  85. #define MANAGEMENT_MAJOR_REV 1
  86. #define MANAGEMENT_MINOR_REV 1
  87. /* the MgmtRevInfo structure */
  88. struct MgmtRevInfo {
  89. uint32_t a_Major;
  90. uint32_t a_Minor;
  91. };
  92. struct get_mgmt_rev_reply {
  93. struct MgmtRevInfo info;
  94. };
  95. #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
  96. /* BSG mailbox request header */
  97. struct dfc_mbox_req {
  98. uint32_t command;
  99. uint32_t mbOffset;
  100. uint32_t inExtWLen;
  101. uint32_t outExtWLen;
  102. uint32_t extMboxTag;
  103. uint32_t extSeqNum;
  104. };
  105. /* Used for menlo command or menlo data. The xri is only used for menlo data */
  106. struct menlo_command {
  107. uint32_t cmd;
  108. uint32_t xri;
  109. };
  110. struct menlo_response {
  111. uint32_t xri; /* return the xri of the iocb exchange */
  112. };
  113. /*
  114. * macros and data structures for handling sli-config mailbox command
  115. * pass-through support, this header file is shared between user and
  116. * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
  117. * with macro names prefixed with bsg_, as the macros defined in
  118. * lpfc_hw4.h are not accessible from user space.
  119. */
  120. /* Macros to deal with bit fields. Each bit field must have 3 #defines
  121. * associated with it (_SHIFT, _MASK, and _WORD).
  122. * EG. For a bit field that is in the 7th bit of the "field4" field of a
  123. * structure and is 2 bits in size the following #defines must exist:
  124. * struct temp {
  125. * uint32_t field1;
  126. * uint32_t field2;
  127. * uint32_t field3;
  128. * uint32_t field4;
  129. * #define example_bit_field_SHIFT 7
  130. * #define example_bit_field_MASK 0x03
  131. * #define example_bit_field_WORD field4
  132. * uint32_t field5;
  133. * };
  134. * Then the macros below may be used to get or set the value of that field.
  135. * EG. To get the value of the bit field from the above example:
  136. * struct temp t1;
  137. * value = bsg_bf_get(example_bit_field, &t1);
  138. * And then to set that bit field:
  139. * bsg_bf_set(example_bit_field, &t1, 2);
  140. * Or clear that bit field:
  141. * bsg_bf_set(example_bit_field, &t1, 0);
  142. */
  143. #define bsg_bf_get_le32(name, ptr) \
  144. ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
  145. #define bsg_bf_get(name, ptr) \
  146. (((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
  147. #define bsg_bf_set_le32(name, ptr, value) \
  148. ((ptr)->name##_WORD = cpu_to_le32(((((value) & \
  149. name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
  150. ~(name##_MASK << name##_SHIFT)))))
  151. #define bsg_bf_set(name, ptr, value) \
  152. ((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
  153. ((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
  154. /*
  155. * The sli_config structure specified here is based on the following
  156. * restriction:
  157. *
  158. * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
  159. * carrying HBD.
  160. * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
  161. * without carrying HBDs.
  162. */
  163. struct lpfc_sli_config_mse {
  164. uint32_t pa_lo;
  165. uint32_t pa_hi;
  166. uint32_t buf_len;
  167. #define lpfc_mbox_sli_config_mse_len_SHIFT 0
  168. #define lpfc_mbox_sli_config_mse_len_MASK 0xffffff
  169. #define lpfc_mbox_sli_config_mse_len_WORD buf_len
  170. };
  171. struct lpfc_sli_config_hbd {
  172. uint32_t buf_len;
  173. #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT 0
  174. #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK 0xffffff
  175. #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD buf_len
  176. uint32_t pa_lo;
  177. uint32_t pa_hi;
  178. };
  179. struct lpfc_sli_config_hdr {
  180. uint32_t word1;
  181. #define lpfc_mbox_hdr_emb_SHIFT 0
  182. #define lpfc_mbox_hdr_emb_MASK 0x00000001
  183. #define lpfc_mbox_hdr_emb_WORD word1
  184. #define lpfc_mbox_hdr_mse_cnt_SHIFT 3
  185. #define lpfc_mbox_hdr_mse_cnt_MASK 0x0000001f
  186. #define lpfc_mbox_hdr_mse_cnt_WORD word1
  187. uint32_t payload_length;
  188. uint32_t tag_lo;
  189. uint32_t tag_hi;
  190. uint32_t reserved5;
  191. };
  192. struct lpfc_sli_config_emb0_subsys {
  193. struct lpfc_sli_config_hdr sli_config_hdr;
  194. #define LPFC_MBX_SLI_CONFIG_MAX_MSE 19
  195. struct lpfc_sli_config_mse mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
  196. uint32_t padding;
  197. uint32_t word64;
  198. #define lpfc_emb0_subcmnd_opcode_SHIFT 0
  199. #define lpfc_emb0_subcmnd_opcode_MASK 0xff
  200. #define lpfc_emb0_subcmnd_opcode_WORD word64
  201. #define lpfc_emb0_subcmnd_subsys_SHIFT 8
  202. #define lpfc_emb0_subcmnd_subsys_MASK 0xff
  203. #define lpfc_emb0_subcmnd_subsys_WORD word64
  204. /* Subsystem FCOE (0x0C) OpCodes */
  205. #define SLI_CONFIG_SUBSYS_FCOE 0x0C
  206. #define FCOE_OPCODE_READ_FCF 0x08
  207. #define FCOE_OPCODE_ADD_FCF 0x09
  208. #define FCOE_OPCODE_SET_DPORT_MODE 0x27
  209. #define FCOE_OPCODE_GET_DPORT_RESULTS 0x28
  210. };
  211. struct lpfc_sli_config_emb1_subsys {
  212. struct lpfc_sli_config_hdr sli_config_hdr;
  213. uint32_t word6;
  214. #define lpfc_emb1_subcmnd_opcode_SHIFT 0
  215. #define lpfc_emb1_subcmnd_opcode_MASK 0xff
  216. #define lpfc_emb1_subcmnd_opcode_WORD word6
  217. #define lpfc_emb1_subcmnd_subsys_SHIFT 8
  218. #define lpfc_emb1_subcmnd_subsys_MASK 0xff
  219. #define lpfc_emb1_subcmnd_subsys_WORD word6
  220. /* Subsystem COMN (0x01) OpCodes */
  221. #define SLI_CONFIG_SUBSYS_COMN 0x01
  222. #define COMN_OPCODE_GET_PROFILE_CONFIG 0xA4
  223. #define COMN_OPCODE_READ_OBJECT 0xAB
  224. #define COMN_OPCODE_WRITE_OBJECT 0xAC
  225. #define COMN_OPCODE_READ_OBJECT_LIST 0xAD
  226. #define COMN_OPCODE_DELETE_OBJECT 0xAE
  227. #define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES 0x79
  228. #define COMN_OPCODE_GET_CNTL_ATTRIBUTES 0x20
  229. uint32_t timeout;
  230. uint32_t request_length;
  231. uint32_t word9;
  232. #define lpfc_subcmnd_version_SHIFT 0
  233. #define lpfc_subcmnd_version_MASK 0xff
  234. #define lpfc_subcmnd_version_WORD word9
  235. uint32_t word10;
  236. #define lpfc_subcmnd_ask_rd_len_SHIFT 0
  237. #define lpfc_subcmnd_ask_rd_len_MASK 0xffffff
  238. #define lpfc_subcmnd_ask_rd_len_WORD word10
  239. uint32_t rd_offset;
  240. uint32_t obj_name[26];
  241. uint32_t hbd_count;
  242. #define LPFC_MBX_SLI_CONFIG_MAX_HBD 8
  243. struct lpfc_sli_config_hbd hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
  244. };
  245. struct lpfc_sli_config_mbox {
  246. uint32_t word0;
  247. #define lpfc_mqe_status_SHIFT 16
  248. #define lpfc_mqe_status_MASK 0x0000FFFF
  249. #define lpfc_mqe_status_WORD word0
  250. #define lpfc_mqe_command_SHIFT 8
  251. #define lpfc_mqe_command_MASK 0x000000FF
  252. #define lpfc_mqe_command_WORD word0
  253. union {
  254. struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
  255. struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
  256. } un;
  257. };
  258. /* driver only */
  259. #define SLI_CONFIG_NOT_HANDLED 0
  260. #define SLI_CONFIG_HANDLED 1