New upstream version 18.05
[deb_dpdk.git] / drivers / net / qede / base / ecore_init_fw_funcs.h
1 /*
2  * Copyright (c) 2016 - 2018 Cavium Inc.
3  * All rights reserved.
4  * www.cavium.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 pf_id                 - PF ID
65  * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
66  * @param is_pf_loading -         indicates if the PF is currently loading,
67  *                                i.e. it has no allocated QM resources.
68  * @param num_pf_cids           - number of connections used by this PF
69  * @param num_vf_cids           - number of connections used by VFs of this PF
70  * @param num_tids              - number of tasks used by this PF
71  * @param start_pq              - first Tx PQ ID associated with this PF
72  * @param num_pf_pqs            - number of Tx PQs associated with this PF
73  *                                (non-VF)
74  * @param num_vf_pqs            - number of Tx PQs associated with a VF
75  * @param start_vport           - first VPORT ID associated with this PF
76  * @param num_vports - number of VPORTs associated with this PF
77  * @param pf_wfq - WFQ weight. if PF WFQ is globally disabled, the weight must
78  *                 be 0. otherwise, the weight must be non-zero.
79  * @param pf_rl - rate limit in Mb/sec units. a value of 0 means don't
80  *                configure. ignored if PF RL is globally disabled.
81  * @param link_speed -            link speed in Mbps.
82  * @param pq_params - array of size (num_pf_pqs+num_vf_pqs) with parameters for
83  *                    each Tx PQ associated with the specified PF.
84  * @param vport_params - array of size num_vports with parameters for each
85  *                       associated VPORT.
86  *
87  * @return 0 on success, -1 on error.
88  */
89 int ecore_qm_pf_rt_init(struct ecore_hwfn *p_hwfn,
90                         struct ecore_ptt *p_ptt,
91                         u8 pf_id,
92                         u8 max_phys_tcs_per_port,
93                         bool is_pf_loading,
94                         u32 num_pf_cids,
95                         u32 num_vf_cids,
96                         u32 num_tids,
97                         u16 start_pq,
98                         u16 num_pf_pqs,
99                         u16 num_vf_pqs,
100                         u8 start_vport,
101                         u8 num_vports,
102                         u16 pf_wfq,
103                         u32 pf_rl,
104                         u32 link_speed,
105                         struct init_qm_pq_params *pq_params,
106                         struct init_qm_vport_params *vport_params);
107
108 /**
109  * @brief ecore_init_pf_wfq  Initializes the WFQ weight of the specified PF
110  *
111  * @param p_hwfn
112  * @param p_ptt         - ptt window used for writing the registers
113  * @param pf_id         - PF ID
114  * @param pf_wfq        - WFQ weight. Must be non-zero.
115  *
116  * @return 0 on success, -1 on error.
117  */
118 int ecore_init_pf_wfq(struct ecore_hwfn *p_hwfn,
119                                           struct ecore_ptt *p_ptt,
120                                           u8 pf_id,
121                                           u16 pf_wfq);
122
123 /**
124  * @brief ecore_init_pf_rl - Initializes the rate limit of the specified PF
125  *
126  * @param p_hwfn
127  * @param p_ptt - ptt window used for writing the registers
128  * @param pf_id - PF ID
129  * @param pf_rl - rate limit in Mb/sec units
130  *
131  * @return 0 on success, -1 on error.
132  */
133 int ecore_init_pf_rl(struct ecore_hwfn *p_hwfn,
134                                          struct ecore_ptt *p_ptt,
135                                          u8 pf_id,
136                                          u32 pf_rl);
137
138 /**
139  * @brief ecore_init_vport_wfq  Initializes the WFQ weight of specified VPORT
140  *
141  * @param p_hwfn
142  * @param p_ptt                 - ptt window used for writing the registers
143  * @param first_tx_pq_id- An array containing the first Tx PQ ID associated
144  *                        with the VPORT for each TC. This array is filled by
145  *                        ecore_qm_pf_rt_init
146  * @param vport_wfq             - WFQ weight. Must be non-zero.
147  *
148  * @return 0 on success, -1 on error.
149  */
150 int ecore_init_vport_wfq(struct ecore_hwfn *p_hwfn,
151                                                  struct ecore_ptt *p_ptt,
152                                                  u16 first_tx_pq_id[NUM_OF_TCS],
153                                                  u16 vport_wfq);
154
155 /**
156  * @brief ecore_init_vport_rl - Initializes the rate limit of the specified
157  * VPORT.
158  *
159  * @param p_hwfn -             HW device data
160  * @param p_ptt -              ptt window used for writing the registers
161  * @param vport_id -   VPORT ID
162  * @param vport_rl -   rate limit in Mb/sec units
163  * @param link_speed - link speed in Mbps.
164  *
165  * @return 0 on success, -1 on error.
166  */
167 int ecore_init_vport_rl(struct ecore_hwfn *p_hwfn,
168                                                 struct ecore_ptt *p_ptt,
169                                                 u8 vport_id,
170                                                 u32 vport_rl,
171                                                 u32 link_speed);
172
173 /**
174  * @brief ecore_send_qm_stop_cmd  Sends a stop command to the QM
175  *
176  * @param p_hwfn
177  * @param p_ptt          - ptt window used for writing the registers
178  * @param is_release_cmd - true for release, false for stop.
179  * @param is_tx_pq       - true for Tx PQs, false for Other PQs.
180  * @param start_pq       - first PQ ID to stop
181  * @param num_pqs        - Number of PQs to stop, starting from start_pq.
182  *
183  * @return bool, true if successful, false if timeout occurred while waiting
184  *  for QM command done.
185  */
186 bool ecore_send_qm_stop_cmd(struct ecore_hwfn *p_hwfn,
187                                                         struct ecore_ptt *p_ptt,
188                                                         bool is_release_cmd,
189                                                         bool is_tx_pq,
190                                                         u16 start_pq,
191                                                         u16 num_pqs);
192 #ifndef UNUSED_HSI_FUNC
193
194 /**
195  * @brief ecore_init_nig_ets - initializes the NIG ETS arbiter
196  *
197  * Based on weight/priority requirements per-TC.
198  *
199  * @param p_ptt - ptt window used for writing the registers.
200  * @param req   - the NIG ETS initialization requirements.
201  * @param is_lb - if set, the loopback port arbiter is initialized, otherwise
202  *                the physical port arbiter is initialized. The pure-LB TC
203  *                requirements are ignored when is_lb is cleared.
204  */
205 void ecore_init_nig_ets(struct ecore_hwfn *p_hwfn,
206                                                 struct ecore_ptt *p_ptt,
207                                                 struct init_ets_req *req,
208                                                 bool is_lb);
209
210 /**
211  * @brief ecore_init_nig_lb_rl - initializes the NIG LB RLs
212  *
213  * Based on global and per-TC rate requirements
214  *
215  * @param p_ptt - ptt window used for writing the registers.
216  * @param req   - the NIG LB RLs initialization requirements.
217  */
218 void ecore_init_nig_lb_rl(struct ecore_hwfn *p_hwfn,
219                                   struct ecore_ptt *p_ptt,
220                                   struct init_nig_lb_rl_req *req);
221 #endif /* UNUSED_HSI_FUNC */
222
223 /**
224  * @brief ecore_init_nig_pri_tc_map - initializes the NIG priority to TC map.
225  *
226  * Assumes valid arguments.
227  *
228  * @param p_ptt - ptt window used for writing the registers.
229  * @param req   - required mapping from prioirties to TCs.
230  */
231 void ecore_init_nig_pri_tc_map(struct ecore_hwfn *p_hwfn,
232                                            struct ecore_ptt *p_ptt,
233                                            struct init_nig_pri_tc_map_req *req);
234
235 #ifndef UNUSED_HSI_FUNC
236 /**
237  * @brief ecore_init_prs_ets - initializes the PRS Rx ETS arbiter
238  *
239  * Based on weight/priority requirements per-TC.
240  *
241  * @param p_ptt - ptt window used for writing the registers.
242  * @param req   - the PRS ETS initialization requirements.
243  */
244 void ecore_init_prs_ets(struct ecore_hwfn *p_hwfn,
245                                                 struct ecore_ptt *p_ptt,
246                                                 struct init_ets_req *req);
247 #endif /* UNUSED_HSI_FUNC */
248
249 #ifndef UNUSED_HSI_FUNC
250 /**
251  * @brief ecore_init_brb_ram - initializes BRB RAM sizes per TC
252  *
253  * Based on weight/priority requirements per-TC.
254  *
255  * @param p_ptt - ptt window used for writing the registers.
256  * @param req   - the BRB RAM initialization requirements.
257  */
258 void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,
259                                                 struct ecore_ptt *p_ptt,
260                                                 struct init_brb_ram_req *req);
261 #endif /* UNUSED_HSI_FUNC */
262
263 /**
264  * @brief ecore_set_vxlan_no_l2_enable - enable or disable VXLAN no L2 parsing
265  *
266  * @param p_ptt             - ptt window used for writing the registers.
267  * @param enable            - VXLAN no L2 enable flag.
268  */
269 void ecore_set_vxlan_no_l2_enable(struct ecore_hwfn *p_hwfn,
270                                   struct ecore_ptt *p_ptt,
271                                   bool enable);
272
273 #ifndef UNUSED_HSI_FUNC
274 /**
275  * @brief ecore_set_port_mf_ovlan_eth_type - initializes DORQ ethType Regs to
276  *                                           input ethType should Be called
277  *                                           once per port.
278  *
279  * @param p_hwfn -          HW device data
280  * @param ethType - etherType to configure
281  */
282 void ecore_set_port_mf_ovlan_eth_type(struct ecore_hwfn *p_hwfn,
283                                       u32 ethType);
284 #endif /* UNUSED_HSI_FUNC */
285
286 /**
287  * @brief ecore_set_vxlan_dest_port - initializes vxlan tunnel destination udp
288  *                                    port
289  *
290  * @param p_ptt     - ptt window used for writing the registers.
291  * @param dest_port - vxlan destination udp port.
292  */
293 void ecore_set_vxlan_dest_port(struct ecore_hwfn *p_hwfn,
294                                struct ecore_ptt *p_ptt,
295                                u16 dest_port);
296
297 /**
298  * @brief ecore_set_vxlan_enable - enable or disable VXLAN tunnel in HW
299  *
300  * @param p_ptt         - ptt window used for writing the registers.
301  * @param vxlan_enable  - vxlan enable flag.
302  */
303 void ecore_set_vxlan_enable(struct ecore_hwfn *p_hwfn,
304                             struct ecore_ptt *p_ptt,
305                             bool vxlan_enable);
306
307 /**
308  * @brief ecore_set_gre_enable - enable or disable GRE tunnel in HW
309  *
310  * @param p_ptt          - ptt window used for writing the registers.
311  * @param eth_gre_enable - eth GRE enable enable flag.
312  * @param ip_gre_enable  - IP GRE enable enable flag.
313  */
314 void ecore_set_gre_enable(struct ecore_hwfn *p_hwfn,
315                           struct ecore_ptt *p_ptt,
316                           bool eth_gre_enable,
317                           bool ip_gre_enable);
318
319 /**
320  * @brief ecore_set_geneve_dest_port - initializes geneve tunnel destination
321  *                                     udp port
322  *
323  * @param p_ptt     - ptt window used for writing the registers.
324  * @param dest_port - geneve destination udp port.
325  */
326 void ecore_set_geneve_dest_port(struct ecore_hwfn *p_hwfn,
327                                 struct ecore_ptt *p_ptt,
328                                 u16 dest_port);
329
330 /**
331  * @brief ecore_set_gre_enable - enable or disable GRE tunnel in HW
332  *
333  * @param p_ptt             - ptt window used for writing the registers.
334  * @param eth_geneve_enable - eth GENEVE enable enable flag.
335  * @param ip_geneve_enable  - IP GENEVE enable enable flag.
336   */
337 void ecore_set_geneve_enable(struct ecore_hwfn *p_hwfn,
338                              struct ecore_ptt *p_ptt,
339                              bool eth_geneve_enable,
340                              bool ip_geneve_enable);
341 #ifndef UNUSED_HSI_FUNC
342
343 /**
344 * @brief ecore_set_gft_event_id_cm_hdr - configure GFT event id and cm header
345 *
346 * @param p_ptt          - ptt window used for writing the registers.
347 */
348 void ecore_set_gft_event_id_cm_hdr(struct ecore_hwfn *p_hwfn,
349                                    struct ecore_ptt *p_ptt);
350
351 /**
352  * @brief ecore_gft_disable - Disable and GFT
353  *
354  * @param p_hwfn -   HW device data
355  * @param p_ptt -   ptt window used for writing the registers.
356  * @param pf_id - pf on which to disable GFT.
357  */
358 void ecore_gft_disable(struct ecore_hwfn *p_hwfn,
359                                                 struct ecore_ptt *p_ptt,
360                                                 u16 pf_id);
361
362 /**
363  * @brief ecore_gft_config - Enable and configure HW for GFT
364 *
365 * @param p_ptt  - ptt window used for writing the registers.
366  * @param pf_id - pf on which to enable GFT.
367 * @param tcp    - set profile tcp packets.
368 * @param udp    - set profile udp  packet.
369 * @param ipv4   - set profile ipv4 packet.
370 * @param ipv6   - set profile ipv6 packet.
371  * @param profile_type -  define packet same fields. Use enum gft_profile_type.
372 */
373 void ecore_gft_config(struct ecore_hwfn *p_hwfn,
374         struct ecore_ptt *p_ptt,
375         u16 pf_id,
376         bool tcp,
377         bool udp,
378         bool ipv4,
379         bool ipv6,
380         enum gft_profile_type profile_type);
381 #endif /* UNUSED_HSI_FUNC */
382
383 /**
384 * @brief ecore_config_vf_zone_size_mode - Configure VF zone size mode. Must be
385 *                                         used before first ETH queue started.
386 *
387 *
388 * @param p_ptt        -  ptt window used for writing the registers. Don't care
389 *                        if runtime_init used
390 * @param mode         -  VF zone size mode. Use enum vf_zone_size_mode.
391 * @param runtime_init -  Set 1 to init runtime registers in engine phase. Set 0
392 *                        if VF zone size mode configured after engine phase.
393 */
394 void ecore_config_vf_zone_size_mode(struct ecore_hwfn *p_hwfn, struct ecore_ptt
395                                     *p_ptt, u16 mode, bool runtime_init);
396
397 /**
398  * @brief ecore_get_mstorm_queue_stat_offset - Get mstorm statistics offset by
399  * VF zone size mode.
400 *
401 * @param stat_cnt_id         -  statistic counter id
402 * @param vf_zone_size_mode   -  VF zone size mode. Use enum vf_zone_size_mode.
403 */
404 u32 ecore_get_mstorm_queue_stat_offset(struct ecore_hwfn *p_hwfn,
405                                        u16 stat_cnt_id, u16 vf_zone_size_mode);
406
407 /**
408  * @brief ecore_get_mstorm_eth_vf_prods_offset - VF producer offset by VF zone
409  * size mode.
410 *
411 * @param vf_id               -  vf id.
412 * @param vf_queue_id         -  per VF rx queue id.
413 * @param vf_zone_size_mode   -  vf zone size mode. Use enum vf_zone_size_mode.
414 */
415 u32 ecore_get_mstorm_eth_vf_prods_offset(struct ecore_hwfn *p_hwfn, u8 vf_id, u8
416                                          vf_queue_id, u16 vf_zone_size_mode);
417 /**
418  * @brief ecore_enable_context_validation - Enable and configure context
419  *                                          validation.
420  *
421  * @param p_ptt - ptt window used for writing the registers.
422  */
423 void ecore_enable_context_validation(struct ecore_hwfn *p_hwfn,
424                                      struct ecore_ptt *p_ptt);
425 /**
426  * @brief ecore_calc_session_ctx_validation - Calcualte validation byte for
427  * session context.
428  *
429  * @param p_ctx_mem -   pointer to context memory.
430  * @param ctx_size -    context size.
431  * @param ctx_type -    context type.
432  * @param cid -         context cid.
433  */
434 void ecore_calc_session_ctx_validation(void *p_ctx_mem,
435                                        u16 ctx_size,
436                                        u8 ctx_type,
437                                        u32 cid);
438
439 /**
440  * @brief ecore_calc_task_ctx_validation - Calcualte validation byte for task
441  * context.
442  *
443  * @param p_ctx_mem -   pointer to context memory.
444  * @param ctx_size -    context size.
445  * @param ctx_type -    context type.
446  * @param tid -             context tid.
447  */
448 void ecore_calc_task_ctx_validation(void *p_ctx_mem,
449                                     u16 ctx_size,
450                                     u8 ctx_type,
451                                     u32 tid);
452
453 /**
454  * @brief ecore_memset_session_ctx - Memset session context to 0 while
455  * preserving validation bytes.
456  *
457  * @param p_hwfn -                HW device data
458  * @param p_ctx_mem - pointer to context memory.
459  * @param ctx_size -  size to initialzie.
460  * @param ctx_type -  context type.
461  */
462 void ecore_memset_session_ctx(void *p_ctx_mem,
463                               u32 ctx_size,
464                               u8 ctx_type);
465 /**
466  * @brief ecore_memset_task_ctx - Memset task context to 0 while preserving
467  * validation bytes.
468  *
469  * @param p_ctx_mem - pointer to context memory.
470  * @param ctx_size -  size to initialzie.
471  * @param ctx_type -  context type.
472  */
473 void ecore_memset_task_ctx(void *p_ctx_mem,
474                            u32 ctx_size,
475                            u8 ctx_type);
476
477 /**
478  * @brief ecore_update_eth_rss_ind_table_entry - Update RSS indirection table
479  * entry.
480  * The function must run in exclusive mode to prevent wrong RSS configuration.
481  *
482  * @param p_hwfn    - HW device data
483  * @param p_ptt  - ptt window used for writing the registers.
484  * @param rss_id - RSS engine ID.
485  * @param ind_table_index -  RSS indirect table index.
486  * @param ind_table_value -  RSS indirect table new value.
487  */
488 void ecore_update_eth_rss_ind_table_entry(struct ecore_hwfn *p_hwfn,
489                                           struct ecore_ptt *p_ptt,
490                                           u8 rss_id,
491                                           u8 ind_table_index,
492                                           u16 ind_table_value);
493
494 #endif