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_HW_H__
33 #define __ECORE_HW_H__
36 #include "ecore_dev_api.h"
38 /* Forward decleration */
43 RESERVED_PTT_USER_SPACE,
49 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1
50 * instead of 0, this should be fixed in later HW versions.
52 #ifndef MISC_REG_DRIVER_CONTROL_0
53 #define MISC_REG_DRIVER_CONTROL_0 MISC_REG_DRIVER_CONTROL_1
55 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
56 #define MISC_REG_DRIVER_CONTROL_0_SIZE MISC_REG_DRIVER_CONTROL_1_SIZE
59 enum _dmae_cmd_dst_mask {
60 DMAE_CMD_DST_MASK_NONE = 0,
61 DMAE_CMD_DST_MASK_PCIE = 1,
62 DMAE_CMD_DST_MASK_GRC = 2
65 enum _dmae_cmd_src_mask {
66 DMAE_CMD_SRC_MASK_PCIE = 0,
67 DMAE_CMD_SRC_MASK_GRC = 1
70 enum _dmae_cmd_crc_mask {
71 DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
72 DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
75 /* definitions for DMA constants */
76 #define DMAE_GO_VALUE 0x1
79 #define DMAE_COMPLETION_VAL 0xAED10000
80 #define DMAE_CMD_ENDIANITY 0x3
82 #define DMAE_COMPLETION_VAL 0xD1AE
83 #define DMAE_CMD_ENDIANITY 0x2
86 #define DMAE_CMD_SIZE 14
87 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */
88 #define DMAE_CMD_SIZE_TO_FILL (DMAE_CMD_SIZE - 5)
89 /* Minimum wait for dmae opertaion to complete 2 milliseconds */
90 #define DMAE_MIN_WAIT_TIME 0x2
91 #define DMAE_MAX_CLIENTS 32
94 * @brief ecore_gtt_init - Initialize GTT windows
98 void ecore_gtt_init(struct ecore_hwfn *p_hwfn);
101 * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
105 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
108 * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
112 * @return _ecore_status_t - success (0), negative - error.
114 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
117 * @brief ecore_ptt_pool_free -
121 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
124 * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
131 u32 ecore_ptt_get_hw_addr(struct ecore_hwfn *p_hwfn,
132 struct ecore_ptt *p_ptt);
135 * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
142 u32 ecore_ptt_get_bar_addr(struct ecore_ptt *p_ptt);
145 * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
151 void ecore_ptt_set_win(struct ecore_hwfn *p_hwfn,
152 struct ecore_ptt *p_ptt,
156 * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
161 * @return struct ecore_ptt *
163 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn *p_hwfn,
164 enum reserved_ptts ptt_idx);
167 * @brief ecore_wr - Write value to BAR using the given ptt
174 void ecore_wr(struct ecore_hwfn *p_hwfn,
175 struct ecore_ptt *p_ptt,
180 * @brief ecore_rd - Read value from BAR using the given ptt
187 u32 ecore_rd(struct ecore_hwfn *p_hwfn,
188 struct ecore_ptt *p_ptt,
192 * @brief ecore_memcpy_from - copy n bytes from BAR using the given
201 void ecore_memcpy_from(struct ecore_hwfn *p_hwfn,
202 struct ecore_ptt *p_ptt,
208 * @brief ecore_memcpy_to - copy n bytes to BAR using the given
217 void ecore_memcpy_to(struct ecore_hwfn *p_hwfn,
218 struct ecore_ptt *p_ptt,
223 * @brief ecore_fid_pretend - pretend to another function when
224 * accessing the ptt window. There is no way to unpretend
225 * a function. The only way to cancel a pretend is to
226 * pretend back to the original function.
230 * @param fid - fid field of pxp_pretend structure. Can contain
231 * either pf / vf, port/path fields are don't care.
233 void ecore_fid_pretend(struct ecore_hwfn *p_hwfn,
234 struct ecore_ptt *p_ptt,
238 * @brief ecore_port_pretend - pretend to another port when
239 * accessing the ptt window
243 * @param port_id - the port to pretend to
245 void ecore_port_pretend(struct ecore_hwfn *p_hwfn,
246 struct ecore_ptt *p_ptt,
250 * @brief ecore_port_unpretend - cancel any previously set port
256 void ecore_port_unpretend(struct ecore_hwfn *p_hwfn,
257 struct ecore_ptt *p_ptt);
260 * @brief ecore_vfid_to_concrete - build a concrete FID for a
267 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
270 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
271 * which is part of p_hwfn.
274 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn *p_hwfn);
277 * @brief ecore_dmae_info_free - Free the dmae_info structure
278 * which is part of p_hwfn
282 void ecore_dmae_info_free(struct ecore_hwfn *p_hwfn);
284 union ecore_qm_pq_params {
301 u8 qpid; /* roce relative */
309 u16 ecore_get_qm_pq(struct ecore_hwfn *p_hwfn,
310 enum protocol_type proto,
311 union ecore_qm_pq_params *params);
313 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
316 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
317 enum ecore_hw_err_type err_type);
319 #endif /* __ECORE_HW_H__ */