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"
17 * @brief ecore_init_dp - initialize the debug level
24 void ecore_init_dp(struct ecore_dev *p_dev,
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,
102 * but fastpath is not.
107 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
111 * @brief ecore_prepare_hibernate -should be called when
112 * the system is going into the hibernate state
117 void ecore_prepare_hibernate(struct ecore_dev *p_dev);
121 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
122 * only if hw_stop_fastpath was called
127 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
130 * @brief ecore_hw_reset -
134 * @return enum _ecore_status_t
136 enum _ecore_status_t ecore_hw_reset(struct ecore_dev *p_dev);
138 struct ecore_hw_prepare_params {
139 /* personality to initialize */
141 /* force the driver's default resource allocation */
143 /* check the reg_fifo after any register access */
148 * @brief ecore_hw_prepare -
153 * @return enum _ecore_status_t
155 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev,
156 struct ecore_hw_prepare_params *p_params);
159 * @brief ecore_hw_remove -
163 void ecore_hw_remove(struct ecore_dev *p_dev);
166 * @brief ecore_ptt_acquire - Allocate a PTT window
168 * Should be called at the entry point to the driver (at the beginning of an
173 * @return struct ecore_ptt
175 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
178 * @brief ecore_ptt_release - Release PTT Window
180 * Should be called at the end of a flow - at the end of the function that
187 void ecore_ptt_release(struct ecore_hwfn *p_hwfn,
188 struct ecore_ptt *p_ptt);
190 #ifndef __EXTRACT__LINUX__
191 struct ecore_eth_stats {
192 u64 no_buff_discards;
193 u64 packet_too_big_discard;
201 u64 mftag_filter_discards;
202 u64 mac_filter_discards;
209 u64 tx_err_drop_pkts;
210 u64 tpa_coalesced_pkts;
211 u64 tpa_coalesced_events;
213 u64 tpa_not_coalesced_pkts;
214 u64 tpa_coalesced_bytes;
217 u64 rx_64_byte_packets;
218 u64 rx_65_to_127_byte_packets;
219 u64 rx_128_to_255_byte_packets;
220 u64 rx_256_to_511_byte_packets;
221 u64 rx_512_to_1023_byte_packets;
222 u64 rx_1024_to_1518_byte_packets;
223 u64 rx_1519_to_1522_byte_packets;
224 u64 rx_1519_to_2047_byte_packets;
225 u64 rx_2048_to_4095_byte_packets;
226 u64 rx_4096_to_9216_byte_packets;
227 u64 rx_9217_to_16383_byte_packets;
229 u64 rx_mac_crtl_frames;
233 u64 rx_carrier_errors;
234 u64 rx_oversize_packets;
236 u64 rx_undersize_packets;
238 u64 tx_64_byte_packets;
239 u64 tx_65_to_127_byte_packets;
240 u64 tx_128_to_255_byte_packets;
241 u64 tx_256_to_511_byte_packets;
242 u64 tx_512_to_1023_byte_packets;
243 u64 tx_1024_to_1518_byte_packets;
244 u64 tx_1519_to_2047_byte_packets;
245 u64 tx_2048_to_4095_byte_packets;
246 u64 tx_4096_to_9216_byte_packets;
247 u64 tx_9217_to_16383_byte_packets;
250 u64 tx_lpi_entry_count;
251 u64 tx_total_collisions;
255 u64 rx_mac_uc_packets;
256 u64 rx_mac_mc_packets;
257 u64 rx_mac_bc_packets;
258 u64 rx_mac_frames_ok;
260 u64 tx_mac_uc_packets;
261 u64 tx_mac_mc_packets;
262 u64 tx_mac_bc_packets;
263 u64 tx_mac_ctrl_frames;
267 enum ecore_dmae_address_type_t {
268 ECORE_DMAE_ADDRESS_HOST_VIRT,
269 ECORE_DMAE_ADDRESS_HOST_PHYS,
270 ECORE_DMAE_ADDRESS_GRC
273 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
274 * source is a block of length DMAE_MAX_RW_SIZE and the
275 * destination is larger, the source block will be duplicated as
276 * many times as required to fill the destination block. This is
277 * used mostly to write a zeroed buffer to destination address
280 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
281 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
282 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
283 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
285 struct ecore_dmae_params {
286 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
292 * @brief ecore_dmae_host2grc - copy data from source addr to
293 * dmae registers using the given ptt
298 * @param grc_addr (dmae_data_offset)
299 * @param size_in_dwords
300 * @param flags (one of the flags defined above)
303 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
304 struct ecore_ptt *p_ptt,
311 * @brief ecore_dmae_grc2host - Read data from dmae data offset
312 * to source address using the given ptt
315 * @param grc_addr (dmae_data_offset)
317 * @param size_in_dwords
318 * @param flags - one of the flags defined above
321 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
322 struct ecore_ptt *p_ptt,
324 dma_addr_t dest_addr,
329 * @brief ecore_dmae_host2host - copy data from to source address
330 * to a destination address (for SRIOV) using the given ptt
336 * @param size_in_dwords
340 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
341 struct ecore_ptt *p_ptt,
342 dma_addr_t source_addr,
343 dma_addr_t dest_addr,
345 struct ecore_dmae_params *p_params);
348 * @brief ecore_chain_alloc - Allocate and initialize a chain
351 * @param intended_use
357 * @return enum _ecore_status_t
360 ecore_chain_alloc(struct ecore_dev *p_dev,
361 enum ecore_chain_use_mode intended_use,
362 enum ecore_chain_mode mode,
363 enum ecore_chain_cnt_type cnt_type,
365 osal_size_t elem_size,
366 struct ecore_chain *p_chain);
369 * @brief ecore_chain_free - Free chain DMA memory
374 void ecore_chain_free(struct ecore_dev *p_dev,
375 struct ecore_chain *p_chain);
378 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
381 * @param src_id - relative to p_hwfn
382 * @param dst_id - absolute per engine
384 * @return enum _ecore_status_t
386 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
391 * @@brief ecore_fw_vport - Get absolute vport ID
394 * @param src_id - relative to p_hwfn
395 * @param dst_id - absolute per engine
397 * @return enum _ecore_status_t
399 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
404 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
407 * @param src_id - relative to p_hwfn
408 * @param dst_id - absolute per engine
410 * @return enum _ecore_status_t
412 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
417 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
421 * @param p_filter - MAC to add
423 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
424 struct ecore_ptt *p_ptt,
428 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
432 * @param p_filter - MAC to remove
434 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
435 struct ecore_ptt *p_ptt,
438 enum ecore_llh_port_filter_type_t {
439 ECORE_LLH_FILTER_ETHERTYPE,
440 ECORE_LLH_FILTER_TCP_SRC_PORT,
441 ECORE_LLH_FILTER_TCP_DEST_PORT,
442 ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
443 ECORE_LLH_FILTER_UDP_SRC_PORT,
444 ECORE_LLH_FILTER_UDP_DEST_PORT,
445 ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT
449 * @brief ecore_llh_add_protocol_filter - configures a protocol filter in llh
453 * @param source_port_or_eth_type - source port or ethertype to add
454 * @param dest_port - destination port to add
455 * @param type - type of filters and comparing
458 ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
459 struct ecore_ptt *p_ptt,
460 u16 source_port_or_eth_type,
462 enum ecore_llh_port_filter_type_t type);
465 * @brief ecore_llh_remove_protocol_filter - remove a protocol filter in llh
469 * @param source_port_or_eth_type - source port or ethertype to add
470 * @param dest_port - destination port to add
471 * @param type - type of filters and comparing
474 ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
475 struct ecore_ptt *p_ptt,
476 u16 source_port_or_eth_type,
478 enum ecore_llh_port_filter_type_t type);
481 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
486 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
487 struct ecore_ptt *p_ptt);
490 * @brief ecore_llh_set_function_as_default - set function as default per port
496 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
497 struct ecore_ptt *p_ptt);
500 *@brief Cleanup of previous driver remains prior to load
504 * @param id - For PF, engine-relative. For VF, PF-relative.
505 * @param is_vf - true iff cleanup is made for a VF.
507 * @return enum _ecore_status_t
509 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
510 struct ecore_ptt *p_ptt,
515 * @brief ecore_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
516 * The fact that we can configure coalescing to up to 511, but on varying
517 * accuracy [the bigger the value the less accurate] up to a mistake of 3usec
518 * for the highest values.
522 * @param coalesce - Coalesce value in micro seconds.
523 * @param qid - Queue index.
526 * @return enum _ecore_status_t
528 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
529 struct ecore_ptt *p_ptt,
530 u16 coalesce, u8 qid, u16 sb_id);
533 * @brief ecore_set_txq_coalesce - Configure coalesce parameters for a Tx queue
534 * While the API allows setting coalescing per-qid, all tx queues sharing a
535 * SB should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
536 * otherwise configuration would break.
540 * @param coalesce - Coalesce value in micro seconds.
541 * @param qid - Queue index.
544 * @return enum _ecore_status_t
546 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
547 struct ecore_ptt *p_ptt,
548 u16 coalesce, u8 qid, u16 sb_id);