2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_DEV_API_H__
10 #define __ECORE_DEV_API_H__
12 #include "ecore_status.h"
13 #include "ecore_chain.h"
14 #include "ecore_int_api.h"
16 struct ecore_tunn_start_params;
19 * @brief ecore_init_dp - initialize the debug level
26 void ecore_init_dp(struct ecore_dev *p_dev,
27 u32 dp_module, u8 dp_level, void *dp_ctx);
30 * @brief ecore_init_struct - initialize the device structure to
35 void ecore_init_struct(struct ecore_dev *p_dev);
38 * @brief ecore_resc_free -
42 void ecore_resc_free(struct ecore_dev *p_dev);
45 * @brief ecore_resc_alloc -
49 * @return enum _ecore_status_t
51 enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev);
54 * @brief ecore_resc_setup -
58 void ecore_resc_setup(struct ecore_dev *p_dev);
61 * @brief ecore_hw_init -
64 * @param p_tunn - tunneling parameters
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 enum _ecore_status_t
74 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
75 struct ecore_tunn_start_params *p_tunn,
77 enum ecore_int_mode int_mode,
78 bool allow_npar_tx_switch,
79 const u8 *bin_fw_data);
82 * @brief ecore_hw_timers_stop_all -
88 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev);
91 * @brief ecore_hw_stop -
95 * @return enum _ecore_status_t
97 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev);
100 * @brief ecore_hw_stop_fastpath -should be called incase
101 * slowpath is still required for the device, but
107 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
110 * @brief ecore_prepare_hibernate -should be called when
111 * the system is going into the hibernate state
116 void ecore_prepare_hibernate(struct ecore_dev *p_dev);
119 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
120 * only if hw_stop_fastpath was called
125 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
128 * @brief ecore_hw_reset -
132 * @return enum _ecore_status_t
134 enum _ecore_status_t ecore_hw_reset(struct ecore_dev *p_dev);
137 * @brief ecore_hw_prepare -
140 * @param personality - personality to initialize
142 * @return enum _ecore_status_t
144 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev, int personality);
147 * @brief ecore_hw_remove -
151 void ecore_hw_remove(struct ecore_dev *p_dev);
154 * @brief ecore_ptt_acquire - Allocate a PTT window
156 * Should be called at the entry point to the driver (at the beginning of an
161 * @return struct ecore_ptt
163 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
166 * @brief ecore_ptt_release - Release PTT Window
168 * Should be called at the end of a flow - at the end of the function that
175 void ecore_ptt_release(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
177 #ifndef __EXTRACT__LINUX__
178 struct ecore_eth_stats {
179 u64 no_buff_discards;
180 u64 packet_too_big_discard;
188 u64 mftag_filter_discards;
189 u64 mac_filter_discards;
196 u64 tx_err_drop_pkts;
197 u64 tpa_coalesced_pkts;
198 u64 tpa_coalesced_events;
200 u64 tpa_not_coalesced_pkts;
201 u64 tpa_coalesced_bytes;
204 u64 rx_64_byte_packets;
205 u64 rx_65_to_127_byte_packets;
206 u64 rx_128_to_255_byte_packets;
207 u64 rx_256_to_511_byte_packets;
208 u64 rx_512_to_1023_byte_packets;
209 u64 rx_1024_to_1518_byte_packets;
210 u64 rx_1519_to_1522_byte_packets;
211 u64 rx_1519_to_2047_byte_packets;
212 u64 rx_2048_to_4095_byte_packets;
213 u64 rx_4096_to_9216_byte_packets;
214 u64 rx_9217_to_16383_byte_packets;
216 u64 rx_mac_crtl_frames;
220 u64 rx_carrier_errors;
221 u64 rx_oversize_packets;
223 u64 rx_undersize_packets;
225 u64 tx_64_byte_packets;
226 u64 tx_65_to_127_byte_packets;
227 u64 tx_128_to_255_byte_packets;
228 u64 tx_256_to_511_byte_packets;
229 u64 tx_512_to_1023_byte_packets;
230 u64 tx_1024_to_1518_byte_packets;
231 u64 tx_1519_to_2047_byte_packets;
232 u64 tx_2048_to_4095_byte_packets;
233 u64 tx_4096_to_9216_byte_packets;
234 u64 tx_9217_to_16383_byte_packets;
237 u64 tx_lpi_entry_count;
238 u64 tx_total_collisions;
242 u64 rx_mac_uc_packets;
243 u64 rx_mac_mc_packets;
244 u64 rx_mac_bc_packets;
245 u64 rx_mac_frames_ok;
247 u64 tx_mac_uc_packets;
248 u64 tx_mac_mc_packets;
249 u64 tx_mac_bc_packets;
250 u64 tx_mac_ctrl_frames;
254 enum ecore_dmae_address_type_t {
255 ECORE_DMAE_ADDRESS_HOST_VIRT,
256 ECORE_DMAE_ADDRESS_HOST_PHYS,
257 ECORE_DMAE_ADDRESS_GRC
260 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
261 * source is a block of length DMAE_MAX_RW_SIZE and the
262 * destination is larger, the source block will be duplicated as
263 * many times as required to fill the destination block. This is
264 * used mostly to write a zeroed buffer to destination address
267 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
268 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
269 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
270 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
272 struct ecore_dmae_params {
273 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
279 * @brief ecore_dmae_host2grc - copy data from source addr to
280 * dmae registers using the given ptt
285 * @param grc_addr (dmae_data_offset)
286 * @param size_in_dwords
287 * @param flags (one of the flags defined above)
290 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
291 struct ecore_ptt *p_ptt,
293 u32 grc_addr, u32 size_in_dwords, u32 flags);
296 * @brief ecore_dmae_grc2host - Read data from dmae data offset
297 * to source address using the given ptt
300 * @param grc_addr (dmae_data_offset)
302 * @param size_in_dwords
303 * @param flags - one of the flags defined above
306 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
307 struct ecore_ptt *p_ptt,
309 dma_addr_t dest_addr, u32 size_in_dwords, u32 flags);
312 * @brief ecore_dmae_host2host - copy data from to source address
313 * to a destination address (for SRIOV) using the given ptt
319 * @param size_in_dwords
323 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
324 struct ecore_ptt *p_ptt,
325 dma_addr_t source_addr,
326 dma_addr_t dest_addr,
327 u32 size_in_dwords, struct ecore_dmae_params *p_params);
330 * @brief ecore_chain_alloc - Allocate and initialize a chain
333 * @param intended_use
339 * @return enum _ecore_status_t
342 ecore_chain_alloc(struct ecore_dev *p_dev,
343 enum ecore_chain_use_mode intended_use,
344 enum ecore_chain_mode mode,
345 enum ecore_chain_cnt_type cnt_type,
347 osal_size_t elem_size, struct ecore_chain *p_chain);
350 * @brief ecore_chain_free - Free chain DMA memory
355 void ecore_chain_free(struct ecore_dev *p_dev, struct ecore_chain *p_chain);
358 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
361 * @param src_id - relative to p_hwfn
362 * @param dst_id - absolute per engine
364 * @return enum _ecore_status_t
366 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
367 u16 src_id, u16 *dst_id);
370 * @@brief ecore_fw_vport - Get absolute vport ID
373 * @param src_id - relative to p_hwfn
374 * @param dst_id - absolute per engine
376 * @return enum _ecore_status_t
378 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
379 u8 src_id, u8 *dst_id);
382 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
385 * @param src_id - relative to p_hwfn
386 * @param dst_id - absolute per engine
388 * @return enum _ecore_status_t
390 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
391 u8 src_id, u8 *dst_id);
394 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
398 * @param p_filter - MAC to add
400 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
401 struct ecore_ptt *p_ptt,
405 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
409 * @param p_filter - MAC to remove
411 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
412 struct ecore_ptt *p_ptt, u8 *p_filter);
415 * @brief ecore_llh_add_ethertype_filter - configures a ethertype filter in llh
419 * @param filter - ethertype to add
421 enum _ecore_status_t ecore_llh_add_ethertype_filter(struct ecore_hwfn *p_hwfn,
422 struct ecore_ptt *p_ptt,
426 * @brief ecore_llh_remove_ethertype_filter - removes a ethertype llh filter
430 * @param filter - ethertype to remove
432 void ecore_llh_remove_ethertype_filter(struct ecore_hwfn *p_hwfn,
433 struct ecore_ptt *p_ptt, u16 filter);
436 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
441 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
442 struct ecore_ptt *p_ptt);
445 *@brief Cleanup of previous driver remains prior to load
449 * @param id - For PF, engine-relative. For VF, PF-relative.
450 * @param is_vf - true iff cleanup is made for a VF.
452 * @return enum _ecore_status_t
454 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
455 struct ecore_ptt *p_ptt,
459 * @brief ecore_test_registers - Perform register tests
464 * @return enum _ecore_status_t
466 enum _ecore_status_t ecore_test_registers(struct ecore_hwfn *p_hwfn,
467 struct ecore_ptt *p_ptt);
470 * @brief ecore_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
474 * @param coalesce - Coalesce value in micro seconds.
475 * @param qid - Queue index.
477 * @return enum _ecore_status_t
479 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
480 struct ecore_ptt *p_ptt,
481 u8 coalesce, u8 qid);
484 * @brief ecore_set_txq_coalesce - Configure coalesce parameters for a Tx queue
488 * @param coalesce - Coalesce value in micro seconds.
489 * @param qid - Queue index.
491 * @return enum _ecore_status_t
493 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
494 struct ecore_ptt *p_ptt,
495 u8 coalesce, u8 qid);