2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef _INIT_FW_FUNCS_H
32 #define _INIT_FW_FUNCS_H
33 /* Forward declarations */
35 struct init_qm_pq_params;
38 * @brief ecore_qm_pf_mem_size - Prepare QM ILT sizes
40 * Returns the required host memory size in 4KB units.
41 * Must be called before all QM init HSI functions.
43 * @param num_pf_cids - number of connections used by this PF
44 * @param num_vf_cids - number of connections used by VFs of this PF
45 * @param num_tids - number of tasks used by this PF
46 * @param num_pf_pqs - number of PQs used by this PF
47 * @param num_vf_pqs - number of PQs used by VFs of this PF
49 * @return The required host memory size in 4KB units.
51 u32 ecore_qm_pf_mem_size(u32 num_pf_cids,
58 * @brief ecore_qm_common_rt_init - Prepare QM runtime init values for the
61 * @param p_hwfn - HW device data
62 * @param max_ports_per_engine - max number of ports per engine in HW
63 * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
64 * @param pf_rl_en - enable per-PF rate limiters
65 * @param pf_wfq_en - enable per-PF WFQ
66 * @param vport_rl_en - enable per-VPORT rate limiters
67 * @param vport_wfq_en - enable per-VPORT WFQ
68 * @param port_params - array of size MAX_NUM_PORTS with parameters
71 * @return 0 on success, -1 on error.
73 int ecore_qm_common_rt_init(struct ecore_hwfn *p_hwfn,
74 u8 max_ports_per_engine,
75 u8 max_phys_tcs_per_port,
80 struct init_qm_port_params port_params[MAX_NUM_PORTS]);
83 * @brief ecore_qm_pf_rt_init - Prepare QM runtime init values for the PF phase
85 * @param p_hwfn - HW device data
86 * @param p_ptt - ptt window used for writing the registers
87 * @param port_id - port ID
88 * @param pf_id - PF ID
89 * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
90 * @param is_pf_loading - indicates if the PF is currently loading,
91 * i.e. it has no allocated QM resources.
92 * @param num_pf_cids - number of connections used by this PF
93 * @param num_vf_cids - number of connections used by VFs of this PF
94 * @param num_tids - number of tasks used by this PF
95 * @param start_pq - first Tx PQ ID associated with this PF
96 * @param num_pf_pqs - number of Tx PQs associated with this PF
98 * @param num_vf_pqs - number of Tx PQs associated with a VF
99 * @param start_vport - first VPORT ID associated with this PF
100 * @param num_vports - number of VPORTs associated with this PF
101 * @param pf_wfq - WFQ weight. if PF WFQ is globally disabled,
102 * the weight must be 0. otherwise, the weight
104 * @param pf_rl - rate limit in Mb/sec units. a value of 0
105 * means don't configure. ignored if PF RL is
107 * @param link_speed - link speed in Mbps.
108 * @param pq_params - array of size (num_pf_pqs + num_vf_pqs) with
109 * parameters for each Tx PQ associated with the
111 * @param vport_params - array of size num_vports with parameters for
112 * each associated VPORT.
114 * @return 0 on success, -1 on error.
116 int ecore_qm_pf_rt_init(struct ecore_hwfn *p_hwfn,
117 struct ecore_ptt *p_ptt,
120 u8 max_phys_tcs_per_port,
133 struct init_qm_pq_params *pq_params,
134 struct init_qm_vport_params *vport_params);
137 * @brief ecore_init_pf_wfq - Initializes the WFQ weight of the specified PF
139 * @param p_hwfn - HW device data
140 * @param p_ptt - ptt window used for writing the registers
141 * @param pf_id - PF ID
142 * @param pf_wfq - WFQ weight. Must be non-zero.
144 * @return 0 on success, -1 on error.
146 int ecore_init_pf_wfq(struct ecore_hwfn *p_hwfn,
147 struct ecore_ptt *p_ptt,
152 * @brief ecore_init_pf_rl - Initializes the rate limit of the specified PF
155 * @param p_ptt - ptt window used for writing the registers
156 * @param pf_id - PF ID
157 * @param pf_rl - rate limit in Mb/sec units
159 * @return 0 on success, -1 on error.
161 int ecore_init_pf_rl(struct ecore_hwfn *p_hwfn,
162 struct ecore_ptt *p_ptt,
167 * @brief ecore_init_vport_wfq - Initializes the WFQ weight of the specified VPORT
169 * @param p_hwfn - HW device data
170 * @param p_ptt - ptt window used for writing the registers
171 * @param first_tx_pq_id - An array containing the first Tx PQ ID associated
172 * with the VPORT for each TC. This array is filled by
173 * ecore_qm_pf_rt_init
174 * @param vport_wfq - WFQ weight. Must be non-zero.
176 * @return 0 on success, -1 on error.
178 int ecore_init_vport_wfq(struct ecore_hwfn *p_hwfn,
179 struct ecore_ptt *p_ptt,
180 u16 first_tx_pq_id[NUM_OF_TCS],
184 * @brief ecore_init_vport_rl - Initializes the rate limit of the specified
187 * @param p_hwfn - HW device data
188 * @param p_ptt - ptt window used for writing the registers
189 * @param vport_id - VPORT ID
190 * @param vport_rl - rate limit in Mb/sec units
191 * @param link_speed - link speed in Mbps.
193 * @return 0 on success, -1 on error.
195 int ecore_init_vport_rl(struct ecore_hwfn *p_hwfn,
196 struct ecore_ptt *p_ptt,
202 * @brief ecore_send_qm_stop_cmd - Sends a stop command to the QM
204 * @param p_hwfn - HW device data
205 * @param p_ptt - ptt window used for writing the registers
206 * @param is_release_cmd - true for release, false for stop.
207 * @param is_tx_pq - true for Tx PQs, false for Other PQs.
208 * @param start_pq - first PQ ID to stop
209 * @param num_pqs - Number of PQs to stop, starting from start_pq.
211 * @return bool, true if successful, false if timeout occured while waiting for
214 bool ecore_send_qm_stop_cmd(struct ecore_hwfn *p_hwfn,
215 struct ecore_ptt *p_ptt,
221 #ifndef UNUSED_HSI_FUNC
224 * @brief ecore_init_nig_ets - Initializes the NIG ETS arbiter
226 * Based on weight/priority requirements per-TC.
228 * @param p_hwfn - HW device data
229 * @param p_ptt - ptt window used for writing the registers.
230 * @param req - the NIG ETS initialization requirements.
231 * @param is_lb - if set, the loopback port arbiter is initialized, otherwise
232 * the physical port arbiter is initialized. The pure-LB TC
233 * requirements are ignored when is_lb is cleared.
235 void ecore_init_nig_ets(struct ecore_hwfn *p_hwfn,
236 struct ecore_ptt *p_ptt,
237 struct init_ets_req* req,
241 * @brief ecore_init_nig_lb_rl - Initializes the NIG LB RLs
243 * Based on global and per-TC rate requirements
245 * @param p_hwfn - HW device data
246 * @param p_ptt - ptt window used for writing the registers.
247 * @param req - the NIG LB RLs initialization requirements.
249 void ecore_init_nig_lb_rl(struct ecore_hwfn *p_hwfn,
250 struct ecore_ptt *p_ptt,
251 struct init_nig_lb_rl_req* req);
253 #endif /* UNUSED_HSI_FUNC */
256 * @brief ecore_init_nig_pri_tc_map - Initializes the NIG priority to TC map.
258 * Assumes valid arguments.
260 * @param p_hwfn - HW device data
261 * @param p_ptt - ptt window used for writing the registers.
262 * @param req - required mapping from prioirties to TCs.
264 void ecore_init_nig_pri_tc_map(struct ecore_hwfn *p_hwfn,
265 struct ecore_ptt *p_ptt,
266 struct init_nig_pri_tc_map_req* req);
268 #ifndef UNUSED_HSI_FUNC
271 * @brief ecore_init_prs_ets - Initializes the PRS Rx ETS arbiter
273 * Based on weight/priority requirements per-TC.
275 * @param p_hwfn - HW device data
276 * @param p_ptt - ptt window used for writing the registers.
277 * @param req - the PRS ETS initialization requirements.
279 void ecore_init_prs_ets(struct ecore_hwfn *p_hwfn,
280 struct ecore_ptt *p_ptt,
281 struct init_ets_req* req);
283 #endif /* UNUSED_HSI_FUNC */
284 #ifndef UNUSED_HSI_FUNC
287 * @brief ecore_init_brb_ram - Initializes BRB RAM sizes per TC.
289 * Based on weight/priority requirements per-TC.
291 * @param p_hwfn - HW device data
292 * @param p_ptt - ptt window used for writing the registers.
293 * @param req - the BRB RAM initialization requirements.
295 void ecore_init_brb_ram(struct ecore_hwfn *p_hwfn,
296 struct ecore_ptt *p_ptt,
297 struct init_brb_ram_req* req);
299 #endif /* UNUSED_HSI_FUNC */
300 #ifndef UNUSED_HSI_FUNC
303 * @brief ecore_set_port_mf_ovlan_eth_type - initializes DORQ ethType Regs to
304 * input ethType. should Be called once per port.
306 * @param p_hwfn - HW device data
307 * @param ethType - etherType to configure
309 void ecore_set_port_mf_ovlan_eth_type(struct ecore_hwfn *p_hwfn,
312 #endif /* UNUSED_HSI_FUNC */
315 * @brief ecore_set_vxlan_dest_port - Initializes vxlan tunnel destination udp
318 * @param p_hwfn - HW device data
319 * @param p_ptt - ptt window used for writing the registers.
320 * @param dest_port - vxlan destination udp port.
322 void ecore_set_vxlan_dest_port(struct ecore_hwfn *p_hwfn,
323 struct ecore_ptt *p_ptt,
327 * @brief ecore_set_vxlan_enable - Enable or disable VXLAN tunnel in HW
329 * @param p_hwfn - HW device data
330 * @param p_ptt - ptt window used for writing the registers.
331 * @param vxlan_enable - vxlan enable flag.
333 void ecore_set_vxlan_enable(struct ecore_hwfn *p_hwfn,
334 struct ecore_ptt *p_ptt,
338 * @brief ecore_set_gre_enable - Enable or disable GRE tunnel in HW
340 * @param p_hwfn - HW device data
341 * @param p_ptt - ptt window used for writing the registers.
342 * @param eth_gre_enable - eth GRE enable enable flag.
343 * @param ip_gre_enable - IP GRE enable enable flag.
345 void ecore_set_gre_enable(struct ecore_hwfn *p_hwfn,
346 struct ecore_ptt *p_ptt,
351 * @brief ecore_set_geneve_dest_port - Initializes geneve tunnel destination
354 * @param p_hwfn - HW device data
355 * @param p_ptt - ptt window used for writing the registers.
356 * @param dest_port - geneve destination udp port.
358 void ecore_set_geneve_dest_port(struct ecore_hwfn *p_hwfn,
359 struct ecore_ptt *p_ptt,
363 * @brief ecore_set_geneve_enable - Enable or disable GRE tunnel in HW
365 * @param p_hwfn - HW device data
366 * @param p_ptt - ptt window used for writing the registers.
367 * @param eth_geneve_enable - eth GENEVE enable enable flag.
368 * @param ip_geneve_enable - IP GENEVE enable enable flag.
370 void ecore_set_geneve_enable(struct ecore_hwfn *p_hwfn,
371 struct ecore_ptt *p_ptt,
372 bool eth_geneve_enable,
373 bool ip_geneve_enable);
376 * @brief ecore_set_vxlan_no_l2_enable - enable or disable VXLAN no L2 parsing
378 * @param p_ptt - ptt window used for writing the registers.
379 * @param enable - VXLAN no L2 enable flag.
381 void ecore_set_vxlan_no_l2_enable(struct ecore_hwfn *p_hwfn,
382 struct ecore_ptt *p_ptt,
385 #ifndef UNUSED_HSI_FUNC
388 * @brief ecore_set_gft_event_id_cm_hdr - Configure GFT event id and cm header
390 * @param p_hwfn - HW device data
391 * @param p_ptt - ptt window used for writing the registers.
393 void ecore_set_gft_event_id_cm_hdr(struct ecore_hwfn *p_hwfn,
394 struct ecore_ptt *p_ptt);
397 * @brief ecore_gft_disable - Disable and GFT
399 * @param p_hwfn - HW device data
400 * @param p_ptt - ptt window used for writing the registers.
401 * @param pf_id - pf on which to disable GFT.
403 void ecore_gft_disable(struct ecore_hwfn *p_hwfn,
404 struct ecore_ptt *p_ptt,
408 * @brief ecore_gft_config - Enable and configure HW for GFT
410 * @param p_hwfn - HW device data
411 * @param p_ptt - ptt window used for writing the registers.
412 * @param pf_id - pf on which to enable GFT.
413 * @param tcp - set profile tcp packets.
414 * @param udp - set profile udp packet.
415 * @param ipv4 - set profile ipv4 packet.
416 * @param ipv6 - set profile ipv6 packet.
417 * @param profile_type - define packet same fields. Use enum gft_profile_type.
419 void ecore_gft_config(struct ecore_hwfn *p_hwfn,
420 struct ecore_ptt *p_ptt,
426 enum gft_profile_type profile_type);
428 #endif /* UNUSED_HSI_FUNC */
431 * @brief ecore_config_vf_zone_size_mode - Configure VF zone size mode. Must be
432 * used before first ETH queue started.
434 * @param p_hwfn - HW device data
435 * @param p_ptt - ptt window used for writing the registers. Don't care
436 * if runtime_init used.
437 * @param mode - VF zone size mode. Use enum vf_zone_size_mode.
438 * @param runtime_init - Set 1 to init runtime registers in engine phase.
439 * Set 0 if VF zone size mode configured after engine
442 void ecore_config_vf_zone_size_mode(struct ecore_hwfn *p_hwfn,
443 struct ecore_ptt *p_ptt,
448 * @brief ecore_get_mstorm_queue_stat_offset - Get mstorm statistics offset by
451 * @param p_hwfn - HW device data
452 * @param stat_cnt_id - statistic counter id
453 * @param vf_zone_size_mode - VF zone size mode. Use enum vf_zone_size_mode.
455 u32 ecore_get_mstorm_queue_stat_offset(struct ecore_hwfn *p_hwfn,
457 u16 vf_zone_size_mode);
460 * @brief ecore_get_mstorm_eth_vf_prods_offset - VF producer offset by VF zone
463 * @param p_hwfn - HW device data
464 * @param vf_id - vf id.
465 * @param vf_queue_id - per VF rx queue id.
466 * @param vf_zone_size_mode - vf zone size mode. Use enum vf_zone_size_mode.
468 u32 ecore_get_mstorm_eth_vf_prods_offset(struct ecore_hwfn *p_hwfn,
471 u16 vf_zone_size_mode);
474 * @brief ecore_enable_context_validation - Enable and configure context
477 * @param p_hwfn - HW device data
478 * @param p_ptt - ptt window used for writing the registers.
480 void ecore_enable_context_validation(struct ecore_hwfn *p_hwfn,
481 struct ecore_ptt *p_ptt);
484 * @brief ecore_calc_session_ctx_validation - Calcualte validation byte for
487 * @param p_ctx_mem - pointer to context memory.
488 * @param ctx_size - context size.
489 * @param ctx_type - context type.
490 * @param cid - context cid.
492 void ecore_calc_session_ctx_validation(void *p_ctx_mem,
498 * @brief ecore_calc_task_ctx_validation - Calcualte validation byte for task
501 * @param p_ctx_mem - pointer to context memory.
502 * @param ctx_size - context size.
503 * @param ctx_type - context type.
504 * @param tid - context tid.
506 void ecore_calc_task_ctx_validation(void *p_ctx_mem,
512 * @brief ecore_memset_session_ctx - Memset session context to 0 while
513 * preserving validation bytes.
515 * @param p_hwfn - HW device data
516 * @param p_ctx_mem - pointer to context memory.
517 * @param ctx_size - size to initialzie.
518 * @param ctx_type - context type.
520 void ecore_memset_session_ctx(void *p_ctx_mem,
525 * @brief ecore_memset_task_ctx - Memset task context to 0 while preserving
528 * @param p_ctx_mem - pointer to context memory.
529 * @param ctx_size - size to initialzie.
530 * @param ctx_type - context type.
532 void ecore_memset_task_ctx(void *p_ctx_mem,
537 * @brief ecore_update_eth_rss_ind_table_entry - Update RSS indirection table entry.
538 * The function must run in exclusive mode to prevent wrong RSS configuration.
540 * @param p_hwfn - HW device data
541 * @param p_ptt - ptt window used for writing the registers.
542 * @param rss_id - RSS engine ID.
543 * @param ind_table_index - RSS indirect table index.
544 * @param ind_table_value - RSS indirect table new value.
546 void ecore_update_eth_rss_ind_table_entry(struct ecore_hwfn * p_hwfn,
547 struct ecore_ptt *p_ptt,
550 u16 ind_table_value);