qed_dev_api.h 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  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 p_tunn
  58. * @param b_hw_start
  59. * @param int_mode - interrupt mode [msix, inta, etc.] to use.
  60. * @param allow_npar_tx_switch - npar tx switching to be used
  61. * for vports configured for tx-switching.
  62. * @param bin_fw_data - binary fw data pointer in binary fw file.
  63. * Pass NULL if not using binary fw file.
  64. *
  65. * @return int
  66. */
  67. int qed_hw_init(struct qed_dev *cdev,
  68. struct qed_tunn_start_params *p_tunn,
  69. bool b_hw_start,
  70. enum qed_int_mode int_mode,
  71. bool allow_npar_tx_switch,
  72. const u8 *bin_fw_data);
  73. /**
  74. * @brief qed_hw_timers_stop_all - stop the timers HW block
  75. *
  76. * @param cdev
  77. *
  78. * @return void
  79. */
  80. void qed_hw_timers_stop_all(struct qed_dev *cdev);
  81. /**
  82. * @brief qed_hw_stop -
  83. *
  84. * @param cdev
  85. *
  86. * @return int
  87. */
  88. int qed_hw_stop(struct qed_dev *cdev);
  89. /**
  90. * @brief qed_hw_stop_fastpath -should be called incase
  91. * slowpath is still required for the device,
  92. * but fastpath is not.
  93. *
  94. * @param cdev
  95. *
  96. */
  97. void qed_hw_stop_fastpath(struct qed_dev *cdev);
  98. /**
  99. * @brief qed_hw_start_fastpath -restart fastpath traffic,
  100. * only if hw_stop_fastpath was called
  101. *
  102. * @param cdev
  103. *
  104. */
  105. void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
  106. /**
  107. * @brief qed_hw_reset -
  108. *
  109. * @param cdev
  110. *
  111. * @return int
  112. */
  113. int qed_hw_reset(struct qed_dev *cdev);
  114. /**
  115. * @brief qed_hw_prepare -
  116. *
  117. * @param cdev
  118. * @param personality - personality to initialize
  119. *
  120. * @return int
  121. */
  122. int qed_hw_prepare(struct qed_dev *cdev,
  123. int personality);
  124. /**
  125. * @brief qed_hw_remove -
  126. *
  127. * @param cdev
  128. */
  129. void qed_hw_remove(struct qed_dev *cdev);
  130. /**
  131. * @brief qed_ptt_acquire - Allocate a PTT window
  132. *
  133. * Should be called at the entry point to the driver (at the beginning of an
  134. * exported function)
  135. *
  136. * @param p_hwfn
  137. *
  138. * @return struct qed_ptt
  139. */
  140. struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
  141. /**
  142. * @brief qed_ptt_release - Release PTT Window
  143. *
  144. * Should be called at the end of a flow - at the end of the function that
  145. * acquired the PTT.
  146. *
  147. *
  148. * @param p_hwfn
  149. * @param p_ptt
  150. */
  151. void qed_ptt_release(struct qed_hwfn *p_hwfn,
  152. struct qed_ptt *p_ptt);
  153. void qed_reset_vport_stats(struct qed_dev *cdev);
  154. enum qed_dmae_address_type_t {
  155. QED_DMAE_ADDRESS_HOST_VIRT,
  156. QED_DMAE_ADDRESS_HOST_PHYS,
  157. QED_DMAE_ADDRESS_GRC
  158. };
  159. /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
  160. * source is a block of length DMAE_MAX_RW_SIZE and the
  161. * destination is larger, the source block will be duplicated as
  162. * many times as required to fill the destination block. This is
  163. * used mostly to write a zeroed buffer to destination address
  164. * using DMA
  165. */
  166. #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
  167. #define QED_DMAE_FLAG_VF_SRC 0x00000002
  168. #define QED_DMAE_FLAG_VF_DST 0x00000004
  169. #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
  170. struct qed_dmae_params {
  171. u32 flags; /* consists of QED_DMAE_FLAG_* values */
  172. u8 src_vfid;
  173. u8 dst_vfid;
  174. };
  175. /**
  176. * @brief qed_dmae_host2grc - copy data from source addr to
  177. * dmae registers using the given ptt
  178. *
  179. * @param p_hwfn
  180. * @param p_ptt
  181. * @param source_addr
  182. * @param grc_addr (dmae_data_offset)
  183. * @param size_in_dwords
  184. * @param flags (one of the flags defined above)
  185. */
  186. int
  187. qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
  188. struct qed_ptt *p_ptt,
  189. u64 source_addr,
  190. u32 grc_addr,
  191. u32 size_in_dwords,
  192. u32 flags);
  193. /**
  194. * @brief qed_dmae_grc2host - Read data from dmae data offset
  195. * to source address using the given ptt
  196. *
  197. * @param p_ptt
  198. * @param grc_addr (dmae_data_offset)
  199. * @param dest_addr
  200. * @param size_in_dwords
  201. * @param flags - one of the flags defined above
  202. */
  203. int qed_dmae_grc2host(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
  204. u32 grc_addr, dma_addr_t dest_addr, u32 size_in_dwords,
  205. u32 flags);
  206. /**
  207. * @brief qed_dmae_host2host - copy data from to source address
  208. * to a destination adress (for SRIOV) using the given ptt
  209. *
  210. * @param p_hwfn
  211. * @param p_ptt
  212. * @param source_addr
  213. * @param dest_addr
  214. * @param size_in_dwords
  215. * @param params
  216. */
  217. int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
  218. struct qed_ptt *p_ptt,
  219. dma_addr_t source_addr,
  220. dma_addr_t dest_addr,
  221. u32 size_in_dwords, struct qed_dmae_params *p_params);
  222. /**
  223. * @brief qed_chain_alloc - Allocate and initialize a chain
  224. *
  225. * @param p_hwfn
  226. * @param intended_use
  227. * @param mode
  228. * @param num_elems
  229. * @param elem_size
  230. * @param p_chain
  231. *
  232. * @return int
  233. */
  234. int
  235. qed_chain_alloc(struct qed_dev *cdev,
  236. enum qed_chain_use_mode intended_use,
  237. enum qed_chain_mode mode,
  238. enum qed_chain_cnt_type cnt_type,
  239. u32 num_elems, size_t elem_size, struct qed_chain *p_chain);
  240. /**
  241. * @brief qed_chain_free - Free chain DMA memory
  242. *
  243. * @param p_hwfn
  244. * @param p_chain
  245. */
  246. void qed_chain_free(struct qed_dev *cdev, struct qed_chain *p_chain);
  247. /**
  248. * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
  249. *
  250. * @param p_hwfn
  251. * @param src_id - relative to p_hwfn
  252. * @param dst_id - absolute per engine
  253. *
  254. * @return int
  255. */
  256. int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
  257. u16 src_id,
  258. u16 *dst_id);
  259. /**
  260. * @@brief qed_fw_vport - Get absolute vport ID
  261. *
  262. * @param p_hwfn
  263. * @param src_id - relative to p_hwfn
  264. * @param dst_id - absolute per engine
  265. *
  266. * @return int
  267. */
  268. int qed_fw_vport(struct qed_hwfn *p_hwfn,
  269. u8 src_id,
  270. u8 *dst_id);
  271. /**
  272. * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
  273. *
  274. * @param p_hwfn
  275. * @param src_id - relative to p_hwfn
  276. * @param dst_id - absolute per engine
  277. *
  278. * @return int
  279. */
  280. int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
  281. u8 src_id,
  282. u8 *dst_id);
  283. /**
  284. * @brief qed_llh_add_mac_filter - configures a MAC filter in llh
  285. *
  286. * @param p_hwfn
  287. * @param p_ptt
  288. * @param p_filter - MAC to add
  289. */
  290. int qed_llh_add_mac_filter(struct qed_hwfn *p_hwfn,
  291. struct qed_ptt *p_ptt, u8 *p_filter);
  292. /**
  293. * @brief qed_llh_remove_mac_filter - removes a MAC filter from llh
  294. *
  295. * @param p_hwfn
  296. * @param p_ptt
  297. * @param p_filter - MAC to remove
  298. */
  299. void qed_llh_remove_mac_filter(struct qed_hwfn *p_hwfn,
  300. struct qed_ptt *p_ptt, u8 *p_filter);
  301. /**
  302. * *@brief Cleanup of previous driver remains prior to load
  303. *
  304. * @param p_hwfn
  305. * @param p_ptt
  306. * @param id - For PF, engine-relative. For VF, PF-relative.
  307. * @param is_vf - true iff cleanup is made for a VF.
  308. *
  309. * @return int
  310. */
  311. int qed_final_cleanup(struct qed_hwfn *p_hwfn,
  312. struct qed_ptt *p_ptt, u16 id, bool is_vf);
  313. /**
  314. * @brief qed_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
  315. * The fact that we can configure coalescing to up to 511, but on varying
  316. * accuracy [the bigger the value the less accurate] up to a mistake of 3usec
  317. * for the highest values.
  318. *
  319. * @param p_hwfn
  320. * @param p_ptt
  321. * @param coalesce - Coalesce value in micro seconds.
  322. * @param qid - Queue index.
  323. * @param qid - SB Id
  324. *
  325. * @return int
  326. */
  327. int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
  328. u16 coalesce, u8 qid, u16 sb_id);
  329. /**
  330. * @brief qed_set_txq_coalesce - Configure coalesce parameters for a Tx queue
  331. * While the API allows setting coalescing per-qid, all tx queues sharing a
  332. * SB should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
  333. * otherwise configuration would break.
  334. *
  335. * @param p_hwfn
  336. * @param p_ptt
  337. * @param coalesce - Coalesce value in micro seconds.
  338. * @param qid - Queue index.
  339. * @param qid - SB Id
  340. *
  341. * @return int
  342. */
  343. int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
  344. u16 coalesce, u8 qid, u16 sb_id);
  345. #endif