n_tty: Reduce branching in canon_copy_from_read_buf()
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_dev_api.h
blobe29a3ba6c8b034039a13014113187fee15e22a96
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
6 * this source tree.
7 */
9 #ifndef _QED_DEV_API_H
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>
17 #include "qed_int.h"
19 /**
20 * @brief qed_init_dp - initialize the debug level
22 * @param cdev
23 * @param dp_module
24 * @param dp_level
26 void qed_init_dp(struct qed_dev *cdev,
27 u32 dp_module,
28 u8 dp_level);
30 /**
31 * @brief qed_init_struct - initialize the device structure to
32 * its defaults
34 * @param cdev
36 void qed_init_struct(struct qed_dev *cdev);
38 /**
39 * @brief qed_resc_free -
41 * @param cdev
43 void qed_resc_free(struct qed_dev *cdev);
45 /**
46 * @brief qed_resc_alloc -
48 * @param cdev
50 * @return int
52 int qed_resc_alloc(struct qed_dev *cdev);
54 /**
55 * @brief qed_resc_setup -
57 * @param cdev
59 void qed_resc_setup(struct qed_dev *cdev);
61 /**
62 * @brief qed_hw_init -
64 * @param cdev
65 * @param b_hw_start
66 * @param int_mode - interrupt mode [msix, inta, etc.] to use.
67 * @param allow_npar_tx_switch - npar tx switching to be used
68 * for vports configured for tx-switching.
69 * @param bin_fw_data - binary fw data pointer in binary fw file.
70 * Pass NULL if not using binary fw file.
72 * @return int
74 int qed_hw_init(struct qed_dev *cdev,
75 bool b_hw_start,
76 enum qed_int_mode int_mode,
77 bool allow_npar_tx_switch,
78 const u8 *bin_fw_data);
80 /**
81 * @brief qed_hw_stop -
83 * @param cdev
85 * @return int
87 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.
94 * @param cdev
97 void qed_hw_stop_fastpath(struct qed_dev *cdev);
99 /**
100 * @brief qed_hw_start_fastpath -restart fastpath traffic,
101 * only if hw_stop_fastpath was called
103 * @param cdev
106 void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
109 * @brief qed_hw_reset -
111 * @param cdev
113 * @return int
115 int qed_hw_reset(struct qed_dev *cdev);
118 * @brief qed_hw_prepare -
120 * @param cdev
121 * @param personality - personality to initialize
123 * @return int
125 int qed_hw_prepare(struct qed_dev *cdev,
126 int personality);
129 * @brief qed_hw_remove -
131 * @param cdev
133 void qed_hw_remove(struct qed_dev *cdev);
136 * @brief qed_ptt_acquire - Allocate a PTT window
138 * Should be called at the entry point to the driver (at the beginning of an
139 * exported function)
141 * @param p_hwfn
143 * @return struct qed_ptt
145 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
148 * @brief qed_ptt_release - Release PTT Window
150 * Should be called at the end of a flow - at the end of the function that
151 * acquired the PTT.
154 * @param p_hwfn
155 * @param p_ptt
157 void qed_ptt_release(struct qed_hwfn *p_hwfn,
158 struct qed_ptt *p_ptt);
159 void qed_get_vport_stats(struct qed_dev *cdev,
160 struct qed_eth_stats *stats);
161 void qed_reset_vport_stats(struct qed_dev *cdev);
163 enum qed_dmae_address_type_t {
164 QED_DMAE_ADDRESS_HOST_VIRT,
165 QED_DMAE_ADDRESS_HOST_PHYS,
166 QED_DMAE_ADDRESS_GRC
169 /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
170 * source is a block of length DMAE_MAX_RW_SIZE and the
171 * destination is larger, the source block will be duplicated as
172 * many times as required to fill the destination block. This is
173 * used mostly to write a zeroed buffer to destination address
174 * using DMA
176 #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
177 #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
179 struct qed_dmae_params {
180 u32 flags; /* consists of QED_DMAE_FLAG_* values */
184 * @brief qed_dmae_host2grc - copy data from source addr to
185 * dmae registers using the given ptt
187 * @param p_hwfn
188 * @param p_ptt
189 * @param source_addr
190 * @param grc_addr (dmae_data_offset)
191 * @param size_in_dwords
192 * @param flags (one of the flags defined above)
195 qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
196 struct qed_ptt *p_ptt,
197 u64 source_addr,
198 u32 grc_addr,
199 u32 size_in_dwords,
200 u32 flags);
203 * @brief qed_chain_alloc - Allocate and initialize a chain
205 * @param p_hwfn
206 * @param intended_use
207 * @param mode
208 * @param num_elems
209 * @param elem_size
210 * @param p_chain
212 * @return int
215 qed_chain_alloc(struct qed_dev *cdev,
216 enum qed_chain_use_mode intended_use,
217 enum qed_chain_mode mode,
218 u16 num_elems,
219 size_t elem_size,
220 struct qed_chain *p_chain);
223 * @brief qed_chain_free - Free chain DMA memory
225 * @param p_hwfn
226 * @param p_chain
228 void qed_chain_free(struct qed_dev *cdev,
229 struct qed_chain *p_chain);
232 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
234 * @param p_hwfn
235 * @param src_id - relative to p_hwfn
236 * @param dst_id - absolute per engine
238 * @return int
240 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
241 u16 src_id,
242 u16 *dst_id);
245 * @@brief qed_fw_vport - Get absolute vport ID
247 * @param p_hwfn
248 * @param src_id - relative to p_hwfn
249 * @param dst_id - absolute per engine
251 * @return int
253 int qed_fw_vport(struct qed_hwfn *p_hwfn,
254 u8 src_id,
255 u8 *dst_id);
258 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
260 * @param p_hwfn
261 * @param src_id - relative to p_hwfn
262 * @param dst_id - absolute per engine
264 * @return int
266 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
267 u8 src_id,
268 u8 *dst_id);
271 * *@brief Cleanup of previous driver remains prior to load
273 * @param p_hwfn
274 * @param p_ptt
275 * @param id - For PF, engine-relative. For VF, PF-relative.
277 * @return int
279 int qed_final_cleanup(struct qed_hwfn *p_hwfn,
280 struct qed_ptt *p_ptt,
281 u16 id);
283 #endif