lpfc_bsg.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2017-2022 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_DIAG_MODE_END 10
  37. #define LPFC_BSG_VENDOR_LINK_DIAG_TEST 11
  38. #define LPFC_BSG_VENDOR_FORCED_LINK_SPEED 14
  39. #define LPFC_BSG_VENDOR_RAS_GET_LWPD 16
  40. #define LPFC_BSG_VENDOR_RAS_GET_FWLOG 17
  41. #define LPFC_BSG_VENDOR_RAS_GET_CONFIG 18
  42. #define LPFC_BSG_VENDOR_RAS_SET_CONFIG 19
  43. #define LPFC_BSG_VENDOR_GET_TRUNK_INFO 20
  44. #define LPFC_BSG_VENDOR_GET_CGNBUF_INFO 21
  45. struct set_ct_event {
  46. uint32_t command;
  47. uint32_t type_mask;
  48. uint32_t ev_req_id;
  49. uint32_t ev_reg_id;
  50. };
  51. struct get_ct_event {
  52. uint32_t command;
  53. uint32_t ev_reg_id;
  54. uint32_t ev_req_id;
  55. };
  56. struct get_ct_event_reply {
  57. uint32_t immed_data;
  58. uint32_t type;
  59. };
  60. struct send_mgmt_resp {
  61. uint32_t command;
  62. uint32_t tag;
  63. };
  64. #define DISABLE_LOOP_BACK 0x0 /* disables loop back */
  65. #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
  66. #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
  67. struct diag_mode_set {
  68. uint32_t command;
  69. uint32_t type;
  70. uint32_t timeout;
  71. uint32_t physical_link;
  72. };
  73. struct sli4_link_diag {
  74. uint32_t command;
  75. uint32_t timeout;
  76. uint32_t test_id;
  77. uint32_t loops;
  78. uint32_t test_version;
  79. uint32_t error_action;
  80. };
  81. struct diag_mode_test {
  82. uint32_t command;
  83. };
  84. struct diag_status {
  85. uint32_t mbox_status;
  86. uint32_t shdr_status;
  87. uint32_t shdr_add_status;
  88. };
  89. #define LPFC_WWNN_TYPE 0
  90. #define LPFC_WWPN_TYPE 1
  91. struct get_mgmt_rev {
  92. uint32_t command;
  93. };
  94. #define MANAGEMENT_MAJOR_REV 1
  95. #define MANAGEMENT_MINOR_REV 1
  96. /* the MgmtRevInfo structure */
  97. struct MgmtRevInfo {
  98. uint32_t a_Major;
  99. uint32_t a_Minor;
  100. };
  101. struct get_mgmt_rev_reply {
  102. struct MgmtRevInfo info;
  103. };
  104. #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
  105. /* BSG mailbox request header */
  106. struct dfc_mbox_req {
  107. uint32_t command;
  108. uint32_t mbOffset;
  109. uint32_t inExtWLen;
  110. uint32_t outExtWLen;
  111. uint32_t extMboxTag;
  112. uint32_t extSeqNum;
  113. };
  114. /*
  115. * macros and data structures for handling sli-config mailbox command
  116. * pass-through support, this header file is shared between user and
  117. * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
  118. * with macro names prefixed with bsg_, as the macros defined in
  119. * lpfc_hw4.h are not accessible from user space.
  120. */
  121. /* Macros to deal with bit fields. Each bit field must have 3 #defines
  122. * associated with it (_SHIFT, _MASK, and _WORD).
  123. * EG. For a bit field that is in the 7th bit of the "field4" field of a
  124. * structure and is 2 bits in size the following #defines must exist:
  125. * struct temp {
  126. * uint32_t field1;
  127. * uint32_t field2;
  128. * uint32_t field3;
  129. * uint32_t field4;
  130. * #define example_bit_field_SHIFT 7
  131. * #define example_bit_field_MASK 0x03
  132. * #define example_bit_field_WORD field4
  133. * uint32_t field5;
  134. * };
  135. * Then the macros below may be used to get or set the value of that field.
  136. * EG. To get the value of the bit field from the above example:
  137. * struct temp t1;
  138. * value = bsg_bf_get(example_bit_field, &t1);
  139. * And then to set that bit field:
  140. * bsg_bf_set(example_bit_field, &t1, 2);
  141. * Or clear that bit field:
  142. * bsg_bf_set(example_bit_field, &t1, 0);
  143. */
  144. #define bsg_bf_get_le32(name, ptr) \
  145. ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
  146. #define bsg_bf_get(name, ptr) \
  147. (((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
  148. #define bsg_bf_set_le32(name, ptr, value) \
  149. ((ptr)->name##_WORD = cpu_to_le32(((((value) & \
  150. name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
  151. ~(name##_MASK << name##_SHIFT)))))
  152. #define bsg_bf_set(name, ptr, value) \
  153. ((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
  154. ((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
  155. /*
  156. * The sli_config structure specified here is based on the following
  157. * restriction:
  158. *
  159. * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
  160. * carrying HBD.
  161. * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
  162. * without carrying HBDs.
  163. */
  164. struct lpfc_sli_config_mse {
  165. uint32_t pa_lo;
  166. uint32_t pa_hi;
  167. uint32_t buf_len;
  168. #define lpfc_mbox_sli_config_mse_len_SHIFT 0
  169. #define lpfc_mbox_sli_config_mse_len_MASK 0xffffff
  170. #define lpfc_mbox_sli_config_mse_len_WORD buf_len
  171. };
  172. struct lpfc_sli_config_hbd {
  173. uint32_t buf_len;
  174. #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT 0
  175. #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK 0xffffff
  176. #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD buf_len
  177. uint32_t pa_lo;
  178. uint32_t pa_hi;
  179. };
  180. struct lpfc_sli_config_hdr {
  181. uint32_t word1;
  182. #define lpfc_mbox_hdr_emb_SHIFT 0
  183. #define lpfc_mbox_hdr_emb_MASK 0x00000001
  184. #define lpfc_mbox_hdr_emb_WORD word1
  185. #define lpfc_mbox_hdr_mse_cnt_SHIFT 3
  186. #define lpfc_mbox_hdr_mse_cnt_MASK 0x0000001f
  187. #define lpfc_mbox_hdr_mse_cnt_WORD word1
  188. uint32_t payload_length;
  189. uint32_t tag_lo;
  190. uint32_t tag_hi;
  191. uint32_t reserved5;
  192. };
  193. #define LPFC_CSF_BOOT_DEV 0x1D
  194. #define LPFC_CSF_QUERY 0
  195. #define LPFC_CSF_SAVE 1
  196. struct lpfc_sli_config_emb0_subsys {
  197. struct lpfc_sli_config_hdr sli_config_hdr;
  198. #define LPFC_MBX_SLI_CONFIG_MAX_MSE 19
  199. struct lpfc_sli_config_mse mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
  200. uint32_t padding;
  201. uint32_t word64;
  202. #define lpfc_emb0_subcmnd_opcode_SHIFT 0
  203. #define lpfc_emb0_subcmnd_opcode_MASK 0xff
  204. #define lpfc_emb0_subcmnd_opcode_WORD word64
  205. #define lpfc_emb0_subcmnd_subsys_SHIFT 8
  206. #define lpfc_emb0_subcmnd_subsys_MASK 0xff
  207. #define lpfc_emb0_subcmnd_subsys_WORD word64
  208. /* Subsystem FCOE (0x0C) OpCodes */
  209. #define SLI_CONFIG_SUBSYS_FCOE 0x0C
  210. #define FCOE_OPCODE_READ_FCF 0x08
  211. #define FCOE_OPCODE_ADD_FCF 0x09
  212. #define FCOE_OPCODE_SET_DPORT_MODE 0x27
  213. #define FCOE_OPCODE_GET_DPORT_RESULTS 0x28
  214. uint32_t timeout; /* comn_set_feature timeout */
  215. uint32_t request_length; /* comn_set_feature request len */
  216. uint32_t version; /* comn_set_feature version */
  217. uint32_t csf_feature; /* comn_set_feature feature */
  218. uint32_t word69; /* comn_set_feature parameter len */
  219. uint32_t word70; /* comn_set_feature parameter val0 */
  220. #define lpfc_emb0_subcmnd_csf_p0_SHIFT 0
  221. #define lpfc_emb0_subcmnd_csf_p0_MASK 0x3
  222. #define lpfc_emb0_subcmnd_csf_p0_WORD word70
  223. };
  224. struct lpfc_sli_config_emb1_subsys {
  225. struct lpfc_sli_config_hdr sli_config_hdr;
  226. uint32_t word6;
  227. #define lpfc_emb1_subcmnd_opcode_SHIFT 0
  228. #define lpfc_emb1_subcmnd_opcode_MASK 0xff
  229. #define lpfc_emb1_subcmnd_opcode_WORD word6
  230. #define lpfc_emb1_subcmnd_subsys_SHIFT 8
  231. #define lpfc_emb1_subcmnd_subsys_MASK 0xff
  232. #define lpfc_emb1_subcmnd_subsys_WORD word6
  233. /* Subsystem COMN (0x01) OpCodes */
  234. #define SLI_CONFIG_SUBSYS_COMN 0x01
  235. #define COMN_OPCODE_GET_PROFILE_CONFIG 0xA4
  236. #define COMN_OPCODE_READ_OBJECT 0xAB
  237. #define COMN_OPCODE_WRITE_OBJECT 0xAC
  238. #define COMN_OPCODE_READ_OBJECT_LIST 0xAD
  239. #define COMN_OPCODE_DELETE_OBJECT 0xAE
  240. #define COMN_OPCODE_SET_FEATURES 0xBF
  241. #define COMN_OPCODE_GET_CNTL_ADDL_ATTRIBUTES 0x79
  242. #define COMN_OPCODE_GET_CNTL_ATTRIBUTES 0x20
  243. uint32_t timeout;
  244. uint32_t request_length;
  245. uint32_t word9;
  246. #define lpfc_subcmnd_version_SHIFT 0
  247. #define lpfc_subcmnd_version_MASK 0xff
  248. #define lpfc_subcmnd_version_WORD word9
  249. uint32_t word10;
  250. #define lpfc_subcmnd_ask_rd_len_SHIFT 0
  251. #define lpfc_subcmnd_ask_rd_len_MASK 0xffffff
  252. #define lpfc_subcmnd_ask_rd_len_WORD word10
  253. uint32_t rd_offset;
  254. uint32_t obj_name[26];
  255. uint32_t hbd_count;
  256. #define LPFC_MBX_SLI_CONFIG_MAX_HBD 8
  257. struct lpfc_sli_config_hbd hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
  258. };
  259. struct lpfc_sli_config_mbox {
  260. uint32_t word0;
  261. #define lpfc_mqe_status_SHIFT 16
  262. #define lpfc_mqe_status_MASK 0x0000FFFF
  263. #define lpfc_mqe_status_WORD word0
  264. #define lpfc_mqe_command_SHIFT 8
  265. #define lpfc_mqe_command_MASK 0x000000FF
  266. #define lpfc_mqe_command_WORD word0
  267. union {
  268. struct lpfc_sli_config_emb0_subsys sli_config_emb0_subsys;
  269. struct lpfc_sli_config_emb1_subsys sli_config_emb1_subsys;
  270. } un;
  271. };
  272. #define LPFC_FORCED_LINK_SPEED_NOT_SUPPORTED 0
  273. #define LPFC_FORCED_LINK_SPEED_SUPPORTED 1
  274. struct get_forced_link_speed_support {
  275. uint32_t command;
  276. };
  277. struct forced_link_speed_support_reply {
  278. uint8_t supported;
  279. };
  280. struct lpfc_bsg_ras_req {
  281. uint32_t command;
  282. };
  283. struct lpfc_bsg_get_fwlog_req {
  284. uint32_t command;
  285. uint32_t read_size;
  286. uint32_t read_offset;
  287. };
  288. struct lpfc_bsg_get_ras_lwpd {
  289. uint32_t offset;
  290. uint32_t wrap_count;
  291. };
  292. struct lpfc_bsg_set_ras_config_req {
  293. uint32_t command;
  294. uint8_t action;
  295. #define LPFC_RASACTION_STOP_LOGGING 0x00
  296. #define LPFC_RASACTION_START_LOGGING 0x01
  297. uint8_t log_level;
  298. };
  299. struct lpfc_bsg_get_ras_config_reply {
  300. uint8_t state;
  301. #define LPFC_RASLOG_STATE_STOPPED 0x00
  302. #define LPFC_RASLOG_STATE_RUNNING 0x01
  303. uint8_t log_level;
  304. uint32_t log_buff_sz;
  305. };
  306. struct lpfc_trunk_info {
  307. uint32_t word0;
  308. #define lpfc_trunk_info_link_status_SHIFT 0
  309. #define lpfc_trunk_info_link_status_MASK 1
  310. #define lpfc_trunk_info_link_status_WORD word0
  311. #define lpfc_trunk_info_trunk_active0_SHIFT 8
  312. #define lpfc_trunk_info_trunk_active0_MASK 1
  313. #define lpfc_trunk_info_trunk_active0_WORD word0
  314. #define lpfc_trunk_info_trunk_active1_SHIFT 9
  315. #define lpfc_trunk_info_trunk_active1_MASK 1
  316. #define lpfc_trunk_info_trunk_active1_WORD word0
  317. #define lpfc_trunk_info_trunk_active2_SHIFT 10
  318. #define lpfc_trunk_info_trunk_active2_MASK 1
  319. #define lpfc_trunk_info_trunk_active2_WORD word0
  320. #define lpfc_trunk_info_trunk_active3_SHIFT 11
  321. #define lpfc_trunk_info_trunk_active3_MASK 1
  322. #define lpfc_trunk_info_trunk_active3_WORD word0
  323. #define lpfc_trunk_info_trunk_config0_SHIFT 12
  324. #define lpfc_trunk_info_trunk_config0_MASK 1
  325. #define lpfc_trunk_info_trunk_config0_WORD word0
  326. #define lpfc_trunk_info_trunk_config1_SHIFT 13
  327. #define lpfc_trunk_info_trunk_config1_MASK 1
  328. #define lpfc_trunk_info_trunk_config1_WORD word0
  329. #define lpfc_trunk_info_trunk_config2_SHIFT 14
  330. #define lpfc_trunk_info_trunk_config2_MASK 1
  331. #define lpfc_trunk_info_trunk_config2_WORD word0
  332. #define lpfc_trunk_info_trunk_config3_SHIFT 15
  333. #define lpfc_trunk_info_trunk_config3_MASK 1
  334. #define lpfc_trunk_info_trunk_config3_WORD word0
  335. uint16_t port_speed;
  336. uint16_t logical_speed;
  337. uint32_t reserved3;
  338. };
  339. struct get_trunk_info_req {
  340. uint32_t command;
  341. };
  342. struct get_cgnbuf_info_req {
  343. uint32_t command;
  344. uint32_t read_size;
  345. uint32_t reset;
  346. #define LPFC_BSG_CGN_RESET_STAT 1
  347. };
  348. /* driver only */
  349. #define SLI_CONFIG_NOT_HANDLED 0
  350. #define SLI_CONFIG_HANDLED 1