]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/dev/qlnx/qlnxe/ecore_hw.h
MFC r316485
[FreeBSD/stable/10.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
32 #ifndef __ECORE_HW_H__
33 #define __ECORE_HW_H__
34
35 #include "ecore.h"
36 #include "ecore_dev_api.h"
37
38 /* Forward decleration */
39 struct ecore_ptt;
40
41 enum reserved_ptts {
42         RESERVED_PTT_EDIAG,
43         RESERVED_PTT_USER_SPACE,
44         RESERVED_PTT_MAIN,
45         RESERVED_PTT_DPC,
46         RESERVED_PTT_MAX
47 };
48
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.
51  */
52 #ifndef MISC_REG_DRIVER_CONTROL_0
53 #define MISC_REG_DRIVER_CONTROL_0       MISC_REG_DRIVER_CONTROL_1
54 #endif
55 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
56 #define MISC_REG_DRIVER_CONTROL_0_SIZE  MISC_REG_DRIVER_CONTROL_1_SIZE
57 #endif
58
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
63 };
64
65 enum _dmae_cmd_src_mask {
66         DMAE_CMD_SRC_MASK_PCIE = 0,
67         DMAE_CMD_SRC_MASK_GRC = 1
68 };
69
70 enum _dmae_cmd_crc_mask {
71         DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
72         DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
73 };
74
75 /* definitions for DMA constants */
76 #define DMAE_GO_VALUE   0x1
77
78 #ifdef __BIG_ENDIAN
79 #define DMAE_COMPLETION_VAL     0xAED10000
80 #define DMAE_CMD_ENDIANITY      0x3
81 #else
82 #define DMAE_COMPLETION_VAL     0xD1AE
83 #define DMAE_CMD_ENDIANITY      0x2
84 #endif
85
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
92
93 /**
94 * @brief ecore_gtt_init - Initialize GTT windows
95 *
96 * @param p_hwfn
97 */
98 void ecore_gtt_init(struct ecore_hwfn *p_hwfn);
99
100 /**
101  * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
102  *
103  * @param p_hwfn
104  */
105 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
106
107 /**
108  * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
109  *
110  * @param p_hwfn
111  *
112  * @return _ecore_status_t - success (0), negative - error.
113  */
114 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
115
116 /**
117  * @brief ecore_ptt_pool_free -
118  *
119  * @param p_hwfn
120  */
121 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
122
123 /**
124  * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
125  *
126  * @param p_hwfn
127  * @param p_ptt
128  *
129  * @return u32
130  */
131 u32 ecore_ptt_get_hw_addr(struct ecore_hwfn     *p_hwfn,
132                           struct ecore_ptt      *p_ptt);
133
134 /**
135  * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
136  *
137  * @param p_hwfn
138  * @param p_ptt
139  *
140  * @return u32
141  */
142 u32 ecore_ptt_get_bar_addr(struct ecore_ptt     *p_ptt);
143
144 /**
145  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
146  *
147  * @param p_hwfn
148  * @param new_hw_addr
149  * @param p_ptt
150  */
151 void ecore_ptt_set_win(struct ecore_hwfn        *p_hwfn,
152                        struct ecore_ptt         *p_ptt,
153                        u32                      new_hw_addr);
154
155 /**
156  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
157  *
158  * @param p_hwfn
159  * @param ptt_idx
160  *
161  * @return struct ecore_ptt *
162  */
163 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn      *p_hwfn,
164                                          enum reserved_ptts     ptt_idx);
165
166 /**
167  * @brief ecore_wr - Write value to BAR using the given ptt
168  *
169  * @param p_hwfn
170  * @param p_ptt
171  * @param val
172  * @param hw_addr
173  */
174 void ecore_wr(struct ecore_hwfn *p_hwfn,
175               struct ecore_ptt  *p_ptt,
176               u32               hw_addr,
177               u32               val);
178
179 /**
180  * @brief ecore_rd - Read value from BAR using the given ptt
181  *
182  * @param p_hwfn
183  * @param p_ptt
184  * @param val
185  * @param hw_addr
186  */
187 u32 ecore_rd(struct ecore_hwfn  *p_hwfn,
188              struct ecore_ptt   *p_ptt,
189              u32                hw_addr);
190
191 /**
192  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
193  *        ptt
194  *
195  * @param p_hwfn
196  * @param p_ptt
197  * @param dest
198  * @param hw_addr
199  * @param n
200  */
201 void ecore_memcpy_from(struct ecore_hwfn        *p_hwfn,
202                        struct ecore_ptt         *p_ptt,
203                        void                     *dest,
204                        u32                      hw_addr,
205                        osal_size_t              n);
206
207 /**
208  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
209  *        ptt
210  *
211  * @param p_hwfn
212  * @param p_ptt
213  * @param hw_addr
214  * @param src
215  * @param n
216  */
217 void ecore_memcpy_to(struct ecore_hwfn  *p_hwfn,
218                      struct ecore_ptt   *p_ptt,
219                      u32                hw_addr,
220                      void               *src,
221                      osal_size_t        n);
222 /**
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.
227  *
228  * @param p_hwfn
229  * @param p_ptt
230  * @param fid - fid field of pxp_pretend structure. Can contain
231  *            either pf / vf, port/path fields are don't care.
232  */
233 void ecore_fid_pretend(struct ecore_hwfn        *p_hwfn,
234                        struct ecore_ptt         *p_ptt,
235                        u16                      fid);
236
237 /**
238  * @brief ecore_port_pretend - pretend to another port when
239  *        accessing the ptt window
240  *
241  * @param p_hwfn
242  * @param p_ptt
243  * @param port_id - the port to pretend to
244  */
245 void ecore_port_pretend(struct ecore_hwfn       *p_hwfn,
246                         struct ecore_ptt        *p_ptt,
247                         u8                      port_id);
248
249 /**
250  * @brief ecore_port_unpretend - cancel any previously set port
251  *        pretend
252  *
253  * @param p_hwfn
254  * @param p_ptt
255  */
256 void ecore_port_unpretend(struct ecore_hwfn     *p_hwfn,
257                           struct ecore_ptt      *p_ptt);
258
259 /**
260  * @brief ecore_vfid_to_concrete - build a concrete FID for a
261  *        given VF ID
262  *
263  * @param p_hwfn
264  * @param p_ptt
265  * @param vfid
266  */
267 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
268
269 /**
270 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
271 * which is part of p_hwfn.
272 * @param p_hwfn
273 */
274 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn    *p_hwfn);
275
276 /**
277 * @brief ecore_dmae_info_free - Free the dmae_info structure
278 * which is part of p_hwfn
279 *
280 * @param p_hwfn
281 */
282 void ecore_dmae_info_free(struct ecore_hwfn     *p_hwfn);
283
284 union ecore_qm_pq_params {
285         struct {
286                 u8 q_idx;
287         } iscsi;
288
289         struct {
290                 u8 tc;
291         } core;
292
293         struct {
294                 u8 is_vf;
295                 u8 vf_id;
296                 u8 tc;
297         } eth;
298
299         struct {
300                 u8 dcqcn;
301                 u8 qpid; /* roce relative */
302         } roce;
303
304         struct {
305                 u8 qidx;
306         } iwarp;
307 };
308
309 u16 ecore_get_qm_pq(struct ecore_hwfn   *p_hwfn,
310                     enum protocol_type  proto,
311                     union ecore_qm_pq_params *params);
312
313 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
314                                         const u8 *fw_data);
315
316 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
317                          enum ecore_hw_err_type err_type);
318
319 #endif /* __ECORE_HW_H__ */