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