2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_INT_H__
10 #define __ECORE_INT_H__
13 #include "ecore_int_api.h"
15 #define ECORE_CAU_DEF_RX_TIMER_RES 0
16 #define ECORE_CAU_DEF_TX_TIMER_RES 0
18 #define ECORE_SB_ATT_IDX 0x0001
19 #define ECORE_SB_EVENT_MASK 0x0003
21 #define SB_ALIGNED_SIZE(p_hwfn) \
22 ALIGNED_TYPE_SIZE(struct status_block, p_hwfn)
24 struct ecore_igu_block {
26 #define ECORE_IGU_STATUS_FREE 0x01
27 #define ECORE_IGU_STATUS_VALID 0x02
28 #define ECORE_IGU_STATUS_PF 0x04
35 struct ecore_igu_map {
36 struct ecore_igu_block igu_blocks[MAX_TOT_SB_PER_PATH];
39 struct ecore_igu_info {
40 struct ecore_igu_map igu_map;
49 /* TODO Names of function may change... */
50 void ecore_int_igu_init_pure_rt(struct ecore_hwfn *p_hwfn,
51 struct ecore_ptt *p_ptt,
52 bool b_set, bool b_slowpath);
54 void ecore_int_igu_init_rt(struct ecore_hwfn *p_hwfn);
57 * @brief ecore_int_igu_read_cam - Reads the IGU CAM.
58 * This function needs to be called during hardware
59 * prepare. It reads the info from igu cam to know which
60 * status block is the default / base status block etc.
65 * @return enum _ecore_status_t
67 enum _ecore_status_t ecore_int_igu_read_cam(struct ecore_hwfn *p_hwfn,
68 struct ecore_ptt *p_ptt);
70 typedef enum _ecore_status_t (*ecore_int_comp_cb_t) (struct ecore_hwfn *p_hwfn,
73 * @brief ecore_int_register_cb - Register callback func for
74 * slowhwfn statusblock.
76 * Every protocol that uses the slowhwfn status block
77 * should register a callback function that will be called
78 * once there is an update of the sp status block.
81 * @param comp_cb - function to be called when there is an
82 * interrupt on the sp sb
84 * @param cookie - passed to the callback function
85 * @param sb_idx - OUT parameter which gives the chosen index
87 * @param p_fw_cons - pointer to the actual address of the
88 * consumer for this protocol.
90 * @return enum _ecore_status_t
92 enum _ecore_status_t ecore_int_register_cb(struct ecore_hwfn *p_hwfn,
93 ecore_int_comp_cb_t comp_cb,
95 u8 *sb_idx, __le16 **p_fw_cons);
97 * @brief ecore_int_unregister_cb - Unregisters callback
98 * function from sp sb.
99 * Partner of ecore_int_register_cb -> should be called
100 * when no longer required.
105 * @return enum _ecore_status_t
107 enum _ecore_status_t ecore_int_unregister_cb(struct ecore_hwfn *p_hwfn, u8 pi);
110 * @brief ecore_int_get_sp_sb_id - Get the slowhwfn sb id.
116 u16 ecore_int_get_sp_sb_id(struct ecore_hwfn *p_hwfn);
119 * @brief Status block cleanup. Should be called for each status
120 * block that will be used -> both PF / VF
124 * @param sb_id - igu status block id
125 * @param opaque - opaque fid of the sb owner.
126 * @param cleanup_set - set(1) / clear(0)
128 void ecore_int_igu_init_pure_rt_single(struct ecore_hwfn *p_hwfn,
129 struct ecore_ptt *p_ptt,
130 u32 sb_id, u16 opaque, bool b_set);
133 * @brief ecore_int_cau_conf - configure cau for a given status
143 void ecore_int_cau_conf_sb(struct ecore_hwfn *p_hwfn,
144 struct ecore_ptt *p_ptt,
146 u16 igu_sb_id, u16 vf_number, u8 vf_valid);
149 * @brief ecore_int_alloc
154 * @return enum _ecore_status_t
156 enum _ecore_status_t ecore_int_alloc(struct ecore_hwfn *p_hwfn,
157 struct ecore_ptt *p_ptt);
160 * @brief ecore_int_free
164 void ecore_int_free(struct ecore_hwfn *p_hwfn);
167 * @brief ecore_int_setup
172 void ecore_int_setup(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt);
175 * @brief - Returns an Rx queue index appropriate for usage with given SB.
178 * @param sb_id - absolute index of SB
180 * @return index of Rx queue
182 u16 ecore_int_queue_id_from_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id);
185 * @brief - Enable Interrupt & Attention for hw function
191 * @return enum _ecore_status_t
193 enum _ecore_status_t ecore_int_igu_enable(struct ecore_hwfn *p_hwfn,
194 struct ecore_ptt *p_ptt,
195 enum ecore_int_mode int_mode);
198 * @brief - Initialize CAU status block entry
206 void ecore_init_cau_sb_entry(struct ecore_hwfn *p_hwfn,
207 struct cau_sb_entry *p_sb_entry, u8 pf_id,
208 u16 vf_number, u8 vf_valid);
210 enum _ecore_status_t ecore_int_set_timer_res(struct ecore_hwfn *p_hwfn,
211 struct ecore_ptt *p_ptt,
212 u8 timer_res, u16 sb_id, bool tx);
214 #define ECORE_MAPPING_MEMORY_SIZE(dev) \
215 ((CHIP_REV_IS_SLOW(dev) && (!(dev)->b_is_emul_full)) ? \
216 136 : NUM_OF_SBS(dev))
218 #define ECORE_MAPPING_MEMORY_SIZE(dev) NUM_OF_SBS(dev)
221 #endif /* __ECORE_INT_H__ */