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 enum _ecore_status_t 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 enum ecore_mfw_timeout_fallback {
61 ECORE_TO_FALLBACK_TO_NONE,
62 ECORE_TO_FALLBACK_TO_DEFAULT,
63 ECORE_TO_FALLBACK_FAIL_LOAD,
66 enum ecore_override_force_load {
67 ECORE_OVERRIDE_FORCE_LOAD_NONE,
68 ECORE_OVERRIDE_FORCE_LOAD_ALWAYS,
69 ECORE_OVERRIDE_FORCE_LOAD_NEVER,
72 struct ecore_drv_load_params {
73 /* Indicates whether the driver is running over a crash kernel.
74 * As part of the load request, this will be used for providing the
75 * driver role to the MFW.
76 * In case of a crash kernel over PDA - this should be set to false.
80 /* The timeout value that the MFW should use when locking the engine for
81 * the driver load process.
82 * A value of '0' means the default value, and '255' means no timeout.
85 #define ECORE_LOAD_REQ_LOCK_TO_DEFAULT 0
86 #define ECORE_LOAD_REQ_LOCK_TO_NONE 255
88 /* Action to take in case the MFW doesn't support timeout values other
89 * than default and none.
91 enum ecore_mfw_timeout_fallback mfw_timeout_fallback;
93 /* Avoid engine reset when first PF loads on it */
96 /* Allow overriding the default force load behavior */
97 enum ecore_override_force_load override_force_load;
100 struct ecore_hw_init_params {
101 /* Tunneling parameters */
102 struct ecore_tunnel_info *p_tunn;
106 /* Interrupt mode [msix, inta, etc.] to use */
107 enum ecore_int_mode int_mode;
109 /* NPAR tx switching to be used for vports configured for tx-switching
111 bool allow_npar_tx_switch;
113 /* Binary fw data pointer in binary fw file */
114 const u8 *bin_fw_data;
116 /* Driver load parameters */
117 struct ecore_drv_load_params *p_drv_load_params;
119 /* SPQ block timeout in msec */
124 * @brief ecore_hw_init -
129 * @return enum _ecore_status_t
131 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
132 struct ecore_hw_init_params *p_params);
135 * @brief ecore_hw_timers_stop_all -
141 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev);
144 * @brief ecore_hw_stop -
148 * @return enum _ecore_status_t
150 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev);
153 * @brief ecore_hw_stop_fastpath -should be called incase
154 * slowpath is still required for the device,
155 * but fastpath is not.
159 * @return enum _ecore_status_t
161 enum _ecore_status_t ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
165 * @brief ecore_prepare_hibernate -should be called when
166 * the system is going into the hibernate state
171 void ecore_prepare_hibernate(struct ecore_dev *p_dev);
173 enum ecore_db_rec_width {
178 enum ecore_db_rec_space {
184 * @brief db_recovery_add - add doorbell information to the doorbell
185 * recovery mechanism.
188 * @param db_addr - doorbell address
189 * @param db_data - address of where db_data is stored
190 * @param db_width - doorbell is 32b pr 64b
191 * @param db_space - doorbell recovery addresses are user or kernel space
193 enum _ecore_status_t ecore_db_recovery_add(struct ecore_dev *p_dev,
194 void OSAL_IOMEM *db_addr,
196 enum ecore_db_rec_width db_width,
197 enum ecore_db_rec_space db_space);
200 * @brief db_recovery_del - remove doorbell information from the doorbell
201 * recovery mechanism. db_data serves as key (db_addr is not unique).
204 * @param db_addr - doorbell address
205 * @param db_data - address where db_data is stored. Serves as key for the
208 enum _ecore_status_t ecore_db_recovery_del(struct ecore_dev *p_dev,
209 void OSAL_IOMEM *db_addr,
212 static OSAL_INLINE bool ecore_is_mf_ufp(struct ecore_hwfn *p_hwfn)
214 return !!OSAL_TEST_BIT(ECORE_MF_UFP_SPECIFIC, &p_hwfn->p_dev->mf_bits);
220 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
221 * only if hw_stop_fastpath was called
225 * @return enum _ecore_status_t
227 enum _ecore_status_t ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
229 enum ecore_hw_prepare_result {
230 ECORE_HW_PREPARE_SUCCESS,
232 /* FAILED results indicate probe has failed & cleaned up */
233 ECORE_HW_PREPARE_FAILED_ENG2,
234 ECORE_HW_PREPARE_FAILED_ME,
235 ECORE_HW_PREPARE_FAILED_MEM,
236 ECORE_HW_PREPARE_FAILED_DEV,
237 ECORE_HW_PREPARE_FAILED_NVM,
239 /* BAD results indicate probe is passed even though some wrongness
240 * has occurred; Trying to actually use [I.e., hw_init()] might have
241 * dire reprecautions.
243 ECORE_HW_PREPARE_BAD_IOV,
244 ECORE_HW_PREPARE_BAD_MCP,
245 ECORE_HW_PREPARE_BAD_IGU,
248 struct ecore_hw_prepare_params {
249 /* Personality to initialize */
252 /* Force the driver's default resource allocation */
255 /* Check the reg_fifo after any register access */
258 /* Request the MFW to initiate PF FLR */
259 bool initiate_pf_flr;
261 /* The OS Epoch time in seconds */
264 /* Allow the MFW to collect a crash dump */
267 /* Allow prepare to pass even if some initializations are failing.
268 * If set, the `p_prepare_res' field would be set with the return,
269 * and might allow probe to pass even if there are certain issues.
271 bool b_relaxed_probe;
272 enum ecore_hw_prepare_result p_relaxed_res;
276 * @brief ecore_hw_prepare -
281 * @return enum _ecore_status_t
283 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev,
284 struct ecore_hw_prepare_params *p_params);
287 * @brief ecore_hw_remove -
291 void ecore_hw_remove(struct ecore_dev *p_dev);
294 * @brief ecore_ptt_acquire - Allocate a PTT window
296 * Should be called at the entry point to the driver (at the beginning of an
301 * @return struct ecore_ptt
303 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
306 * @brief ecore_ptt_release - Release PTT Window
308 * Should be called at the end of a flow - at the end of the function that
315 void ecore_ptt_release(struct ecore_hwfn *p_hwfn,
316 struct ecore_ptt *p_ptt);
318 struct ecore_eth_stats_common {
319 u64 no_buff_discards;
320 u64 packet_too_big_discard;
328 u64 mftag_filter_discards;
329 u64 mac_filter_discards;
336 u64 tx_err_drop_pkts;
337 u64 tpa_coalesced_pkts;
338 u64 tpa_coalesced_events;
340 u64 tpa_not_coalesced_pkts;
341 u64 tpa_coalesced_bytes;
344 u64 rx_64_byte_packets;
345 u64 rx_65_to_127_byte_packets;
346 u64 rx_128_to_255_byte_packets;
347 u64 rx_256_to_511_byte_packets;
348 u64 rx_512_to_1023_byte_packets;
349 u64 rx_1024_to_1518_byte_packets;
351 u64 rx_mac_crtl_frames;
355 u64 rx_carrier_errors;
356 u64 rx_oversize_packets;
358 u64 rx_undersize_packets;
360 u64 tx_64_byte_packets;
361 u64 tx_65_to_127_byte_packets;
362 u64 tx_128_to_255_byte_packets;
363 u64 tx_256_to_511_byte_packets;
364 u64 tx_512_to_1023_byte_packets;
365 u64 tx_1024_to_1518_byte_packets;
371 u64 rx_mac_uc_packets;
372 u64 rx_mac_mc_packets;
373 u64 rx_mac_bc_packets;
374 u64 rx_mac_frames_ok;
376 u64 tx_mac_uc_packets;
377 u64 tx_mac_mc_packets;
378 u64 tx_mac_bc_packets;
379 u64 tx_mac_ctrl_frames;
380 u64 link_change_count;
383 struct ecore_eth_stats_bb {
384 u64 rx_1519_to_1522_byte_packets;
385 u64 rx_1519_to_2047_byte_packets;
386 u64 rx_2048_to_4095_byte_packets;
387 u64 rx_4096_to_9216_byte_packets;
388 u64 rx_9217_to_16383_byte_packets;
389 u64 tx_1519_to_2047_byte_packets;
390 u64 tx_2048_to_4095_byte_packets;
391 u64 tx_4096_to_9216_byte_packets;
392 u64 tx_9217_to_16383_byte_packets;
393 u64 tx_lpi_entry_count;
394 u64 tx_total_collisions;
397 struct ecore_eth_stats_ah {
398 u64 rx_1519_to_max_byte_packets;
399 u64 tx_1519_to_max_byte_packets;
402 struct ecore_eth_stats {
403 struct ecore_eth_stats_common common;
405 struct ecore_eth_stats_bb bb;
406 struct ecore_eth_stats_ah ah;
410 enum ecore_dmae_address_type_t {
411 ECORE_DMAE_ADDRESS_HOST_VIRT,
412 ECORE_DMAE_ADDRESS_HOST_PHYS,
413 ECORE_DMAE_ADDRESS_GRC
416 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
417 * source is a block of length DMAE_MAX_RW_SIZE and the
418 * destination is larger, the source block will be duplicated as
419 * many times as required to fill the destination block. This is
420 * used mostly to write a zeroed buffer to destination address
423 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
424 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
425 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
426 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
428 struct ecore_dmae_params {
429 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
435 * @brief ecore_dmae_host2grc - copy data from source addr to
436 * dmae registers using the given ptt
441 * @param grc_addr (dmae_data_offset)
442 * @param size_in_dwords
443 * @param flags (one of the flags defined above)
446 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
447 struct ecore_ptt *p_ptt,
454 * @brief ecore_dmae_grc2host - Read data from dmae data offset
455 * to source address using the given ptt
458 * @param grc_addr (dmae_data_offset)
460 * @param size_in_dwords
461 * @param flags - one of the flags defined above
464 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
465 struct ecore_ptt *p_ptt,
467 dma_addr_t dest_addr,
472 * @brief ecore_dmae_host2host - copy data from to source address
473 * to a destination address (for SRIOV) using the given ptt
479 * @param size_in_dwords
483 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
484 struct ecore_ptt *p_ptt,
485 dma_addr_t source_addr,
486 dma_addr_t dest_addr,
488 struct ecore_dmae_params *p_params);
491 * @brief ecore_chain_alloc - Allocate and initialize a chain
494 * @param intended_use
500 * @return enum _ecore_status_t
503 ecore_chain_alloc(struct ecore_dev *p_dev,
504 enum ecore_chain_use_mode intended_use,
505 enum ecore_chain_mode mode,
506 enum ecore_chain_cnt_type cnt_type,
508 osal_size_t elem_size,
509 struct ecore_chain *p_chain,
510 struct ecore_chain_ext_pbl *ext_pbl);
513 * @brief ecore_chain_free - Free chain DMA memory
518 void ecore_chain_free(struct ecore_dev *p_dev,
519 struct ecore_chain *p_chain);
522 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
525 * @param src_id - relative to p_hwfn
526 * @param dst_id - absolute per engine
528 * @return enum _ecore_status_t
530 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
535 * @@brief ecore_fw_vport - Get absolute vport ID
538 * @param src_id - relative to p_hwfn
539 * @param dst_id - absolute per engine
541 * @return enum _ecore_status_t
543 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
548 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
551 * @param src_id - relative to p_hwfn
552 * @param dst_id - absolute per engine
554 * @return enum _ecore_status_t
556 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
561 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
565 * @param p_filter - MAC to add
567 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
568 struct ecore_ptt *p_ptt,
572 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
576 * @param p_filter - MAC to remove
578 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
579 struct ecore_ptt *p_ptt,
582 enum ecore_llh_port_filter_type_t {
583 ECORE_LLH_FILTER_ETHERTYPE,
584 ECORE_LLH_FILTER_TCP_SRC_PORT,
585 ECORE_LLH_FILTER_TCP_DEST_PORT,
586 ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
587 ECORE_LLH_FILTER_UDP_SRC_PORT,
588 ECORE_LLH_FILTER_UDP_DEST_PORT,
589 ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT
593 * @brief ecore_llh_add_protocol_filter - configures a protocol filter in llh
597 * @param source_port_or_eth_type - source port or ethertype to add
598 * @param dest_port - destination port to add
599 * @param type - type of filters and comparing
602 ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
603 struct ecore_ptt *p_ptt,
604 u16 source_port_or_eth_type,
606 enum ecore_llh_port_filter_type_t type);
609 * @brief ecore_llh_remove_protocol_filter - remove a protocol filter in llh
613 * @param source_port_or_eth_type - source port or ethertype to add
614 * @param dest_port - destination port to add
615 * @param type - type of filters and comparing
618 ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
619 struct ecore_ptt *p_ptt,
620 u16 source_port_or_eth_type,
622 enum ecore_llh_port_filter_type_t type);
625 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
630 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
631 struct ecore_ptt *p_ptt);
634 * @brief ecore_llh_set_function_as_default - set function as default per port
640 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
641 struct ecore_ptt *p_ptt);
644 *@brief Cleanup of previous driver remains prior to load
648 * @param id - For PF, engine-relative. For VF, PF-relative.
649 * @param is_vf - true iff cleanup is made for a VF.
651 * @return enum _ecore_status_t
653 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
654 struct ecore_ptt *p_ptt,
659 * @brief ecore_get_queue_coalesce - Retrieve coalesce value for a given queue.
662 * @param p_coal - store coalesce value read from the hardware.
665 * @return enum _ecore_status_t
668 ecore_get_queue_coalesce(struct ecore_hwfn *p_hwfn, u16 *coal,
672 * @brief ecore_set_queue_coalesce - Configure coalesce parameters for Rx and
673 * Tx queue. The fact that we can configure coalescing to up to 511, but on
674 * varying accuracy [the bigger the value the less accurate] up to a mistake
675 * of 3usec for the highest values.
676 * While the API allows setting coalescing per-qid, all queues sharing a SB
677 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
678 * otherwise configuration would break.
681 * @param rx_coal - Rx Coalesce value in micro seconds.
682 * @param tx_coal - TX Coalesce value in micro seconds.
685 * @return enum _ecore_status_t
688 ecore_set_queue_coalesce(struct ecore_hwfn *p_hwfn, u16 rx_coal,
689 u16 tx_coal, void *p_handle);
692 * @brief ecore_pglueb_set_pfid_enable - Enable or disable PCI BUS MASTER
696 * @param b_enable - true/false
698 * @return enum _ecore_status_t
700 enum _ecore_status_t ecore_pglueb_set_pfid_enable(struct ecore_hwfn *p_hwfn,
701 struct ecore_ptt *p_ptt,