lpfc_bsg.h 9.3 KB

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