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