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.
31 #ifndef __ECORE_INT_H__
32 #define __ECORE_INT_H__
35 #include "ecore_int_api.h"
37 #define ECORE_CAU_DEF_RX_TIMER_RES 0
38 #define ECORE_CAU_DEF_TX_TIMER_RES 0
40 #define ECORE_SB_ATT_IDX 0x0001
41 #define ECORE_SB_EVENT_MASK 0x0003
43 #define SB_ALIGNED_SIZE(p_hwfn) \
44 ALIGNED_TYPE_SIZE(struct status_block_e4, p_hwfn)
46 #define ECORE_SB_INVALID_IDX 0xffff
48 struct ecore_igu_block
51 #define ECORE_IGU_STATUS_FREE 0x01
52 #define ECORE_IGU_STATUS_VALID 0x02
53 #define ECORE_IGU_STATUS_PF 0x04
54 #define ECORE_IGU_STATUS_DSB 0x08
60 /* Index inside IGU [meant for back reference] */
63 struct ecore_sb_info *sb_info;
68 struct ecore_igu_block entry[MAX_TOT_SB_PER_PATH];
71 /* The numbers can shift when using APIs to switch SBs between PF and
74 struct ecore_sb_cnt_info usage;
76 /* Determine whether we can shift SBs between VFs and PFs */
77 bool b_allow_pf_vf_change;
81 * @brief - Make sure the IGU CAM reflects the resources provided by MFW
86 int ecore_int_igu_reset_cam(struct ecore_hwfn *p_hwfn,
87 struct ecore_ptt *p_ptt);
90 * @brief - Make sure IGU CAM reflects the default resources once again,
91 * starting with a 'dirty' SW database.
95 int ecore_int_igu_reset_cam_default(struct ecore_hwfn *p_hwfn,
96 struct ecore_ptt *p_ptt);
99 * @brief Translate the weakly-defined client sb-id into an IGU sb-id
102 * @param sb_id - user provided sb_id
104 * @return an index inside IGU CAM where the SB resides
106 u16 ecore_get_igu_sb_id(struct ecore_hwfn *p_hwfn, u16 sb_id);
109 * @brief return a pointer to an unused valid SB
112 * @param b_is_pf - true iff we want a SB belonging to a PF
114 * @return point to an igu_block, OSAL_NULL if none is available
116 struct ecore_igu_block *
117 ecore_get_igu_free_sb(struct ecore_hwfn *p_hwfn, bool b_is_pf);
119 /* TODO Names of function may change... */
120 void ecore_int_igu_init_pure_rt(struct ecore_hwfn *p_hwfn,
121 struct ecore_ptt *p_ptt,
125 void ecore_int_igu_init_rt(struct ecore_hwfn *p_hwfn);
128 * @brief ecore_int_igu_read_cam - Reads the IGU CAM.
129 * This function needs to be called during hardware
130 * prepare. It reads the info from igu cam to know which
131 * status block is the default / base status block etc.
136 * @return enum _ecore_status_t
138 enum _ecore_status_t ecore_int_igu_read_cam(struct ecore_hwfn *p_hwfn,
139 struct ecore_ptt *p_ptt);
141 typedef enum _ecore_status_t(*ecore_int_comp_cb_t)(struct ecore_hwfn *p_hwfn,
144 * @brief ecore_int_register_cb - Register callback func for
145 * slowhwfn statusblock.
147 * Every protocol that uses the slowhwfn status block
148 * should register a callback function that will be called
149 * once there is an update of the sp status block.
152 * @param comp_cb - function to be called when there is an
153 * interrupt on the sp sb
155 * @param cookie - passed to the callback function
156 * @param sb_idx - OUT parameter which gives the chosen index
158 * @param p_fw_cons - pointer to the actual address of the
159 * consumer for this protocol.
161 * @return enum _ecore_status_t
163 enum _ecore_status_t ecore_int_register_cb(struct ecore_hwfn *p_hwfn,
164 ecore_int_comp_cb_t comp_cb,
169 * @brief ecore_int_unregister_cb - Unregisters callback
170 * function from sp sb.
171 * Partner of ecore_int_register_cb -> should be called
172 * when no longer required.
177 * @return enum _ecore_status_t
179 enum _ecore_status_t ecore_int_unregister_cb(struct ecore_hwfn *p_hwfn,
183 * @brief ecore_int_get_sp_sb_id - Get the slowhwfn sb id.
189 u16 ecore_int_get_sp_sb_id(struct ecore_hwfn *p_hwfn);
192 * @brief Status block cleanup. Should be called for each status
193 * block that will be used -> both PF / VF
197 * @param sb_id - igu status block id
198 * @param opaque - opaque fid of the sb owner.
199 * @param cleanup_set - set(1) / clear(0)
201 void ecore_int_igu_init_pure_rt_single(struct ecore_hwfn *p_hwfn,
202 struct ecore_ptt *p_ptt,
208 * @brief ecore_int_cau_conf - configure cau for a given status
218 void ecore_int_cau_conf_sb(struct ecore_hwfn *p_hwfn,
219 struct ecore_ptt *p_ptt,
226 * @brief ecore_int_alloc
231 * @return enum _ecore_status_t
233 enum _ecore_status_t ecore_int_alloc(struct ecore_hwfn *p_hwfn,
234 struct ecore_ptt *p_ptt);
237 * @brief ecore_int_free
241 void ecore_int_free(struct ecore_hwfn *p_hwfn);
244 * @brief ecore_int_setup
249 void ecore_int_setup(struct ecore_hwfn *p_hwfn,
250 struct ecore_ptt *p_ptt);
253 * @brief - Enable Interrupt & Attention for hw function
259 * @return enum _ecore_status_t
261 enum _ecore_status_t ecore_int_igu_enable(struct ecore_hwfn *p_hwfn,
262 struct ecore_ptt *p_ptt,
263 enum ecore_int_mode int_mode);
266 * @brief - Initialize CAU status block entry
274 void ecore_init_cau_sb_entry(struct ecore_hwfn *p_hwfn,
275 struct cau_sb_entry *p_sb_entry, u8 pf_id,
276 u16 vf_number, u8 vf_valid);
278 enum _ecore_status_t ecore_int_set_timer_res(struct ecore_hwfn *p_hwfn,
279 struct ecore_ptt *p_ptt,
280 u8 timer_res, u16 sb_id, bool tx);
282 #define ECORE_MAPPING_MEMORY_SIZE(dev) \
283 ((CHIP_REV_IS_SLOW(dev) && (!(dev)->b_is_emul_full)) ? \
284 136 : NUM_OF_SBS(dev))
286 #define ECORE_MAPPING_MEMORY_SIZE(dev) NUM_OF_SBS(dev)
289 enum _ecore_status_t ecore_pglueb_rbc_attn_handler(struct ecore_hwfn *p_hwfn,
290 struct ecore_ptt *p_ptt);
292 #endif /* __ECORE_INT_H__ */