1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright (c) 2016 - 2018 Cavium Inc.
11 #include "ecore_dev_api.h"
13 /* Forward decleration */
18 RESERVED_PTT_USER_SPACE,
24 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1
25 * instead of 0, this should be fixed in later HW versions.
27 #ifndef MISC_REG_DRIVER_CONTROL_0
28 #define MISC_REG_DRIVER_CONTROL_0 MISC_REG_DRIVER_CONTROL_1
30 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
31 #define MISC_REG_DRIVER_CONTROL_0_SIZE MISC_REG_DRIVER_CONTROL_1_SIZE
34 /* Definitions for DMA constants */
35 #define DMAE_GO_VALUE 0x1
38 #define DMAE_COMPLETION_VAL 0xAED10000
39 #define DMAE_CMD_ENDIANITY 0x3
41 #define DMAE_COMPLETION_VAL 0xD1AE
42 #define DMAE_CMD_ENDIANITY 0x2
45 #define DMAE_CMD_SIZE 14
46 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */
47 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
48 /* Minimum wait for dmae opertaion to complete 2 milliseconds */
49 #define DMAE_MIN_WAIT_TIME 0x2
50 #define DMAE_MAX_CLIENTS 32
53 * @brief ecore_gtt_init - Initialize GTT windows
58 void ecore_gtt_init(struct ecore_hwfn *p_hwfn,
59 struct ecore_ptt *p_ptt);
62 * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
66 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
69 * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
73 * @return _ecore_status_t - success (0), negative - error.
75 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
78 * @brief ecore_ptt_pool_free -
82 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
85 * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
92 u32 ecore_ptt_get_bar_addr(struct ecore_ptt *p_ptt);
95 * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
101 void ecore_ptt_set_win(struct ecore_hwfn *p_hwfn,
102 struct ecore_ptt *p_ptt,
106 * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
111 * @return struct ecore_ptt *
113 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn *p_hwfn,
114 enum reserved_ptts ptt_idx);
117 * @brief ecore_wr - Write value to BAR using the given ptt
124 void ecore_wr(struct ecore_hwfn *p_hwfn,
125 struct ecore_ptt *p_ptt,
130 * @brief ecore_rd - Read value from BAR using the given ptt
136 u32 ecore_rd(struct ecore_hwfn *p_hwfn,
137 struct ecore_ptt *p_ptt,
141 * @brief ecore_memcpy_from - copy n bytes from BAR using the given
150 void ecore_memcpy_from(struct ecore_hwfn *p_hwfn,
151 struct ecore_ptt *p_ptt,
157 * @brief ecore_memcpy_to - copy n bytes to BAR using the given
166 void ecore_memcpy_to(struct ecore_hwfn *p_hwfn,
167 struct ecore_ptt *p_ptt,
172 * @brief ecore_fid_pretend - pretend to another function when
173 * accessing the ptt window. There is no way to unpretend
174 * a function. The only way to cancel a pretend is to
175 * pretend back to the original function.
179 * @param fid - fid field of pxp_pretend structure. Can contain
180 * either pf / vf, port/path fields are don't care.
182 void ecore_fid_pretend(struct ecore_hwfn *p_hwfn,
183 struct ecore_ptt *p_ptt,
187 * @brief ecore_port_pretend - pretend to another port when
188 * accessing the ptt window
192 * @param port_id - the port to pretend to
194 void ecore_port_pretend(struct ecore_hwfn *p_hwfn,
195 struct ecore_ptt *p_ptt,
199 * @brief ecore_port_unpretend - cancel any previously set port
205 void ecore_port_unpretend(struct ecore_hwfn *p_hwfn,
206 struct ecore_ptt *p_ptt);
209 * @brief ecore_port_fid_pretend - pretend to another port and another function
210 * when accessing the ptt window
214 * @param port_id - the port to pretend to
215 * @param fid - fid field of pxp_pretend structure. Can contain either pf / vf.
217 void ecore_port_fid_pretend(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
218 u8 port_id, u16 fid);
221 * @brief ecore_vfid_to_concrete - build a concrete FID for a
228 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
231 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
232 * which is part of p_hwfn.
235 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn *p_hwfn);
238 * @brief ecore_dmae_info_free - Free the dmae_info structure
239 * which is part of p_hwfn
243 void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn);
246 * @brief ecore_dmae_host2grc - copy data from source address to
247 * dmae registers using the given ptt
252 * @param grc_addr (dmae_data_offset)
253 * @param size_in_dwords
254 * @param p_params (default parameters will be used in case of OSAL_NULL)
256 * @return enum _ecore_status_t
259 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
260 struct ecore_ptt *p_ptt,
264 struct dmae_params *p_params);
267 * @brief ecore_dmae_grc2host - Read data from dmae data offset
268 * to source address using the given ptt
271 * @param grc_addr (dmae_data_offset)
273 * @param size_in_dwords
274 * @param p_params (default parameters will be used in case of OSAL_NULL)
276 * @return enum _ecore_status_t
279 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
280 struct ecore_ptt *p_ptt,
282 dma_addr_t dest_addr,
284 struct dmae_params *p_params);
287 * @brief ecore_dmae_host2host - copy data from to source address
288 * to a destination address (for SRIOV) using the given ptt
294 * @param size_in_dwords
295 * @param p_params (default parameters will be used in case of OSAL_NULL)
297 * @return enum _ecore_status_t
300 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
301 struct ecore_ptt *p_ptt,
302 dma_addr_t source_addr,
303 dma_addr_t dest_addr,
305 struct dmae_params *p_params);
307 enum _ecore_status_t ecore_dmae_sanity(struct ecore_hwfn *p_hwfn,
308 struct ecore_ptt *p_ptt,
311 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
314 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
315 enum ecore_hw_err_type err_type);
318 * @brief ecore_ppfid_wr - Write value to BAR using the given ptt while
319 * pretending to a PF to which the given PPFID pertains.
327 void ecore_ppfid_wr(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
328 u8 abs_ppfid, u32 hw_addr, u32 val);
331 * @brief ecore_ppfid_rd - Read value from BAR using the given ptt while
332 * pretending to a PF to which the given PPFID pertains.
339 u32 ecore_ppfid_rd(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
340 u8 abs_ppfid, u32 hw_addr);
342 #endif /* __ECORE_HW_H__ */