a258bd16064040ed66fc4961db98e5992f2863b8
[dpdk.git] / drivers / net / qede / base / ecore_init_fw_funcs.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 _INIT_FW_FUNCS_H
10 #define _INIT_FW_FUNCS_H
11 /* Forward declarations */
12
13 struct init_qm_pq_params;
14
15 /**
16  * @brief ecore_qm_pf_mem_size - Prepare QM ILT sizes
17  *
18  * Returns the required host memory size in 4KB units.
19  * Must be called before all QM init HSI functions.
20  *
21  * @param num_pf_cids - number of connections used by this PF
22  * @param num_vf_cids - number of connections used by VFs of this PF
23  * @param num_tids -    number of tasks used by this PF
24  * @param num_pf_pqs -  number of PQs used by this PF
25  * @param num_vf_pqs -  number of PQs used by VFs of this PF
26  *
27  * @return The required host memory size in 4KB units.
28  */
29 u32 ecore_qm_pf_mem_size(u32 num_pf_cids,
30                          u32 num_vf_cids,
31                          u32 num_tids,
32                          u16 num_pf_pqs,
33                          u16 num_vf_pqs);
34
35 /**
36  * @brief ecore_qm_common_rt_init - Prepare QM runtime init values for engine
37  *                                  phase
38  *
39  * @param p_hwfn
40  * @param max_ports_per_engine  - max number of ports per engine in HW
41  * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
42  * @param pf_rl_en              - enable per-PF rate limiters
43  * @param pf_wfq_en             - enable per-PF WFQ
44  * @param vport_rl_en           - enable per-VPORT rate limiters
45  * @param vport_wfq_en          - enable per-VPORT WFQ
46  * @param port_params - array of size MAX_NUM_PORTS with params for each port
47  *
48  * @return 0 on success, -1 on error.
49  */
50 int ecore_qm_common_rt_init(struct ecore_hwfn *p_hwfn,
51                          u8 max_ports_per_engine,
52                          u8 max_phys_tcs_per_port,
53                          bool pf_rl_en,
54                          bool pf_wfq_en,
55                          bool vport_rl_en,
56                          bool vport_wfq_en,
57                          struct init_qm_port_params port_params[MAX_NUM_PORTS]);
58
59 /**
60  * @brief ecore_qm_pf_rt_init  Prepare QM runtime init values for the PF phase
61  *
62  * @param p_hwfn
63  * @param p_ptt                 - ptt window used for writing the registers
64  * @param port_id               - port ID
65  * @param pf_id                 - PF ID
66  * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
67  * @param num_pf_cids           - number of connections used by this PF
68  * @param num_vf_cids           - number of connections used by VFs of this PF
69  * @param num_tids              - number of tasks used by this PF
70  * @param start_pq              - first Tx PQ ID associated with this PF
71  * @param num_pf_pqs            - number of Tx PQs associated with this PF
72  *                                (non-VF)
73  * @param num_vf_pqs            - number of Tx PQs associated with a VF
74  * @param start_vport           - first VPORT ID associated with this PF
75  * @param num_vports - number of VPORTs associated with this PF
76  * @param pf_wfq - WFQ weight. if PF WFQ is globally disabled, the weight must
77  *                 be 0. otherwise, the weight must be non-zero.
78  * @param pf_rl - rate limit in Mb/sec units. a value of 0 means don't
79  *                configure. ignored if PF RL is globally disabled.
80  * @param pq_params - array of size (num_pf_pqs+num_vf_pqs) with parameters for
81  *                    each Tx PQ associated with the specified PF.
82  * @param vport_params - array of size num_vports with parameters for each
83  *                       associated VPORT.
84  *
85  * @return 0 on success, -1 on error.
86  */
87 int ecore_qm_pf_rt_init(struct ecore_hwfn *p_hwfn,
88                         struct ecore_ptt *p_ptt,
89                         u8 port_id,
90                         u8 pf_id,
91                         u8 max_phys_tcs_per_port,
92                         u32 num_pf_cids,
93                         u32 num_vf_cids,
94                         u32 num_tids,
95                         u16 start_pq,
96                         u16 num_pf_pqs,
97                         u16 num_vf_pqs,
98                         u8 start_vport,
99                         u8 num_vports,
100                         u16 pf_wfq,
101                         u32 pf_rl,
102                         struct init_qm_pq_params *pq_params,
103                         struct init_qm_vport_params *vport_params);
104
105 /**
106  * @brief ecore_init_pf_wfq  Initializes the WFQ weight of the specified PF
107  *
108  * @param p_hwfn
109  * @param p_ptt         - ptt window used for writing the registers
110  * @param pf_id         - PF ID
111  * @param pf_wfq        - WFQ weight. Must be non-zero.
112  *
113  * @return 0 on success, -1 on error.
114  */
115 int ecore_init_pf_wfq(struct ecore_hwfn *p_hwfn,
116                                           struct ecore_ptt *p_ptt,
117                                           u8 pf_id,
118                                           u16 pf_wfq);
119
120 /**
121  * @brief ecore_init_pf_rl - Initializes the rate limit of the specified PF
122  *
123  * @param p_hwfn
124  * @param p_ptt - ptt window used for writing the registers
125  * @param pf_id - PF ID
126  * @param pf_rl - rate limit in Mb/sec units
127  *
128  * @return 0 on success, -1 on error.
129  */
130 int ecore_init_pf_rl(struct ecore_hwfn *p_hwfn,
131                                          struct ecore_ptt *p_ptt,
132                                          u8 pf_id,
133                                          u32 pf_rl);
134
135 /**
136  * @brief ecore_init_vport_wfq  Initializes the WFQ weight of specified VPORT
137  *
138  * @param p_hwfn
139  * @param p_ptt                 - ptt window used for writing the registers
140  * @param first_tx_pq_id- An array containing the first Tx PQ ID associated
141  *                        with the VPORT for each TC. This array is filled by
142  *                        ecore_qm_pf_rt_init
143  * @param vport_wfq             - WFQ weight. Must be non-zero.
144  *
145  * @return 0 on success, -1 on error.
146  */
147 int ecore_init_vport_wfq(struct ecore_hwfn *p_hwfn,
148                                                  struct ecore_ptt *p_ptt,
149                                                  u16 first_tx_pq_id[NUM_OF_TCS],
150                                                  u16 vport_wfq);
151
152 /**
153  * @brief ecore_init_vport_rl - Initializes the rate limit of the specified
154  * VPORT.
155  *
156  * @param p_hwfn        - HW device data
157  * @param p_ptt         - ptt window used for writing the registers
158  * @param vport_id      - VPORT ID
159  * @param vport_rl      - rate limit in Mb/sec units
160  *
161  * @return 0 on success, -1 on error.
162  */
163 int ecore_init_vport_rl(struct ecore_hwfn *p_hwfn,
164                                                 struct ecore_ptt *p_ptt,
165                                                 u8 vport_id,
166                                                 u32 vport_rl);
167
168 /**
169  * @brief ecore_send_qm_stop_cmd  Sends a stop command to the QM
170  *
171  * @param p_hwfn
172  * @param p_ptt          - ptt window used for writing the registers
173  * @param is_release_cmd - true for release, false for stop.
174  * @param is_tx_pq       - true for Tx PQs, false for Other PQs.
175  * @param start_pq       - first PQ ID to stop
176  * @param num_pqs        - Number of PQs to stop, starting from start_pq.
177  *
178  * @return bool, true if successful, false if timeout occurred while waiting
179  *  for QM command done.
180  */
181 bool ecore_send_qm_stop_cmd(struct ecore_hwfn *p_hwfn,
182                                                         struct ecore_ptt *p_ptt,
183                                                         bool is_release_cmd,
184                                                         bool is_tx_pq,
185                                                         u16 start_pq,
186                                                         u16 num_pqs);
187 #ifndef UNUSED_HSI_FUNC
188
189 /**
190  * @brief ecore_init_nig_ets - initializes the NIG ETS arbiter
191  *
192  * Based on weight/priority requirements per-TC.
193  *
194  * @param p_ptt - ptt window used for writing the registers.
195  * @param req   - the NIG ETS initialization requirements.
196  * @param is_lb - if set, the loopback port arbiter is initialized, otherwise
197  *                the physical port arbiter is initialized. The pure-LB TC
198  *                requirements are ignored when is_lb is cleared.
199  */
200 void ecore_init_nig_ets(struct ecore_hwfn *p_hwfn,
201                                                 struct ecore_ptt *p_ptt,
202                                                 struct init_ets_req *req,
203                                                 bool is_lb);
204
205 /**
206  * @brief ecore_init_nig_lb_rl - initializes the NIG LB RLs
207  *
208  * Based on global and per-TC rate requirements
209  *
210  * @param p_ptt - ptt window used for writing the registers.
211  * @param req   - the NIG LB RLs initialization requirements.
212  */
213 void ecore_init_nig_lb_rl(struct ecore_hwfn *p_hwfn,
214                                   struct ecore_ptt *p_ptt,
215                                   struct init_nig_lb_rl_req *req);
216 #endif /* UNUSED_HSI_FUNC */
217
218 /**
219  * @brief ecore_init_nig_pri_tc_map - initializes the NIG priority to TC map.
220  *
221  * Assumes valid arguments.
222  *
223  * @param p_ptt - ptt window used for writing the registers.
224  * @param req   - required mapping from prioirties to TCs.
225  */
226 void ecore_init_nig_pri_tc_map(struct ecore_hwfn *p_hwfn,
227                                            struct ecore_ptt *p_ptt,
228                                            struct init_nig_pri_tc_map_req *req);
229
230 #ifndef UNUSED_HSI_FUNC
231 /**
232  * @brief ecore_init_prs_ets - initializes the PRS Rx ETS arbiter
233  *
234  * Based on weight/priority requirements per-TC.
235  *
236  * @param p_ptt - ptt window used for writing the registers.
237  * @param req   - the PRS ETS initialization requirements.
238  */
239 void ecore_init_prs_ets(struct ecore_hwfn *p_hwfn,
240                                                 struct ecore_ptt *p_ptt,
241                                                 struct init_ets_req *req);
242 #endif /* UNUSED_HSI_FUNC */
243
244 #ifndef UNUSED_HSI_FUNC
245 /**
246  * @brief ecore_init_brb_ram - initializes BRB RAM sizes per TC
247  *
248  * Based on weight/priority requirements per-TC.
249  *
250  * @param p_ptt - ptt window used for writing the registers.
251  * @param req   - the BRB RAM initialization requirements.
252  */
253 void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,
254                                                 struct ecore_ptt *p_ptt,
255                                                 struct init_brb_ram_req *req);
256 #endif /* UNUSED_HSI_FUNC */
257
258 #ifndef UNUSED_HSI_FUNC
259 /**
260  * @brief ecore_set_port_mf_ovlan_eth_type - initializes DORQ ethType Regs to
261  *                                           input ethType should Be called
262  *                                           once per port.
263  *
264  * @param p_hwfn -          HW device data
265  * @param ethType - etherType to configure
266  */
267 void ecore_set_port_mf_ovlan_eth_type(struct ecore_hwfn *p_hwfn, u32 ethType);
268 #endif /* UNUSED_HSI_FUNC */
269
270 /**
271  * @brief ecore_set_vxlan_dest_port - initializes vxlan tunnel destination udp
272  *                                    port
273  *
274  * @param p_ptt     - ptt window used for writing the registers.
275  * @param dest_port - vxlan destination udp port.
276  */
277 void ecore_set_vxlan_dest_port(struct ecore_hwfn *p_hwfn,
278                                struct ecore_ptt *p_ptt,
279                                u16 dest_port);
280
281 /**
282  * @brief ecore_set_vxlan_enable - enable or disable VXLAN tunnel in HW
283  *
284  * @param p_ptt         - ptt window used for writing the registers.
285  * @param vxlan_enable  - vxlan enable flag.
286  */
287 void ecore_set_vxlan_enable(struct ecore_hwfn *p_hwfn,
288                             struct ecore_ptt *p_ptt,
289                             bool vxlan_enable);
290
291 /**
292  * @brief ecore_set_gre_enable - enable or disable GRE tunnel in HW
293  *
294  * @param p_ptt          - ptt window used for writing the registers.
295  * @param eth_gre_enable - eth GRE enable enable flag.
296  * @param ip_gre_enable  - IP GRE enable enable flag.
297  */
298 void ecore_set_gre_enable(struct ecore_hwfn *p_hwfn,
299                           struct ecore_ptt *p_ptt,
300                           bool eth_gre_enable,
301                           bool ip_gre_enable);
302
303 /**
304  * @brief ecore_set_geneve_dest_port - initializes geneve tunnel destination
305  *                                     udp port
306  *
307  * @param p_ptt     - ptt window used for writing the registers.
308  * @param dest_port - geneve destination udp port.
309  */
310 void ecore_set_geneve_dest_port(struct ecore_hwfn *p_hwfn,
311                                 struct ecore_ptt *p_ptt,
312                                 u16 dest_port);
313
314 /**
315  * @brief ecore_set_gre_enable - enable or disable GRE tunnel in HW
316  *
317  * @param p_ptt             - ptt window used for writing the registers.
318  * @param eth_geneve_enable - eth GENEVE enable enable flag.
319  * @param ip_geneve_enable  - IP GENEVE enable enable flag.
320   */
321 void ecore_set_geneve_enable(struct ecore_hwfn *p_hwfn,
322                              struct ecore_ptt *p_ptt,
323                              bool eth_geneve_enable,
324                              bool ip_geneve_enable);
325 #ifndef UNUSED_HSI_FUNC
326
327 /**
328 * @brief ecore_set_gft_event_id_cm_hdr - configure GFT event id and cm header
329 *
330 * @param p_ptt          - ptt window used for writing the registers.
331 */
332 void ecore_set_gft_event_id_cm_hdr(struct ecore_hwfn *p_hwfn,
333                                    struct ecore_ptt *p_ptt);
334
335 /**
336  * @brief ecore_set_rfs_mode_disable - Disable and configure HW for RFS
337  *
338  * @param p_hwfn -   HW device data
339  * @param p_ptt -   ptt window used for writing the registers.
340  * @param pf_id - pf on which to disable RFS.
341  */
342 void ecore_set_rfs_mode_disable(struct ecore_hwfn *p_hwfn,
343                                 struct ecore_ptt *p_ptt,
344                                 u16 pf_id);
345
346 /**
347 * @brief ecore_set_rfs_mode_enable - enable and configure HW for RFS
348 *
349 * @param p_ptt  - ptt window used for writing the registers.
350 * @param pf_id  - pf on which to enable RFS.
351 * @param tcp    - set profile tcp packets.
352 * @param udp    - set profile udp  packet.
353 * @param ipv4   - set profile ipv4 packet.
354 * @param ipv6   - set profile ipv6 packet.
355 */
356 void ecore_set_rfs_mode_enable(struct ecore_hwfn *p_hwfn,
357         struct ecore_ptt *p_ptt,
358         u16 pf_id,
359         bool tcp,
360         bool udp,
361         bool ipv4,
362         bool ipv6);
363 #endif /* UNUSED_HSI_FUNC */
364
365 /**
366 * @brief ecore_config_vf_zone_size_mode - Configure VF zone size mode. Must be
367 *                                         used before first ETH queue started.
368 *
369 *
370 * @param p_ptt        -  ptt window used for writing the registers. Don't care
371 *                        if runtime_init used
372 * @param mode         -  VF zone size mode. Use enum vf_zone_size_mode.
373 * @param runtime_init -  Set 1 to init runtime registers in engine phase. Set 0
374 *                        if VF zone size mode configured after engine phase.
375 */
376 void ecore_config_vf_zone_size_mode(struct ecore_hwfn *p_hwfn, struct ecore_ptt
377                                     *p_ptt, u16 mode, bool runtime_init);
378
379 /**
380  * @brief ecore_get_mstorm_queue_stat_offset - Get mstorm statistics offset by
381  * VF zone size mode.
382 *
383 * @param stat_cnt_id         -  statistic counter id
384 * @param vf_zone_size_mode   -  VF zone size mode. Use enum vf_zone_size_mode.
385 */
386 u32 ecore_get_mstorm_queue_stat_offset(struct ecore_hwfn *p_hwfn,
387                                        u16 stat_cnt_id, u16 vf_zone_size_mode);
388
389 /**
390  * @brief ecore_get_mstorm_eth_vf_prods_offset - VF producer offset by VF zone
391  * size mode.
392 *
393 * @param vf_id               -  vf id.
394 * @param vf_queue_id         -  per VF rx queue id.
395 * @param vf_zone_size_mode   -  vf zone size mode. Use enum vf_zone_size_mode.
396 */
397 u32 ecore_get_mstorm_eth_vf_prods_offset(struct ecore_hwfn *p_hwfn, u8 vf_id, u8
398                                          vf_queue_id, u16 vf_zone_size_mode);
399 /**
400  * @brief ecore_enable_context_validation - Enable and configure context
401  *                                          validation.
402  *
403  * @param p_ptt - ptt window used for writing the registers.
404  */
405 void ecore_enable_context_validation(struct ecore_hwfn *p_hwfn,
406                                      struct ecore_ptt *p_ptt);
407 /**
408  * @brief ecore_calc_session_ctx_validation - Calcualte validation byte for
409  * session context.
410  *
411  * @param p_ctx_mem -   pointer to context memory.
412  * @param ctx_size -    context size.
413  * @param ctx_type -    context type.
414  * @param cid -         context cid.
415  */
416 void ecore_calc_session_ctx_validation(void *p_ctx_mem, u16 ctx_size,
417                                        u8 ctx_type, u32 cid);
418
419 /**
420  * @brief ecore_calc_task_ctx_validation - Calcualte validation byte for task
421  * context.
422  *
423  * @param p_ctx_mem -   pointer to context memory.
424  * @param ctx_size -    context size.
425  * @param ctx_type -    context type.
426  * @param tid -             context tid.
427  */
428 void ecore_calc_task_ctx_validation(void *p_ctx_mem, u16 ctx_size, u8 ctx_type,
429                                     u32 tid);
430 /**
431  * @brief ecore_memset_session_ctx - Memset session context to 0 while
432  * preserving validation bytes.
433  *
434  * @param p_hwfn -                HW device data
435  * @param p_ctx_mem - pointer to context memory.
436  * @param ctx_size -  size to initialzie.
437  * @param ctx_type -  context type.
438  */
439 void ecore_memset_session_ctx(void *p_ctx_mem,
440                               u32 ctx_size,
441                               u8 ctx_type);
442 /**
443  * @brief ecore_memset_task_ctx - Memset task context to 0 while preserving
444  * validation bytes.
445  *
446  * @param p_ctx_mem - pointer to context memory.
447  * @param ctx_size -  size to initialzie.
448  * @param ctx_type -  context type.
449  */
450 void ecore_memset_task_ctx(void *p_ctx_mem,
451                            u32 ctx_size,
452                            u8 ctx_type);
453 #endif