ecore_hw.h revision 320164
1/*
2 * Copyright (c) 2017-2018 Cavium, Inc.
3 * All rights reserved.
4 *
5 *  Redistribution and use in source and binary forms, with or without
6 *  modification, are permitted provided that the following conditions
7 *  are met:
8 *
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.
14 *
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.
26 *
27 * $FreeBSD: stable/11/sys/dev/qlnx/qlnxe/ecore_hw.h 320164 2017-06-20 19:16:06Z davidcs $
28 *
29 */
30
31#ifndef __ECORE_HW_H__
32#define __ECORE_HW_H__
33
34#include "ecore.h"
35#include "ecore_dev_api.h"
36
37/* Forward decleration */
38struct ecore_ptt;
39
40enum reserved_ptts {
41	RESERVED_PTT_EDIAG,
42	RESERVED_PTT_USER_SPACE,
43	RESERVED_PTT_MAIN,
44	RESERVED_PTT_DPC,
45	RESERVED_PTT_MAX
46};
47
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.
50 */
51#ifndef MISC_REG_DRIVER_CONTROL_0
52#define MISC_REG_DRIVER_CONTROL_0	MISC_REG_DRIVER_CONTROL_1
53#endif
54#ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
55#define MISC_REG_DRIVER_CONTROL_0_SIZE	MISC_REG_DRIVER_CONTROL_1_SIZE
56#endif
57
58enum _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
62};
63
64enum _dmae_cmd_src_mask {
65	DMAE_CMD_SRC_MASK_PCIE = 0,
66	DMAE_CMD_SRC_MASK_GRC = 1
67};
68
69enum _dmae_cmd_crc_mask {
70	DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
71	DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
72};
73
74/* definitions for DMA constants */
75#define DMAE_GO_VALUE	0x1
76
77#ifdef __BIG_ENDIAN
78#define DMAE_COMPLETION_VAL	0xAED10000
79#define DMAE_CMD_ENDIANITY	0x3
80#else
81#define DMAE_COMPLETION_VAL	0xD1AE
82#define DMAE_CMD_ENDIANITY	0x2
83#endif
84
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
91
92/**
93* @brief ecore_gtt_init - Initialize GTT windows
94*
95* @param p_hwfn
96* @param p_ptt
97*/
98void ecore_gtt_init(struct ecore_hwfn *p_hwfn,
99		    struct ecore_ptt *p_ptt);
100
101/**
102 * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
103 *
104 * @param p_hwfn
105 */
106void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
107
108/**
109 * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
110 *
111 * @param p_hwfn
112 *
113 * @return _ecore_status_t - success (0), negative - error.
114 */
115enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
116
117/**
118 * @brief ecore_ptt_pool_free -
119 *
120 * @param p_hwfn
121 */
122void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
123
124/**
125 * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
126 *
127 * @param p_ptt
128 *
129 * @return u32
130 */
131u32 ecore_ptt_get_hw_addr(struct ecore_ptt *p_ptt);
132
133/**
134 * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
135 *
136 * @param p_hwfn
137 * @param p_ptt
138 *
139 * @return u32
140 */
141u32 ecore_ptt_get_bar_addr(struct ecore_ptt	*p_ptt);
142
143/**
144 * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
145 *
146 * @param p_hwfn
147 * @param new_hw_addr
148 * @param p_ptt
149 */
150void ecore_ptt_set_win(struct ecore_hwfn	*p_hwfn,
151		       struct ecore_ptt		*p_ptt,
152		       u32			new_hw_addr);
153
154/**
155 * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
156 *
157 * @param p_hwfn
158 * @param ptt_idx
159 *
160 * @return struct ecore_ptt *
161 */
162struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn	*p_hwfn,
163					 enum reserved_ptts	ptt_idx);
164
165/**
166 * @brief ecore_wr - Write value to BAR using the given ptt
167 *
168 * @param p_hwfn
169 * @param p_ptt
170 * @param val
171 * @param hw_addr
172 */
173void ecore_wr(struct ecore_hwfn	*p_hwfn,
174	      struct ecore_ptt	*p_ptt,
175	      u32		hw_addr,
176	      u32		val);
177
178/**
179 * @brief ecore_rd - Read value from BAR using the given ptt
180 *
181 * @param p_hwfn
182 * @param p_ptt
183 * @param val
184 * @param hw_addr
185 */
186u32 ecore_rd(struct ecore_hwfn	*p_hwfn,
187	     struct ecore_ptt	*p_ptt,
188	     u32		hw_addr);
189
190/**
191 * @brief ecore_memcpy_from - copy n bytes from BAR using the given
192 *        ptt
193 *
194 * @param p_hwfn
195 * @param p_ptt
196 * @param dest
197 * @param hw_addr
198 * @param n
199 */
200void ecore_memcpy_from(struct ecore_hwfn	*p_hwfn,
201		       struct ecore_ptt		*p_ptt,
202		       void			*dest,
203		       u32			hw_addr,
204		       osal_size_t		n);
205
206/**
207 * @brief ecore_memcpy_to - copy n bytes to BAR using the given
208 *        ptt
209 *
210 * @param p_hwfn
211 * @param p_ptt
212 * @param hw_addr
213 * @param src
214 * @param n
215 */
216void ecore_memcpy_to(struct ecore_hwfn	*p_hwfn,
217		     struct ecore_ptt	*p_ptt,
218		     u32		hw_addr,
219		     void		*src,
220		     osal_size_t	n);
221/**
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.
226 *
227 * @param p_hwfn
228 * @param p_ptt
229 * @param fid - fid field of pxp_pretend structure. Can contain
230 *            either pf / vf, port/path fields are don't care.
231 */
232void ecore_fid_pretend(struct ecore_hwfn	*p_hwfn,
233		       struct ecore_ptt		*p_ptt,
234		       u16			fid);
235
236/**
237 * @brief ecore_port_pretend - pretend to another port when
238 *        accessing the ptt window
239 *
240 * @param p_hwfn
241 * @param p_ptt
242 * @param port_id - the port to pretend to
243 */
244void ecore_port_pretend(struct ecore_hwfn	*p_hwfn,
245			struct ecore_ptt	*p_ptt,
246			u8			port_id);
247
248/**
249 * @brief ecore_port_unpretend - cancel any previously set port
250 *        pretend
251 *
252 * @param p_hwfn
253 * @param p_ptt
254 */
255void ecore_port_unpretend(struct ecore_hwfn	*p_hwfn,
256			  struct ecore_ptt	*p_ptt);
257
258/**
259 * @brief ecore_vfid_to_concrete - build a concrete FID for a
260 *        given VF ID
261 *
262 * @param p_hwfn
263 * @param p_ptt
264 * @param vfid
265 */
266u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
267
268/**
269* @brief ecore_dmae_info_alloc - Init the dmae_info structure
270* which is part of p_hwfn.
271* @param p_hwfn
272*/
273enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn	*p_hwfn);
274
275/**
276* @brief ecore_dmae_info_free - Free the dmae_info structure
277* which is part of p_hwfn
278*
279* @param p_hwfn
280*/
281void ecore_dmae_info_free(struct ecore_hwfn	*p_hwfn);
282
283enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
284					const u8 *fw_data);
285
286void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
287			 enum ecore_hw_err_type err_type);
288
289#endif /* __ECORE_HW_H__ */
290