]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/qlnx/qlnxe/ecore_hw.h
Import riscv DTS files
[FreeBSD/FreeBSD.git] / sys / dev / qlnx / qlnxe / ecore_hw.h
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_bar_addr - Get PPT's external BAR address
117  *
118  * @param p_hwfn
119  * @param p_ptt
120  *
121  * @return u32
122  */
123 u32 ecore_ptt_get_bar_addr(struct ecore_ptt     *p_ptt);
124
125 /**
126  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
127  *
128  * @param p_hwfn
129  * @param new_hw_addr
130  * @param p_ptt
131  */
132 void ecore_ptt_set_win(struct ecore_hwfn        *p_hwfn,
133                        struct ecore_ptt         *p_ptt,
134                        u32                      new_hw_addr);
135
136 /**
137  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
138  *
139  * @param p_hwfn
140  * @param ptt_idx
141  *
142  * @return struct ecore_ptt *
143  */
144 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn      *p_hwfn,
145                                          enum reserved_ptts     ptt_idx);
146
147 /**
148  * @brief ecore_wr - Write value to BAR using the given ptt
149  *
150  * @param p_hwfn
151  * @param p_ptt
152  * @param hw_addr
153  * @param val
154  */
155 void ecore_wr(struct ecore_hwfn *p_hwfn,
156               struct ecore_ptt  *p_ptt,
157               u32               hw_addr,
158               u32               val);
159
160 /**
161  * @brief ecore_rd - Read value from BAR using the given ptt
162  *
163  * @param p_hwfn
164  * @param p_ptt
165  * @param hw_addr
166  */
167 u32 ecore_rd(struct ecore_hwfn  *p_hwfn,
168              struct ecore_ptt   *p_ptt,
169              u32                hw_addr);
170
171 /**
172  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
173  *        ptt
174  *
175  * @param p_hwfn
176  * @param p_ptt
177  * @param dest
178  * @param hw_addr
179  * @param n
180  */
181 void ecore_memcpy_from(struct ecore_hwfn        *p_hwfn,
182                        struct ecore_ptt         *p_ptt,
183                        void                     *dest,
184                        u32                      hw_addr,
185                        osal_size_t              n);
186
187 /**
188  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
189  *        ptt
190  *
191  * @param p_hwfn
192  * @param p_ptt
193  * @param hw_addr
194  * @param src
195  * @param n
196  */
197 void ecore_memcpy_to(struct ecore_hwfn  *p_hwfn,
198                      struct ecore_ptt   *p_ptt,
199                      u32                hw_addr,
200                      void               *src,
201                      osal_size_t        n);
202 /**
203  * @brief ecore_fid_pretend - pretend to another function when
204  *        accessing the ptt window. There is no way to unpretend
205  *        a function. The only way to cancel a pretend is to
206  *        pretend back to the original function.
207  *
208  * @param p_hwfn
209  * @param p_ptt
210  * @param fid - fid field of pxp_pretend structure. Can contain
211  *            either pf / vf, port/path fields are don't care.
212  */
213 void ecore_fid_pretend(struct ecore_hwfn        *p_hwfn,
214                        struct ecore_ptt         *p_ptt,
215                        u16                      fid);
216
217 /**
218  * @brief ecore_port_pretend - pretend to another port when
219  *        accessing the ptt window
220  *
221  * @param p_hwfn
222  * @param p_ptt
223  * @param port_id - the port to pretend to
224  */
225 void ecore_port_pretend(struct ecore_hwfn       *p_hwfn,
226                         struct ecore_ptt        *p_ptt,
227                         u8                      port_id);
228
229 /**
230  * @brief ecore_port_unpretend - cancel any previously set port
231  *        pretend
232  *
233  * @param p_hwfn
234  * @param p_ptt
235  */
236 void ecore_port_unpretend(struct ecore_hwfn     *p_hwfn,
237                           struct ecore_ptt      *p_ptt);
238
239 /**
240  * @brief ecore_vfid_to_concrete - build a concrete FID for a
241  *        given VF ID
242  *
243  * @param p_hwfn
244  * @param p_ptt
245  * @param vfid
246  */
247 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
248
249 /**
250 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
251 * which is part of p_hwfn.
252 * @param p_hwfn
253 */
254 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn    *p_hwfn);
255
256 /**
257 * @brief ecore_dmae_info_free - Free the dmae_info structure
258 * which is part of p_hwfn
259 *
260 * @param p_hwfn
261 */
262 void ecore_dmae_info_free(struct ecore_hwfn     *p_hwfn);
263
264 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
265                                         const u8 *fw_data);
266
267 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
268                          enum ecore_hw_err_type err_type);
269
270 enum _ecore_status_t ecore_dmae_sanity(struct ecore_hwfn *p_hwfn,
271                                        struct ecore_ptt *p_ptt,
272                                        const char *phase);
273
274 /**
275  * @brief ecore_ppfid_wr - Write value to BAR using the given ptt while
276  *      pretending to a PF to which the given PPFID pertains.
277  *
278  * @param p_hwfn
279  * @param p_ptt
280  * @param abs_ppfid
281  * @param hw_addr
282  * @param val
283  */
284 void ecore_ppfid_wr(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
285                     u8 abs_ppfid, u32 hw_addr, u32 val);
286
287 /**
288  * @brief ecore_ppfid_rd - Read value from BAR using the given ptt while
289  *       pretending to a PF to which the given PPFID pertains.
290  *
291  * @param p_hwfn
292  * @param p_ptt
293  * @param abs_ppfid
294  * @param hw_addr
295  */
296 u32 ecore_ppfid_rd(struct ecore_hwfn *p_hwfn, struct ecore_ptt *p_ptt,
297                    u8 abs_ppfid, u32 hw_addr);
298
299 #endif /* __ECORE_HW_H__ */