qed_dev_api.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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_stop -
  73. *
  74. * @param cdev
  75. *
  76. * @return int
  77. */
  78. int qed_hw_stop(struct qed_dev *cdev);
  79. /**
  80. * @brief qed_hw_stop_fastpath -should be called incase
  81. * slowpath is still required for the device,
  82. * but fastpath is not.
  83. *
  84. * @param cdev
  85. *
  86. */
  87. void qed_hw_stop_fastpath(struct qed_dev *cdev);
  88. /**
  89. * @brief qed_hw_start_fastpath -restart fastpath traffic,
  90. * only if hw_stop_fastpath was called
  91. *
  92. * @param cdev
  93. *
  94. */
  95. void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
  96. /**
  97. * @brief qed_hw_reset -
  98. *
  99. * @param cdev
  100. *
  101. * @return int
  102. */
  103. int qed_hw_reset(struct qed_dev *cdev);
  104. /**
  105. * @brief qed_hw_prepare -
  106. *
  107. * @param cdev
  108. * @param personality - personality to initialize
  109. *
  110. * @return int
  111. */
  112. int qed_hw_prepare(struct qed_dev *cdev,
  113. int personality);
  114. /**
  115. * @brief qed_hw_remove -
  116. *
  117. * @param cdev
  118. */
  119. void qed_hw_remove(struct qed_dev *cdev);
  120. /**
  121. * @brief qed_ptt_acquire - Allocate a PTT window
  122. *
  123. * Should be called at the entry point to the driver (at the beginning of an
  124. * exported function)
  125. *
  126. * @param p_hwfn
  127. *
  128. * @return struct qed_ptt
  129. */
  130. struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
  131. /**
  132. * @brief qed_ptt_release - Release PTT Window
  133. *
  134. * Should be called at the end of a flow - at the end of the function that
  135. * acquired the PTT.
  136. *
  137. *
  138. * @param p_hwfn
  139. * @param p_ptt
  140. */
  141. void qed_ptt_release(struct qed_hwfn *p_hwfn,
  142. struct qed_ptt *p_ptt);
  143. void qed_get_vport_stats(struct qed_dev *cdev,
  144. struct qed_eth_stats *stats);
  145. void qed_reset_vport_stats(struct qed_dev *cdev);
  146. enum qed_dmae_address_type_t {
  147. QED_DMAE_ADDRESS_HOST_VIRT,
  148. QED_DMAE_ADDRESS_HOST_PHYS,
  149. QED_DMAE_ADDRESS_GRC
  150. };
  151. /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
  152. * source is a block of length DMAE_MAX_RW_SIZE and the
  153. * destination is larger, the source block will be duplicated as
  154. * many times as required to fill the destination block. This is
  155. * used mostly to write a zeroed buffer to destination address
  156. * using DMA
  157. */
  158. #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
  159. #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
  160. struct qed_dmae_params {
  161. u32 flags; /* consists of QED_DMAE_FLAG_* values */
  162. };
  163. /**
  164. * @brief qed_dmae_host2grc - copy data from source addr to
  165. * dmae registers using the given ptt
  166. *
  167. * @param p_hwfn
  168. * @param p_ptt
  169. * @param source_addr
  170. * @param grc_addr (dmae_data_offset)
  171. * @param size_in_dwords
  172. * @param flags (one of the flags defined above)
  173. */
  174. int
  175. qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
  176. struct qed_ptt *p_ptt,
  177. u64 source_addr,
  178. u32 grc_addr,
  179. u32 size_in_dwords,
  180. u32 flags);
  181. /**
  182. * @brief qed_chain_alloc - Allocate and initialize a chain
  183. *
  184. * @param p_hwfn
  185. * @param intended_use
  186. * @param mode
  187. * @param num_elems
  188. * @param elem_size
  189. * @param p_chain
  190. *
  191. * @return int
  192. */
  193. int
  194. qed_chain_alloc(struct qed_dev *cdev,
  195. enum qed_chain_use_mode intended_use,
  196. enum qed_chain_mode mode,
  197. u16 num_elems,
  198. size_t elem_size,
  199. struct qed_chain *p_chain);
  200. /**
  201. * @brief qed_chain_free - Free chain DMA memory
  202. *
  203. * @param p_hwfn
  204. * @param p_chain
  205. */
  206. void qed_chain_free(struct qed_dev *cdev,
  207. struct qed_chain *p_chain);
  208. /**
  209. * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
  210. *
  211. * @param p_hwfn
  212. * @param src_id - relative to p_hwfn
  213. * @param dst_id - absolute per engine
  214. *
  215. * @return int
  216. */
  217. int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
  218. u16 src_id,
  219. u16 *dst_id);
  220. /**
  221. * @@brief qed_fw_vport - Get absolute vport ID
  222. *
  223. * @param p_hwfn
  224. * @param src_id - relative to p_hwfn
  225. * @param dst_id - absolute per engine
  226. *
  227. * @return int
  228. */
  229. int qed_fw_vport(struct qed_hwfn *p_hwfn,
  230. u8 src_id,
  231. u8 *dst_id);
  232. /**
  233. * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
  234. *
  235. * @param p_hwfn
  236. * @param src_id - relative to p_hwfn
  237. * @param dst_id - absolute per engine
  238. *
  239. * @return int
  240. */
  241. int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
  242. u8 src_id,
  243. u8 *dst_id);
  244. /**
  245. * *@brief Cleanup of previous driver remains prior to load
  246. *
  247. * @param p_hwfn
  248. * @param p_ptt
  249. * @param id - For PF, engine-relative. For VF, PF-relative.
  250. *
  251. * @return int
  252. */
  253. int qed_final_cleanup(struct qed_hwfn *p_hwfn,
  254. struct qed_ptt *p_ptt,
  255. u16 id);
  256. #endif