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_HW_H__
32 #define __ECORE_HW_H__
35 #include "ecore_dev_api.h"
37 /* Forward decleration */
42 RESERVED_PTT_USER_SPACE,
48 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1
49 * instead of 0, this should be fixed in later HW versions.
51 #ifndef MISC_REG_DRIVER_CONTROL_0
52 #define MISC_REG_DRIVER_CONTROL_0 MISC_REG_DRIVER_CONTROL_1
54 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
55 #define MISC_REG_DRIVER_CONTROL_0_SIZE MISC_REG_DRIVER_CONTROL_1_SIZE
58 enum _dmae_cmd_dst_mask {
59 DMAE_CMD_DST_MASK_NONE = 0,
60 DMAE_CMD_DST_MASK_PCIE = 1,
61 DMAE_CMD_DST_MASK_GRC = 2
64 enum _dmae_cmd_src_mask {
65 DMAE_CMD_SRC_MASK_PCIE = 0,
66 DMAE_CMD_SRC_MASK_GRC = 1
69 enum _dmae_cmd_crc_mask {
70 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
71 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
74 /* definitions for DMA constants */
75 #define DMAE_GO_VALUE 0x1
78 #define DMAE_COMPLETION_VAL 0xAED10000
79 #define DMAE_CMD_ENDIANITY 0x3
81 #define DMAE_COMPLETION_VAL 0xD1AE
82 #define DMAE_CMD_ENDIANITY 0x2
85 #define DMAE_CMD_SIZE 14
86 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */
87 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
88 /* Minimum wait for dmae opertaion to complete 2 milliseconds */
89 #define DMAE_MIN_WAIT_TIME 0x2
90 #define DMAE_MAX_CLIENTS 32
93 * @brief ecore_gtt_init - Initialize GTT windows
98 void ecore_gtt_init(struct ecore_hwfn *p_hwfn,
99 struct ecore_ptt *p_ptt);
102 * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
106 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
109 * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
113 * @return _ecore_status_t - success (0), negative - error.
115 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
118 * @brief ecore_ptt_pool_free -
122 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
125 * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
131 u32 ecore_ptt_get_hw_addr(struct ecore_ptt *p_ptt);
134 * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
141 u32 ecore_ptt_get_bar_addr(struct ecore_ptt *p_ptt);
144 * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
150 void ecore_ptt_set_win(struct ecore_hwfn *p_hwfn,
151 struct ecore_ptt *p_ptt,
155 * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
160 * @return struct ecore_ptt *
162 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn *p_hwfn,
163 enum reserved_ptts ptt_idx);
166 * @brief ecore_wr - Write value to BAR using the given ptt
173 void ecore_wr(struct ecore_hwfn *p_hwfn,
174 struct ecore_ptt *p_ptt,
179 * @brief ecore_rd - Read value from BAR using the given ptt
186 u32 ecore_rd(struct ecore_hwfn *p_hwfn,
187 struct ecore_ptt *p_ptt,
191 * @brief ecore_memcpy_from - copy n bytes from BAR using the given
200 void ecore_memcpy_from(struct ecore_hwfn *p_hwfn,
201 struct ecore_ptt *p_ptt,
207 * @brief ecore_memcpy_to - copy n bytes to BAR using the given
216 void ecore_memcpy_to(struct ecore_hwfn *p_hwfn,
217 struct ecore_ptt *p_ptt,
222 * @brief ecore_fid_pretend - pretend to another function when
223 * accessing the ptt window. There is no way to unpretend
224 * a function. The only way to cancel a pretend is to
225 * pretend back to the original function.
229 * @param fid - fid field of pxp_pretend structure. Can contain
230 * either pf / vf, port/path fields are don't care.
232 void ecore_fid_pretend(struct ecore_hwfn *p_hwfn,
233 struct ecore_ptt *p_ptt,
237 * @brief ecore_port_pretend - pretend to another port when
238 * accessing the ptt window
242 * @param port_id - the port to pretend to
244 void ecore_port_pretend(struct ecore_hwfn *p_hwfn,
245 struct ecore_ptt *p_ptt,
249 * @brief ecore_port_unpretend - cancel any previously set port
255 void ecore_port_unpretend(struct ecore_hwfn *p_hwfn,
256 struct ecore_ptt *p_ptt);
259 * @brief ecore_vfid_to_concrete - build a concrete FID for a
266 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
269 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
270 * which is part of p_hwfn.
273 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn *p_hwfn);
276 * @brief ecore_dmae_info_free - Free the dmae_info structure
277 * which is part of p_hwfn
281 void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn);
283 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
286 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
287 enum ecore_hw_err_type err_type);
289 #endif /* __ECORE_HW_H__ */