5a7db7600a07a6cad0904106581527ee97b10849
[dpdk.git] / drivers / net / qede / base / ecore_l2_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_L2_API_H__
10 #define __ECORE_L2_API_H__
11
12 #include "ecore_status.h"
13 #include "ecore_sp_api.h"
14
15 #ifndef __EXTRACT__LINUX__
16 enum ecore_rss_caps {
17         ECORE_RSS_IPV4          = 0x1,
18         ECORE_RSS_IPV6          = 0x2,
19         ECORE_RSS_IPV4_TCP      = 0x4,
20         ECORE_RSS_IPV6_TCP      = 0x8,
21         ECORE_RSS_IPV4_UDP      = 0x10,
22         ECORE_RSS_IPV6_UDP      = 0x20,
23 };
24
25 /* Should be the same as ETH_RSS_IND_TABLE_ENTRIES_NUM */
26 #define ECORE_RSS_IND_TABLE_SIZE 128
27 #define ECORE_RSS_KEY_SIZE 10 /* size in 32b chunks */
28 #endif
29
30 struct ecore_queue_start_common_params {
31         /* Should always be relative to entity sending this. */
32         u8 vport_id;
33         u16 queue_id;
34
35         /* Relative, but relevant only for PFs */
36         u8 stats_id;
37
38         /* These are always absolute */
39         u16 sb;
40         u8 sb_idx;
41 };
42
43 struct ecore_rxq_start_ret_params {
44         void OSAL_IOMEM *p_prod;
45         void *p_handle;
46 };
47
48 struct ecore_txq_start_ret_params {
49         void OSAL_IOMEM *p_doorbell;
50         void *p_handle;
51 };
52
53 struct ecore_rss_params {
54         u8 update_rss_config;
55         u8 rss_enable;
56         u8 rss_eng_id;
57         u8 update_rss_capabilities;
58         u8 update_rss_ind_table;
59         u8 update_rss_key;
60         u8 rss_caps;
61         u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
62
63         /* Indirection table consist of rx queue handles */
64         void *rss_ind_table[ECORE_RSS_IND_TABLE_SIZE];
65         u32 rss_key[ECORE_RSS_KEY_SIZE];
66 };
67
68 struct ecore_sge_tpa_params {
69         u8 max_buffers_per_cqe;
70
71         u8 update_tpa_en_flg;
72         u8 tpa_ipv4_en_flg;
73         u8 tpa_ipv6_en_flg;
74         u8 tpa_ipv4_tunn_en_flg;
75         u8 tpa_ipv6_tunn_en_flg;
76
77         u8 update_tpa_param_flg;
78         u8 tpa_pkt_split_flg;
79         u8 tpa_hdr_data_split_flg;
80         u8 tpa_gro_consistent_flg;
81         u8 tpa_max_aggs_num;
82         u16 tpa_max_size;
83         u16 tpa_min_size_to_start;
84         u16 tpa_min_size_to_cont;
85 };
86
87 enum ecore_filter_opcode {
88         ECORE_FILTER_ADD,
89         ECORE_FILTER_REMOVE,
90         ECORE_FILTER_MOVE,
91         ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
92         ECORE_FILTER_FLUSH, /* Removes all filters */
93 };
94
95 enum ecore_filter_ucast_type {
96         ECORE_FILTER_MAC,
97         ECORE_FILTER_VLAN,
98         ECORE_FILTER_MAC_VLAN,
99         ECORE_FILTER_INNER_MAC,
100         ECORE_FILTER_INNER_VLAN,
101         ECORE_FILTER_INNER_PAIR,
102         ECORE_FILTER_INNER_MAC_VNI_PAIR,
103         ECORE_FILTER_MAC_VNI_PAIR,
104         ECORE_FILTER_VNI,
105         ECORE_FILTER_UNUSED, /* @DPDK */
106 };
107
108 struct ecore_filter_ucast {
109         enum ecore_filter_opcode opcode;
110         enum ecore_filter_ucast_type type;
111         u8 is_rx_filter;
112         u8 is_tx_filter;
113         u8 vport_to_add_to;
114         u8 vport_to_remove_from;
115         unsigned char mac[ETH_ALEN];
116         u8 assert_on_error;
117         u16 vlan;
118         u32 vni;
119 };
120
121 struct ecore_filter_mcast {
122         /* MOVE is not supported for multicast */
123         enum ecore_filter_opcode opcode;
124         u8 vport_to_add_to;
125         u8 vport_to_remove_from;
126         u8      num_mc_addrs;
127 #define ECORE_MAX_MC_ADDRS      64
128         unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
129 };
130
131 struct ecore_filter_accept_flags {
132         u8 update_rx_mode_config;
133         u8 update_tx_mode_config;
134         u8 rx_accept_filter;
135         u8 tx_accept_filter;
136 #define ECORE_ACCEPT_NONE               0x01
137 #define ECORE_ACCEPT_UCAST_MATCHED      0x02
138 #define ECORE_ACCEPT_UCAST_UNMATCHED    0x04
139 #define ECORE_ACCEPT_MCAST_MATCHED      0x08
140 #define ECORE_ACCEPT_MCAST_UNMATCHED    0x10
141 #define ECORE_ACCEPT_BCAST              0x20
142 };
143
144 /* Add / remove / move / remove-all unicast MAC-VLAN filters.
145  * FW will assert in the following cases, so driver should take care...:
146  * 1. Adding a filter to a full table.
147  * 2. Adding a filter which already exists on that vport.
148  * 3. Removing a filter which doesn't exist.
149  */
150
151 enum _ecore_status_t
152 ecore_filter_ucast_cmd(struct ecore_dev *p_dev,
153                        struct ecore_filter_ucast *p_filter_cmd,
154                        enum spq_mode comp_mode,
155                        struct ecore_spq_comp_cb *p_comp_data);
156
157 /* Add / remove / move multicast MAC filters. */
158 enum _ecore_status_t
159 ecore_filter_mcast_cmd(struct ecore_dev *p_dev,
160                        struct ecore_filter_mcast *p_filter_cmd,
161                        enum spq_mode comp_mode,
162                        struct ecore_spq_comp_cb *p_comp_data);
163
164 /* Set "accept" filters */
165 enum _ecore_status_t
166 ecore_filter_accept_cmd(
167         struct ecore_dev                 *p_dev,
168         u8                               vport,
169         struct ecore_filter_accept_flags accept_flags,
170         u8                               update_accept_any_vlan,
171         u8                               accept_any_vlan,
172         enum spq_mode                    comp_mode,
173         struct ecore_spq_comp_cb         *p_comp_data);
174
175 /**
176  * @brief ecore_eth_rx_queue_start - RX Queue Start Ramrod
177  *
178  * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
179  * the VPort ID is not currently initialized.
180  *
181  * @param p_hwfn
182  * @param opaque_fid
183  * @p_params                    Inputs; Relative for PF [SB being an exception]
184  * @param bd_max_bytes          Maximum bytes that can be placed on a BD
185  * @param bd_chain_phys_addr    Physical address of BDs for receive.
186  * @param cqe_pbl_addr          Physical address of the CQE PBL Table.
187  * @param cqe_pbl_size          Size of the CQE PBL Table
188  * @param p_ret_params          Pointed struct to be filled with outputs.
189  *
190  * @return enum _ecore_status_t
191  */
192 enum _ecore_status_t
193 ecore_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
194                          u16 opaque_fid,
195                          struct ecore_queue_start_common_params *p_params,
196                          u16 bd_max_bytes,
197                          dma_addr_t bd_chain_phys_addr,
198                          dma_addr_t cqe_pbl_addr,
199                          u16 cqe_pbl_size,
200                          struct ecore_rxq_start_ret_params *p_ret_params);
201
202 /**
203  * @brief ecore_eth_rx_queue_stop - This ramrod closes an Rx queue
204  *
205  * @param p_hwfn
206  * @param p_rxq                 Handler of queue to close
207  * @param eq_completion_only    If True completion will be on
208  *                              EQe, if False completion will be
209  *                              on EQe if p_hwfn opaque
210  *                              different from the RXQ opaque
211  *                              otherwise on CQe.
212  * @param cqe_completion        If True completion will be
213  *                              receive on CQe.
214  * @return enum _ecore_status_t
215  */
216 enum _ecore_status_t
217 ecore_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
218                         void *p_rxq,
219                         bool eq_completion_only,
220                         bool cqe_completion);
221
222 /**
223  * @brief - TX Queue Start Ramrod
224  *
225  * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
226  * the VPort is not currently initialized.
227  *
228  * @param p_hwfn
229  * @param opaque_fid
230  * @p_params
231  * @param tc                    traffic class to use with this L2 txq
232  * @param pbl_addr              address of the pbl array
233  * @param pbl_size              number of entries in pbl
234  * @param p_ret_params          Pointer to fill the return parameters in.
235  *
236  * @return enum _ecore_status_t
237  */
238 enum _ecore_status_t
239 ecore_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
240                          u16 opaque_fid,
241                          struct ecore_queue_start_common_params *p_params,
242                          u8 tc,
243                          dma_addr_t pbl_addr,
244                          u16 pbl_size,
245                          struct ecore_txq_start_ret_params *p_ret_params);
246
247 /**
248  * @brief ecore_eth_tx_queue_stop - closes a Tx queue
249  *
250  * @param p_hwfn
251  * @param p_txq - handle to Tx queue needed to be closed
252  *
253  * @return enum _ecore_status_t
254  */
255 enum _ecore_status_t ecore_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
256                                              void *p_txq);
257
258 enum ecore_tpa_mode     {
259         ECORE_TPA_MODE_NONE,
260         ECORE_TPA_MODE_RSC,
261         ECORE_TPA_MODE_GRO,
262         ECORE_TPA_MODE_MAX
263 };
264
265 struct ecore_sp_vport_start_params {
266         enum ecore_tpa_mode tpa_mode;
267         bool remove_inner_vlan; /* Inner VLAN removal is enabled */
268         bool tx_switching;      /* Vport supports tx-switching */
269         bool handle_ptp_pkts;   /* Handle PTP packets */
270         bool only_untagged;     /* Untagged pkt control */
271         bool drop_ttl0;         /* Drop packets with TTL = 0 */
272         u8 max_buffers_per_cqe;
273         u32 concrete_fid;
274         u16 opaque_fid;
275         u8 vport_id;            /* VPORT ID */
276         u16 mtu;                /* VPORT MTU */
277         bool zero_placement_offset;
278         bool check_mac;
279         bool check_ethtype;
280
281         /* Strict behavior on transmission errors */
282         bool b_err_illegal_vlan_mode;
283         bool b_err_illegal_inband_mode;
284         bool b_err_vlan_insert_with_inband;
285         bool b_err_small_pkt;
286         bool b_err_big_pkt;
287         bool b_err_anti_spoof;
288         bool b_err_ctrl_frame;
289 };
290
291 /**
292  * @brief ecore_sp_vport_start -
293  *
294  * This ramrod initializes a VPort. An Assert if generated if the Function ID
295  * of the VPort is not enabled.
296  *
297  * @param p_hwfn
298  * @param p_params              VPORT start params
299  *
300  * @return enum _ecore_status_t
301  */
302 enum _ecore_status_t
303 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
304                      struct ecore_sp_vport_start_params *p_params);
305
306 struct ecore_sp_vport_update_params {
307         u16                     opaque_fid;
308         u8                      vport_id;
309         u8                      update_vport_active_rx_flg;
310         u8                      vport_active_rx_flg;
311         u8                      update_vport_active_tx_flg;
312         u8                      vport_active_tx_flg;
313         u8                      update_inner_vlan_removal_flg;
314         u8                      inner_vlan_removal_flg;
315         u8                      silent_vlan_removal_flg;
316         u8                      update_default_vlan_enable_flg;
317         u8                      default_vlan_enable_flg;
318         u8                      update_default_vlan_flg;
319         u16                     default_vlan;
320         u8                      update_tx_switching_flg;
321         u8                      tx_switching_flg;
322         u8                      update_approx_mcast_flg;
323         u8                      update_anti_spoofing_en_flg;
324         u8                      anti_spoofing_en;
325         u8                      update_accept_any_vlan_flg;
326         u8                      accept_any_vlan;
327         unsigned long           bins[8];
328         struct ecore_rss_params *rss_params;
329         struct ecore_filter_accept_flags accept_flags;
330         struct ecore_sge_tpa_params *sge_tpa_params;
331         /* MTU change - notice this requires the vport to be disabled.
332          * If non-zero, value would be used.
333          */
334         u16 mtu;
335 };
336
337 /**
338  * @brief ecore_sp_vport_update -
339  *
340  * This ramrod updates the parameters of the VPort. Every field can be updated
341  * independently, according to flags.
342  *
343  * This ramrod is also used to set the VPort state to active after creation.
344  * An Assert is generated if the VPort does not contain an RX queue.
345  *
346  * @param p_hwfn
347  * @param p_params
348  *
349  * @return enum _ecore_status_t
350  */
351 enum _ecore_status_t
352 ecore_sp_vport_update(struct ecore_hwfn *p_hwfn,
353                       struct ecore_sp_vport_update_params *p_params,
354                       enum spq_mode comp_mode,
355                       struct ecore_spq_comp_cb *p_comp_data);
356 /**
357  * @brief ecore_sp_vport_stop -
358  *
359  * This ramrod closes a VPort after all its RX and TX queues are terminated.
360  * An Assert is generated if any queues are left open.
361  *
362  * @param p_hwfn
363  * @param opaque_fid
364  * @param vport_id VPort ID
365  *
366  * @return enum _ecore_status_t
367  */
368 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
369                                          u16 opaque_fid,
370                                          u8 vport_id);
371
372 enum _ecore_status_t
373 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
374                           u16 opaque_fid,
375                           struct ecore_filter_ucast *p_filter_cmd,
376                           enum spq_mode comp_mode,
377                           struct ecore_spq_comp_cb *p_comp_data);
378
379 /**
380  * @brief ecore_sp_rx_eth_queues_update -
381  *
382  * This ramrod updates an RX queue. It is used for setting the active state
383  * of the queue and updating the TPA and SGE parameters.
384  *
385  * @note Final phase API.
386  *
387  * @param p_hwfn
388  * @param pp_rxq_handlers       An array of queue handlers to be updated.
389  * @param num_rxqs              number of queues to update.
390  * @param complete_cqe_flg      Post completion to the CQE Ring if set
391  * @param complete_event_flg    Post completion to the Event Ring if set
392  * @param comp_mode
393  * @param p_comp_data
394  *
395  * @return enum _ecore_status_t
396  */
397
398 enum _ecore_status_t
399 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
400                               void **pp_rxq_handlers,
401                               u8 num_rxqs,
402                               u8 complete_cqe_flg,
403                               u8 complete_event_flg,
404                               enum spq_mode comp_mode,
405                               struct ecore_spq_comp_cb *p_comp_data);
406
407 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
408                              struct ecore_ptt *p_ptt,
409                              struct ecore_eth_stats *stats,
410                              u16 statistics_bin, bool b_get_port_stats);
411
412 void ecore_get_vport_stats(struct ecore_dev *p_dev,
413                            struct ecore_eth_stats *stats);
414
415 void ecore_reset_vport_stats(struct ecore_dev *p_dev);
416
417 #endif