xref: /dpdk/drivers/net/qede/base/ecore_hw.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.com
5  */
6 
7 #ifndef __ECORE_HW_H__
8 #define __ECORE_HW_H__
9 
10 #include "ecore.h"
11 
12 /* Forward declaration */
13 struct ecore_ptt;
14 
15 enum reserved_ptts {
16 	RESERVED_PTT_EDIAG,
17 	RESERVED_PTT_USER_SPACE,
18 	RESERVED_PTT_MAIN,
19 	RESERVED_PTT_DPC,
20 	RESERVED_PTT_MAX
21 };
22 
23 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1
24  * instead of 0, this should be fixed in later HW versions.
25  */
26 #ifndef MISC_REG_DRIVER_CONTROL_0
27 #define MISC_REG_DRIVER_CONTROL_0	MISC_REG_DRIVER_CONTROL_1
28 #endif
29 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
30 #define MISC_REG_DRIVER_CONTROL_0_SIZE	MISC_REG_DRIVER_CONTROL_1_SIZE
31 #endif
32 
33 /* Definitions for DMA constants */
34 #define DMAE_GO_VALUE	0x1
35 
36 #ifdef __BIG_ENDIAN
37 #define DMAE_COMPLETION_VAL	0xAED10000
38 #define DMAE_CMD_ENDIANITY	0x3
39 #else
40 #define DMAE_COMPLETION_VAL	0xD1AE
41 #define DMAE_CMD_ENDIANITY	0x2
42 #endif
43 
44 #define DMAE_CMD_SIZE	14
45 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */
46 #define DMAE_CMD_SIZE_TO_FILL	(DMAE_CMD_SIZE - 5)
47 /* Minimum wait for dmae opertaion to complete 2 milliseconds */
48 #define DMAE_MIN_WAIT_TIME	0x2
49 #define DMAE_MAX_CLIENTS	32
50 
51 /**
52 * @brief ecore_gtt_init - Initialize GTT windows
53 *
54 * @param p_hwfn
55 */
56 void ecore_gtt_init(struct ecore_hwfn *p_hwfn);
57 
58 /**
59  * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
60  *
61  * @param p_hwfn
62  */
63 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
64 
65 /**
66  * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
67  *
68  * @param p_hwfn
69  *
70  * @return _ecore_status_t - success (0), negative - error.
71  */
72 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
73 
74 /**
75  * @brief ecore_ptt_pool_free -
76  *
77  * @param p_hwfn
78  */
79 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
80 
81 /**
82  * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
83  *
84  * @param p_ptt
85  *
86  * @return u32
87  */
88 u32 ecore_ptt_get_bar_addr(struct ecore_ptt	*p_ptt);
89 
90 /**
91  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
92  *
93  * @param p_hwfn
94  * @param p_ptt
95  * @param new_hw_addr
96  */
97 void ecore_ptt_set_win(struct ecore_hwfn	*p_hwfn,
98 		       struct ecore_ptt		*p_ptt,
99 		       u32			new_hw_addr);
100 
101 /**
102  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
103  *
104  * @param p_hwfn
105  * @param ptt_idx
106  *
107  * @return struct ecore_ptt *
108  */
109 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn	*p_hwfn,
110 					 enum reserved_ptts	ptt_idx);
111 
112 /**
113  * @brief ecore_wr - Write value to BAR using the given ptt
114  *
115  * @param p_hwfn
116  * @param p_ptt
117  * @param hw_addr
118  * @param val
119  */
120 void ecore_wr(struct ecore_hwfn	*p_hwfn,
121 	      struct ecore_ptt	*p_ptt,
122 	      u32		hw_addr,
123 	      u32		val);
124 
125 /**
126  * @brief ecore_rd - Read value from BAR using the given ptt
127  *
128  * @param p_hwfn
129  * @param p_ptt
130  * @param hw_addr
131  */
132 u32 ecore_rd(struct ecore_hwfn	*p_hwfn,
133 	     struct ecore_ptt	*p_ptt,
134 	     u32		hw_addr);
135 
136 /**
137  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
138  *        ptt
139  *
140  * @param p_hwfn
141  * @param p_ptt
142  * @param dest
143  * @param hw_addr
144  * @param n
145  */
146 void ecore_memcpy_from(struct ecore_hwfn	*p_hwfn,
147 		       struct ecore_ptt		*p_ptt,
148 		       void			*dest,
149 		       u32			hw_addr,
150 		       osal_size_t		n);
151 
152 /**
153  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
154  *        ptt
155  *
156  * @param p_hwfn
157  * @param p_ptt
158  * @param hw_addr
159  * @param src
160  * @param n
161  */
162 void ecore_memcpy_to(struct ecore_hwfn	*p_hwfn,
163 		     struct ecore_ptt	*p_ptt,
164 		     u32		hw_addr,
165 		     void		*src,
166 		     osal_size_t	n);
167 /**
168  * @brief ecore_fid_pretend - pretend to another function when
169  *        accessing the ptt window. There is no way to unpretend
170  *        a function. The only way to cancel a pretend is to
171  *        pretend back to the original function.
172  *
173  * @param p_hwfn
174  * @param p_ptt
175  * @param fid - fid field of pxp_pretend structure. Can contain
176  *            either pf / vf, port/path fields are don't care.
177  */
178 void ecore_fid_pretend(struct ecore_hwfn	*p_hwfn,
179 		       struct ecore_ptt		*p_ptt,
180 		       u16			fid);
181 
182 /**
183  * @brief ecore_port_pretend - pretend to another port when
184  *        accessing the ptt window
185  *
186  * @param p_hwfn
187  * @param p_ptt
188  * @param port_id - the port to pretend to
189  */
190 void ecore_port_pretend(struct ecore_hwfn	*p_hwfn,
191 			struct ecore_ptt	*p_ptt,
192 			u8			port_id);
193 
194 /**
195  * @brief ecore_port_unpretend - cancel any previously set port
196  *        pretend
197  *
198  * @param p_hwfn
199  * @param p_ptt
200  */
201 void ecore_port_unpretend(struct ecore_hwfn	*p_hwfn,
202 			  struct ecore_ptt	*p_ptt);
203 
204 /**
205  * @brief ecore_port_fid_pretend - pretend to another port and another function
206  *        when accessing the ptt window
207  *
208  * @param p_hwfn
209  * @param p_ptt
210  * @param port_id - the port to pretend to
211  * @param fid - fid field of pxp_pretend structure. Can contain either pf / vf.
212  */
213 void ecore_port_fid_pretend(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
214 			    u8 port_id, u16 fid);
215 
216 /**
217  * @brief ecore_vfid_to_concrete - build a concrete FID for a
218  *        given VF ID
219  *
220  * @param p_hwfn
221  * @param p_ptt
222  * @param vfid
223  */
224 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
225 
226 /**
227 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
228 * which is part of p_hwfn.
229 * @param p_hwfn
230 */
231 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn	*p_hwfn);
232 
233 /**
234 * @brief ecore_dmae_info_free - Free the dmae_info structure
235 * which is part of p_hwfn
236 *
237 * @param p_hwfn
238 */
239 void ecore_dmae_info_free(struct ecore_hwfn	*p_hwfn);
240 
241 /**
242  * @brief ecore_dmae_host2grc - copy data from source address to
243  * dmae registers using the given ptt
244  *
245  * @param p_hwfn
246  * @param p_ptt
247  * @param source_addr
248  * @param grc_addr (dmae_data_offset)
249  * @param size_in_dwords
250  * @param p_params (default parameters will be used in case of OSAL_NULL)
251  *
252  * @return enum _ecore_status_t
253  */
254 enum _ecore_status_t
255 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
256 		    struct ecore_ptt *p_ptt,
257 		    u64 source_addr,
258 		    u32 grc_addr,
259 		    u32 size_in_dwords,
260 		    struct dmae_params *p_params);
261 
262 /**
263  * @brief ecore_dmae_grc2host - Read data from dmae data offset
264  * to source address using the given ptt
265  *
266  * @param p_ptt
267  * @param grc_addr (dmae_data_offset)
268  * @param dest_addr
269  * @param size_in_dwords
270  * @param p_params (default parameters will be used in case of OSAL_NULL)
271  *
272  * @return enum _ecore_status_t
273  */
274 enum _ecore_status_t
275 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
276 		    struct ecore_ptt *p_ptt,
277 		    u32 grc_addr,
278 		    dma_addr_t dest_addr,
279 		    u32 size_in_dwords,
280 		    struct dmae_params *p_params);
281 
282 /**
283  * @brief ecore_dmae_host2host - copy data from to source address
284  * to a destination address (for SRIOV) using the given ptt
285  *
286  * @param p_hwfn
287  * @param p_ptt
288  * @param source_addr
289  * @param dest_addr
290  * @param size_in_dwords
291  * @param p_params (default parameters will be used in case of OSAL_NULL)
292  *
293  * @return enum _ecore_status_t
294  */
295 enum _ecore_status_t
296 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
297 		     struct ecore_ptt *p_ptt,
298 		     dma_addr_t source_addr,
299 		     dma_addr_t dest_addr,
300 		     u32 size_in_dwords,
301 		     struct dmae_params *p_params);
302 
303 enum _ecore_status_t ecore_dmae_sanity(struct ecore_hwfn *p_hwfn,
304 				       struct ecore_ptt *p_ptt,
305 				       const char *phase);
306 
307 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
308 					const u8 *fw_data);
309 
310 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
311 			 enum ecore_hw_err_type err_type);
312 
313 /**
314  * @brief ecore_ppfid_wr - Write value to BAR using the given ptt while
315  *	pretending to a PF to which the given PPFID pertains.
316  *
317  * @param p_hwfn
318  * @param p_ptt
319  * @param abs_ppfid
320  * @param hw_addr
321  * @param val
322  */
323 void ecore_ppfid_wr(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
324 		    u8 abs_ppfid, u32 hw_addr, u32 val);
325 
326 /**
327  * @brief ecore_ppfid_rd - Read value from BAR using the given ptt while
328  *	 pretending to a PF to which the given PPFID pertains.
329  *
330  * @param p_hwfn
331  * @param p_ptt
332  * @param abs_ppfid
333  * @param hw_addr
334  */
335 u32 ecore_ppfid_rd(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
336 		   u8 abs_ppfid, u32 hw_addr);
337 
338 #endif /* __ECORE_HW_H__ */
339