qed_hw.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. /* QLogic qed NIC Driver
  2. * Copyright (c) 2015 QLogic Corporation
  3. *
  4. * This software is available under the terms of the GNU General Public License
  5. * (GPL) Version 2, available from the file COPYING in the main directory of
  6. * this source tree.
  7. */
  8. #ifndef _QED_HW_H
  9. #define _QED_HW_H
  10. #include <linux/types.h>
  11. #include <linux/bitops.h>
  12. #include <linux/slab.h>
  13. #include <linux/string.h>
  14. #include "qed.h"
  15. #include "qed_dev_api.h"
  16. /* Forward decleration */
  17. struct qed_ptt;
  18. enum reserved_ptts {
  19. RESERVED_PTT_EDIAG,
  20. RESERVED_PTT_USER_SPACE,
  21. RESERVED_PTT_MAIN,
  22. RESERVED_PTT_DPC,
  23. RESERVED_PTT_MAX
  24. };
  25. enum _dmae_cmd_dst_mask {
  26. DMAE_CMD_DST_MASK_NONE = 0,
  27. DMAE_CMD_DST_MASK_PCIE = 1,
  28. DMAE_CMD_DST_MASK_GRC = 2
  29. };
  30. enum _dmae_cmd_src_mask {
  31. DMAE_CMD_SRC_MASK_PCIE = 0,
  32. DMAE_CMD_SRC_MASK_GRC = 1
  33. };
  34. enum _dmae_cmd_crc_mask {
  35. DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
  36. DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
  37. };
  38. /* definitions for DMA constants */
  39. #define DMAE_GO_VALUE 0x1
  40. #define DMAE_COMPLETION_VAL 0xD1AE
  41. #define DMAE_CMD_ENDIANITY 0x2
  42. #define DMAE_CMD_SIZE 14
  43. #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
  44. #define DMAE_MIN_WAIT_TIME 0x2
  45. #define DMAE_MAX_CLIENTS 32
  46. /**
  47. * @brief qed_gtt_init - Initialize GTT windows
  48. *
  49. * @param p_hwfn
  50. */
  51. void qed_gtt_init(struct qed_hwfn *p_hwfn);
  52. /**
  53. * @brief qed_ptt_invalidate - Forces all ptt entries to be re-configured
  54. *
  55. * @param p_hwfn
  56. */
  57. void qed_ptt_invalidate(struct qed_hwfn *p_hwfn);
  58. /**
  59. * @brief qed_ptt_pool_alloc - Allocate and initialize PTT pool
  60. *
  61. * @param p_hwfn
  62. *
  63. * @return struct _qed_status - success (0), negative - error.
  64. */
  65. int qed_ptt_pool_alloc(struct qed_hwfn *p_hwfn);
  66. /**
  67. * @brief qed_ptt_pool_free -
  68. *
  69. * @param p_hwfn
  70. */
  71. void qed_ptt_pool_free(struct qed_hwfn *p_hwfn);
  72. /**
  73. * @brief qed_ptt_get_hw_addr - Get PTT's GRC/HW address
  74. *
  75. * @param p_hwfn
  76. * @param p_ptt
  77. *
  78. * @return u32
  79. */
  80. u32 qed_ptt_get_hw_addr(struct qed_hwfn *p_hwfn,
  81. struct qed_ptt *p_ptt);
  82. /**
  83. * @brief qed_ptt_get_bar_addr - Get PPT's external BAR address
  84. *
  85. * @param p_hwfn
  86. * @param p_ptt
  87. *
  88. * @return u32
  89. */
  90. u32 qed_ptt_get_bar_addr(struct qed_ptt *p_ptt);
  91. /**
  92. * @brief qed_ptt_set_win - Set PTT Window's GRC BAR address
  93. *
  94. * @param p_hwfn
  95. * @param new_hw_addr
  96. * @param p_ptt
  97. */
  98. void qed_ptt_set_win(struct qed_hwfn *p_hwfn,
  99. struct qed_ptt *p_ptt,
  100. u32 new_hw_addr);
  101. /**
  102. * @brief qed_get_reserved_ptt - Get a specific reserved PTT
  103. *
  104. * @param p_hwfn
  105. * @param ptt_idx
  106. *
  107. * @return struct qed_ptt *
  108. */
  109. struct qed_ptt *qed_get_reserved_ptt(struct qed_hwfn *p_hwfn,
  110. enum reserved_ptts ptt_idx);
  111. /**
  112. * @brief qed_wr - Write value to BAR using the given ptt
  113. *
  114. * @param p_hwfn
  115. * @param p_ptt
  116. * @param val
  117. * @param hw_addr
  118. */
  119. void qed_wr(struct qed_hwfn *p_hwfn,
  120. struct qed_ptt *p_ptt,
  121. u32 hw_addr,
  122. u32 val);
  123. /**
  124. * @brief qed_rd - Read value from BAR using the given ptt
  125. *
  126. * @param p_hwfn
  127. * @param p_ptt
  128. * @param val
  129. * @param hw_addr
  130. */
  131. u32 qed_rd(struct qed_hwfn *p_hwfn,
  132. struct qed_ptt *p_ptt,
  133. u32 hw_addr);
  134. /**
  135. * @brief qed_memcpy_from - copy n bytes from BAR using the given
  136. * ptt
  137. *
  138. * @param p_hwfn
  139. * @param p_ptt
  140. * @param dest
  141. * @param hw_addr
  142. * @param n
  143. */
  144. void qed_memcpy_from(struct qed_hwfn *p_hwfn,
  145. struct qed_ptt *p_ptt,
  146. void *dest,
  147. u32 hw_addr,
  148. size_t n);
  149. /**
  150. * @brief qed_memcpy_to - copy n bytes to BAR using the given
  151. * ptt
  152. *
  153. * @param p_hwfn
  154. * @param p_ptt
  155. * @param hw_addr
  156. * @param src
  157. * @param n
  158. */
  159. void qed_memcpy_to(struct qed_hwfn *p_hwfn,
  160. struct qed_ptt *p_ptt,
  161. u32 hw_addr,
  162. void *src,
  163. size_t n);
  164. /**
  165. * @brief qed_fid_pretend - pretend to another function when
  166. * accessing the ptt window. There is no way to unpretend
  167. * a function. The only way to cancel a pretend is to
  168. * pretend back to the original function.
  169. *
  170. * @param p_hwfn
  171. * @param p_ptt
  172. * @param fid - fid field of pxp_pretend structure. Can contain
  173. * either pf / vf, port/path fields are don't care.
  174. */
  175. void qed_fid_pretend(struct qed_hwfn *p_hwfn,
  176. struct qed_ptt *p_ptt,
  177. u16 fid);
  178. /**
  179. * @brief qed_port_pretend - pretend to another port when
  180. * accessing the ptt window
  181. *
  182. * @param p_hwfn
  183. * @param p_ptt
  184. * @param port_id - the port to pretend to
  185. */
  186. void qed_port_pretend(struct qed_hwfn *p_hwfn,
  187. struct qed_ptt *p_ptt,
  188. u8 port_id);
  189. /**
  190. * @brief qed_port_unpretend - cancel any previously set port
  191. * pretend
  192. *
  193. * @param p_hwfn
  194. * @param p_ptt
  195. */
  196. void qed_port_unpretend(struct qed_hwfn *p_hwfn,
  197. struct qed_ptt *p_ptt);
  198. /**
  199. * @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd
  200. * this is declared here since other files will require it.
  201. * @param idx
  202. */
  203. u32 qed_dmae_idx_to_go_cmd(u8 idx);
  204. /**
  205. * @brief qed_dmae_info_alloc - Init the dmae_info structure
  206. * which is part of p_hwfn.
  207. * @param p_hwfn
  208. */
  209. int qed_dmae_info_alloc(struct qed_hwfn *p_hwfn);
  210. /**
  211. * @brief qed_dmae_info_free - Free the dmae_info structure
  212. * which is part of p_hwfn
  213. *
  214. * @param p_hwfn
  215. */
  216. void qed_dmae_info_free(struct qed_hwfn *p_hwfn);
  217. union qed_qm_pq_params {
  218. struct {
  219. u8 tc;
  220. } core;
  221. struct {
  222. u8 is_vf;
  223. u8 vf_id;
  224. u8 tc;
  225. } eth;
  226. };
  227. u16 qed_get_qm_pq(struct qed_hwfn *p_hwfn,
  228. enum protocol_type proto,
  229. union qed_qm_pq_params *params);
  230. int qed_init_fw_data(struct qed_dev *cdev,
  231. const u8 *fw_data);
  232. #endif