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_rss_params {
34 u8 update_rss_capabilities;
35 u8 update_rss_ind_table;
38 u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
39 u16 rss_ind_table[ECORE_RSS_IND_TABLE_SIZE];
40 u32 rss_key[ECORE_RSS_KEY_SIZE];
43 struct ecore_sge_tpa_params {
44 u8 max_buffers_per_cqe;
49 u8 tpa_ipv4_tunn_en_flg;
50 u8 tpa_ipv6_tunn_en_flg;
52 u8 update_tpa_param_flg;
54 u8 tpa_hdr_data_split_flg;
55 u8 tpa_gro_consistent_flg;
58 u16 tpa_min_size_to_start;
59 u16 tpa_min_size_to_cont;
62 enum ecore_filter_opcode {
66 ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
67 ECORE_FILTER_FLUSH, /* Removes all filters */
70 enum ecore_filter_ucast_type {
73 ECORE_FILTER_MAC_VLAN,
74 ECORE_FILTER_INNER_MAC,
75 ECORE_FILTER_INNER_VLAN,
76 ECORE_FILTER_INNER_PAIR,
77 ECORE_FILTER_INNER_MAC_VNI_PAIR,
78 ECORE_FILTER_MAC_VNI_PAIR,
82 struct ecore_filter_ucast {
83 enum ecore_filter_opcode opcode;
84 enum ecore_filter_ucast_type type;
88 u8 vport_to_remove_from;
89 unsigned char mac[ETH_ALEN];
95 struct ecore_filter_mcast {
96 /* MOVE is not supported for multicast */
97 enum ecore_filter_opcode opcode;
99 u8 vport_to_remove_from;
101 #define ECORE_MAX_MC_ADDRS 64
102 unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
105 struct ecore_filter_accept_flags {
106 u8 update_rx_mode_config;
107 u8 update_tx_mode_config;
110 #define ECORE_ACCEPT_NONE 0x01
111 #define ECORE_ACCEPT_UCAST_MATCHED 0x02
112 #define ECORE_ACCEPT_UCAST_UNMATCHED 0x04
113 #define ECORE_ACCEPT_MCAST_MATCHED 0x08
114 #define ECORE_ACCEPT_MCAST_UNMATCHED 0x10
115 #define ECORE_ACCEPT_BCAST 0x20
118 /* Add / remove / move / remove-all unicast MAC-VLAN filters.
119 * FW will assert in the following cases, so driver should take care...:
120 * 1. Adding a filter to a full table.
121 * 2. Adding a filter which already exists on that vport.
122 * 3. Removing a filter which doesn't exist.
126 ecore_filter_ucast_cmd(struct ecore_dev *p_dev,
127 struct ecore_filter_ucast *p_filter_cmd,
128 enum spq_mode comp_mode,
129 struct ecore_spq_comp_cb *p_comp_data);
131 /* Add / remove / move multicast MAC filters. */
133 ecore_filter_mcast_cmd(struct ecore_dev *p_dev,
134 struct ecore_filter_mcast *p_filter_cmd,
135 enum spq_mode comp_mode,
136 struct ecore_spq_comp_cb *p_comp_data);
138 /* Set "accept" filters */
140 ecore_filter_accept_cmd(struct ecore_dev *p_dev,
142 struct ecore_filter_accept_flags accept_flags,
143 u8 update_accept_any_vlan,
145 enum spq_mode comp_mode,
146 struct ecore_spq_comp_cb *p_comp_data);
149 * @brief ecore_sp_eth_rx_queue_start - RX Queue Start Ramrod
151 * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
152 * the VPort ID is not currently initialized.
156 * @param rx_queue_id RX Queue ID: Zero based, per VPort, allocated
157 * by assignment (=rssId)
158 * @param vport_id VPort ID
159 * @param u8 stats_id VPort ID which the queue stats
161 * @param sb Status Block of the Function Event Ring
162 * @param sb_index Index into the status block of the
163 * Function Event Ring
164 * @param bd_max_bytes Maximum bytes that can be placed on a BD
165 * @param bd_chain_phys_addr Physical address of BDs for receive.
166 * @param cqe_pbl_addr Physical address of the CQE PBL Table.
167 * @param cqe_pbl_size Size of the CQE PBL Table
168 * @param pp_prod Pointer to place producer's
169 * address for the Rx Q (May be
172 * @return enum _ecore_status_t
174 enum _ecore_status_t ecore_sp_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
182 dma_addr_t bd_chain_phys_addr,
183 dma_addr_t cqe_pbl_addr,
185 void OSAL_IOMEM * *pp_prod);
188 * @brief ecore_sp_eth_rx_queue_stop -
190 * This ramrod closes an RX queue. It sends RX queue stop ramrod
191 * + CFC delete ramrod
194 * @param rx_queue_id RX Queue ID
195 * @param eq_completion_only If True completion will be on
196 * EQe, if False completion will be
197 * on EQe if p_hwfn opaque
198 * different from the RXQ opaque
200 * @param cqe_completion If True completion will be
202 * @return enum _ecore_status_t
205 ecore_sp_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
207 bool eq_completion_only, bool cqe_completion);
210 * @brief ecore_sp_eth_tx_queue_start - TX Queue Start Ramrod
212 * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
213 * the VPort is not currently initialized.
217 * @param tx_queue_id TX Queue ID
218 * @param vport_id VPort ID
219 * @param stats_id VPort ID which the queue stats
221 * @param sb Status Block of the Function Event Ring
222 * @param sb_index Index into the status block of the Function
224 * @param pbl_addr address of the pbl array
225 * @param pbl_size number of entries in pbl
226 * @param pp_doorbell Pointer to place doorbell pointer (May be NULL).
227 * This address should be used with the
228 * DIRECT_REG_WR macro.
230 * @return enum _ecore_status_t
232 enum _ecore_status_t ecore_sp_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
245 * @brief ecore_sp_eth_tx_queue_stop -
247 * This ramrod closes a TX queue. It sends TX queue stop ramrod
248 * + CFC delete ramrod
251 * @param tx_queue_id TX Queue ID
253 * @return enum _ecore_status_t
255 enum _ecore_status_t ecore_sp_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
258 enum ecore_tpa_mode {
265 struct ecore_sp_vport_start_params {
266 enum ecore_tpa_mode tpa_mode;
267 bool remove_inner_vlan; /* Inner VLAN removal is enabled */
268 bool tx_switching; /* Vport supports tx-switching */
269 bool handle_ptp_pkts; /* Handle PTP packets */
270 bool only_untagged; /* Untagged pkt control */
271 bool drop_ttl0; /* Drop packets with TTL = 0 */
272 u8 max_buffers_per_cqe;
275 u8 vport_id; /* VPORT ID */
276 u16 mtu; /* VPORT MTU */
277 bool zero_placement_offset;
281 * @brief ecore_sp_vport_start -
283 * This ramrod initializes a VPort. An Assert if generated if the Function ID
284 * of the VPort is not enabled.
287 * @param p_params VPORT start params
289 * @return enum _ecore_status_t
292 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
293 struct ecore_sp_vport_start_params *p_params);
295 struct ecore_sp_vport_update_params {
298 u8 update_vport_active_rx_flg;
299 u8 vport_active_rx_flg;
300 u8 update_vport_active_tx_flg;
301 u8 vport_active_tx_flg;
302 u8 update_inner_vlan_removal_flg;
303 u8 inner_vlan_removal_flg;
304 u8 silent_vlan_removal_flg;
305 u8 update_default_vlan_enable_flg;
306 u8 default_vlan_enable_flg;
307 u8 update_default_vlan_flg;
309 u8 update_tx_switching_flg;
311 u8 update_approx_mcast_flg;
312 u8 update_anti_spoofing_en_flg;
314 u8 update_accept_any_vlan_flg;
316 unsigned long bins[8];
317 struct ecore_rss_params *rss_params;
318 struct ecore_filter_accept_flags accept_flags;
319 struct ecore_sge_tpa_params *sge_tpa_params;
323 * @brief ecore_sp_vport_update -
325 * This ramrod updates the parameters of the VPort. Every field can be updated
326 * independently, according to flags.
328 * This ramrod is also used to set the VPort state to active after creation.
329 * An Assert is generated if the VPort does not contain an RX queue.
334 * @return enum _ecore_status_t
337 ecore_sp_vport_update(struct ecore_hwfn *p_hwfn,
338 struct ecore_sp_vport_update_params *p_params,
339 enum spq_mode comp_mode,
340 struct ecore_spq_comp_cb *p_comp_data);
342 * @brief ecore_sp_vport_stop -
344 * This ramrod closes a VPort after all its RX and TX queues are terminated.
345 * An Assert is generated if any queues are left open.
349 * @param vport_id VPort ID
351 * @return enum _ecore_status_t
353 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
354 u16 opaque_fid, u8 vport_id);
357 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
359 struct ecore_filter_ucast *p_filter_cmd,
360 enum spq_mode comp_mode,
361 struct ecore_spq_comp_cb *p_comp_data);
364 * @brief ecore_sp_rx_eth_queues_update -
366 * This ramrod updates an RX queue. It is used for setting the active state
367 * of the queue and updating the TPA and SGE parameters.
369 * @note Final phase API.
372 * @param rx_queue_id RX Queue ID
373 * @param num_rxqs Allow to update multiple rx
374 * queues, from rx_queue_id to
375 * (rx_queue_id + num_rxqs)
376 * @param complete_cqe_flg Post completion to the CQE Ring if set
377 * @param complete_event_flg Post completion to the Event Ring if set
379 * @return enum _ecore_status_t
383 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
387 u8 complete_event_flg,
388 enum spq_mode comp_mode,
389 struct ecore_spq_comp_cb *p_comp_data);
391 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
392 struct ecore_ptt *p_ptt,
393 struct ecore_eth_stats *stats,
394 u16 statistics_bin, bool b_get_port_stats);
396 void ecore_get_vport_stats(struct ecore_dev *p_dev,
397 struct ecore_eth_stats *stats);
399 void ecore_reset_vport_stats(struct ecore_dev *p_dev);