1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015 QLogic Corporation
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
10 #define _QED_DEV_API_H
12 #include <linux/types.h>
13 #include <linux/kernel.h>
14 #include <linux/slab.h>
15 #include <linux/qed/qed_chain.h>
16 #include <linux/qed/qed_if.h>
20 * @brief qed_init_dp - initialize the debug level
26 void qed_init_dp(struct qed_dev *cdev,
31 * @brief qed_init_struct - initialize the device structure to
36 void qed_init_struct(struct qed_dev *cdev);
39 * @brief qed_resc_free -
43 void qed_resc_free(struct qed_dev *cdev);
46 * @brief qed_resc_alloc -
52 int qed_resc_alloc(struct qed_dev *cdev);
55 * @brief qed_resc_setup -
59 void qed_resc_setup(struct qed_dev *cdev);
62 * @brief qed_hw_init -
67 * @param int_mode - interrupt mode [msix, inta, etc.] to use.
68 * @param allow_npar_tx_switch - npar tx switching to be used
69 * for vports configured for tx-switching.
70 * @param bin_fw_data - binary fw data pointer in binary fw file.
71 * Pass NULL if not using binary fw file.
75 int qed_hw_init(struct qed_dev *cdev,
76 struct qed_tunn_start_params *p_tunn,
78 enum qed_int_mode int_mode,
79 bool allow_npar_tx_switch,
80 const u8 *bin_fw_data);
83 * @brief qed_hw_timers_stop_all - stop the timers HW block
89 void qed_hw_timers_stop_all(struct qed_dev *cdev);
92 * @brief qed_hw_stop -
98 int qed_hw_stop(struct qed_dev *cdev);
101 * @brief qed_hw_stop_fastpath -should be called incase
102 * slowpath is still required for the device,
103 * but fastpath is not.
108 void qed_hw_stop_fastpath(struct qed_dev *cdev);
111 * @brief qed_hw_start_fastpath -restart fastpath traffic,
112 * only if hw_stop_fastpath was called
117 void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
120 * @brief qed_hw_reset -
126 int qed_hw_reset(struct qed_dev *cdev);
129 * @brief qed_hw_prepare -
132 * @param personality - personality to initialize
136 int qed_hw_prepare(struct qed_dev *cdev,
140 * @brief qed_hw_remove -
144 void qed_hw_remove(struct qed_dev *cdev);
147 * @brief qed_ptt_acquire - Allocate a PTT window
149 * Should be called at the entry point to the driver (at the beginning of an
154 * @return struct qed_ptt
156 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
159 * @brief qed_ptt_release - Release PTT Window
161 * Should be called at the end of a flow - at the end of the function that
168 void qed_ptt_release(struct qed_hwfn *p_hwfn,
169 struct qed_ptt *p_ptt);
170 void qed_reset_vport_stats(struct qed_dev *cdev);
172 enum qed_dmae_address_type_t {
173 QED_DMAE_ADDRESS_HOST_VIRT,
174 QED_DMAE_ADDRESS_HOST_PHYS,
178 /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
179 * source is a block of length DMAE_MAX_RW_SIZE and the
180 * destination is larger, the source block will be duplicated as
181 * many times as required to fill the destination block. This is
182 * used mostly to write a zeroed buffer to destination address
185 #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
186 #define QED_DMAE_FLAG_VF_SRC 0x00000002
187 #define QED_DMAE_FLAG_VF_DST 0x00000004
188 #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
190 struct qed_dmae_params {
191 u32 flags; /* consists of QED_DMAE_FLAG_* values */
197 * @brief qed_dmae_host2grc - copy data from source addr to
198 * dmae registers using the given ptt
203 * @param grc_addr (dmae_data_offset)
204 * @param size_in_dwords
205 * @param flags (one of the flags defined above)
208 qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
209 struct qed_ptt *p_ptt,
216 * @brief qed_dmae_host2host - copy data from to source address
217 * to a destination adress (for SRIOV) using the given ptt
223 * @param size_in_dwords
226 int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
227 struct qed_ptt *p_ptt,
228 dma_addr_t source_addr,
229 dma_addr_t dest_addr,
230 u32 size_in_dwords, struct qed_dmae_params *p_params);
233 * @brief qed_chain_alloc - Allocate and initialize a chain
236 * @param intended_use
245 qed_chain_alloc(struct qed_dev *cdev,
246 enum qed_chain_use_mode intended_use,
247 enum qed_chain_mode mode,
250 struct qed_chain *p_chain);
253 * @brief qed_chain_free - Free chain DMA memory
258 void qed_chain_free(struct qed_dev *cdev,
259 struct qed_chain *p_chain);
262 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
265 * @param src_id - relative to p_hwfn
266 * @param dst_id - absolute per engine
270 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
275 * @@brief qed_fw_vport - Get absolute vport ID
278 * @param src_id - relative to p_hwfn
279 * @param dst_id - absolute per engine
283 int qed_fw_vport(struct qed_hwfn *p_hwfn,
288 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
291 * @param src_id - relative to p_hwfn
292 * @param dst_id - absolute per engine
296 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
301 * *@brief Cleanup of previous driver remains prior to load
305 * @param id - For PF, engine-relative. For VF, PF-relative.
306 * @param is_vf - true iff cleanup is made for a VF.
310 int qed_final_cleanup(struct qed_hwfn *p_hwfn,
311 struct qed_ptt *p_ptt, u16 id, bool is_vf);