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