2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
32 #ifndef __ECORE_DEV_API_H__
33 #define __ECORE_DEV_API_H__
35 #include "ecore_status.h"
36 #include "ecore_chain.h"
37 #include "ecore_int_api.h"
39 struct ecore_wake_info {
47 * @brief ecore_init_dp - initialize the debug level
54 void ecore_init_dp(struct ecore_dev *p_dev,
60 * @brief ecore_init_struct - initialize the device structure to
65 void ecore_init_struct(struct ecore_dev *p_dev);
68 * @brief ecore_resc_free -
72 void ecore_resc_free(struct ecore_dev *p_dev);
75 * @brief ecore_resc_alloc -
79 * @return enum _ecore_status_t
81 enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev);
84 * @brief ecore_resc_setup -
88 void ecore_resc_setup(struct ecore_dev *p_dev);
90 enum ecore_override_force_load {
91 ECORE_OVERRIDE_FORCE_LOAD_NONE,
92 ECORE_OVERRIDE_FORCE_LOAD_ALWAYS,
93 ECORE_OVERRIDE_FORCE_LOAD_NEVER,
96 struct ecore_drv_load_params {
97 /* Indicates whether the driver is running over a crash kernel.
98 * As part of the load request, this will be used for providing the
99 * driver role to the MFW.
100 * In case of a crash kernel over PDA - this should be set to false.
102 bool is_crash_kernel;
104 /* The timeout value that the MFW should use when locking the engine for
105 * the driver load process.
106 * A value of '0' means the default value, and '255' means no timeout.
109 #define ECORE_LOAD_REQ_LOCK_TO_DEFAULT 0
110 #define ECORE_LOAD_REQ_LOCK_TO_NONE 255
112 /* Avoid engine reset when first PF loads on it */
113 bool avoid_eng_reset;
115 /* Allow overriding the default force load behavior */
116 enum ecore_override_force_load override_force_load;
119 struct ecore_hw_init_params {
120 /* Tunneling parameters */
121 struct ecore_tunnel_info *p_tunn;
125 /* Interrupt mode [msix, inta, etc.] to use */
126 enum ecore_int_mode int_mode;
128 /* NPAR tx switching to be used for vports configured for tx-switching */
129 bool allow_npar_tx_switch;
131 /* Binary fw data pointer in binary fw file */
132 const u8 *bin_fw_data;
134 /* Driver load parameters */
135 struct ecore_drv_load_params *p_drv_load_params;
139 * @brief ecore_hw_init -
144 * @return enum _ecore_status_t
146 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
147 struct ecore_hw_init_params *p_params);
150 * @brief ecore_hw_timers_stop_all -
156 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev);
159 * @brief ecore_hw_stop -
163 * @return enum _ecore_status_t
165 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev);
168 * @brief ecore_hw_stop_fastpath -should be called incase
169 * slowpath is still required for the device,
170 * but fastpath is not.
175 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
178 * @brief ecore_hw_hibernate_prepare -should be called when
179 * the system is going into the hibernate state
184 void ecore_hw_hibernate_prepare(struct ecore_dev *p_dev);
187 * @brief ecore_hw_hibernate_resume -should be called when the system is
188 resuming from D3 power state and before calling ecore_hw_init.
193 void ecore_hw_hibernate_resume(struct ecore_dev *p_dev);
197 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
198 * only if hw_stop_fastpath was called
203 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
205 enum ecore_hw_prepare_result {
206 ECORE_HW_PREPARE_SUCCESS,
208 /* FAILED results indicate probe has failed & cleaned up */
209 ECORE_HW_PREPARE_FAILED_ENG2,
210 ECORE_HW_PREPARE_FAILED_ME,
211 ECORE_HW_PREPARE_FAILED_MEM,
212 ECORE_HW_PREPARE_FAILED_DEV,
213 ECORE_HW_PREPARE_FAILED_NVM,
215 /* BAD results indicate probe is passed even though some wrongness
216 * has occurred; Trying to actually use [I.e., hw_init()] might have
217 * dire reprecautions.
219 ECORE_HW_PREPARE_BAD_IOV,
220 ECORE_HW_PREPARE_BAD_MCP,
221 ECORE_HW_PREPARE_BAD_IGU,
224 struct ecore_hw_prepare_params {
225 /* Personality to initialize */
228 /* Force the driver's default resource allocation */
231 /* Check the reg_fifo after any register access */
234 /* Request the MFW to initiate PF FLR */
235 bool initiate_pf_flr;
237 /* The OS Epoch time in seconds */
240 /* Allow the MFW to collect a crash dump */
243 /* Allow prepare to pass even if some initializations are failing.
244 * If set, the `p_prepare_res' field would be set with the return,
245 * and might allow probe to pass even if there are certain issues.
247 bool b_relaxed_probe;
248 enum ecore_hw_prepare_result p_relaxed_res;
252 * @brief ecore_hw_prepare -
257 * @return enum _ecore_status_t
259 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev,
260 struct ecore_hw_prepare_params *p_params);
263 * @brief ecore_hw_remove -
267 void ecore_hw_remove(struct ecore_dev *p_dev);
270 * @brief ecore_set_nwuf_reg -
273 * @param wol_flag - wol_capability
274 * @param reg_idx - Index of the pattern register
275 * @param pattern_size - size of pattern
276 * @param crc - CRC value of patter & mask
278 * @return enum _ecore_status_t
280 enum _ecore_status_t ecore_set_nwuf_reg(struct ecore_dev *p_dev,
287 * @brief ecore_get_wake_info - get magic packet buffer
290 * @param wake_info - pointer to ecore_wake_info buffer
292 * @return enum _ecore_status_t
294 enum _ecore_status_t ecore_get_wake_info(struct ecore_dev *p_dev,
295 struct ecore_wake_info *wake_info);
298 * @brief ecore_wol_buffer_clear - Clear magic package buffer
304 void ecore_wol_buffer_clear(struct ecore_dev *p_dev);
307 * @brief ecore_ptt_acquire - Allocate a PTT window
309 * Should be called at the entry point to the driver (at the beginning of an
314 * @return struct ecore_ptt
316 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
319 * @brief ecore_ptt_release - Release PTT Window
321 * Should be called at the end of a flow - at the end of the function that
328 void ecore_ptt_release(struct ecore_hwfn *p_hwfn,
329 struct ecore_ptt *p_ptt);
331 struct ecore_eth_stats_common {
332 u64 no_buff_discards;
333 u64 packet_too_big_discard;
341 u64 mftag_filter_discards;
342 u64 mac_filter_discards;
349 u64 tx_err_drop_pkts;
350 u64 tpa_coalesced_pkts;
351 u64 tpa_coalesced_events;
353 u64 tpa_not_coalesced_pkts;
354 u64 tpa_coalesced_bytes;
357 u64 rx_64_byte_packets;
358 u64 rx_65_to_127_byte_packets;
359 u64 rx_128_to_255_byte_packets;
360 u64 rx_256_to_511_byte_packets;
361 u64 rx_512_to_1023_byte_packets;
362 u64 rx_1024_to_1518_byte_packets;
364 u64 rx_mac_crtl_frames;
368 u64 rx_carrier_errors;
369 u64 rx_oversize_packets;
371 u64 rx_undersize_packets;
373 u64 tx_64_byte_packets;
374 u64 tx_65_to_127_byte_packets;
375 u64 tx_128_to_255_byte_packets;
376 u64 tx_256_to_511_byte_packets;
377 u64 tx_512_to_1023_byte_packets;
378 u64 tx_1024_to_1518_byte_packets;
384 u64 rx_mac_uc_packets;
385 u64 rx_mac_mc_packets;
386 u64 rx_mac_bc_packets;
387 u64 rx_mac_frames_ok;
389 u64 tx_mac_uc_packets;
390 u64 tx_mac_mc_packets;
391 u64 tx_mac_bc_packets;
392 u64 tx_mac_ctrl_frames;
395 struct ecore_eth_stats_bb {
396 u64 rx_1519_to_1522_byte_packets;
397 u64 rx_1519_to_2047_byte_packets;
398 u64 rx_2048_to_4095_byte_packets;
399 u64 rx_4096_to_9216_byte_packets;
400 u64 rx_9217_to_16383_byte_packets;
401 u64 tx_1519_to_2047_byte_packets;
402 u64 tx_2048_to_4095_byte_packets;
403 u64 tx_4096_to_9216_byte_packets;
404 u64 tx_9217_to_16383_byte_packets;
405 u64 tx_lpi_entry_count;
406 u64 tx_total_collisions;
409 struct ecore_eth_stats_ah {
410 u64 rx_1519_to_max_byte_packets;
411 u64 tx_1519_to_max_byte_packets;
414 struct ecore_eth_stats {
415 struct ecore_eth_stats_common common;
417 struct ecore_eth_stats_bb bb;
418 struct ecore_eth_stats_ah ah;
422 enum ecore_dmae_address_type_t {
423 ECORE_DMAE_ADDRESS_HOST_VIRT,
424 ECORE_DMAE_ADDRESS_HOST_PHYS,
425 ECORE_DMAE_ADDRESS_GRC
428 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
429 * source is a block of length DMAE_MAX_RW_SIZE and the
430 * destination is larger, the source block will be duplicated as
431 * many times as required to fill the destination block. This is
432 * used mostly to write a zeroed buffer to destination address
435 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
436 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
437 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
438 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
440 struct ecore_dmae_params {
441 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
447 * @brief ecore_dmae_host2grc - copy data from source addr to
448 * dmae registers using the given ptt
453 * @param grc_addr (dmae_data_offset)
454 * @param size_in_dwords
455 * @param flags (one of the flags defined above)
458 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
459 struct ecore_ptt *p_ptt,
466 * @brief ecore_dmae_grc2host - Read data from dmae data offset
467 * to source address using the given ptt
470 * @param grc_addr (dmae_data_offset)
472 * @param size_in_dwords
473 * @param flags - one of the flags defined above
476 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
477 struct ecore_ptt *p_ptt,
479 dma_addr_t dest_addr,
484 * @brief ecore_dmae_host2host - copy data from to source address
485 * to a destination address (for SRIOV) using the given ptt
491 * @param size_in_dwords
495 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
496 struct ecore_ptt *p_ptt,
497 dma_addr_t source_addr,
498 dma_addr_t dest_addr,
500 struct ecore_dmae_params *p_params);
503 * @brief ecore_chain_alloc - Allocate and initialize a chain
506 * @param intended_use
512 * @return enum _ecore_status_t
515 ecore_chain_alloc(struct ecore_dev *p_dev,
516 enum ecore_chain_use_mode intended_use,
517 enum ecore_chain_mode mode,
518 enum ecore_chain_cnt_type cnt_type,
520 osal_size_t elem_size,
521 struct ecore_chain *p_chain,
522 struct ecore_chain_ext_pbl *ext_pbl);
525 * @brief ecore_chain_free - Free chain DMA memory
530 void ecore_chain_free(struct ecore_dev *p_dev,
531 struct ecore_chain *p_chain);
534 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
537 * @param src_id - relative to p_hwfn
538 * @param dst_id - absolute per engine
540 * @return enum _ecore_status_t
542 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
547 * @@brief ecore_fw_vport - Get absolute vport ID
550 * @param src_id - relative to p_hwfn
551 * @param dst_id - absolute per engine
553 * @return enum _ecore_status_t
555 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
560 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
563 * @param src_id - relative to p_hwfn
564 * @param dst_id - absolute per engine
566 * @return enum _ecore_status_t
568 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
573 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
577 * @param p_filter - MAC to add
579 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
580 struct ecore_ptt *p_ptt,
584 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
588 * @param p_filter - MAC to remove
590 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
591 struct ecore_ptt *p_ptt,
594 enum ecore_llh_port_filter_type_t {
595 ECORE_LLH_FILTER_ETHERTYPE,
596 ECORE_LLH_FILTER_TCP_SRC_PORT,
597 ECORE_LLH_FILTER_TCP_DEST_PORT,
598 ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
599 ECORE_LLH_FILTER_UDP_SRC_PORT,
600 ECORE_LLH_FILTER_UDP_DEST_PORT,
601 ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT
605 * @brief ecore_llh_add_protocol_filter - configures a protocol filter in llh
609 * @param source_port_or_eth_type - source port or ethertype to add
610 * @param dest_port - destination port to add
611 * @param type - type of filters and comparing
614 ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
615 struct ecore_ptt *p_ptt,
616 u16 source_port_or_eth_type,
618 enum ecore_llh_port_filter_type_t type);
621 * @brief ecore_llh_remove_protocol_filter - remove a protocol filter in llh
625 * @param source_port_or_eth_type - source port or ethertype to add
626 * @param dest_port - destination port to add
627 * @param type - type of filters and comparing
630 ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
631 struct ecore_ptt *p_ptt,
632 u16 source_port_or_eth_type,
634 enum ecore_llh_port_filter_type_t type);
637 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
642 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
643 struct ecore_ptt *p_ptt);
646 * @brief ecore_llh_set_function_as_default - set function as defult per port
652 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
653 struct ecore_ptt *p_ptt);
656 *@brief Cleanup of previous driver remains prior to load
660 * @param id - For PF, engine-relative. For VF, PF-relative.
661 * @param is_vf - true iff cleanup is made for a VF.
663 * @return enum _ecore_status_t
665 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
666 struct ecore_ptt *p_ptt,
670 * @brief ecore_set_queue_coalesce - Configure coalesce parameters for Rx and
671 * Tx queue. The fact that we can configure coalescing to up to 511, but on
672 * varying accuracy [the bigger the value the less accurate] up to a mistake
673 * of 3usec for the highest values.
674 * While the API allows setting coalescing per-qid, all queues sharing a SB
675 * should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
676 * otherwise configuration would break.
679 * @param rx_coal - Rx Coalesce value in micro seconds.
680 * @param tx_coal - TX Coalesce value in micro seconds.
683 * @return enum _ecore_status_t
686 ecore_set_queue_coalesce(struct ecore_hwfn *p_hwfn, u16 rx_coal,
687 u16 tx_coal, void *p_handle);
690 * @brief - Recalculate feature distributions based on HW resources and
691 * user inputs. Currently this affects RDMA_CNQ, PF_L2_QUE and VF_L2_QUE.
692 * As a result, this must not be called while RDMA is active or while VFs
697 void ecore_hw_set_feat(struct ecore_hwfn *p_hwfn);
700 * @brief ecore_change_pci_hwfn - Enable or disable PCI BUS MASTER
704 * @param enable - true/false
706 * @return enum _ecore_status_t
709 ecore_change_pci_hwfn(struct ecore_hwfn *p_hwfn,
710 struct ecore_ptt *p_ptt,