lpfc_bsg.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /*******************************************************************
  2. * This file is part of the Emulex Linux Device Driver for *
  3. * Fibre Channel Host Bus Adapters. *
  4. * Copyright (C) 2010 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_TEST 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. struct set_ct_event {
  37. uint32_t command;
  38. uint32_t type_mask;
  39. uint32_t ev_req_id;
  40. uint32_t ev_reg_id;
  41. };
  42. struct get_ct_event {
  43. uint32_t command;
  44. uint32_t ev_reg_id;
  45. uint32_t ev_req_id;
  46. };
  47. struct get_ct_event_reply {
  48. uint32_t immed_data;
  49. uint32_t type;
  50. };
  51. struct send_mgmt_resp {
  52. uint32_t command;
  53. uint32_t tag;
  54. };
  55. #define INTERNAL_LOOP_BACK 0x1 /* adapter short cuts the loop internally */
  56. #define EXTERNAL_LOOP_BACK 0x2 /* requires an external loopback plug */
  57. struct diag_mode_set {
  58. uint32_t command;
  59. uint32_t type;
  60. uint32_t timeout;
  61. };
  62. struct diag_mode_test {
  63. uint32_t command;
  64. };
  65. #define LPFC_WWNN_TYPE 0
  66. #define LPFC_WWPN_TYPE 1
  67. struct get_mgmt_rev {
  68. uint32_t command;
  69. };
  70. #define MANAGEMENT_MAJOR_REV 1
  71. #define MANAGEMENT_MINOR_REV 0
  72. /* the MgmtRevInfo structure */
  73. struct MgmtRevInfo {
  74. uint32_t a_Major;
  75. uint32_t a_Minor;
  76. };
  77. struct get_mgmt_rev_reply {
  78. struct MgmtRevInfo info;
  79. };
  80. #define BSG_MBOX_SIZE 4096 /* mailbox command plus extended data */
  81. struct dfc_mbox_req {
  82. uint32_t command;
  83. uint32_t mbOffset;
  84. uint32_t inExtWLen;
  85. uint32_t outExtWLen;
  86. };
  87. /* Used for menlo command or menlo data. The xri is only used for menlo data */
  88. struct menlo_command {
  89. uint32_t cmd;
  90. uint32_t xri;
  91. };
  92. struct menlo_response {
  93. uint32_t xri; /* return the xri of the iocb exchange */
  94. };
  95. /*
  96. * macros and data structures for handling sli-config mailbox command
  97. * pass-through support, this header file is shared between user and
  98. * kernel spaces, note the set of macros are duplicates from lpfc_hw4.h,
  99. * with macro names prefixed with bsg_, as the macros defined in
  100. * lpfc_hw4.h are not accessible from user space.
  101. */
  102. /* Macros to deal with bit fields. Each bit field must have 3 #defines
  103. * associated with it (_SHIFT, _MASK, and _WORD).
  104. * EG. For a bit field that is in the 7th bit of the "field4" field of a
  105. * structure and is 2 bits in size the following #defines must exist:
  106. * struct temp {
  107. * uint32_t field1;
  108. * uint32_t field2;
  109. * uint32_t field3;
  110. * uint32_t field4;
  111. * #define example_bit_field_SHIFT 7
  112. * #define example_bit_field_MASK 0x03
  113. * #define example_bit_field_WORD field4
  114. * uint32_t field5;
  115. * };
  116. * Then the macros below may be used to get or set the value of that field.
  117. * EG. To get the value of the bit field from the above example:
  118. * struct temp t1;
  119. * value = bsg_bf_get(example_bit_field, &t1);
  120. * And then to set that bit field:
  121. * bsg_bf_set(example_bit_field, &t1, 2);
  122. * Or clear that bit field:
  123. * bsg_bf_set(example_bit_field, &t1, 0);
  124. */
  125. #define bsg_bf_get_le32(name, ptr) \
  126. ((le32_to_cpu((ptr)->name##_WORD) >> name##_SHIFT) & name##_MASK)
  127. #define bsg_bf_get(name, ptr) \
  128. (((ptr)->name##_WORD >> name##_SHIFT) & name##_MASK)
  129. #define bsg_bf_set_le32(name, ptr, value) \
  130. ((ptr)->name##_WORD = cpu_to_le32(((((value) & \
  131. name##_MASK) << name##_SHIFT) | (le32_to_cpu((ptr)->name##_WORD) & \
  132. ~(name##_MASK << name##_SHIFT)))))
  133. #define bsg_bf_set(name, ptr, value) \
  134. ((ptr)->name##_WORD = ((((value) & name##_MASK) << name##_SHIFT) | \
  135. ((ptr)->name##_WORD & ~(name##_MASK << name##_SHIFT))))
  136. /*
  137. * The sli_config structure specified here is based on the following
  138. * restriction:
  139. *
  140. * -- SLI_CONFIG EMB=0, carrying MSEs, will carry subcommands without
  141. * carrying HBD.
  142. * -- SLI_CONFIG EMB=1, not carrying MSE, will carry subcommands with or
  143. * without carrying HBDs.
  144. */
  145. struct lpfc_sli_config_mse {
  146. uint32_t pa_lo;
  147. uint32_t pa_hi;
  148. uint32_t buf_len;
  149. #define lpfc_mbox_sli_config_mse_len_SHIFT 0
  150. #define lpfc_mbox_sli_config_mse_len_MASK 0xffffff
  151. #define lpfc_mbox_sli_config_mse_len_WORD buf_len
  152. };
  153. struct lpfc_sli_config_subcmd_hbd {
  154. uint32_t buf_len;
  155. #define lpfc_mbox_sli_config_ecmn_hbd_len_SHIFT 0
  156. #define lpfc_mbox_sli_config_ecmn_hbd_len_MASK 0xffffff
  157. #define lpfc_mbox_sli_config_ecmn_hbd_len_WORD buf_len
  158. uint32_t pa_lo;
  159. uint32_t pa_hi;
  160. };
  161. struct lpfc_sli_config_hdr {
  162. uint32_t word1;
  163. #define lpfc_mbox_hdr_emb_SHIFT 0
  164. #define lpfc_mbox_hdr_emb_MASK 0x00000001
  165. #define lpfc_mbox_hdr_emb_WORD word1
  166. #define lpfc_mbox_hdr_mse_cnt_SHIFT 3
  167. #define lpfc_mbox_hdr_mse_cnt_MASK 0x0000001f
  168. #define lpfc_mbox_hdr_mse_cnt_WORD word1
  169. uint32_t payload_length;
  170. uint32_t tag_lo;
  171. uint32_t tag_hi;
  172. uint32_t reserved5;
  173. };
  174. struct lpfc_sli_config_generic {
  175. struct lpfc_sli_config_hdr sli_config_hdr;
  176. #define LPFC_MBX_SLI_CONFIG_MAX_MSE 19
  177. struct lpfc_sli_config_mse mse[LPFC_MBX_SLI_CONFIG_MAX_MSE];
  178. };
  179. struct lpfc_sli_config_subcmnd {
  180. struct lpfc_sli_config_hdr sli_config_hdr;
  181. uint32_t word6;
  182. #define lpfc_subcmnd_opcode_SHIFT 0
  183. #define lpfc_subcmnd_opcode_MASK 0xff
  184. #define lpfc_subcmnd_opcode_WORD word6
  185. #define lpfc_subcmnd_subsys_SHIFT 8
  186. #define lpfc_subcmnd_subsys_MASK 0xff
  187. #define lpfc_subcmnd_subsys_WORD word6
  188. uint32_t timeout;
  189. uint32_t request_length;
  190. uint32_t word9;
  191. #define lpfc_subcmnd_version_SHIFT 0
  192. #define lpfc_subcmnd_version_MASK 0xff
  193. #define lpfc_subcmnd_version_WORD word9
  194. uint32_t word10;
  195. #define lpfc_subcmnd_ask_rd_len_SHIFT 0
  196. #define lpfc_subcmnd_ask_rd_len_MASK 0xffffff
  197. #define lpfc_subcmnd_ask_rd_len_WORD word10
  198. uint32_t rd_offset;
  199. uint32_t obj_name[26];
  200. uint32_t hbd_count;
  201. #define LPFC_MBX_SLI_CONFIG_MAX_HBD 10
  202. struct lpfc_sli_config_subcmd_hbd hbd[LPFC_MBX_SLI_CONFIG_MAX_HBD];
  203. };
  204. struct lpfc_sli_config_mbox {
  205. uint32_t word0;
  206. #define lpfc_mqe_status_SHIFT 16
  207. #define lpfc_mqe_status_MASK 0x0000FFFF
  208. #define lpfc_mqe_status_WORD word0
  209. #define lpfc_mqe_command_SHIFT 8
  210. #define lpfc_mqe_command_MASK 0x000000FF
  211. #define lpfc_mqe_command_WORD word0
  212. union {
  213. struct lpfc_sli_config_generic sli_config_generic;
  214. struct lpfc_sli_config_subcmnd sli_config_subcmnd;
  215. } un;
  216. };