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