2 * Copyright (c) 2017-2018 Cavium, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
31 #ifndef __ECORE_L2_API_H__
32 #define __ECORE_L2_API_H__
34 #include "ecore_status.h"
35 #include "ecore_sp_api.h"
36 #include "ecore_int_api.h"
38 #ifndef __EXTRACT__LINUX__
42 ECORE_RSS_IPV4_TCP = 0x4,
43 ECORE_RSS_IPV6_TCP = 0x8,
44 ECORE_RSS_IPV4_UDP = 0x10,
45 ECORE_RSS_IPV6_UDP = 0x20,
48 /* Should be the same as ETH_RSS_IND_TABLE_ENTRIES_NUM */
49 #define ECORE_RSS_IND_TABLE_SIZE 128
50 #define ECORE_RSS_KEY_SIZE 10 /* size in 32b chunks */
52 #define ECORE_MAX_PHC_DRIFT_PPB 291666666
54 enum ecore_ptp_filter_type {
55 ECORE_PTP_FILTER_NONE,
57 ECORE_PTP_FILTER_V1_L4_EVENT,
58 ECORE_PTP_FILTER_V1_L4_GEN,
59 ECORE_PTP_FILTER_V2_L4_EVENT,
60 ECORE_PTP_FILTER_V2_L4_GEN,
61 ECORE_PTP_FILTER_V2_L2_EVENT,
62 ECORE_PTP_FILTER_V2_L2_GEN,
63 ECORE_PTP_FILTER_V2_EVENT,
64 ECORE_PTP_FILTER_V2_GEN
67 enum ecore_ptp_hwtstamp_tx_type {
68 ECORE_PTP_HWTSTAMP_TX_OFF,
69 ECORE_PTP_HWTSTAMP_TX_ON,
73 #ifndef __EXTRACT__LINUX__
74 struct ecore_queue_start_common_params {
75 /* Should always be relative to entity sending this. */
79 /* Relative, but relevant only for PFs */
82 struct ecore_sb_info *p_sb;
88 struct ecore_rxq_start_ret_params {
89 void OSAL_IOMEM *p_prod;
93 struct ecore_txq_start_ret_params {
94 void OSAL_IOMEM *p_doorbell;
99 struct ecore_rss_params {
100 u8 update_rss_config;
103 u8 update_rss_capabilities;
104 u8 update_rss_ind_table;
107 u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
109 /* Indirection table consist of rx queue handles */
110 void *rss_ind_table[ECORE_RSS_IND_TABLE_SIZE];
111 u32 rss_key[ECORE_RSS_KEY_SIZE];
114 struct ecore_sge_tpa_params {
115 u8 max_buffers_per_cqe;
117 u8 update_tpa_en_flg;
120 u8 tpa_ipv4_tunn_en_flg;
121 u8 tpa_ipv6_tunn_en_flg;
123 u8 update_tpa_param_flg;
124 u8 tpa_pkt_split_flg;
125 u8 tpa_hdr_data_split_flg;
126 u8 tpa_gro_consistent_flg;
129 u16 tpa_min_size_to_start;
130 u16 tpa_min_size_to_cont;
133 enum ecore_filter_opcode {
137 ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
138 ECORE_FILTER_FLUSH, /* Removes all filters */
141 enum ecore_filter_ucast_type {
144 ECORE_FILTER_MAC_VLAN,
145 ECORE_FILTER_INNER_MAC,
146 ECORE_FILTER_INNER_VLAN,
147 ECORE_FILTER_INNER_PAIR,
148 ECORE_FILTER_INNER_MAC_VNI_PAIR,
149 ECORE_FILTER_MAC_VNI_PAIR,
153 struct ecore_filter_ucast {
154 enum ecore_filter_opcode opcode;
155 enum ecore_filter_ucast_type type;
159 u8 vport_to_remove_from;
160 unsigned char mac[ETH_ALEN];
166 struct ecore_filter_mcast {
167 /* MOVE is not supported for multicast */
168 enum ecore_filter_opcode opcode;
170 u8 vport_to_remove_from;
172 #define ECORE_MAX_MC_ADDRS 64
173 unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
176 struct ecore_filter_accept_flags {
177 u8 update_rx_mode_config;
178 u8 update_tx_mode_config;
181 #define ECORE_ACCEPT_NONE 0x01
182 #define ECORE_ACCEPT_UCAST_MATCHED 0x02
183 #define ECORE_ACCEPT_UCAST_UNMATCHED 0x04
184 #define ECORE_ACCEPT_MCAST_MATCHED 0x08
185 #define ECORE_ACCEPT_MCAST_UNMATCHED 0x10
186 #define ECORE_ACCEPT_BCAST 0x20
189 #ifndef __EXTRACT__LINUX__
190 enum ecore_filter_config_mode {
191 ECORE_FILTER_CONFIG_MODE_DISABLE,
192 ECORE_FILTER_CONFIG_MODE_5_TUPLE,
193 ECORE_FILTER_CONFIG_MODE_L4_PORT,
194 ECORE_FILTER_CONFIG_MODE_IP_DEST,
198 struct ecore_arfs_config_params {
203 enum ecore_filter_config_mode mode;
206 /* Add / remove / move / remove-all unicast MAC-VLAN filters.
207 * FW will assert in the following cases, so driver should take care...:
208 * 1. Adding a filter to a full table.
209 * 2. Adding a filter which already exists on that vport.
210 * 3. Removing a filter which doesn't exist.
214 ecore_filter_ucast_cmd(struct ecore_dev *p_dev,
215 struct ecore_filter_ucast *p_filter_cmd,
216 enum spq_mode comp_mode,
217 struct ecore_spq_comp_cb *p_comp_data);
219 /* Add / remove / move multicast MAC filters. */
221 ecore_filter_mcast_cmd(struct ecore_dev *p_dev,
222 struct ecore_filter_mcast *p_filter_cmd,
223 enum spq_mode comp_mode,
224 struct ecore_spq_comp_cb *p_comp_data);
226 /* Set "accept" filters */
228 ecore_filter_accept_cmd(
229 struct ecore_dev *p_dev,
231 struct ecore_filter_accept_flags accept_flags,
232 u8 update_accept_any_vlan,
234 enum spq_mode comp_mode,
235 struct ecore_spq_comp_cb *p_comp_data);
238 * @brief ecore_eth_rx_queue_start - RX Queue Start Ramrod
240 * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
241 * the VPort ID is not currently initialized.
245 * @p_params Inputs; Relative for PF [SB being an exception]
246 * @param bd_max_bytes Maximum bytes that can be placed on a BD
247 * @param bd_chain_phys_addr Physical address of BDs for receive.
248 * @param cqe_pbl_addr Physical address of the CQE PBL Table.
249 * @param cqe_pbl_size Size of the CQE PBL Table
250 * @param p_ret_params Pointed struct to be filled with outputs.
252 * @return enum _ecore_status_t
255 ecore_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
257 struct ecore_queue_start_common_params *p_params,
259 dma_addr_t bd_chain_phys_addr,
260 dma_addr_t cqe_pbl_addr,
262 struct ecore_rxq_start_ret_params *p_ret_params);
265 * @brief ecore_eth_rx_queue_stop - This ramrod closes an Rx queue
268 * @param p_rxq Handler of queue to close
269 * @param eq_completion_only If True completion will be on
270 * EQe, if False completion will be
271 * on EQe if p_hwfn opaque
272 * different from the RXQ opaque
274 * @param cqe_completion If True completion will be
276 * @return enum _ecore_status_t
279 ecore_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
281 bool eq_completion_only,
282 bool cqe_completion);
285 * @brief - TX Queue Start Ramrod
287 * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
288 * the VPort is not currently initialized.
293 * @param tc traffic class to use with this L2 txq
294 * @param pbl_addr address of the pbl array
295 * @param pbl_size number of entries in pbl
296 * @oaram p_ret_params Pointer to fill the return parameters in.
298 * @return enum _ecore_status_t
301 ecore_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
303 struct ecore_queue_start_common_params *p_params,
307 struct ecore_txq_start_ret_params *p_ret_params);
310 * @brief ecore_eth_tx_queue_stop - closes a Tx queue
313 * @param p_txq - handle to Tx queue needed to be closed
315 * @return enum _ecore_status_t
317 enum _ecore_status_t ecore_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
320 enum ecore_tpa_mode {
327 struct ecore_sp_vport_start_params {
328 enum ecore_tpa_mode tpa_mode;
329 bool remove_inner_vlan; /* Inner VLAN removal is enabled */
330 bool tx_switching; /* Vport supports tx-switching */
331 bool handle_ptp_pkts; /* Handle PTP packets */
332 bool only_untagged; /* Untagged pkt control */
333 bool drop_ttl0; /* Drop packets with TTL = 0 */
334 u8 max_buffers_per_cqe;
337 u8 vport_id; /* VPORT ID */
338 u16 mtu; /* VPORT MTU */
339 bool zero_placement_offset;
343 /* Strict behavior on transmission errors */
344 bool b_err_illegal_vlan_mode;
345 bool b_err_illegal_inband_mode;
346 bool b_err_vlan_insert_with_inband;
347 bool b_err_small_pkt;
349 bool b_err_anti_spoof;
350 bool b_err_ctrl_frame;
354 * @brief ecore_sp_vport_start -
356 * This ramrod initializes a VPort. An Assert if generated if the Function ID
357 * of the VPort is not enabled.
360 * @param p_params VPORT start params
362 * @return enum _ecore_status_t
365 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
366 struct ecore_sp_vport_start_params *p_params);
368 struct ecore_sp_vport_update_params {
371 u8 update_vport_active_rx_flg;
372 u8 vport_active_rx_flg;
373 u8 update_vport_active_tx_flg;
374 u8 vport_active_tx_flg;
375 u8 update_inner_vlan_removal_flg;
376 u8 inner_vlan_removal_flg;
377 u8 silent_vlan_removal_flg;
378 u8 update_default_vlan_enable_flg;
379 u8 default_vlan_enable_flg;
380 u8 update_default_vlan_flg;
382 u8 update_tx_switching_flg;
384 u8 update_approx_mcast_flg;
385 u8 update_anti_spoofing_en_flg;
387 u8 update_accept_any_vlan_flg;
390 struct ecore_rss_params *rss_params;
391 struct ecore_filter_accept_flags accept_flags;
392 struct ecore_sge_tpa_params *sge_tpa_params;
396 * @brief ecore_sp_vport_update -
398 * This ramrod updates the parameters of the VPort. Every field can be updated
399 * independently, according to flags.
401 * This ramrod is also used to set the VPort state to active after creation.
402 * An Assert is generated if the VPort does not contain an RX queue.
407 * @return enum _ecore_status_t
410 ecore_sp_vport_update(struct ecore_hwfn *p_hwfn,
411 struct ecore_sp_vport_update_params *p_params,
412 enum spq_mode comp_mode,
413 struct ecore_spq_comp_cb *p_comp_data);
415 * @brief ecore_sp_vport_stop -
417 * This ramrod closes a VPort after all its RX and TX queues are terminated.
418 * An Assert is generated if any queues are left open.
422 * @param vport_id VPort ID
424 * @return enum _ecore_status_t
426 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
431 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
433 struct ecore_filter_ucast *p_filter_cmd,
434 enum spq_mode comp_mode,
435 struct ecore_spq_comp_cb *p_comp_data);
438 * @brief ecore_sp_rx_eth_queues_update -
440 * This ramrod updates an RX queue. It is used for setting the active state
441 * of the queue and updating the TPA and SGE parameters.
443 * @note Final phase API.
446 * @param pp_rxq_handlers An array of queue handlers to be updated.
447 * @param num_rxqs number of queues to update.
448 * @param complete_cqe_flg Post completion to the CQE Ring if set
449 * @param complete_event_flg Post completion to the Event Ring if set
453 * @return enum _ecore_status_t
457 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
458 void **pp_rxq_handlers,
461 u8 complete_event_flg,
462 enum spq_mode comp_mode,
463 struct ecore_spq_comp_cb *p_comp_data);
466 * @brief ecore_sp_eth_rx_queues_set_default -
468 * This ramrod sets RSS RX queue as default one.
470 * @note Final phase API.
473 * @param p_rxq_handlers queue handlers to be updated.
477 * @return enum _ecore_status_t
481 ecore_sp_eth_rx_queues_set_default(struct ecore_hwfn *p_hwfn,
483 enum spq_mode comp_mode,
484 struct ecore_spq_comp_cb *p_comp_data);
486 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
487 struct ecore_ptt *p_ptt,
488 struct ecore_eth_stats *stats,
489 u16 statistics_bin, bool b_get_port_stats);
491 void ecore_get_vport_stats(struct ecore_dev *p_dev,
492 struct ecore_eth_stats *stats);
494 void ecore_reset_vport_stats(struct ecore_dev *p_dev);
497 *@brief ecore_arfs_mode_configure -
499 *Enable or disable rfs mode. It must accept atleast one of tcp or udp true
500 *and atleast one of ipv4 or ipv6 true to enable rfs mode.
504 *@param p_cfg_params arfs mode configuration parameters.
507 void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
508 struct ecore_ptt *p_ptt,
509 struct ecore_arfs_config_params *p_cfg_params);
511 #ifndef __EXTRACT__LINUX__
512 struct ecore_ntuple_filter_params {
513 /* Physically mapped address containing header of buffer to be used
518 /* Length of header in bytes */
521 /* Relative queue-id to receive classified packet */
522 #define ECORE_RFS_NTUPLE_QID_RSS ((u16)-1)
525 /* Identifier can either be according to vport-id or vfid */
530 /* true iff this filter is to be added. Else to be removed */
536 * @brief - ecore_configure_rfs_ntuple_filter
538 * This ramrod should be used to add or remove arfs hw filter
541 * @params p_cb Used for ECORE_SPQ_MODE_CB,where client would initialize
542 * it with cookie and callback function address, if not
543 * using this mode then client must pass NULL.
547 ecore_configure_rfs_ntuple_filter(struct ecore_hwfn *p_hwfn,
548 struct ecore_spq_comp_cb *p_cb,
549 struct ecore_ntuple_filter_params *p_params);