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