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