2 * Copyright (c) 2016 QLogic Corporation.
6 * See LICENSE.qede_pmd for copyright and licensing details.
9 #ifndef __ECORE_L2_API_H__
10 #define __ECORE_L2_API_H__
12 #include "ecore_status.h"
13 #include "ecore_sp_api.h"
15 #ifndef __EXTRACT__LINUX__
19 ECORE_RSS_IPV4_TCP = 0x4,
20 ECORE_RSS_IPV6_TCP = 0x8,
21 ECORE_RSS_IPV4_UDP = 0x10,
22 ECORE_RSS_IPV6_UDP = 0x20,
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 */
30 struct ecore_queue_start_common_params {
35 /* stats_id is relative or absolute depends on function */
42 struct ecore_rss_params {
46 u8 update_rss_capabilities;
47 u8 update_rss_ind_table;
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];
55 struct ecore_sge_tpa_params {
56 u8 max_buffers_per_cqe;
61 u8 tpa_ipv4_tunn_en_flg;
62 u8 tpa_ipv6_tunn_en_flg;
64 u8 update_tpa_param_flg;
66 u8 tpa_hdr_data_split_flg;
67 u8 tpa_gro_consistent_flg;
70 u16 tpa_min_size_to_start;
71 u16 tpa_min_size_to_cont;
74 enum ecore_filter_opcode {
78 ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
79 ECORE_FILTER_FLUSH, /* Removes all filters */
82 enum ecore_filter_ucast_type {
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,
94 struct ecore_filter_ucast {
95 enum ecore_filter_opcode opcode;
96 enum ecore_filter_ucast_type type;
100 u8 vport_to_remove_from;
101 unsigned char mac[ETH_ALEN];
107 struct ecore_filter_mcast {
108 /* MOVE is not supported for multicast */
109 enum ecore_filter_opcode opcode;
111 u8 vport_to_remove_from;
113 #define ECORE_MAX_MC_ADDRS 64
114 unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
117 struct ecore_filter_accept_flags {
118 u8 update_rx_mode_config;
119 u8 update_tx_mode_config;
122 #define ECORE_ACCEPT_NONE 0x01
123 #define ECORE_ACCEPT_UCAST_MATCHED 0x02
124 #define ECORE_ACCEPT_UCAST_UNMATCHED 0x04
125 #define ECORE_ACCEPT_MCAST_MATCHED 0x08
126 #define ECORE_ACCEPT_MCAST_UNMATCHED 0x10
127 #define ECORE_ACCEPT_BCAST 0x20
130 /* Add / remove / move / remove-all unicast MAC-VLAN filters.
131 * FW will assert in the following cases, so driver should take care...:
132 * 1. Adding a filter to a full table.
133 * 2. Adding a filter which already exists on that vport.
134 * 3. Removing a filter which doesn't exist.
138 ecore_filter_ucast_cmd(struct ecore_dev *p_dev,
139 struct ecore_filter_ucast *p_filter_cmd,
140 enum spq_mode comp_mode,
141 struct ecore_spq_comp_cb *p_comp_data);
143 /* Add / remove / move multicast MAC filters. */
145 ecore_filter_mcast_cmd(struct ecore_dev *p_dev,
146 struct ecore_filter_mcast *p_filter_cmd,
147 enum spq_mode comp_mode,
148 struct ecore_spq_comp_cb *p_comp_data);
150 /* Set "accept" filters */
152 ecore_filter_accept_cmd(
153 struct ecore_dev *p_dev,
155 struct ecore_filter_accept_flags accept_flags,
156 u8 update_accept_any_vlan,
158 enum spq_mode comp_mode,
159 struct ecore_spq_comp_cb *p_comp_data);
162 * @brief ecore_sp_eth_rx_queue_start - RX Queue Start Ramrod
164 * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
165 * the VPort ID is not currently initialized.
169 * @p_params [stats_id is relative, packed in p_params]
170 * @param bd_max_bytes Maximum bytes that can be placed on a BD
171 * @param bd_chain_phys_addr Physical address of BDs for receive.
172 * @param cqe_pbl_addr Physical address of the CQE PBL Table.
173 * @param cqe_pbl_size Size of the CQE PBL Table
174 * @param pp_prod Pointer to place producer's
175 * address for the Rx Q (May be
178 * @return enum _ecore_status_t
181 ecore_sp_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
183 struct ecore_queue_start_common_params *p_params,
185 dma_addr_t bd_chain_phys_addr,
186 dma_addr_t cqe_pbl_addr,
188 void OSAL_IOMEM * *pp_prod);
191 * @brief ecore_sp_eth_rx_queue_stop -
193 * This ramrod closes an RX queue. It sends RX queue stop ramrod
194 * + CFC delete ramrod
197 * @param rx_queue_id RX Queue ID
198 * @param eq_completion_only If True completion will be on
199 * EQe, if False completion will be
200 * on EQe if p_hwfn opaque
201 * different from the RXQ opaque
203 * @param cqe_completion If True completion will be
205 * @return enum _ecore_status_t
208 ecore_sp_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
210 bool eq_completion_only,
211 bool cqe_completion);
214 * @brief ecore_sp_eth_tx_queue_start - TX Queue Start Ramrod
216 * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
217 * the VPort is not currently initialized.
222 * @param tc traffic class to use with this L2 txq
223 * @param pbl_addr address of the pbl array
224 * @param pbl_size number of entries in pbl
225 * @param pp_doorbell Pointer to place doorbell pointer (May be NULL).
226 * This address should be used with the
227 * DIRECT_REG_WR macro.
229 * @return enum _ecore_status_t
232 ecore_sp_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
234 struct ecore_queue_start_common_params *p_params,
238 void OSAL_IOMEM * *pp_doorbell);
241 * @brief ecore_sp_eth_tx_queue_stop -
243 * This ramrod closes a TX queue. It sends TX queue stop ramrod
244 * + CFC delete ramrod
247 * @param tx_queue_id TX Queue ID
249 * @return enum _ecore_status_t
251 enum _ecore_status_t ecore_sp_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
254 enum ecore_tpa_mode {
261 struct ecore_sp_vport_start_params {
262 enum ecore_tpa_mode tpa_mode;
263 bool remove_inner_vlan; /* Inner VLAN removal is enabled */
264 bool tx_switching; /* Vport supports tx-switching */
265 bool handle_ptp_pkts; /* Handle PTP packets */
266 bool only_untagged; /* Untagged pkt control */
267 bool drop_ttl0; /* Drop packets with TTL = 0 */
268 u8 max_buffers_per_cqe;
271 u8 vport_id; /* VPORT ID */
272 u16 mtu; /* VPORT MTU */
273 bool zero_placement_offset;
279 * @brief ecore_sp_vport_start -
281 * This ramrod initializes a VPort. An Assert if generated if the Function ID
282 * of the VPort is not enabled.
285 * @param p_params VPORT start params
287 * @return enum _ecore_status_t
290 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
291 struct ecore_sp_vport_start_params *p_params);
293 struct ecore_sp_vport_update_params {
296 u8 update_vport_active_rx_flg;
297 u8 vport_active_rx_flg;
298 u8 update_vport_active_tx_flg;
299 u8 vport_active_tx_flg;
300 u8 update_inner_vlan_removal_flg;
301 u8 inner_vlan_removal_flg;
302 u8 silent_vlan_removal_flg;
303 u8 update_default_vlan_enable_flg;
304 u8 default_vlan_enable_flg;
305 u8 update_default_vlan_flg;
307 u8 update_tx_switching_flg;
309 u8 update_approx_mcast_flg;
310 u8 update_anti_spoofing_en_flg;
312 u8 update_accept_any_vlan_flg;
314 unsigned long bins[8];
315 struct ecore_rss_params *rss_params;
316 struct ecore_filter_accept_flags accept_flags;
317 struct ecore_sge_tpa_params *sge_tpa_params;
318 /* MTU change - notice this requires the vport to be disabled.
319 * If non-zero, value would be used.
325 * @brief ecore_sp_vport_update -
327 * This ramrod updates the parameters of the VPort. Every field can be updated
328 * independently, according to flags.
330 * This ramrod is also used to set the VPort state to active after creation.
331 * An Assert is generated if the VPort does not contain an RX queue.
336 * @return enum _ecore_status_t
339 ecore_sp_vport_update(struct ecore_hwfn *p_hwfn,
340 struct ecore_sp_vport_update_params *p_params,
341 enum spq_mode comp_mode,
342 struct ecore_spq_comp_cb *p_comp_data);
344 * @brief ecore_sp_vport_stop -
346 * This ramrod closes a VPort after all its RX and TX queues are terminated.
347 * An Assert is generated if any queues are left open.
351 * @param vport_id VPort ID
353 * @return enum _ecore_status_t
355 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
360 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
362 struct ecore_filter_ucast *p_filter_cmd,
363 enum spq_mode comp_mode,
364 struct ecore_spq_comp_cb *p_comp_data);
367 * @brief ecore_sp_rx_eth_queues_update -
369 * This ramrod updates an RX queue. It is used for setting the active state
370 * of the queue and updating the TPA and SGE parameters.
372 * @note Final phase API.
375 * @param rx_queue_id RX Queue ID
376 * @param num_rxqs Allow to update multiple rx
377 * queues, from rx_queue_id to
378 * (rx_queue_id + num_rxqs)
379 * @param complete_cqe_flg Post completion to the CQE Ring if set
380 * @param complete_event_flg Post completion to the Event Ring if set
382 * @return enum _ecore_status_t
386 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
390 u8 complete_event_flg,
391 enum spq_mode comp_mode,
392 struct ecore_spq_comp_cb *p_comp_data);
394 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
395 struct ecore_ptt *p_ptt,
396 struct ecore_eth_stats *stats,
397 u16 statistics_bin, bool b_get_port_stats);
399 void ecore_get_vport_stats(struct ecore_dev *p_dev,
400 struct ecore_eth_stats *stats);
402 void ecore_reset_vport_stats(struct ecore_dev *p_dev);