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