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);
60 struct ecore_hw_init_params {
61 /* Tunnelling parameters */
62 struct ecore_tunnel_info *p_tunn;
66 /* Interrupt mode [msix, inta, etc.] to use */
67 enum ecore_int_mode int_mode;
69 /* NPAR tx switching to be used for vports configured for tx-switching
71 bool allow_npar_tx_switch;
73 /* Binary fw data pointer in binary fw file */
74 const u8 *bin_fw_data;
76 /* Indicates whether the driver is running over a crash kernel.
77 * As part of the load request, this will be used for providing the
78 * driver role to the MFW.
79 * In case of a crash kernel over PDA - this should be set to false.
83 /* The timeout value that the MFW should use when locking the engine for
84 * the driver load process.
85 * A value of '0' means the default value, and '255' means no timeout.
88 #define ECORE_LOAD_REQ_LOCK_TO_DEFAULT 0
89 #define ECORE_LOAD_REQ_LOCK_TO_NONE 255
91 /* Avoid engine reset when first PF loads on it */
96 * @brief ecore_hw_init -
101 * @return enum _ecore_status_t
103 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
104 struct ecore_hw_init_params *p_params);
107 * @brief ecore_hw_timers_stop_all -
113 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev);
116 * @brief ecore_hw_stop -
120 * @return enum _ecore_status_t
122 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev);
125 * @brief ecore_hw_stop_fastpath -should be called incase
126 * slowpath is still required for the device,
127 * but fastpath is not.
132 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
136 * @brief ecore_prepare_hibernate -should be called when
137 * the system is going into the hibernate state
142 void ecore_prepare_hibernate(struct ecore_dev *p_dev);
146 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
147 * only if hw_stop_fastpath was called
152 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
154 enum ecore_hw_prepare_result {
155 ECORE_HW_PREPARE_SUCCESS,
157 /* FAILED results indicate probe has failed & cleaned up */
158 ECORE_HW_PREPARE_FAILED_ENG2,
159 ECORE_HW_PREPARE_FAILED_ME,
160 ECORE_HW_PREPARE_FAILED_MEM,
161 ECORE_HW_PREPARE_FAILED_DEV,
162 ECORE_HW_PREPARE_FAILED_NVM,
164 /* BAD results indicate probe is passed even though some wrongness
165 * has occurred; Trying to actually use [I.e., hw_init()] might have
166 * dire reprecautions.
168 ECORE_HW_PREPARE_BAD_IOV,
169 ECORE_HW_PREPARE_BAD_MCP,
170 ECORE_HW_PREPARE_BAD_IGU,
173 struct ecore_hw_prepare_params {
174 /* Personality to initialize */
177 /* Force the driver's default resource allocation */
180 /* Check the reg_fifo after any register access */
183 /* Request the MFW to initiate PF FLR */
184 bool initiate_pf_flr;
186 /* The OS Epoch time in seconds */
189 /* Allow prepare to pass even if some initializations are failing.
190 * If set, the `p_prepare_res' field would be set with the return,
191 * and might allow probe to pass even if there are certain issues.
193 bool b_relaxed_probe;
194 enum ecore_hw_prepare_result p_relaxed_res;
198 * @brief ecore_hw_prepare -
203 * @return enum _ecore_status_t
205 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev,
206 struct ecore_hw_prepare_params *p_params);
209 * @brief ecore_hw_remove -
213 void ecore_hw_remove(struct ecore_dev *p_dev);
216 * @brief ecore_ptt_acquire - Allocate a PTT window
218 * Should be called at the entry point to the driver (at the beginning of an
223 * @return struct ecore_ptt
225 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
228 * @brief ecore_ptt_release - Release PTT Window
230 * Should be called at the end of a flow - at the end of the function that
237 void ecore_ptt_release(struct ecore_hwfn *p_hwfn,
238 struct ecore_ptt *p_ptt);
240 #ifndef __EXTRACT__LINUX__
241 struct ecore_eth_stats {
242 u64 no_buff_discards;
243 u64 packet_too_big_discard;
251 u64 mftag_filter_discards;
252 u64 mac_filter_discards;
259 u64 tx_err_drop_pkts;
260 u64 tpa_coalesced_pkts;
261 u64 tpa_coalesced_events;
263 u64 tpa_not_coalesced_pkts;
264 u64 tpa_coalesced_bytes;
267 u64 rx_64_byte_packets;
268 u64 rx_65_to_127_byte_packets;
269 u64 rx_128_to_255_byte_packets;
270 u64 rx_256_to_511_byte_packets;
271 u64 rx_512_to_1023_byte_packets;
272 u64 rx_1024_to_1518_byte_packets;
273 u64 rx_1519_to_1522_byte_packets;
274 u64 rx_1519_to_2047_byte_packets;
275 u64 rx_2048_to_4095_byte_packets;
276 u64 rx_4096_to_9216_byte_packets;
277 u64 rx_9217_to_16383_byte_packets;
279 u64 rx_mac_crtl_frames;
283 u64 rx_carrier_errors;
284 u64 rx_oversize_packets;
286 u64 rx_undersize_packets;
288 u64 tx_64_byte_packets;
289 u64 tx_65_to_127_byte_packets;
290 u64 tx_128_to_255_byte_packets;
291 u64 tx_256_to_511_byte_packets;
292 u64 tx_512_to_1023_byte_packets;
293 u64 tx_1024_to_1518_byte_packets;
294 u64 tx_1519_to_2047_byte_packets;
295 u64 tx_2048_to_4095_byte_packets;
296 u64 tx_4096_to_9216_byte_packets;
297 u64 tx_9217_to_16383_byte_packets;
300 u64 tx_lpi_entry_count;
301 u64 tx_total_collisions;
305 u64 rx_mac_uc_packets;
306 u64 rx_mac_mc_packets;
307 u64 rx_mac_bc_packets;
308 u64 rx_mac_frames_ok;
310 u64 tx_mac_uc_packets;
311 u64 tx_mac_mc_packets;
312 u64 tx_mac_bc_packets;
313 u64 tx_mac_ctrl_frames;
317 enum ecore_dmae_address_type_t {
318 ECORE_DMAE_ADDRESS_HOST_VIRT,
319 ECORE_DMAE_ADDRESS_HOST_PHYS,
320 ECORE_DMAE_ADDRESS_GRC
323 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
324 * source is a block of length DMAE_MAX_RW_SIZE and the
325 * destination is larger, the source block will be duplicated as
326 * many times as required to fill the destination block. This is
327 * used mostly to write a zeroed buffer to destination address
330 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
331 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
332 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
333 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
335 struct ecore_dmae_params {
336 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
342 * @brief ecore_dmae_host2grc - copy data from source addr to
343 * dmae registers using the given ptt
348 * @param grc_addr (dmae_data_offset)
349 * @param size_in_dwords
350 * @param flags (one of the flags defined above)
353 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
354 struct ecore_ptt *p_ptt,
361 * @brief ecore_dmae_grc2host - Read data from dmae data offset
362 * to source address using the given ptt
365 * @param grc_addr (dmae_data_offset)
367 * @param size_in_dwords
368 * @param flags - one of the flags defined above
371 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
372 struct ecore_ptt *p_ptt,
374 dma_addr_t dest_addr,
379 * @brief ecore_dmae_host2host - copy data from to source address
380 * to a destination address (for SRIOV) using the given ptt
386 * @param size_in_dwords
390 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
391 struct ecore_ptt *p_ptt,
392 dma_addr_t source_addr,
393 dma_addr_t dest_addr,
395 struct ecore_dmae_params *p_params);
398 * @brief ecore_chain_alloc - Allocate and initialize a chain
401 * @param intended_use
407 * @return enum _ecore_status_t
410 ecore_chain_alloc(struct ecore_dev *p_dev,
411 enum ecore_chain_use_mode intended_use,
412 enum ecore_chain_mode mode,
413 enum ecore_chain_cnt_type cnt_type,
415 osal_size_t elem_size,
416 struct ecore_chain *p_chain,
417 struct ecore_chain_ext_pbl *ext_pbl);
420 * @brief ecore_chain_free - Free chain DMA memory
425 void ecore_chain_free(struct ecore_dev *p_dev,
426 struct ecore_chain *p_chain);
429 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
432 * @param src_id - relative to p_hwfn
433 * @param dst_id - absolute per engine
435 * @return enum _ecore_status_t
437 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
442 * @@brief ecore_fw_vport - Get absolute vport ID
445 * @param src_id - relative to p_hwfn
446 * @param dst_id - absolute per engine
448 * @return enum _ecore_status_t
450 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
455 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
458 * @param src_id - relative to p_hwfn
459 * @param dst_id - absolute per engine
461 * @return enum _ecore_status_t
463 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
468 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
472 * @param p_filter - MAC to add
474 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
475 struct ecore_ptt *p_ptt,
479 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
483 * @param p_filter - MAC to remove
485 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
486 struct ecore_ptt *p_ptt,
489 enum ecore_llh_port_filter_type_t {
490 ECORE_LLH_FILTER_ETHERTYPE,
491 ECORE_LLH_FILTER_TCP_SRC_PORT,
492 ECORE_LLH_FILTER_TCP_DEST_PORT,
493 ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
494 ECORE_LLH_FILTER_UDP_SRC_PORT,
495 ECORE_LLH_FILTER_UDP_DEST_PORT,
496 ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT
500 * @brief ecore_llh_add_protocol_filter - configures a protocol filter in llh
504 * @param source_port_or_eth_type - source port or ethertype to add
505 * @param dest_port - destination port to add
506 * @param type - type of filters and comparing
509 ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
510 struct ecore_ptt *p_ptt,
511 u16 source_port_or_eth_type,
513 enum ecore_llh_port_filter_type_t type);
516 * @brief ecore_llh_remove_protocol_filter - remove a protocol filter in llh
520 * @param source_port_or_eth_type - source port or ethertype to add
521 * @param dest_port - destination port to add
522 * @param type - type of filters and comparing
525 ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
526 struct ecore_ptt *p_ptt,
527 u16 source_port_or_eth_type,
529 enum ecore_llh_port_filter_type_t type);
532 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
537 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
538 struct ecore_ptt *p_ptt);
541 * @brief ecore_llh_set_function_as_default - set function as default per port
547 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
548 struct ecore_ptt *p_ptt);
551 *@brief Cleanup of previous driver remains prior to load
555 * @param id - For PF, engine-relative. For VF, PF-relative.
556 * @param is_vf - true iff cleanup is made for a VF.
558 * @return enum _ecore_status_t
560 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
561 struct ecore_ptt *p_ptt,
565 * @brief ecore_set_queue_coalesce - Configure coalesce parameters for Rx and
566 * Tx queue. The fact that we can configure coalescing to up to 511, but on
567 * varying accuracy [the bigger the value the less accurate] up to a mistake
568 * of 3usec for the highest values.
569 * While the API allows setting coalescing per-qid, all queues sharing a SB
570 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
571 * otherwise configuration would break.
574 * @param rx_coal - Rx Coalesce value in micro seconds.
575 * @param tx_coal - TX Coalesce value in micro seconds.
578 * @return enum _ecore_status_t
581 ecore_set_queue_coalesce(struct ecore_hwfn *p_hwfn, u16 rx_coal,
582 u16 tx_coal, void *p_handle);