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