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 {
31 /* Rx/Tx queue relative id to keep obtained cid in corresponding array
32 * RX - upper-bounded by number of FW-queues
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
42 /* stats_id is relative or absolute depends on function */
49 struct ecore_rss_params {
53 u8 update_rss_capabilities;
54 u8 update_rss_ind_table;
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];
62 struct ecore_sge_tpa_params {
63 u8 max_buffers_per_cqe;
68 u8 tpa_ipv4_tunn_en_flg;
69 u8 tpa_ipv6_tunn_en_flg;
71 u8 update_tpa_param_flg;
73 u8 tpa_hdr_data_split_flg;
74 u8 tpa_gro_consistent_flg;
77 u16 tpa_min_size_to_start;
78 u16 tpa_min_size_to_cont;
81 enum ecore_filter_opcode {
85 ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
86 ECORE_FILTER_FLUSH, /* Removes all filters */
89 enum ecore_filter_ucast_type {
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,
99 ECORE_FILTER_UNUSED, /* @DPDK */
102 struct ecore_filter_ucast {
103 enum ecore_filter_opcode opcode;
104 enum ecore_filter_ucast_type type;
108 u8 vport_to_remove_from;
109 unsigned char mac[ETH_ALEN];
115 struct ecore_filter_mcast {
116 /* MOVE is not supported for multicast */
117 enum ecore_filter_opcode opcode;
119 u8 vport_to_remove_from;
121 #define ECORE_MAX_MC_ADDRS 64
122 unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
125 struct ecore_filter_accept_flags {
126 u8 update_rx_mode_config;
127 u8 update_tx_mode_config;
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
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.
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);
151 /* Add / remove / move multicast MAC filters. */
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);
158 /* Set "accept" filters */
160 ecore_filter_accept_cmd(
161 struct ecore_dev *p_dev,
163 struct ecore_filter_accept_flags accept_flags,
164 u8 update_accept_any_vlan,
166 enum spq_mode comp_mode,
167 struct ecore_spq_comp_cb *p_comp_data);
170 * @brief ecore_sp_eth_rx_queue_start - RX Queue Start Ramrod
172 * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
173 * the VPort ID is not currently initialized.
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
186 * @return enum _ecore_status_t
189 ecore_sp_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
191 struct ecore_queue_start_common_params *p_params,
193 dma_addr_t bd_chain_phys_addr,
194 dma_addr_t cqe_pbl_addr,
196 void OSAL_IOMEM * *pp_prod);
199 * @brief ecore_sp_eth_rx_queue_stop -
201 * This ramrod closes an RX queue. It sends RX queue stop ramrod
202 * + CFC delete ramrod
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
211 * @param cqe_completion If True completion will be
213 * @return enum _ecore_status_t
216 ecore_sp_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
218 bool eq_completion_only,
219 bool cqe_completion);
222 * @brief ecore_sp_eth_tx_queue_start - TX Queue Start Ramrod
224 * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
225 * the VPort is not currently initialized.
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.
237 * @return enum _ecore_status_t
240 ecore_sp_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
242 struct ecore_queue_start_common_params *p_params,
246 void OSAL_IOMEM * *pp_doorbell);
249 * @brief ecore_sp_eth_tx_queue_stop -
251 * This ramrod closes a TX queue. It sends TX queue stop ramrod
252 * + CFC delete ramrod
255 * @param tx_queue_id TX Queue ID
257 * @return enum _ecore_status_t
259 enum _ecore_status_t ecore_sp_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
262 enum ecore_tpa_mode {
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;
279 u8 vport_id; /* VPORT ID */
280 u16 mtu; /* VPORT MTU */
281 bool zero_placement_offset;
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;
291 bool b_err_anti_spoof;
292 bool b_err_ctrl_frame;
296 * @brief ecore_sp_vport_start -
298 * This ramrod initializes a VPort. An Assert if generated if the Function ID
299 * of the VPort is not enabled.
302 * @param p_params VPORT start params
304 * @return enum _ecore_status_t
307 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
308 struct ecore_sp_vport_start_params *p_params);
310 struct ecore_sp_vport_update_params {
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;
324 u8 update_tx_switching_flg;
326 u8 update_approx_mcast_flg;
327 u8 update_anti_spoofing_en_flg;
329 u8 update_accept_any_vlan_flg;
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.
342 * @brief ecore_sp_vport_update -
344 * This ramrod updates the parameters of the VPort. Every field can be updated
345 * independently, according to flags.
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.
353 * @return 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);
361 * @brief ecore_sp_vport_stop -
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.
368 * @param vport_id VPort ID
370 * @return enum _ecore_status_t
372 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
377 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
379 struct ecore_filter_ucast *p_filter_cmd,
380 enum spq_mode comp_mode,
381 struct ecore_spq_comp_cb *p_comp_data);
384 * @brief ecore_sp_rx_eth_queues_update -
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.
389 * @note Final phase API.
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
399 * @return enum _ecore_status_t
403 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
407 u8 complete_event_flg,
408 enum spq_mode comp_mode,
409 struct ecore_spq_comp_cb *p_comp_data);
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);
416 void ecore_get_vport_stats(struct ecore_dev *p_dev,
417 struct ecore_eth_stats *stats);
419 void ecore_reset_vport_stats(struct ecore_dev *p_dev);