]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/drivers/net/qede/base/ecore_dev_api.h
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / dpdk / drivers / net / qede / base / ecore_dev_api.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 __ECORE_DEV_API_H__
10 #define __ECORE_DEV_API_H__
11
12 #include "ecore_status.h"
13 #include "ecore_chain.h"
14 #include "ecore_int_api.h"
15
16 /**
17 * @brief ecore_init_dp - initialize the debug level
18 *
19 * @param p_dev
20 * @param dp_module
21 * @param dp_level
22 * @param dp_ctx
23 */
24 void ecore_init_dp(struct ecore_dev *p_dev,
25 u32 dp_module,
26 u8 dp_level,
27 void *dp_ctx);
28
29 /**
30 * @brief ecore_init_struct - initialize the device structure to
31 * its defaults
32 *
33 * @param p_dev
34 */
35 void ecore_init_struct(struct ecore_dev *p_dev);
36
37 /**
38 * @brief ecore_resc_free -
39 *
40 * @param p_dev
41 */
42 void ecore_resc_free(struct ecore_dev *p_dev);
43
44 /**
45 * @brief ecore_resc_alloc -
46 *
47 * @param p_dev
48 *
49 * @return enum _ecore_status_t
50 */
51 enum _ecore_status_t ecore_resc_alloc(struct ecore_dev *p_dev);
52
53 /**
54 * @brief ecore_resc_setup -
55 *
56 * @param p_dev
57 */
58 void ecore_resc_setup(struct ecore_dev *p_dev);
59
60 struct ecore_hw_init_params {
61 /* tunnelling parameters */
62 struct ecore_tunn_start_params *p_tunn;
63 bool b_hw_start;
64 /* interrupt mode [msix, inta, etc.] to use */
65 enum ecore_int_mode int_mode;
66 /* npar tx switching to be used for vports configured for tx-switching */
67
68 bool allow_npar_tx_switch;
69 /* binary fw data pointer in binary fw file */
70 const u8 *bin_fw_data;
71 /* the OS Epoch time in seconds */
72 u32 epoch;
73 };
74
75 /**
76 * @brief ecore_hw_init -
77 *
78 * @param p_dev
79 * @param p_params
80 *
81 * @return enum _ecore_status_t
82 */
83 enum _ecore_status_t ecore_hw_init(struct ecore_dev *p_dev,
84 struct ecore_hw_init_params *p_params);
85
86 /**
87 * @brief ecore_hw_timers_stop_all -
88 *
89 * @param p_dev
90 *
91 * @return void
92 */
93 void ecore_hw_timers_stop_all(struct ecore_dev *p_dev);
94
95 /**
96 * @brief ecore_hw_stop -
97 *
98 * @param p_dev
99 *
100 * @return enum _ecore_status_t
101 */
102 enum _ecore_status_t ecore_hw_stop(struct ecore_dev *p_dev);
103
104 /**
105 * @brief ecore_hw_stop_fastpath -should be called incase
106 * slowpath is still required for the device,
107 * but fastpath is not.
108 *
109 * @param p_dev
110 *
111 */
112 void ecore_hw_stop_fastpath(struct ecore_dev *p_dev);
113
114 #ifndef LINUX_REMOVE
115 /**
116 * @brief ecore_prepare_hibernate -should be called when
117 * the system is going into the hibernate state
118 *
119 * @param p_dev
120 *
121 */
122 void ecore_prepare_hibernate(struct ecore_dev *p_dev);
123 #endif
124
125 /**
126 * @brief ecore_hw_start_fastpath -restart fastpath traffic,
127 * only if hw_stop_fastpath was called
128
129 * @param p_dev
130 *
131 */
132 void ecore_hw_start_fastpath(struct ecore_hwfn *p_hwfn);
133
134 /**
135 * @brief ecore_hw_reset -
136 *
137 * @param p_dev
138 *
139 * @return enum _ecore_status_t
140 */
141 enum _ecore_status_t ecore_hw_reset(struct ecore_dev *p_dev);
142
143 struct ecore_hw_prepare_params {
144 /* personality to initialize */
145 int personality;
146 /* force the driver's default resource allocation */
147 bool drv_resc_alloc;
148 /* check the reg_fifo after any register access */
149 bool chk_reg_fifo;
150 };
151
152 /**
153 * @brief ecore_hw_prepare -
154 *
155 * @param p_dev
156 * @param p_params
157 *
158 * @return enum _ecore_status_t
159 */
160 enum _ecore_status_t ecore_hw_prepare(struct ecore_dev *p_dev,
161 struct ecore_hw_prepare_params *p_params);
162
163 /**
164 * @brief ecore_hw_remove -
165 *
166 * @param p_dev
167 */
168 void ecore_hw_remove(struct ecore_dev *p_dev);
169
170 /**
171 * @brief ecore_ptt_acquire - Allocate a PTT window
172 *
173 * Should be called at the entry point to the driver (at the beginning of an
174 * exported function)
175 *
176 * @param p_hwfn
177 *
178 * @return struct ecore_ptt
179 */
180 struct ecore_ptt *ecore_ptt_acquire(struct ecore_hwfn *p_hwfn);
181
182 /**
183 * @brief ecore_ptt_release - Release PTT Window
184 *
185 * Should be called at the end of a flow - at the end of the function that
186 * acquired the PTT.
187 *
188 *
189 * @param p_hwfn
190 * @param p_ptt
191 */
192 void ecore_ptt_release(struct ecore_hwfn *p_hwfn,
193 struct ecore_ptt *p_ptt);
194
195 #ifndef __EXTRACT__LINUX__
196 struct ecore_eth_stats {
197 u64 no_buff_discards;
198 u64 packet_too_big_discard;
199 u64 ttl0_discard;
200 u64 rx_ucast_bytes;
201 u64 rx_mcast_bytes;
202 u64 rx_bcast_bytes;
203 u64 rx_ucast_pkts;
204 u64 rx_mcast_pkts;
205 u64 rx_bcast_pkts;
206 u64 mftag_filter_discards;
207 u64 mac_filter_discards;
208 u64 tx_ucast_bytes;
209 u64 tx_mcast_bytes;
210 u64 tx_bcast_bytes;
211 u64 tx_ucast_pkts;
212 u64 tx_mcast_pkts;
213 u64 tx_bcast_pkts;
214 u64 tx_err_drop_pkts;
215 u64 tpa_coalesced_pkts;
216 u64 tpa_coalesced_events;
217 u64 tpa_aborts_num;
218 u64 tpa_not_coalesced_pkts;
219 u64 tpa_coalesced_bytes;
220
221 /* port */
222 u64 rx_64_byte_packets;
223 u64 rx_65_to_127_byte_packets;
224 u64 rx_128_to_255_byte_packets;
225 u64 rx_256_to_511_byte_packets;
226 u64 rx_512_to_1023_byte_packets;
227 u64 rx_1024_to_1518_byte_packets;
228 u64 rx_1519_to_1522_byte_packets;
229 u64 rx_1519_to_2047_byte_packets;
230 u64 rx_2048_to_4095_byte_packets;
231 u64 rx_4096_to_9216_byte_packets;
232 u64 rx_9217_to_16383_byte_packets;
233 u64 rx_crc_errors;
234 u64 rx_mac_crtl_frames;
235 u64 rx_pause_frames;
236 u64 rx_pfc_frames;
237 u64 rx_align_errors;
238 u64 rx_carrier_errors;
239 u64 rx_oversize_packets;
240 u64 rx_jabbers;
241 u64 rx_undersize_packets;
242 u64 rx_fragments;
243 u64 tx_64_byte_packets;
244 u64 tx_65_to_127_byte_packets;
245 u64 tx_128_to_255_byte_packets;
246 u64 tx_256_to_511_byte_packets;
247 u64 tx_512_to_1023_byte_packets;
248 u64 tx_1024_to_1518_byte_packets;
249 u64 tx_1519_to_2047_byte_packets;
250 u64 tx_2048_to_4095_byte_packets;
251 u64 tx_4096_to_9216_byte_packets;
252 u64 tx_9217_to_16383_byte_packets;
253 u64 tx_pause_frames;
254 u64 tx_pfc_frames;
255 u64 tx_lpi_entry_count;
256 u64 tx_total_collisions;
257 u64 brb_truncates;
258 u64 brb_discards;
259 u64 rx_mac_bytes;
260 u64 rx_mac_uc_packets;
261 u64 rx_mac_mc_packets;
262 u64 rx_mac_bc_packets;
263 u64 rx_mac_frames_ok;
264 u64 tx_mac_bytes;
265 u64 tx_mac_uc_packets;
266 u64 tx_mac_mc_packets;
267 u64 tx_mac_bc_packets;
268 u64 tx_mac_ctrl_frames;
269 };
270 #endif
271
272 enum ecore_dmae_address_type_t {
273 ECORE_DMAE_ADDRESS_HOST_VIRT,
274 ECORE_DMAE_ADDRESS_HOST_PHYS,
275 ECORE_DMAE_ADDRESS_GRC
276 };
277
278 /* value of flags If ECORE_DMAE_FLAG_RW_REPL_SRC flag is set and the
279 * source is a block of length DMAE_MAX_RW_SIZE and the
280 * destination is larger, the source block will be duplicated as
281 * many times as required to fill the destination block. This is
282 * used mostly to write a zeroed buffer to destination address
283 * using DMA
284 */
285 #define ECORE_DMAE_FLAG_RW_REPL_SRC 0x00000001
286 #define ECORE_DMAE_FLAG_VF_SRC 0x00000002
287 #define ECORE_DMAE_FLAG_VF_DST 0x00000004
288 #define ECORE_DMAE_FLAG_COMPLETION_DST 0x00000008
289
290 struct ecore_dmae_params {
291 u32 flags; /* consists of ECORE_DMAE_FLAG_* values */
292 u8 src_vfid;
293 u8 dst_vfid;
294 };
295
296 /**
297 * @brief ecore_dmae_host2grc - copy data from source addr to
298 * dmae registers using the given ptt
299 *
300 * @param p_hwfn
301 * @param p_ptt
302 * @param source_addr
303 * @param grc_addr (dmae_data_offset)
304 * @param size_in_dwords
305 * @param flags (one of the flags defined above)
306 */
307 enum _ecore_status_t
308 ecore_dmae_host2grc(struct ecore_hwfn *p_hwfn,
309 struct ecore_ptt *p_ptt,
310 u64 source_addr,
311 u32 grc_addr,
312 u32 size_in_dwords,
313 u32 flags);
314
315 /**
316 * @brief ecore_dmae_grc2host - Read data from dmae data offset
317 * to source address using the given ptt
318 *
319 * @param p_ptt
320 * @param grc_addr (dmae_data_offset)
321 * @param dest_addr
322 * @param size_in_dwords
323 * @param flags - one of the flags defined above
324 */
325 enum _ecore_status_t
326 ecore_dmae_grc2host(struct ecore_hwfn *p_hwfn,
327 struct ecore_ptt *p_ptt,
328 u32 grc_addr,
329 dma_addr_t dest_addr,
330 u32 size_in_dwords,
331 u32 flags);
332
333 /**
334 * @brief ecore_dmae_host2host - copy data from to source address
335 * to a destination address (for SRIOV) using the given ptt
336 *
337 * @param p_hwfn
338 * @param p_ptt
339 * @param source_addr
340 * @param dest_addr
341 * @param size_in_dwords
342 * @param params
343 */
344 enum _ecore_status_t
345 ecore_dmae_host2host(struct ecore_hwfn *p_hwfn,
346 struct ecore_ptt *p_ptt,
347 dma_addr_t source_addr,
348 dma_addr_t dest_addr,
349 u32 size_in_dwords,
350 struct ecore_dmae_params *p_params);
351
352 /**
353 * @brief ecore_chain_alloc - Allocate and initialize a chain
354 *
355 * @param p_hwfn
356 * @param intended_use
357 * @param mode
358 * @param num_elems
359 * @param elem_size
360 * @param p_chain
361 *
362 * @return enum _ecore_status_t
363 */
364 enum _ecore_status_t
365 ecore_chain_alloc(struct ecore_dev *p_dev,
366 enum ecore_chain_use_mode intended_use,
367 enum ecore_chain_mode mode,
368 enum ecore_chain_cnt_type cnt_type,
369 u32 num_elems,
370 osal_size_t elem_size,
371 struct ecore_chain *p_chain);
372
373 /**
374 * @brief ecore_chain_free - Free chain DMA memory
375 *
376 * @param p_hwfn
377 * @param p_chain
378 */
379 void ecore_chain_free(struct ecore_dev *p_dev,
380 struct ecore_chain *p_chain);
381
382 /**
383 * @@brief ecore_fw_l2_queue - Get absolute L2 queue ID
384 *
385 * @param p_hwfn
386 * @param src_id - relative to p_hwfn
387 * @param dst_id - absolute per engine
388 *
389 * @return enum _ecore_status_t
390 */
391 enum _ecore_status_t ecore_fw_l2_queue(struct ecore_hwfn *p_hwfn,
392 u16 src_id,
393 u16 *dst_id);
394
395 /**
396 * @@brief ecore_fw_vport - Get absolute vport ID
397 *
398 * @param p_hwfn
399 * @param src_id - relative to p_hwfn
400 * @param dst_id - absolute per engine
401 *
402 * @return enum _ecore_status_t
403 */
404 enum _ecore_status_t ecore_fw_vport(struct ecore_hwfn *p_hwfn,
405 u8 src_id,
406 u8 *dst_id);
407
408 /**
409 * @@brief ecore_fw_rss_eng - Get absolute RSS engine ID
410 *
411 * @param p_hwfn
412 * @param src_id - relative to p_hwfn
413 * @param dst_id - absolute per engine
414 *
415 * @return enum _ecore_status_t
416 */
417 enum _ecore_status_t ecore_fw_rss_eng(struct ecore_hwfn *p_hwfn,
418 u8 src_id,
419 u8 *dst_id);
420
421 /**
422 * @brief ecore_llh_add_mac_filter - configures a MAC filter in llh
423 *
424 * @param p_hwfn
425 * @param p_ptt
426 * @param p_filter - MAC to add
427 */
428 enum _ecore_status_t ecore_llh_add_mac_filter(struct ecore_hwfn *p_hwfn,
429 struct ecore_ptt *p_ptt,
430 u8 *p_filter);
431
432 /**
433 * @brief ecore_llh_remove_mac_filter - removes a MAC filtre from llh
434 *
435 * @param p_hwfn
436 * @param p_ptt
437 * @param p_filter - MAC to remove
438 */
439 void ecore_llh_remove_mac_filter(struct ecore_hwfn *p_hwfn,
440 struct ecore_ptt *p_ptt,
441 u8 *p_filter);
442
443 enum ecore_llh_port_filter_type_t {
444 ECORE_LLH_FILTER_ETHERTYPE,
445 ECORE_LLH_FILTER_TCP_SRC_PORT,
446 ECORE_LLH_FILTER_TCP_DEST_PORT,
447 ECORE_LLH_FILTER_TCP_SRC_AND_DEST_PORT,
448 ECORE_LLH_FILTER_UDP_SRC_PORT,
449 ECORE_LLH_FILTER_UDP_DEST_PORT,
450 ECORE_LLH_FILTER_UDP_SRC_AND_DEST_PORT
451 };
452
453 /**
454 * @brief ecore_llh_add_protocol_filter - configures a protocol filter in llh
455 *
456 * @param p_hwfn
457 * @param p_ptt
458 * @param source_port_or_eth_type - source port or ethertype to add
459 * @param dest_port - destination port to add
460 * @param type - type of filters and comparing
461 */
462 enum _ecore_status_t
463 ecore_llh_add_protocol_filter(struct ecore_hwfn *p_hwfn,
464 struct ecore_ptt *p_ptt,
465 u16 source_port_or_eth_type,
466 u16 dest_port,
467 enum ecore_llh_port_filter_type_t type);
468
469 /**
470 * @brief ecore_llh_remove_protocol_filter - remove a protocol filter in llh
471 *
472 * @param p_hwfn
473 * @param p_ptt
474 * @param source_port_or_eth_type - source port or ethertype to add
475 * @param dest_port - destination port to add
476 * @param type - type of filters and comparing
477 */
478 void
479 ecore_llh_remove_protocol_filter(struct ecore_hwfn *p_hwfn,
480 struct ecore_ptt *p_ptt,
481 u16 source_port_or_eth_type,
482 u16 dest_port,
483 enum ecore_llh_port_filter_type_t type);
484
485 /**
486 * @brief ecore_llh_clear_all_filters - removes all MAC filters from llh
487 *
488 * @param p_hwfn
489 * @param p_ptt
490 */
491 void ecore_llh_clear_all_filters(struct ecore_hwfn *p_hwfn,
492 struct ecore_ptt *p_ptt);
493
494 /**
495 * @brief ecore_llh_set_function_as_default - set function as default per port
496 *
497 * @param p_hwfn
498 * @param p_ptt
499 */
500 enum _ecore_status_t
501 ecore_llh_set_function_as_default(struct ecore_hwfn *p_hwfn,
502 struct ecore_ptt *p_ptt);
503
504 /**
505 *@brief Cleanup of previous driver remains prior to load
506 *
507 * @param p_hwfn
508 * @param p_ptt
509 * @param id - For PF, engine-relative. For VF, PF-relative.
510 * @param is_vf - true iff cleanup is made for a VF.
511 *
512 * @return enum _ecore_status_t
513 */
514 enum _ecore_status_t ecore_final_cleanup(struct ecore_hwfn *p_hwfn,
515 struct ecore_ptt *p_ptt,
516 u16 id,
517 bool is_vf);
518
519 /**
520 * @brief ecore_set_rxq_coalesce - Configure coalesce parameters for an Rx queue
521 * The fact that we can configure coalescing to up to 511, but on varying
522 * accuracy [the bigger the value the less accurate] up to a mistake of 3usec
523 * for the highest values.
524 *
525 * @param p_hwfn
526 * @param p_ptt
527 * @param coalesce - Coalesce value in micro seconds.
528 * @param qid - Queue index.
529 * @param qid - SB Id
530 *
531 * @return enum _ecore_status_t
532 */
533 enum _ecore_status_t ecore_set_rxq_coalesce(struct ecore_hwfn *p_hwfn,
534 struct ecore_ptt *p_ptt,
535 u16 coalesce, u8 qid, u16 sb_id);
536
537 /**
538 * @brief ecore_set_txq_coalesce - Configure coalesce parameters for a Tx queue
539 * While the API allows setting coalescing per-qid, all tx queues sharing a
540 * SB should be in same range [i.e., either 0-0x7f, 0x80-0xff or 0x100-0x1ff]
541 * otherwise configuration would break.
542 *
543 * @param p_hwfn
544 * @param p_ptt
545 * @param coalesce - Coalesce value in micro seconds.
546 * @param qid - Queue index.
547 * @param qid - SB Id
548 *
549 * @return enum _ecore_status_t
550 */
551 enum _ecore_status_t ecore_set_txq_coalesce(struct ecore_hwfn *p_hwfn,
552 struct ecore_ptt *p_ptt,
553 u16 coalesce, u8 qid, u16 sb_id);
554
555 #endif