qed_dev_api.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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_reset -
  81. *
  82. * @param cdev
  83. *
  84. * @return int
  85. */
  86. int qed_hw_reset(struct qed_dev *cdev);
  87. /**
  88. * @brief qed_hw_prepare -
  89. *
  90. * @param cdev
  91. * @param personality - personality to initialize
  92. *
  93. * @return int
  94. */
  95. int qed_hw_prepare(struct qed_dev *cdev,
  96. int personality);
  97. /**
  98. * @brief qed_hw_remove -
  99. *
  100. * @param cdev
  101. */
  102. void qed_hw_remove(struct qed_dev *cdev);
  103. /**
  104. * @brief qed_ptt_acquire - Allocate a PTT window
  105. *
  106. * Should be called at the entry point to the driver (at the beginning of an
  107. * exported function)
  108. *
  109. * @param p_hwfn
  110. *
  111. * @return struct qed_ptt
  112. */
  113. struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
  114. /**
  115. * @brief qed_ptt_release - Release PTT Window
  116. *
  117. * Should be called at the end of a flow - at the end of the function that
  118. * acquired the PTT.
  119. *
  120. *
  121. * @param p_hwfn
  122. * @param p_ptt
  123. */
  124. void qed_ptt_release(struct qed_hwfn *p_hwfn,
  125. struct qed_ptt *p_ptt);
  126. enum qed_dmae_address_type_t {
  127. QED_DMAE_ADDRESS_HOST_VIRT,
  128. QED_DMAE_ADDRESS_HOST_PHYS,
  129. QED_DMAE_ADDRESS_GRC
  130. };
  131. /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
  132. * source is a block of length DMAE_MAX_RW_SIZE and the
  133. * destination is larger, the source block will be duplicated as
  134. * many times as required to fill the destination block. This is
  135. * used mostly to write a zeroed buffer to destination address
  136. * using DMA
  137. */
  138. #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
  139. #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
  140. struct qed_dmae_params {
  141. u32 flags; /* consists of QED_DMAE_FLAG_* values */
  142. };
  143. /**
  144. * @brief qed_dmae_host2grc - copy data from source addr to
  145. * dmae registers using the given ptt
  146. *
  147. * @param p_hwfn
  148. * @param p_ptt
  149. * @param source_addr
  150. * @param grc_addr (dmae_data_offset)
  151. * @param size_in_dwords
  152. * @param flags (one of the flags defined above)
  153. */
  154. int
  155. qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
  156. struct qed_ptt *p_ptt,
  157. u64 source_addr,
  158. u32 grc_addr,
  159. u32 size_in_dwords,
  160. u32 flags);
  161. /**
  162. * @brief qed_chain_alloc - Allocate and initialize a chain
  163. *
  164. * @param p_hwfn
  165. * @param intended_use
  166. * @param mode
  167. * @param num_elems
  168. * @param elem_size
  169. * @param p_chain
  170. *
  171. * @return int
  172. */
  173. int
  174. qed_chain_alloc(struct qed_dev *cdev,
  175. enum qed_chain_use_mode intended_use,
  176. enum qed_chain_mode mode,
  177. u16 num_elems,
  178. size_t elem_size,
  179. struct qed_chain *p_chain);
  180. /**
  181. * @brief qed_chain_free - Free chain DMA memory
  182. *
  183. * @param p_hwfn
  184. * @param p_chain
  185. */
  186. void qed_chain_free(struct qed_dev *cdev,
  187. struct qed_chain *p_chain);
  188. /**
  189. * *@brief Cleanup of previous driver remains prior to load
  190. *
  191. * @param p_hwfn
  192. * @param p_ptt
  193. * @param id - For PF, engine-relative. For VF, PF-relative.
  194. *
  195. * @return int
  196. */
  197. int qed_final_cleanup(struct qed_hwfn *p_hwfn,
  198. struct qed_ptt *p_ptt,
  199. u16 id);
  200. #endif