xref: /freebsd/sys/dev/qlnx/qlnxe/ecore_hw.h (revision 38069501)
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$
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 */
38 struct ecore_ptt;
39 
40 enum 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 
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
62 };
63 
64 enum _dmae_cmd_src_mask {
65 	DMAE_CMD_SRC_MASK_PCIE = 0,
66 	DMAE_CMD_SRC_MASK_GRC = 1
67 };
68 
69 enum _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_ptt_invalidate - Forces all ptt entries to be re-configured
94  *
95  * @param p_hwfn
96  */
97 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
98 
99 /**
100  * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
101  *
102  * @param p_hwfn
103  *
104  * @return _ecore_status_t - success (0), negative - error.
105  */
106 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
107 
108 /**
109  * @brief ecore_ptt_pool_free -
110  *
111  * @param p_hwfn
112  */
113 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
114 
115 /**
116  * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
117  *
118  * @param p_ptt
119  *
120  * @return u32
121  */
122 u32 ecore_ptt_get_hw_addr(struct ecore_ptt *p_ptt);
123 
124 /**
125  * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
126  *
127  * @param p_hwfn
128  * @param p_ptt
129  *
130  * @return u32
131  */
132 u32 ecore_ptt_get_bar_addr(struct ecore_ptt	*p_ptt);
133 
134 /**
135  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
136  *
137  * @param p_hwfn
138  * @param new_hw_addr
139  * @param p_ptt
140  */
141 void ecore_ptt_set_win(struct ecore_hwfn	*p_hwfn,
142 		       struct ecore_ptt		*p_ptt,
143 		       u32			new_hw_addr);
144 
145 /**
146  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
147  *
148  * @param p_hwfn
149  * @param ptt_idx
150  *
151  * @return struct ecore_ptt *
152  */
153 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn	*p_hwfn,
154 					 enum reserved_ptts	ptt_idx);
155 
156 /**
157  * @brief ecore_wr - Write value to BAR using the given ptt
158  *
159  * @param p_hwfn
160  * @param p_ptt
161  * @param val
162  * @param hw_addr
163  */
164 void ecore_wr(struct ecore_hwfn	*p_hwfn,
165 	      struct ecore_ptt	*p_ptt,
166 	      u32		hw_addr,
167 	      u32		val);
168 
169 /**
170  * @brief ecore_rd - Read value from BAR using the given ptt
171  *
172  * @param p_hwfn
173  * @param p_ptt
174  * @param val
175  * @param hw_addr
176  */
177 u32 ecore_rd(struct ecore_hwfn	*p_hwfn,
178 	     struct ecore_ptt	*p_ptt,
179 	     u32		hw_addr);
180 
181 /**
182  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
183  *        ptt
184  *
185  * @param p_hwfn
186  * @param p_ptt
187  * @param dest
188  * @param hw_addr
189  * @param n
190  */
191 void ecore_memcpy_from(struct ecore_hwfn	*p_hwfn,
192 		       struct ecore_ptt		*p_ptt,
193 		       void			*dest,
194 		       u32			hw_addr,
195 		       osal_size_t		n);
196 
197 /**
198  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
199  *        ptt
200  *
201  * @param p_hwfn
202  * @param p_ptt
203  * @param hw_addr
204  * @param src
205  * @param n
206  */
207 void ecore_memcpy_to(struct ecore_hwfn	*p_hwfn,
208 		     struct ecore_ptt	*p_ptt,
209 		     u32		hw_addr,
210 		     void		*src,
211 		     osal_size_t	n);
212 /**
213  * @brief ecore_fid_pretend - pretend to another function when
214  *        accessing the ptt window. There is no way to unpretend
215  *        a function. The only way to cancel a pretend is to
216  *        pretend back to the original function.
217  *
218  * @param p_hwfn
219  * @param p_ptt
220  * @param fid - fid field of pxp_pretend structure. Can contain
221  *            either pf / vf, port/path fields are don't care.
222  */
223 void ecore_fid_pretend(struct ecore_hwfn	*p_hwfn,
224 		       struct ecore_ptt		*p_ptt,
225 		       u16			fid);
226 
227 /**
228  * @brief ecore_port_pretend - pretend to another port when
229  *        accessing the ptt window
230  *
231  * @param p_hwfn
232  * @param p_ptt
233  * @param port_id - the port to pretend to
234  */
235 void ecore_port_pretend(struct ecore_hwfn	*p_hwfn,
236 			struct ecore_ptt	*p_ptt,
237 			u8			port_id);
238 
239 /**
240  * @brief ecore_port_unpretend - cancel any previously set port
241  *        pretend
242  *
243  * @param p_hwfn
244  * @param p_ptt
245  */
246 void ecore_port_unpretend(struct ecore_hwfn	*p_hwfn,
247 			  struct ecore_ptt	*p_ptt);
248 
249 /**
250  * @brief ecore_vfid_to_concrete - build a concrete FID for a
251  *        given VF ID
252  *
253  * @param p_hwfn
254  * @param p_ptt
255  * @param vfid
256  */
257 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
258 
259 /**
260 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
261 * which is part of p_hwfn.
262 * @param p_hwfn
263 */
264 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn	*p_hwfn);
265 
266 /**
267 * @brief ecore_dmae_info_free - Free the dmae_info structure
268 * which is part of p_hwfn
269 *
270 * @param p_hwfn
271 */
272 void ecore_dmae_info_free(struct ecore_hwfn	*p_hwfn);
273 
274 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
275 					const u8 *fw_data);
276 
277 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
278 			 enum ecore_hw_err_type err_type);
279 
280 #endif /* __ECORE_HW_H__ */
281