4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1, (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1, (the "License").
27 * You may not use this file except in compliance with the License.
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
36 #ifndef _INIT_FW_FUNCS_H
37 #define _INIT_FW_FUNCS_H
38 /* Forward declarations */
40 struct init_qm_pq_params
;
43 * @brief ecore_qm_pf_mem_size - Prepare QM ILT sizes
45 * Returns the required host memory size in 4KB units.
46 * Must be called before all QM init HSI functions.
48 * @param pf_id - physical function ID
49 * @param num_pf_cids - number of connections used by this PF
50 * @param num_vf_cids - number of connections used by VFs of this PF
51 * @param num_tids - number of tasks used by this PF
52 * @param num_pf_pqs - number of PQs used by this PF
53 * @param num_vf_pqs - number of PQs used by VFs of this PF
55 * @return The required host memory size in 4KB units.
57 u32
ecore_qm_pf_mem_size(u8 pf_id
,
65 * @brief ecore_qm_common_rt_init - Prepare QM runtime init values for the
68 * @param p_hwfn - HW device data
69 * @param max_ports_per_engine - max number of ports per engine in HW
70 * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
71 * @param pf_rl_en - enable per-PF rate limiters
72 * @param pf_wfq_en - enable per-PF WFQ
73 * @param vport_rl_en - enable per-VPORT rate limiters
74 * @param vport_wfq_en - enable per-VPORT WFQ
75 * @param port_params - array of size MAX_NUM_PORTS with parameters
78 * @return 0 on success, -1 on error.
80 int ecore_qm_common_rt_init(struct ecore_hwfn
*p_hwfn
,
81 u8 max_ports_per_engine
,
82 u8 max_phys_tcs_per_port
,
87 struct init_qm_port_params port_params
[MAX_NUM_PORTS
]);
90 * @brief ecore_qm_pf_rt_init - Prepare QM runtime init values for the PF phase
92 * @param p_hwfn - HW device data
93 * @param p_ptt - ptt window used for writing the registers
94 * @param port_id - port ID
95 * @param pf_id - PF ID
96 * @param max_phys_tcs_per_port - max number of physical TCs per port in HW
97 * @param is_first_pf - 1 = first PF in engine, 0 = othwerwise
98 * @param num_pf_cids - number of connections used by this PF
99 * @param num_vf_cids - number of connections used by VFs of this PF
100 * @param num_tids - number of tasks used by this PF
101 * @param start_pq - first Tx PQ ID associated with this PF
102 * @param num_pf_pqs - number of Tx PQs associated with this PF
104 * @param num_vf_pqs - number of Tx PQs associated with a VF
105 * @param start_vport - first VPORT ID associated with this PF
106 * @param num_vports - number of VPORTs associated with this PF
107 * @param pf_wfq - WFQ weight. if PF WFQ is globally disabled,
108 * the weight must be 0. otherwise, the weight
110 * @param pf_rl - rate limit in Mb/sec units. a value of 0
111 * means don't configure. ignored if PF RL is
113 * @param pq_params - array of size (num_pf_pqs + num_vf_pqs) with
114 * parameters for each Tx PQ associated with the
116 * @param vport_params - array of size num_vports with parameters for
117 * each associated VPORT.
119 * @return 0 on success, -1 on error.
121 int ecore_qm_pf_rt_init(struct ecore_hwfn
*p_hwfn
,
122 struct ecore_ptt
*p_ptt
,
125 u8 max_phys_tcs_per_port
,
137 struct init_qm_pq_params
*pq_params
,
138 struct init_qm_vport_params
*vport_params
);
141 * @brief ecore_init_pf_wfq - Initializes the WFQ weight of the specified PF
143 * @param p_hwfn - HW device data
144 * @param p_ptt - ptt window used for writing the registers
145 * @param pf_id - PF ID
146 * @param pf_wfq - WFQ weight. Must be non-zero.
148 * @return 0 on success, -1 on error.
150 int ecore_init_pf_wfq(struct ecore_hwfn
*p_hwfn
,
151 struct ecore_ptt
*p_ptt
,
156 * @brief ecore_init_pf_rl - Initializes the rate limit of the specified PF
159 * @param p_ptt - ptt window used for writing the registers
160 * @param pf_id - PF ID
161 * @param pf_rl - rate limit in Mb/sec units
163 * @return 0 on success, -1 on error.
165 int ecore_init_pf_rl(struct ecore_hwfn
*p_hwfn
,
166 struct ecore_ptt
*p_ptt
,
171 * @brief ecore_init_vport_wfq - Initializes the WFQ weight of the specified VPORT
173 * @param p_hwfn - HW device data
174 * @param p_ptt - ptt window used for writing the registers
175 * @param first_tx_pq_id - An array containing the first Tx PQ ID associated
176 * with the VPORT for each TC. This array is filled by
177 * ecore_qm_pf_rt_init
178 * @param vport_wfq - WFQ weight. Must be non-zero.
180 * @return 0 on success, -1 on error.
182 int ecore_init_vport_wfq(struct ecore_hwfn
*p_hwfn
,
183 struct ecore_ptt
*p_ptt
,
184 u16 first_tx_pq_id
[NUM_OF_TCS
],
188 * @brief ecore_init_vport_rl - Initializes the rate limit of the specified
191 * @param p_hwfn - HW device data
192 * @param p_ptt - ptt window used for writing the registers
193 * @param vport_id - VPORT ID
194 * @param vport_rl - rate limit in Mb/sec units
196 * @return 0 on success, -1 on error.
198 int ecore_init_vport_rl(struct ecore_hwfn
*p_hwfn
,
199 struct ecore_ptt
*p_ptt
,
204 * @brief ecore_send_qm_stop_cmd - Sends a stop command to the QM
206 * @param p_hwfn - HW device data
207 * @param p_ptt - ptt window used for writing the registers
208 * @param is_release_cmd - true for release, false for stop.
209 * @param is_tx_pq - true for Tx PQs, false for Other PQs.
210 * @param start_pq - first PQ ID to stop
211 * @param num_pqs - Number of PQs to stop, starting from start_pq.
213 * @return bool, true if successful, false if timeout occured while waiting for
216 bool ecore_send_qm_stop_cmd(struct ecore_hwfn
*p_hwfn
,
217 struct ecore_ptt
*p_ptt
,
223 #ifndef UNUSED_HSI_FUNC
226 * @brief ecore_init_nig_ets - Initializes the NIG ETS arbiter
228 * Based on weight/priority requirements per-TC.
230 * @param p_hwfn - HW device data
231 * @param p_ptt - ptt window used for writing the registers.
232 * @param req - the NIG ETS initialization requirements.
233 * @param is_lb - if set, the loopback port arbiter is initialized, otherwise
234 * the physical port arbiter is initialized. The pure-LB TC
235 * requirements are ignored when is_lb is cleared.
237 void ecore_init_nig_ets(struct ecore_hwfn
*p_hwfn
,
238 struct ecore_ptt
*p_ptt
,
239 struct init_ets_req
* req
,
243 * @brief ecore_init_nig_lb_rl - Initializes the NIG LB RLs
245 * Based on global and per-TC rate requirements
247 * @param p_hwfn - HW device data
248 * @param p_ptt - ptt window used for writing the registers.
249 * @param req - the NIG LB RLs initialization requirements.
251 void ecore_init_nig_lb_rl(struct ecore_hwfn
*p_hwfn
,
252 struct ecore_ptt
*p_ptt
,
253 struct init_nig_lb_rl_req
* req
);
255 #endif /* UNUSED_HSI_FUNC */
258 * @brief ecore_init_nig_pri_tc_map - Initializes the NIG priority to TC map.
260 * Assumes valid arguments.
262 * @param p_hwfn - HW device data
263 * @param p_ptt - ptt window used for writing the registers.
264 * @param req - required mapping from prioirties to TCs.
266 void ecore_init_nig_pri_tc_map(struct ecore_hwfn
*p_hwfn
,
267 struct ecore_ptt
*p_ptt
,
268 struct init_nig_pri_tc_map_req
* req
);
270 #ifndef UNUSED_HSI_FUNC
273 * @brief ecore_init_prs_ets - Initializes the PRS Rx ETS arbiter
275 * Based on weight/priority requirements per-TC.
277 * @param p_hwfn - HW device data
278 * @param p_ptt - ptt window used for writing the registers.
279 * @param req - the PRS ETS initialization requirements.
281 void ecore_init_prs_ets(struct ecore_hwfn
*p_hwfn
,
282 struct ecore_ptt
*p_ptt
,
283 struct init_ets_req
* req
);
285 #endif /* UNUSED_HSI_FUNC */
286 #ifndef UNUSED_HSI_FUNC
289 * @brief ecore_init_brb_ram - Initializes BRB RAM sizes per TC.
291 * Based on weight/priority requirements per-TC.
293 * @param p_hwfn - HW device data
294 * @param p_ptt - ptt window used for writing the registers.
295 * @param req - the BRB RAM initialization requirements.
297 void ecore_init_brb_ram(struct ecore_hwfn
*p_hwfn
,
298 struct ecore_ptt
*p_ptt
,
299 struct init_brb_ram_req
* req
);
301 #endif /* UNUSED_HSI_FUNC */
302 #ifndef UNUSED_HSI_FUNC
305 * @brief ecore_set_engine_mf_ovlan_eth_type - Initializes Nig,Prs,Pbf and llh
306 * ethType Regs to input ethType. Should Be called once per engine if engine
309 * @param p_hwfn - HW device data
310 * @param p_ptt - ptt window used for writing the registers.
311 * @param ethType - etherType to configure
313 void ecore_set_engine_mf_ovlan_eth_type(struct ecore_hwfn
*p_hwfn
,
314 struct ecore_ptt
*p_ptt
,
318 * @brief ecore_set_port_mf_ovlan_eth_type - initializes DORQ ethType Regs to
319 * input ethType. should Be called once per port.
321 * @param p_hwfn - HW device data
322 * @param p_ptt - ptt window used for writing the registers.
323 * @param ethType - etherType to configure
325 void ecore_set_port_mf_ovlan_eth_type(struct ecore_hwfn
*p_hwfn
,
326 struct ecore_ptt
*p_ptt
,
329 #endif /* UNUSED_HSI_FUNC */
332 * @brief ecore_set_vxlan_dest_port - Initializes vxlan tunnel destination udp
335 * @param p_hwfn - HW device data
336 * @param p_ptt - ptt window used for writing the registers.
337 * @param dest_port - vxlan destination udp port.
339 void ecore_set_vxlan_dest_port(struct ecore_hwfn
*p_hwfn
,
340 struct ecore_ptt
*p_ptt
,
344 * @brief ecore_set_vxlan_enable - Enable or disable VXLAN tunnel in HW
346 * @param p_hwfn - HW device data
347 * @param p_ptt - ptt window used for writing the registers.
348 * @param vxlan_enable - vxlan enable flag.
350 void ecore_set_vxlan_enable(struct ecore_hwfn
*p_hwfn
,
351 struct ecore_ptt
*p_ptt
,
355 * @brief ecore_set_gre_enable - Enable or disable GRE tunnel in HW
357 * @param p_hwfn - HW device data
358 * @param p_ptt - ptt window used for writing the registers.
359 * @param eth_gre_enable - eth GRE enable enable flag.
360 * @param ip_gre_enable - IP GRE enable enable flag.
362 void ecore_set_gre_enable(struct ecore_hwfn
*p_hwfn
,
363 struct ecore_ptt
*p_ptt
,
368 * @brief ecore_set_geneve_dest_port - Initializes geneve tunnel destination
371 * @param p_hwfn - HW device data
372 * @param p_ptt - ptt window used for writing the registers.
373 * @param dest_port - geneve destination udp port.
375 void ecore_set_geneve_dest_port(struct ecore_hwfn
*p_hwfn
,
376 struct ecore_ptt
*p_ptt
,
380 * @brief ecore_set_geneve_enable - Enable or disable GRE tunnel in HW
382 * @param p_hwfn - HW device data
383 * @param p_ptt - ptt window used for writing the registers.
384 * @param eth_geneve_enable - eth GENEVE enable enable flag.
385 * @param ip_geneve_enable - IP GENEVE enable enable flag.
387 void ecore_set_geneve_enable(struct ecore_hwfn
*p_hwfn
,
388 struct ecore_ptt
*p_ptt
,
389 bool eth_geneve_enable
,
390 bool ip_geneve_enable
);
392 #ifndef UNUSED_HSI_FUNC
395 * @brief ecore_set_gft_event_id_cm_hdr - Configure GFT event id and cm header
397 * @param p_hwfn - HW device data
398 * @param p_ptt - ptt window used for writing the registers.
400 void ecore_set_gft_event_id_cm_hdr(struct ecore_hwfn
*p_hwfn
,
401 struct ecore_ptt
*p_ptt
);
404 * @brief ecore_set_rfs_mode_disable - Disable and configure HW for RFS
406 * @param p_hwfn - HW device data
407 * @param p_ptt - ptt window used for writing the registers.
408 * @param pf_id - pf on which to disable RFS.
410 void ecore_set_rfs_mode_disable(struct ecore_hwfn
*p_hwfn
,
411 struct ecore_ptt
*p_ptt
,
415 * @brief ecore_set_rfs_mode_enable - Enable and configure HW for RFS
417 * @param p_hwfn - HW device data
418 * @param p_ptt - ptt window used for writing the registers.
419 * @param pf_id - pf on which to enable RFS.
420 * @param tcp - set profile tcp packets.
421 * @param udp - set profile udp packet.
422 * @param ipv4 - set profile ipv4 packet.
423 * @param ipv6 - set profile ipv6 packet.
425 void ecore_set_rfs_mode_enable(struct ecore_hwfn
*p_hwfn
,
426 struct ecore_ptt
*p_ptt
,
433 #endif /* UNUSED_HSI_FUNC */
436 * @brief ecore_config_vf_zone_size_mode - Configure VF zone size mode. Must be
437 * used before first ETH queue started.
439 * @param p_hwfn - HW device data
440 * @param p_ptt - ptt window used for writing the registers. Don't care
441 * if runtime_init used.
442 * @param mode - VF zone size mode. Use enum vf_zone_size_mode.
443 * @param runtime_init - Set 1 to init runtime registers in engine phase.
444 * Set 0 if VF zone size mode configured after engine
447 void ecore_config_vf_zone_size_mode(struct ecore_hwfn
*p_hwfn
,
448 struct ecore_ptt
*p_ptt
,
453 * @brief ecore_get_mstorm_queue_stat_offset - Get mstorm statistics offset by
456 * @param p_hwfn - HW device data
457 * @param stat_cnt_id - statistic counter id
458 * @param vf_zone_size_mode - VF zone size mode. Use enum vf_zone_size_mode.
460 u32
ecore_get_mstorm_queue_stat_offset(struct ecore_hwfn
*p_hwfn
,
462 u16 vf_zone_size_mode
);
465 * @brief ecore_get_mstorm_eth_vf_prods_offset - VF producer offset by VF zone
468 * @param p_hwfn - HW device data
469 * @param vf_id - vf id.
470 * @param vf_queue_id - per VF rx queue id.
471 * @param vf_zone_size_mode - vf zone size mode. Use enum vf_zone_size_mode.
473 u32
ecore_get_mstorm_eth_vf_prods_offset(struct ecore_hwfn
*p_hwfn
,
476 u16 vf_zone_size_mode
);
479 * @brief ecore_enable_context_validation - Enable and configure context
482 * @param p_hwfn - HW device data
483 * @param p_ptt - ptt window used for writing the registers.
485 void ecore_enable_context_validation(struct ecore_hwfn
*p_hwfn
,
486 struct ecore_ptt
*p_ptt
);
489 * @brief ecore_calc_session_ctx_validation - Calcualte validation byte for
492 * @param p_ctx_mem - pointer to context memory.
493 * @param ctx_size - context size.
494 * @param ctx_type - context type.
495 * @param cid - context cid.
497 void ecore_calc_session_ctx_validation(struct ecore_hwfn
* p_hwfn
,
504 * @brief ecore_calc_task_ctx_validation - Calcualte validation byte for task
507 * @param p_hwfn - HW device data
508 * @param p_ctx_mem - pointer to context memory.
509 * @param ctx_size - context size.
510 * @param ctx_type - context type.
511 * @param tid - context tid.
513 void ecore_calc_task_ctx_validation(struct ecore_hwfn
* p_hwfn
,
520 * @brief ecore_memset_session_ctx - Memset session context to 0 while
521 * preserving validation bytes.
523 * @param p_hwfn - HW device data
524 * @param p_ctx_mem - pointer to context memory.
525 * @param ctx_size - size to initialzie.
526 * @param ctx_type - context type.
528 void ecore_memset_session_ctx(void *p_ctx_mem
,
533 * @brief ecore_memset_task_ctx - Memset task context to 0 while preserving
536 * @param p_ctx_mem - pointer to context memory.
537 * @param ctx_size - size to initialzie.
538 * @param ctx_type - context type.
540 void ecore_memset_task_ctx(void *p_ctx_mem
,