WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / qlogic / qed / qed_dev_api.h
blobd3c1f3879be8700b6eb58453a5b24c413ea225c1
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /* QLogic qed NIC Driver
3 * Copyright (c) 2015-2017 QLogic Corporation
4 * Copyright (c) 2019-2020 Marvell International Ltd.
5 */
7 #ifndef _QED_DEV_API_H
8 #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"
17 /**
18 * @brief qed_init_dp - initialize the debug level
20 * @param cdev
21 * @param dp_module
22 * @param dp_level
24 void qed_init_dp(struct qed_dev *cdev,
25 u32 dp_module,
26 u8 dp_level);
28 /**
29 * @brief qed_init_struct - initialize the device structure to
30 * its defaults
32 * @param cdev
34 void qed_init_struct(struct qed_dev *cdev);
36 /**
37 * @brief qed_resc_free -
39 * @param cdev
41 void qed_resc_free(struct qed_dev *cdev);
43 /**
44 * @brief qed_resc_alloc -
46 * @param cdev
48 * @return int
50 int qed_resc_alloc(struct qed_dev *cdev);
52 /**
53 * @brief qed_resc_setup -
55 * @param cdev
57 void qed_resc_setup(struct qed_dev *cdev);
59 enum qed_override_force_load {
60 QED_OVERRIDE_FORCE_LOAD_NONE,
61 QED_OVERRIDE_FORCE_LOAD_ALWAYS,
62 QED_OVERRIDE_FORCE_LOAD_NEVER,
65 struct qed_drv_load_params {
66 /* Indicates whether the driver is running over a crash kernel.
67 * As part of the load request, this will be used for providing the
68 * driver role to the MFW.
69 * In case of a crash kernel over PDA - this should be set to false.
71 bool is_crash_kernel;
73 /* The timeout value that the MFW should use when locking the engine for
74 * the driver load process.
75 * A value of '0' means the default value, and '255' means no timeout.
77 u8 mfw_timeout_val;
78 #define QED_LOAD_REQ_LOCK_TO_DEFAULT 0
79 #define QED_LOAD_REQ_LOCK_TO_NONE 255
81 /* Avoid engine reset when first PF loads on it */
82 bool avoid_eng_reset;
84 /* Allow overriding the default force load behavior */
85 enum qed_override_force_load override_force_load;
88 struct qed_hw_init_params {
89 /* Tunneling parameters */
90 struct qed_tunnel_info *p_tunn;
92 bool b_hw_start;
94 /* Interrupt mode [msix, inta, etc.] to use */
95 enum qed_int_mode int_mode;
97 /* NPAR tx switching to be used for vports for tx-switching */
98 bool allow_npar_tx_switch;
100 /* Binary fw data pointer in binary fw file */
101 const u8 *bin_fw_data;
103 /* Driver load parameters */
104 struct qed_drv_load_params *p_drv_load_params;
108 * @brief qed_hw_init -
110 * @param cdev
111 * @param p_params
113 * @return int
115 int qed_hw_init(struct qed_dev *cdev, struct qed_hw_init_params *p_params);
118 * @brief qed_hw_timers_stop_all - stop the timers HW block
120 * @param cdev
122 * @return void
124 void qed_hw_timers_stop_all(struct qed_dev *cdev);
127 * @brief qed_hw_stop -
129 * @param cdev
131 * @return int
133 int qed_hw_stop(struct qed_dev *cdev);
136 * @brief qed_hw_stop_fastpath -should be called incase
137 * slowpath is still required for the device,
138 * but fastpath is not.
140 * @param cdev
142 * @return int
144 int qed_hw_stop_fastpath(struct qed_dev *cdev);
147 * @brief qed_hw_start_fastpath -restart fastpath traffic,
148 * only if hw_stop_fastpath was called
150 * @param p_hwfn
152 * @return int
154 int qed_hw_start_fastpath(struct qed_hwfn *p_hwfn);
158 * @brief qed_hw_prepare -
160 * @param cdev
161 * @param personality - personality to initialize
163 * @return int
165 int qed_hw_prepare(struct qed_dev *cdev,
166 int personality);
169 * @brief qed_hw_remove -
171 * @param cdev
173 void qed_hw_remove(struct qed_dev *cdev);
176 * @brief qed_ptt_acquire - Allocate a PTT window
178 * Should be called at the entry point to the driver (at the beginning of an
179 * exported function)
181 * @param p_hwfn
183 * @return struct qed_ptt
185 struct qed_ptt *qed_ptt_acquire(struct qed_hwfn *p_hwfn);
188 * @brief qed_ptt_release - Release PTT Window
190 * Should be called at the end of a flow - at the end of the function that
191 * acquired the PTT.
194 * @param p_hwfn
195 * @param p_ptt
197 void qed_ptt_release(struct qed_hwfn *p_hwfn,
198 struct qed_ptt *p_ptt);
199 void qed_reset_vport_stats(struct qed_dev *cdev);
201 enum qed_dmae_address_type_t {
202 QED_DMAE_ADDRESS_HOST_VIRT,
203 QED_DMAE_ADDRESS_HOST_PHYS,
204 QED_DMAE_ADDRESS_GRC
208 * @brief qed_dmae_host2grc - copy data from source addr to
209 * dmae registers using the given ptt
211 * @param p_hwfn
212 * @param p_ptt
213 * @param source_addr
214 * @param grc_addr (dmae_data_offset)
215 * @param size_in_dwords
216 * @param p_params (default parameters will be used in case of NULL)
219 qed_dmae_host2grc(struct qed_hwfn *p_hwfn,
220 struct qed_ptt *p_ptt,
221 u64 source_addr,
222 u32 grc_addr,
223 u32 size_in_dwords,
224 struct qed_dmae_params *p_params);
227 * @brief qed_dmae_grc2host - Read data from dmae data offset
228 * to source address using the given ptt
230 * @param p_ptt
231 * @param grc_addr (dmae_data_offset)
232 * @param dest_addr
233 * @param size_in_dwords
234 * @param p_params (default parameters will be used in case of NULL)
236 int qed_dmae_grc2host(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt,
237 u32 grc_addr, dma_addr_t dest_addr, u32 size_in_dwords,
238 struct qed_dmae_params *p_params);
241 * @brief qed_dmae_host2host - copy data from to source address
242 * to a destination adress (for SRIOV) using the given ptt
244 * @param p_hwfn
245 * @param p_ptt
246 * @param source_addr
247 * @param dest_addr
248 * @param size_in_dwords
249 * @param p_params (default parameters will be used in case of NULL)
251 int qed_dmae_host2host(struct qed_hwfn *p_hwfn,
252 struct qed_ptt *p_ptt,
253 dma_addr_t source_addr,
254 dma_addr_t dest_addr,
255 u32 size_in_dwords, struct qed_dmae_params *p_params);
257 int qed_chain_alloc(struct qed_dev *cdev, struct qed_chain *chain,
258 struct qed_chain_init_params *params);
259 void qed_chain_free(struct qed_dev *cdev, struct qed_chain *chain);
262 * @@brief qed_fw_l2_queue - Get absolute L2 queue ID
264 * @param p_hwfn
265 * @param src_id - relative to p_hwfn
266 * @param dst_id - absolute per engine
268 * @return int
270 int qed_fw_l2_queue(struct qed_hwfn *p_hwfn,
271 u16 src_id,
272 u16 *dst_id);
275 * @@brief qed_fw_vport - Get absolute vport ID
277 * @param p_hwfn
278 * @param src_id - relative to p_hwfn
279 * @param dst_id - absolute per engine
281 * @return int
283 int qed_fw_vport(struct qed_hwfn *p_hwfn,
284 u8 src_id,
285 u8 *dst_id);
288 * @@brief qed_fw_rss_eng - Get absolute RSS engine ID
290 * @param p_hwfn
291 * @param src_id - relative to p_hwfn
292 * @param dst_id - absolute per engine
294 * @return int
296 int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
297 u8 src_id,
298 u8 *dst_id);
301 * @brief qed_llh_get_num_ppfid - Return the allocated number of LLH filter
302 * banks that are allocated to the PF.
304 * @param cdev
306 * @return u8 - Number of LLH filter banks
308 u8 qed_llh_get_num_ppfid(struct qed_dev *cdev);
310 enum qed_eng {
311 QED_ENG0,
312 QED_ENG1,
313 QED_BOTH_ENG,
317 * @brief qed_llh_set_ppfid_affinity - Set the engine affinity for the given
318 * LLH filter bank.
320 * @param cdev
321 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
322 * @param eng
324 * @return int
326 int qed_llh_set_ppfid_affinity(struct qed_dev *cdev,
327 u8 ppfid, enum qed_eng eng);
330 * @brief qed_llh_set_roce_affinity - Set the RoCE engine affinity
332 * @param cdev
333 * @param eng
335 * @return int
337 int qed_llh_set_roce_affinity(struct qed_dev *cdev, enum qed_eng eng);
340 * @brief qed_llh_add_mac_filter - Add a LLH MAC filter into the given filter
341 * bank.
343 * @param cdev
344 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
345 * @param mac_addr - MAC to add
347 int qed_llh_add_mac_filter(struct qed_dev *cdev,
348 u8 ppfid, u8 mac_addr[ETH_ALEN]);
351 * @brief qed_llh_remove_mac_filter - Remove a LLH MAC filter from the given
352 * filter bank.
354 * @param p_ptt
355 * @param p_filter - MAC to remove
357 void qed_llh_remove_mac_filter(struct qed_dev *cdev,
358 u8 ppfid, u8 mac_addr[ETH_ALEN]);
360 enum qed_llh_prot_filter_type_t {
361 QED_LLH_FILTER_ETHERTYPE,
362 QED_LLH_FILTER_TCP_SRC_PORT,
363 QED_LLH_FILTER_TCP_DEST_PORT,
364 QED_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
365 QED_LLH_FILTER_UDP_SRC_PORT,
366 QED_LLH_FILTER_UDP_DEST_PORT,
367 QED_LLH_FILTER_UDP_SRC_AND_DEST_PORT
371 * @brief qed_llh_add_protocol_filter - Add a LLH protocol filter into the
372 * given filter bank.
374 * @param cdev
375 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
376 * @param type - type of filters and comparing
377 * @param source_port_or_eth_type - source port or ethertype to add
378 * @param dest_port - destination port to add
379 * @param type - type of filters and comparing
382 qed_llh_add_protocol_filter(struct qed_dev *cdev,
383 u8 ppfid,
384 enum qed_llh_prot_filter_type_t type,
385 u16 source_port_or_eth_type, u16 dest_port);
388 * @brief qed_llh_remove_protocol_filter - Remove a LLH protocol filter from
389 * the given filter bank.
391 * @param cdev
392 * @param ppfid - relative within the allocated ppfids ('0' is the default one).
393 * @param type - type of filters and comparing
394 * @param source_port_or_eth_type - source port or ethertype to add
395 * @param dest_port - destination port to add
397 void
398 qed_llh_remove_protocol_filter(struct qed_dev *cdev,
399 u8 ppfid,
400 enum qed_llh_prot_filter_type_t type,
401 u16 source_port_or_eth_type, u16 dest_port);
404 * *@brief Cleanup of previous driver remains prior to load
406 * @param p_hwfn
407 * @param p_ptt
408 * @param id - For PF, engine-relative. For VF, PF-relative.
409 * @param is_vf - true iff cleanup is made for a VF.
411 * @return int
413 int qed_final_cleanup(struct qed_hwfn *p_hwfn,
414 struct qed_ptt *p_ptt, u16 id, bool is_vf);
417 * @brief qed_get_queue_coalesce - Retrieve coalesce value for a given queue.
419 * @param p_hwfn
420 * @param p_coal - store coalesce value read from the hardware.
421 * @param p_handle
423 * @return int
425 int qed_get_queue_coalesce(struct qed_hwfn *p_hwfn, u16 *coal, void *handle);
428 * @brief qed_set_queue_coalesce - Configure coalesce parameters for Rx and
429 * Tx queue. The fact that we can configure coalescing to up to 511, but on
430 * varying accuracy [the bigger the value the less accurate] up to a mistake
431 * of 3usec for the highest values.
432 * While the API allows setting coalescing per-qid, all queues sharing a SB
433 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
434 * otherwise configuration would break.
437 * @param rx_coal - Rx Coalesce value in micro seconds.
438 * @param tx_coal - TX Coalesce value in micro seconds.
439 * @param p_handle
441 * @return int
444 qed_set_queue_coalesce(u16 rx_coal, u16 tx_coal, void *p_handle);
447 * @brief qed_pglueb_set_pfid_enable - Enable or disable PCI BUS MASTER
449 * @param p_hwfn
450 * @param p_ptt
451 * @param b_enable - true/false
453 * @return int
455 int qed_pglueb_set_pfid_enable(struct qed_hwfn *p_hwfn,
456 struct qed_ptt *p_ptt, bool b_enable);
459 * @brief db_recovery_add - add doorbell information to the doorbell
460 * recovery mechanism.
462 * @param cdev
463 * @param db_addr - doorbell address
464 * @param db_data - address of where db_data is stored
465 * @param db_width - doorbell is 32b pr 64b
466 * @param db_space - doorbell recovery addresses are user or kernel space
468 int qed_db_recovery_add(struct qed_dev *cdev,
469 void __iomem *db_addr,
470 void *db_data,
471 enum qed_db_rec_width db_width,
472 enum qed_db_rec_space db_space);
475 * @brief db_recovery_del - remove doorbell information from the doorbell
476 * recovery mechanism. db_data serves as key (db_addr is not unique).
478 * @param cdev
479 * @param db_addr - doorbell address
480 * @param db_data - address where db_data is stored. Serves as key for the
481 * entry to delete.
483 int qed_db_recovery_del(struct qed_dev *cdev,
484 void __iomem *db_addr, void *db_data);
487 const char *qed_hw_get_resc_name(enum qed_resources res_id);
488 #endif