x86/mm/pat: Don't report PAT on CPUs that don't support it
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_dev_api.h
blob6812003411cdc9870a6508de198a962e4bd1e68e
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
33 #ifndef _QED_DEV_API_H
34 #define _QED_DEV_API_H
36 #include <linux/types.h>
37 #include <linux/kernel.h>
38 #include <linux/slab.h>
39 #include <linux/qed/qed_chain.h>
40 #include <linux/qed/qed_if.h>
41 #include "qed_int.h"
43 /**
44 * @brief qed_init_dp - initialize the debug level
46 * @param cdev
47 * @param dp_module
48 * @param dp_level
50 void qed_init_dp(struct qed_dev *cdev,
51 u32 dp_module,
52 u8 dp_level);
54 /**
55 * @brief qed_init_struct - initialize the device structure to
56 * its defaults
58 * @param cdev
60 void qed_init_struct(struct qed_dev *cdev);
62 /**
63 * @brief qed_resc_free -
65 * @param cdev
67 void qed_resc_free(struct qed_dev *cdev);
69 /**
70 * @brief qed_resc_alloc -
72 * @param cdev
74 * @return int
76 int qed_resc_alloc(struct qed_dev *cdev);
78 /**
79 * @brief qed_resc_setup -
81 * @param cdev
83 void qed_resc_setup(struct qed_dev *cdev);
85 /**
86 * @brief qed_hw_init -
88 * @param cdev
89 * @param p_tunn
90 * @param b_hw_start
91 * @param int_mode - interrupt mode [msix, inta, etc.] to use.
92 * @param allow_npar_tx_switch - npar tx switching to be used
93 * for vports configured for tx-switching.
94 * @param bin_fw_data - binary fw data pointer in binary fw file.
95 * Pass NULL if not using binary fw file.
97 * @return int
99 int qed_hw_init(struct qed_dev *cdev,
100 struct qed_tunn_start_params *p_tunn,
101 bool b_hw_start,
102 enum qed_int_mode int_mode,
103 bool allow_npar_tx_switch,
104 const u8 *bin_fw_data);
107 * @brief qed_hw_timers_stop_all - stop the timers HW block
109 * @param cdev
111 * @return void
113 void qed_hw_timers_stop_all(struct qed_dev *cdev);
116 * @brief qed_hw_stop -
118 * @param cdev
120 * @return int
122 int qed_hw_stop(struct qed_dev *cdev);
125 * @brief qed_hw_stop_fastpath -should be called incase
126 * slowpath is still required for the device,
127 * but fastpath is not.
129 * @param cdev
132 void qed_hw_stop_fastpath(struct qed_dev *cdev);
135 * @brief qed_hw_start_fastpath -restart fastpath traffic,
136 * only if hw_stop_fastpath was called
138 * @param cdev
141 void qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
144 * @brief qed_hw_reset -
146 * @param cdev
148 * @return int
150 int qed_hw_reset(struct qed_dev *cdev);
153 * @brief qed_hw_prepare -
155 * @param cdev
156 * @param personality - personality to initialize
158 * @return int
160 int qed_hw_prepare(struct qed_dev *cdev,
161 int personality);
164 * @brief qed_hw_remove -
166 * @param cdev
168 void qed_hw_remove(struct qed_dev *cdev);
171 * @brief qed_ptt_acquire - Allocate a PTT window
173 * Should be called at the entry point to the driver (at the beginning of an
174 * exported function)
176 * @param p_hwfn
178 * @return struct qed_ptt
180 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
183 * @brief qed_ptt_release - Release PTT Window
185 * Should be called at the end of a flow - at the end of the function that
186 * acquired the PTT.
189 * @param p_hwfn
190 * @param p_ptt
192 void qed_ptt_release(struct qed_hwfn *p_hwfn,
193 struct qed_ptt *p_ptt);
194 void qed_reset_vport_stats(struct qed_dev *cdev);
196 enum qed_dmae_address_type_t {
197 QED_DMAE_ADDRESS_HOST_VIRT,
198 QED_DMAE_ADDRESS_HOST_PHYS,
199 QED_DMAE_ADDRESS_GRC
202 /* value of flags If QED_DMAE_FLAG_RW_REPL_SRC flag is set and the
203 * source is a block of length DMAE_MAX_RW_SIZE and the
204 * destination is larger, the source block will be duplicated as
205 * many times as required to fill the destination block. This is
206 * used mostly to write a zeroed buffer to destination address
207 * using DMA
209 #define QED_DMAE_FLAG_RW_REPL_SRC 0x00000001
210 #define QED_DMAE_FLAG_VF_SRC 0x00000002
211 #define QED_DMAE_FLAG_VF_DST 0x00000004
212 #define QED_DMAE_FLAG_COMPLETION_DST 0x00000008
214 struct qed_dmae_params {
215 u32 flags; /* consists of QED_DMAE_FLAG_* values */
216 u8 src_vfid;
217 u8 dst_vfid;
221 * @brief qed_dmae_host2grc - copy data from source addr to
222 * dmae registers using the given ptt
224 * @param p_hwfn
225 * @param p_ptt
226 * @param source_addr
227 * @param grc_addr (dmae_data_offset)
228 * @param size_in_dwords
229 * @param flags (one of the flags defined above)
232 qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
233 struct qed_ptt *p_ptt,
234 u64 source_addr,
235 u32 grc_addr,
236 u32 size_in_dwords,
237 u32 flags);
240 * @brief qed_dmae_grc2host - Read data from dmae data offset
241 * to source address using the given ptt
243 * @param p_ptt
244 * @param grc_addr (dmae_data_offset)
245 * @param dest_addr
246 * @param size_in_dwords
247 * @param flags - one of the flags defined above
249 int qed_dmae_grc2host(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
250 u32 grc_addr, dma_addr_t dest_addr, u32 size_in_dwords,
251 u32 flags);
254 * @brief qed_dmae_host2host - copy data from to source address
255 * to a destination adress (for SRIOV) using the given ptt
257 * @param p_hwfn
258 * @param p_ptt
259 * @param source_addr
260 * @param dest_addr
261 * @param size_in_dwords
262 * @param params
264 int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
265 struct qed_ptt *p_ptt,
266 dma_addr_t source_addr,
267 dma_addr_t dest_addr,
268 u32 size_in_dwords, struct qed_dmae_params *p_params);
271 * @brief qed_chain_alloc - Allocate and initialize a chain
273 * @param p_hwfn
274 * @param intended_use
275 * @param mode
276 * @param num_elems
277 * @param elem_size
278 * @param p_chain
280 * @return int
283 qed_chain_alloc(struct qed_dev *cdev,
284 enum qed_chain_use_mode intended_use,
285 enum qed_chain_mode mode,
286 enum qed_chain_cnt_type cnt_type,
287 u32 num_elems, size_t elem_size, struct qed_chain *p_chain);
290 * @brief qed_chain_free - Free chain DMA memory
292 * @param p_hwfn
293 * @param p_chain
295 void qed_chain_free(struct qed_dev *cdev, struct qed_chain *p_chain);
298 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
300 * @param p_hwfn
301 * @param src_id - relative to p_hwfn
302 * @param dst_id - absolute per engine
304 * @return int
306 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
307 u16 src_id,
308 u16 *dst_id);
311 * @@brief qed_fw_vport - Get absolute vport ID
313 * @param p_hwfn
314 * @param src_id - relative to p_hwfn
315 * @param dst_id - absolute per engine
317 * @return int
319 int qed_fw_vport(struct qed_hwfn *p_hwfn,
320 u8 src_id,
321 u8 *dst_id);
324 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
326 * @param p_hwfn
327 * @param src_id - relative to p_hwfn
328 * @param dst_id - absolute per engine
330 * @return int
332 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
333 u8 src_id,
334 u8 *dst_id);
337 * @brief qed_llh_add_mac_filter - configures a MAC filter in llh
339 * @param p_hwfn
340 * @param p_ptt
341 * @param p_filter - MAC to add
343 int qed_llh_add_mac_filter(struct qed_hwfn *p_hwfn,
344 struct qed_ptt *p_ptt, u8 *p_filter);
347 * @brief qed_llh_remove_mac_filter - removes a MAC filter from llh
349 * @param p_hwfn
350 * @param p_ptt
351 * @param p_filter - MAC to remove
353 void qed_llh_remove_mac_filter(struct qed_hwfn *p_hwfn,
354 struct qed_ptt *p_ptt, u8 *p_filter);
356 enum qed_llh_port_filter_type_t {
357 QED_LLH_FILTER_ETHERTYPE,
358 QED_LLH_FILTER_TCP_SRC_PORT,
359 QED_LLH_FILTER_TCP_DEST_PORT,
360 QED_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
361 QED_LLH_FILTER_UDP_SRC_PORT,
362 QED_LLH_FILTER_UDP_DEST_PORT,
363 QED_LLH_FILTER_UDP_SRC_AND_DEST_PORT
367 * @brief qed_llh_add_protocol_filter - configures a protocol filter in llh
369 * @param p_hwfn
370 * @param p_ptt
371 * @param source_port_or_eth_type - source port or ethertype to add
372 * @param dest_port - destination port to add
373 * @param type - type of filters and comparing
376 qed_llh_add_protocol_filter(struct qed_hwfn *p_hwfn,
377 struct qed_ptt *p_ptt,
378 u16 source_port_or_eth_type,
379 u16 dest_port,
380 enum qed_llh_port_filter_type_t type);
383 * @brief qed_llh_remove_protocol_filter - remove a protocol filter in llh
385 * @param p_hwfn
386 * @param p_ptt
387 * @param source_port_or_eth_type - source port or ethertype to add
388 * @param dest_port - destination port to add
389 * @param type - type of filters and comparing
391 void
392 qed_llh_remove_protocol_filter(struct qed_hwfn *p_hwfn,
393 struct qed_ptt *p_ptt,
394 u16 source_port_or_eth_type,
395 u16 dest_port,
396 enum qed_llh_port_filter_type_t type);
399 * *@brief Cleanup of previous driver remains prior to load
401 * @param p_hwfn
402 * @param p_ptt
403 * @param id - For PF, engine-relative. For VF, PF-relative.
404 * @param is_vf - true iff cleanup is made for a VF.
406 * @return int
408 int qed_final_cleanup(struct qed_hwfn *p_hwfn,
409 struct qed_ptt *p_ptt, u16 id, bool is_vf);
412 * @brief qed_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
413 * The fact that we can configure coalescing to up to 511, but on varying
414 * accuracy [the bigger the value the less accurate] up to a mistake of 3usec
415 * for the highest values.
417 * @param p_hwfn
418 * @param p_ptt
419 * @param coalesce - Coalesce value in micro seconds.
420 * @param qid - Queue index.
421 * @param qid - SB Id
423 * @return int
425 int qed_set_rxq_coalesce(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
426 u16 coalesce, u8 qid, u16 sb_id);
429 * @brief qed_set_txq_coalesce - Configure coalesce parameters for a Tx queue
430 * While the API allows setting coalescing per-qid, all tx queues sharing a
431 * SB should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
432 * otherwise configuration would break.
434 * @param p_hwfn
435 * @param p_ptt
436 * @param coalesce - Coalesce value in micro seconds.
437 * @param qid - Queue index.
438 * @param qid - SB Id
440 * @return int
442 int qed_set_txq_coalesce(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
443 u16 coalesce, u8 qid, u16 sb_id);
444 #endif