qed_dev_api.h 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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_DEV_API_H
  9. #define _QED_DEV_API_H
  10. #include <linux/types.h>
  11. #include <linux/kernel.h>
  12. #include <linux/slab.h>
  13. #include <linux/qed/qed_chain.h>
  14. #include <linux/qed/qed_if.h>
  15. #include "qed_int.h"
  16. /**
  17. * @brief qed_init_dp - initialize the debug level
  18. *
  19. * @param cdev
  20. * @param dp_module
  21. * @param dp_level
  22. */
  23. void qed_init_dp(struct qed_dev *cdev,
  24. u32 dp_module,
  25. u8 dp_level);
  26. /**
  27. * @brief qed_init_struct - initialize the device structure to
  28. * its defaults
  29. *
  30. * @param cdev
  31. */
  32. void qed_init_struct(struct qed_dev *cdev);
  33. /**
  34. * @brief qed_resc_free -
  35. *
  36. * @param cdev
  37. */
  38. void qed_resc_free(struct qed_dev *cdev);
  39. /**
  40. * @brief qed_resc_alloc -
  41. *
  42. * @param cdev
  43. *
  44. * @return int
  45. */
  46. int qed_resc_alloc(struct qed_dev *cdev);
  47. /**
  48. * @brief qed_resc_setup -
  49. *
  50. * @param cdev
  51. */
  52. void qed_resc_setup(struct qed_dev *cdev);
  53. /**
  54. * @brief qed_hw_init -
  55. *
  56. * @param cdev
  57. * @param b_hw_start
  58. * @param int_mode - interrupt mode [msix, inta, etc.] to use.
  59. * @param allow_npar_tx_switch - npar tx switching to be used
  60. * for vports configured for tx-switching.
  61. * @param bin_fw_data - binary fw data pointer in binary fw file.
  62. * Pass NULL if not using binary fw file.
  63. *
  64. * @return int
  65. */
  66. int qed_hw_init(struct qed_dev *cdev,
  67. bool b_hw_start,
  68. enum qed_int_mode int_mode,
  69. bool allow_npar_tx_switch,
  70. const u8 *bin_fw_data);
  71. /**
  72. * @brief qed_hw_timers_stop_all - stop the timers HW block
  73. *
  74. * @param cdev
  75. *
  76. * @return void
  77. */
  78. void qed_hw_timers_stop_all(struct qed_dev *cdev);
  79. /**
  80. * @brief qed_hw_stop -
  81. *
  82. * @param cdev
  83. *
  84. * @return int
  85. */
  86. int qed_hw_stop(struct qed_dev *cdev);
  87. /**
  88. * @brief qed_hw_stop_fastpath -should be called incase
  89. * slowpath is still required for the device,
  90. * but fastpath is not.
  91. *
  92. * @param cdev
  93. *
  94. */
  95. void qed_hw_stop_fastpath(struct qed_dev *cdev);
  96. /**
  97. * @brief qed_hw_start_fastpath -restart fastpath traffic,
  98. * only if hw_stop_fastpath was called
  99. *
  100. * @param cdev
  101. *
  102. */
  103. void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
  104. /**
  105. * @brief qed_hw_reset -
  106. *
  107. * @param cdev
  108. *
  109. * @return int
  110. */
  111. int qed_hw_reset(struct qed_dev *cdev);
  112. /**
  113. * @brief qed_hw_prepare -
  114. *
  115. * @param cdev
  116. * @param personality - personality to initialize
  117. *
  118. * @return int
  119. */
  120. int qed_hw_prepare(struct qed_dev *cdev,
  121. int personality);
  122. /**
  123. * @brief qed_hw_remove -
  124. *
  125. * @param cdev
  126. */
  127. void qed_hw_remove(struct qed_dev *cdev);
  128. /**
  129. * @brief qed_ptt_acquire - Allocate a PTT window
  130. *
  131. * Should be called at the entry point to the driver (at the beginning of an
  132. * exported function)
  133. *
  134. * @param p_hwfn
  135. *
  136. * @return struct qed_ptt
  137. */
  138. struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
  139. /**
  140. * @brief qed_ptt_release - Release PTT Window
  141. *
  142. * Should be called at the end of a flow - at the end of the function that
  143. * acquired the PTT.
  144. *
  145. *
  146. * @param p_hwfn
  147. * @param p_ptt
  148. */
  149. void qed_ptt_release(struct qed_hwfn *p_hwfn,
  150. struct qed_ptt *p_ptt);
  151. void qed_reset_vport_stats(struct qed_dev *cdev);
  152. enum qed_dmae_address_type_t {
  153. QED_DMAE_ADDRESS_HOST_VIRT,
  154. QED_DMAE_ADDRESS_HOST_PHYS,
  155. QED_DMAE_ADDRESS_GRC
  156. };
  157. /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
  158. * source is a block of length DMAE_MAX_RW_SIZE and the
  159. * destination is larger, the source block will be duplicated as
  160. * many times as required to fill the destination block. This is
  161. * used mostly to write a zeroed buffer to destination address
  162. * using DMA
  163. */
  164. #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
  165. #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
  166. struct qed_dmae_params {
  167. u32 flags; /* consists of QED_DMAE_FLAG_* values */
  168. };
  169. /**
  170. * @brief qed_dmae_host2grc - copy data from source addr to
  171. * dmae registers using the given ptt
  172. *
  173. * @param p_hwfn
  174. * @param p_ptt
  175. * @param source_addr
  176. * @param grc_addr (dmae_data_offset)
  177. * @param size_in_dwords
  178. * @param flags (one of the flags defined above)
  179. */
  180. int
  181. qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
  182. struct qed_ptt *p_ptt,
  183. u64 source_addr,
  184. u32 grc_addr,
  185. u32 size_in_dwords,
  186. u32 flags);
  187. /**
  188. * @brief qed_chain_alloc - Allocate and initialize a chain
  189. *
  190. * @param p_hwfn
  191. * @param intended_use
  192. * @param mode
  193. * @param num_elems
  194. * @param elem_size
  195. * @param p_chain
  196. *
  197. * @return int
  198. */
  199. int
  200. qed_chain_alloc(struct qed_dev *cdev,
  201. enum qed_chain_use_mode intended_use,
  202. enum qed_chain_mode mode,
  203. u16 num_elems,
  204. size_t elem_size,
  205. struct qed_chain *p_chain);
  206. /**
  207. * @brief qed_chain_free - Free chain DMA memory
  208. *
  209. * @param p_hwfn
  210. * @param p_chain
  211. */
  212. void qed_chain_free(struct qed_dev *cdev,
  213. struct qed_chain *p_chain);
  214. /**
  215. * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
  216. *
  217. * @param p_hwfn
  218. * @param src_id - relative to p_hwfn
  219. * @param dst_id - absolute per engine
  220. *
  221. * @return int
  222. */
  223. int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
  224. u16 src_id,
  225. u16 *dst_id);
  226. /**
  227. * @@brief qed_fw_vport - Get absolute vport ID
  228. *
  229. * @param p_hwfn
  230. * @param src_id - relative to p_hwfn
  231. * @param dst_id - absolute per engine
  232. *
  233. * @return int
  234. */
  235. int qed_fw_vport(struct qed_hwfn *p_hwfn,
  236. u8 src_id,
  237. u8 *dst_id);
  238. /**
  239. * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
  240. *
  241. * @param p_hwfn
  242. * @param src_id - relative to p_hwfn
  243. * @param dst_id - absolute per engine
  244. *
  245. * @return int
  246. */
  247. int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
  248. u8 src_id,
  249. u8 *dst_id);
  250. /**
  251. * *@brief Cleanup of previous driver remains prior to load
  252. *
  253. * @param p_hwfn
  254. * @param p_ptt
  255. * @param id - For PF, engine-relative. For VF, PF-relative.
  256. *
  257. * @return int
  258. */
  259. int qed_final_cleanup(struct qed_hwfn *p_hwfn,
  260. struct qed_ptt *p_ptt,
  261. u16 id);
  262. #endif