New upstream version 17.11-rc3
[deb_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_bar_addr - Get PPT's external BAR address
104  *
105  * @param p_hwfn
106  * @param p_ptt
107  *
108  * @return u32
109  */
110 u32 ecore_ptt_get_bar_addr(struct ecore_ptt     *p_ptt);
111
112 /**
113  * @brief ecore_ptt_set_win - Set PTT Window's GRC BAR address
114  *
115  * @param p_hwfn
116  * @param new_hw_addr
117  * @param p_ptt
118  */
119 void ecore_ptt_set_win(struct ecore_hwfn        *p_hwfn,
120                        struct ecore_ptt         *p_ptt,
121                        u32                      new_hw_addr);
122
123 /**
124  * @brief ecore_get_reserved_ptt - Get a specific reserved PTT
125  *
126  * @param p_hwfn
127  * @param ptt_idx
128  *
129  * @return struct ecore_ptt *
130  */
131 struct ecore_ptt *ecore_get_reserved_ptt(struct ecore_hwfn      *p_hwfn,
132                                          enum reserved_ptts     ptt_idx);
133
134 /**
135  * @brief ecore_wr - Write value to BAR using the given ptt
136  *
137  * @param p_hwfn
138  * @param p_ptt
139  * @param val
140  * @param hw_addr
141  */
142 void ecore_wr(struct ecore_hwfn *p_hwfn,
143               struct ecore_ptt  *p_ptt,
144               u32               hw_addr,
145               u32               val);
146
147 /**
148  * @brief ecore_rd - Read value from BAR using the given ptt
149  *
150  * @param p_hwfn
151  * @param p_ptt
152  * @param val
153  * @param hw_addr
154  */
155 u32 ecore_rd(struct ecore_hwfn  *p_hwfn,
156              struct ecore_ptt   *p_ptt,
157              u32                hw_addr);
158
159 /**
160  * @brief ecore_memcpy_from - copy n bytes from BAR using the given
161  *        ptt
162  *
163  * @param p_hwfn
164  * @param p_ptt
165  * @param dest
166  * @param hw_addr
167  * @param n
168  */
169 void ecore_memcpy_from(struct ecore_hwfn        *p_hwfn,
170                        struct ecore_ptt         *p_ptt,
171                        void                     *dest,
172                        u32                      hw_addr,
173                        osal_size_t              n);
174
175 /**
176  * @brief ecore_memcpy_to - copy n bytes to BAR using the given
177  *        ptt
178  *
179  * @param p_hwfn
180  * @param p_ptt
181  * @param hw_addr
182  * @param src
183  * @param n
184  */
185 void ecore_memcpy_to(struct ecore_hwfn  *p_hwfn,
186                      struct ecore_ptt   *p_ptt,
187                      u32                hw_addr,
188                      void               *src,
189                      osal_size_t        n);
190 /**
191  * @brief ecore_fid_pretend - pretend to another function when
192  *        accessing the ptt window. There is no way to unpretend
193  *        a function. The only way to cancel a pretend is to
194  *        pretend back to the original function.
195  *
196  * @param p_hwfn
197  * @param p_ptt
198  * @param fid - fid field of pxp_pretend structure. Can contain
199  *            either pf / vf, port/path fields are don't care.
200  */
201 void ecore_fid_pretend(struct ecore_hwfn        *p_hwfn,
202                        struct ecore_ptt         *p_ptt,
203                        u16                      fid);
204
205 /**
206  * @brief ecore_port_pretend - pretend to another port when
207  *        accessing the ptt window
208  *
209  * @param p_hwfn
210  * @param p_ptt
211  * @param port_id - the port to pretend to
212  */
213 void ecore_port_pretend(struct ecore_hwfn       *p_hwfn,
214                         struct ecore_ptt        *p_ptt,
215                         u8                      port_id);
216
217 /**
218  * @brief ecore_port_unpretend - cancel any previously set port
219  *        pretend
220  *
221  * @param p_hwfn
222  * @param p_ptt
223  */
224 void ecore_port_unpretend(struct ecore_hwfn     *p_hwfn,
225                           struct ecore_ptt      *p_ptt);
226
227 /**
228  * @brief ecore_vfid_to_concrete - build a concrete FID for a
229  *        given VF ID
230  *
231  * @param p_hwfn
232  * @param p_ptt
233  * @param vfid
234  */
235 u32 ecore_vfid_to_concrete(struct ecore_hwfn *p_hwfn, u8 vfid);
236
237 /**
238 * @brief ecore_dmae_info_alloc - Init the dmae_info structure
239 * which is part of p_hwfn.
240 * @param p_hwfn
241 */
242 enum _ecore_status_t ecore_dmae_info_alloc(struct ecore_hwfn    *p_hwfn);
243
244 /**
245 * @brief ecore_dmae_info_free - Free the dmae_info structure
246 * which is part of p_hwfn
247 *
248 * @param p_hwfn
249 */
250 void ecore_dmae_info_free(struct ecore_hwfn     *p_hwfn);
251
252 enum _ecore_status_t ecore_init_fw_data(struct ecore_dev *p_dev,
253                                         const u8 *fw_data);
254
255 void ecore_hw_err_notify(struct ecore_hwfn *p_hwfn,
256                          enum ecore_hw_err_type err_type);
257
258 #endif /* __ECORE_HW_H__ */