726bc182d5b5480e121f46f817398f5db2350d66
[dpdk.git] / drivers / net / qede / base / ecore_hw.h
1 /*
2  * Copyright (c) 2016 QLogic Corporation.
3  * All rights reserved.
4  * www.qlogic.com
5  *
6  * See LICENSE.qede_pmd for copyright and licensing details.
7  */
8
9 #ifndef __ECORE_HW_H__
10 #define __ECORE_HW_H__
11
12 #include "ecore.h"
13 #include "ecore_dev_api.h"
14
15 /* Forward decleration */
16 struct ecore_ptt;
17
18 enum reserved_ptts {
19         RESERVED_PTT_EDIAG,
20         RESERVED_PTT_USER_SPACE,
21         RESERVED_PTT_MAIN,
22         RESERVED_PTT_DPC,
23         RESERVED_PTT_MAX
24 };
25
26 /* @@@TMP - in earlier versions of the emulation, the HW lock started from 1
27  * instead of 0, this should be fixed in later HW versions.
28  */
29 #ifndef MISC_REG_DRIVER_CONTROL_0
30 #define MISC_REG_DRIVER_CONTROL_0       MISC_REG_DRIVER_CONTROL_1
31 #endif
32 #ifndef MISC_REG_DRIVER_CONTROL_0_SIZE
33 #define MISC_REG_DRIVER_CONTROL_0_SIZE  MISC_REG_DRIVER_CONTROL_1_SIZE
34 #endif
35
36 enum _dmae_cmd_dst_mask {
37         DMAE_CMD_DST_MASK_NONE = 0,
38         DMAE_CMD_DST_MASK_PCIE = 1,
39         DMAE_CMD_DST_MASK_GRC = 2
40 };
41
42 enum _dmae_cmd_src_mask {
43         DMAE_CMD_SRC_MASK_PCIE = 0,
44         DMAE_CMD_SRC_MASK_GRC = 1
45 };
46
47 enum _dmae_cmd_crc_mask {
48         DMAE_CMD_COMP_CRC_EN_MASK_NONE = 0,
49         DMAE_CMD_COMP_CRC_EN_MASK_SET = 1
50 };
51
52 /* definitions for DMA constants */
53 #define DMAE_GO_VALUE   0x1
54
55 #ifdef __BIG_ENDIAN
56 #define DMAE_COMPLETION_VAL     0xAED10000
57 #define DMAE_CMD_ENDIANITY      0x3
58 #else
59 #define DMAE_COMPLETION_VAL     0xD1AE
60 #define DMAE_CMD_ENDIANITY      0x2
61 #endif
62
63 #define DMAE_CMD_SIZE   14
64 /* size of DMAE command structure to fill.. DMAE_CMD_SIZE-5 */
65 #define DMAE_CMD_SIZE_TO_FILL   (DMAE_CMD_SIZE - 5)
66 /* Minimum wait for dmae opertaion to complete 2 milliseconds */
67 #define DMAE_MIN_WAIT_TIME      0x2
68 #define DMAE_MAX_CLIENTS        32
69
70 /**
71 * @brief ecore_gtt_init - Initialize GTT windows
72 *
73 * @param p_hwfn
74 * @param p_ptt
75 */
76 void ecore_gtt_init(struct ecore_hwfn *p_hwfn,
77                     struct ecore_ptt *p_ptt);
78
79 /**
80  * @brief ecore_ptt_invalidate - Forces all ptt entries to be re-configured
81  *
82  * @param p_hwfn
83  */
84 void ecore_ptt_invalidate(struct ecore_hwfn *p_hwfn);
85
86 /**
87  * @brief ecore_ptt_pool_alloc - Allocate and initialize PTT pool
88  *
89  * @param p_hwfn
90  *
91  * @return _ecore_status_t - success (0), negative - error.
92  */
93 enum _ecore_status_t ecore_ptt_pool_alloc(struct ecore_hwfn *p_hwfn);
94
95 /**
96  * @brief ecore_ptt_pool_free -
97  *
98  * @param p_hwfn
99  */
100 void ecore_ptt_pool_free(struct ecore_hwfn *p_hwfn);
101
102 /**
103  * @brief ecore_ptt_get_hw_addr - Get PTT's GRC/HW address
104  *
105  * @param p_hwfn
106  * @param p_ptt
107  *
108  * @return u32
109  */
110 u32 ecore_ptt_get_hw_addr(struct ecore_hwfn     *p_hwfn,
111                           struct ecore_ptt      *p_ptt);
112
113 /**
114  * @brief ecore_ptt_get_bar_addr - Get PPT's external BAR address
115  *
116  * @param p_hwfn
117  * @param p_ptt
118  *
119  * @return u32
120  */
121 u32 ecore_ptt_get_bar_addr(struct ecore_ptt     *p_ptt);
122
123 /**
124  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
125  *
126  * @param p_hwfn
127  * @param new_hw_addr
128  * @param p_ptt
129  */
130 void ecore_ptt_set_win(struct ecore_hwfn        *p_hwfn,
131                        struct ecore_ptt         *p_ptt,
132                        u32                      new_hw_addr);
133
134 /**
135  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
136  *
137  * @param p_hwfn
138  * @param ptt_idx
139  *
140  * @return struct ecore_ptt *
141  */
142 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn      *p_hwfn,
143                                          enum reserved_ptts     ptt_idx);
144
145 /**
146  * @brief ecore_wr - Write value to BAR using the given ptt
147  *
148  * @param p_hwfn
149  * @param p_ptt
150  * @param val
151  * @param hw_addr
152  */
153 void ecore_wr(struct ecore_hwfn *p_hwfn,
154               struct ecore_ptt  *p_ptt,
155               u32               hw_addr,
156               u32               val);
157
158 /**
159  * @brief ecore_rd - Read value from BAR using the given ptt
160  *
161  * @param p_hwfn
162  * @param p_ptt
163  * @param val
164  * @param hw_addr
165  */
166 u32 ecore_rd(struct ecore_hwfn  *p_hwfn,
167              struct ecore_ptt   *p_ptt,
168              u32                hw_addr);
169
170 /**
171  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
172  *        ptt
173  *
174  * @param p_hwfn
175  * @param p_ptt
176  * @param dest
177  * @param hw_addr
178  * @param n
179  */
180 void ecore_memcpy_from(struct ecore_hwfn        *p_hwfn,
181                        struct ecore_ptt         *p_ptt,
182                        void                     *dest,
183                        u32                      hw_addr,
184                        osal_size_t              n);
185
186 /**
187  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
188  *        ptt
189  *
190  * @param p_hwfn
191  * @param p_ptt
192  * @param hw_addr
193  * @param src
194  * @param n
195  */
196 void ecore_memcpy_to(struct ecore_hwfn  *p_hwfn,
197                      struct ecore_ptt   *p_ptt,
198                      u32                hw_addr,
199                      void               *src,
200                      osal_size_t        n);
201 /**
202  * @brief ecore_fid_pretend - pretend to another function when
203  *        accessing the ptt window. There is no way to unpretend
204  *        a function. The only way to cancel a pretend is to
205  *        pretend back to the original function.
206  *
207  * @param p_hwfn
208  * @param p_ptt
209  * @param fid - fid field of pxp_pretend structure. Can contain
210  *            either pf / vf, port/path fields are don't care.
211  */
212 void ecore_fid_pretend(struct ecore_hwfn        *p_hwfn,
213                        struct ecore_ptt         *p_ptt,
214                        u16                      fid);
215
216 /**
217  * @brief ecore_port_pretend - pretend to another port when
218  *        accessing the ptt window
219  *
220  * @param p_hwfn
221  * @param p_ptt
222  * @param port_id - the port to pretend to
223  */
224 void ecore_port_pretend(struct ecore_hwfn       *p_hwfn,
225                         struct ecore_ptt        *p_ptt,
226                         u8                      port_id);
227
228 /**
229  * @brief ecore_port_unpretend - cancel any previously set port
230  *        pretend
231  *
232  * @param p_hwfn
233  * @param p_ptt
234  */
235 void ecore_port_unpretend(struct ecore_hwfn     *p_hwfn,
236                           struct ecore_ptt      *p_ptt);
237
238 /**
239  * @brief ecore_vfid_to_concrete - build a concrete FID for a
240  *        given VF ID
241  *
242  * @param p_hwfn
243  * @param p_ptt
244  * @param vfid
245  */
246 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
247
248 /**
249 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
250 * which is part of p_hwfn.
251 * @param p_hwfn
252 */
253 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn    *p_hwfn);
254
255 /**
256 * @brief ecore_dmae_info_free - Free the dmae_info structure
257 * which is part of p_hwfn
258 *
259 * @param p_hwfn
260 */
261 void ecore_dmae_info_free(struct ecore_hwfn     *p_hwfn);
262
263 union ecore_qm_pq_params {
264         struct {
265                 u8 q_idx;
266         } iscsi;
267
268         struct {
269                 u8 tc;
270         } core;
271
272         struct {
273                 u8 is_vf;
274                 u8 vf_id;
275                 u8 tc;
276         } eth;
277
278         struct {
279                 u8 dcqcn;
280                 u8 qpid; /* roce relative */
281         } roce;
282
283         struct {
284                 u8 qidx;
285         } iwarp;
286 };
287
288 u16 ecore_get_qm_pq(struct ecore_hwfn   *p_hwfn,
289                     enum protocol_type  proto,
290                     union ecore_qm_pq_params *params);
291
292 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
293                                         const u8 *fw_data);
294
295 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
296                          enum ecore_hw_err_type err_type);
297
298 #endif /* __ECORE_HW_H__ */