xref: /illumos-gate/usr/src/uts/common/io/qede/579xx/drivers/ecore/ecore_l2_api.h (revision 14b24e2b79293068c8e016a69ef1d872fb5e2fd5)
1 /*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, v.1,  (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://opensource.org/licenses/CDDL-1.0.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21 
22 /*
23 * Copyright 2014-2017 Cavium, Inc.
24 * The contents of this file are subject to the terms of the Common Development
25 * and Distribution License, v.1,  (the "License").
26 
27 * You may not use this file except in compliance with the License.
28 
29 * You can obtain a copy of the License at available
30 * at http://opensource.org/licenses/CDDL-1.0
31 
32 * See the License for the specific language governing permissions and
33 * limitations under the License.
34 */
35 
36 #ifndef __ECORE_L2_API_H__
37 #define __ECORE_L2_API_H__
38 
39 #include "ecore_status.h"
40 #include "ecore_sp_api.h"
41 #include "ecore_int_api.h"
42 
43 #ifndef __EXTRACT__LINUX__
44 enum ecore_rss_caps {
45 	ECORE_RSS_IPV4		= 0x1,
46 	ECORE_RSS_IPV6		= 0x2,
47 	ECORE_RSS_IPV4_TCP	= 0x4,
48 	ECORE_RSS_IPV6_TCP	= 0x8,
49 	ECORE_RSS_IPV4_UDP	= 0x10,
50 	ECORE_RSS_IPV6_UDP	= 0x20,
51 };
52 
53 /* Should be the same as ETH_RSS_IND_TABLE_ENTRIES_NUM */
54 #define ECORE_RSS_IND_TABLE_SIZE 128
55 #define ECORE_RSS_KEY_SIZE 10 /* size in 32b chunks */
56 
57 #define ECORE_MAX_PHC_DRIFT_PPB	291666666
58 
59 enum ecore_ptp_filter_type {
60 	ECORE_PTP_FILTER_L2,
61 	ECORE_PTP_FILTER_IPV4,
62 	ECORE_PTP_FILTER_IPV4_IPV6,
63 	ECORE_PTP_FILTER_L2_IPV4_IPV6
64 };
65 
66 #endif
67 
68 #ifndef __EXTRACT__LINUX__
69 struct ecore_queue_start_common_params {
70 	/* Should always be relative to entity sending this. */
71 	u8 vport_id;
72 	u16 queue_id;
73 
74 	/* Relative, but relevant only for PFs */
75 	u8 stats_id;
76 
77 	struct ecore_sb_info *p_sb;
78 	u8 sb_idx;
79 };
80 
81 struct ecore_rxq_start_ret_params {
82 	void OSAL_IOMEM *p_prod;
83 	void *p_handle;
84 };
85 
86 struct ecore_txq_start_ret_params {
87 	void OSAL_IOMEM *p_doorbell;
88 	void *p_handle;
89 };
90 #endif
91 
92 struct ecore_rss_params {
93 	u8 update_rss_config;
94 	u8 rss_enable;
95 	u8 rss_eng_id;
96 	u8 update_rss_capabilities;
97 	u8 update_rss_ind_table;
98 	u8 update_rss_key;
99 	u8 rss_caps;
100 	u8 rss_table_size_log; /* The table size is 2 ^ rss_table_size_log */
101 
102 	/* Indirection table consist of rx queue handles */
103 	void *rss_ind_table[ECORE_RSS_IND_TABLE_SIZE];
104 	u32 rss_key[ECORE_RSS_KEY_SIZE];
105 };
106 
107 struct ecore_sge_tpa_params {
108 	u8 max_buffers_per_cqe;
109 
110 	u8 update_tpa_en_flg;
111 	u8 tpa_ipv4_en_flg;
112 	u8 tpa_ipv6_en_flg;
113 	u8 tpa_ipv4_tunn_en_flg;
114 	u8 tpa_ipv6_tunn_en_flg;
115 
116 	u8 update_tpa_param_flg;
117 	u8 tpa_pkt_split_flg;
118 	u8 tpa_hdr_data_split_flg;
119 	u8 tpa_gro_consistent_flg;
120 	u8 tpa_max_aggs_num;
121 	u16 tpa_max_size;
122 	u16 tpa_min_size_to_start;
123 	u16 tpa_min_size_to_cont;
124 };
125 
126 enum ecore_filter_opcode {
127 	ECORE_FILTER_ADD,
128 	ECORE_FILTER_REMOVE,
129 	ECORE_FILTER_MOVE,
130 	ECORE_FILTER_REPLACE, /* Delete all MACs and add new one instead */
131 	ECORE_FILTER_FLUSH, /* Removes all filters */
132 };
133 
134 enum ecore_filter_ucast_type {
135 	ECORE_FILTER_MAC,
136 	ECORE_FILTER_VLAN,
137 	ECORE_FILTER_MAC_VLAN,
138 	ECORE_FILTER_INNER_MAC,
139 	ECORE_FILTER_INNER_VLAN,
140 	ECORE_FILTER_INNER_PAIR,
141 	ECORE_FILTER_INNER_MAC_VNI_PAIR,
142 	ECORE_FILTER_MAC_VNI_PAIR,
143 	ECORE_FILTER_VNI,
144 };
145 
146 struct ecore_filter_ucast {
147 	enum ecore_filter_opcode opcode;
148 	enum ecore_filter_ucast_type type;
149 	u8 is_rx_filter;
150 	u8 is_tx_filter;
151 	u8 vport_to_add_to;
152 	u8 vport_to_remove_from;
153 	unsigned char mac[ETH_ALEN];
154 	u8 assert_on_error;
155 	u16 vlan;
156 	u32 vni;
157 };
158 
159 struct ecore_filter_mcast {
160 	/* MOVE is not supported for multicast */
161 	enum ecore_filter_opcode opcode;
162 	u8 vport_to_add_to;
163 	u8 vport_to_remove_from;
164 	u8	num_mc_addrs;
165 #define ECORE_MAX_MC_ADDRS	64
166 	unsigned char mac[ECORE_MAX_MC_ADDRS][ETH_ALEN];
167 };
168 
169 struct ecore_filter_accept_flags {
170 	u8 update_rx_mode_config;
171 	u8 update_tx_mode_config;
172 	u8 rx_accept_filter;
173 	u8 tx_accept_filter;
174 #define	ECORE_ACCEPT_NONE		0x01
175 #define ECORE_ACCEPT_UCAST_MATCHED	0x02
176 #define ECORE_ACCEPT_UCAST_UNMATCHED	0x04
177 #define ECORE_ACCEPT_MCAST_MATCHED	0x08
178 #define ECORE_ACCEPT_MCAST_UNMATCHED	0x10
179 #define ECORE_ACCEPT_BCAST		0x20
180 };
181 
182 struct ecore_arfs_config_params {
183 	bool tcp;
184 	bool udp;
185 	bool ipv4;
186 	bool ipv6;
187 	bool arfs_enable;	/* Enable or disable arfs mode */
188 };
189 
190 /* Add / remove / move / remove-all unicast MAC-VLAN filters.
191  * FW will assert in the following cases, so driver should take care...:
192  * 1. Adding a filter to a full table.
193  * 2. Adding a filter which already exists on that vport.
194  * 3. Removing a filter which doesn't exist.
195  */
196 
197 enum _ecore_status_t
198 ecore_filter_ucast_cmd(struct ecore_dev *p_dev,
199 		       struct ecore_filter_ucast *p_filter_cmd,
200 		       enum spq_mode comp_mode,
201 		       struct ecore_spq_comp_cb *p_comp_data);
202 
203 /* Add / remove / move multicast MAC filters. */
204 enum _ecore_status_t
205 ecore_filter_mcast_cmd(struct ecore_dev *p_dev,
206 		       struct ecore_filter_mcast *p_filter_cmd,
207 		       enum spq_mode comp_mode,
208 		       struct ecore_spq_comp_cb *p_comp_data);
209 
210 /* Set "accept" filters */
211 enum _ecore_status_t
212 ecore_filter_accept_cmd(
213 	struct ecore_dev		 *p_dev,
214 	u8				 vport,
215 	struct ecore_filter_accept_flags accept_flags,
216 	u8				 update_accept_any_vlan,
217 	u8				 accept_any_vlan,
218 	enum spq_mode			 comp_mode,
219 	struct ecore_spq_comp_cb	 *p_comp_data);
220 
221 /**
222  * @brief ecore_eth_rx_queue_start - RX Queue Start Ramrod
223  *
224  * This ramrod initializes an RX Queue for a VPort. An Assert is generated if
225  * the VPort ID is not currently initialized.
226  *
227  * @param p_hwfn
228  * @param opaque_fid
229  * @p_params			Inputs; Relative for PF [SB being an exception]
230  * @param bd_max_bytes 		Maximum bytes that can be placed on a BD
231  * @param bd_chain_phys_addr	Physical address of BDs for receive.
232  * @param cqe_pbl_addr		Physical address of the CQE PBL Table.
233  * @param cqe_pbl_size 		Size of the CQE PBL Table
234  * @param p_ret_params		Pointed struct to be filled with outputs.
235  *
236  * @return enum _ecore_status_t
237  */
238 enum _ecore_status_t
239 ecore_eth_rx_queue_start(struct ecore_hwfn *p_hwfn,
240 			 u16 opaque_fid,
241 			 struct ecore_queue_start_common_params *p_params,
242 			 u16 bd_max_bytes,
243 			 dma_addr_t bd_chain_phys_addr,
244 			 dma_addr_t cqe_pbl_addr,
245 			 u16 cqe_pbl_size,
246 			 struct ecore_rxq_start_ret_params *p_ret_params);
247 
248 /**
249  * @brief ecore_eth_rx_queue_stop - This ramrod closes an Rx queue
250  *
251  * @param p_hwfn
252  * @param p_rxq			Handler of queue to close
253  * @param eq_completion_only	If True completion will be on
254  *				EQe, if False completion will be
255  *				on EQe if p_hwfn opaque
256  *				different from the RXQ opaque
257  *				otherwise on CQe.
258  * @param cqe_completion	If True completion will be
259  *				recieve on CQe.
260  * @return enum _ecore_status_t
261  */
262 enum _ecore_status_t
263 ecore_eth_rx_queue_stop(struct ecore_hwfn *p_hwfn,
264 			void *p_rxq,
265 			bool eq_completion_only,
266 			bool cqe_completion);
267 
268 /**
269  * @brief - TX Queue Start Ramrod
270  *
271  * This ramrod initializes a TX Queue for a VPort. An Assert is generated if
272  * the VPort is not currently initialized.
273  *
274  * @param p_hwfn
275  * @param opaque_fid
276  * @p_params
277  * @param tc			traffic class to use with this L2 txq
278  * @param pbl_addr		address of the pbl array
279  * @param pbl_size 		number of entries in pbl
280  * @oaram p_ret_params		Pointer to fill the return parameters in.
281  *
282  * @return enum _ecore_status_t
283  */
284 enum _ecore_status_t
285 ecore_eth_tx_queue_start(struct ecore_hwfn *p_hwfn,
286 			 u16 opaque_fid,
287 			 struct ecore_queue_start_common_params *p_params,
288 			 u8 tc,
289 			 dma_addr_t pbl_addr,
290 			 u16 pbl_size,
291 			 struct ecore_txq_start_ret_params *p_ret_params);
292 
293 /**
294  * @brief ecore_eth_tx_queue_stop - closes a Tx queue
295  *
296  * @param p_hwfn
297  * @param p_txq - handle to Tx queue needed to be closed
298  *
299  * @return enum _ecore_status_t
300  */
301 enum _ecore_status_t ecore_eth_tx_queue_stop(struct ecore_hwfn *p_hwfn,
302 					     void *p_txq);
303 
304 enum ecore_tpa_mode	{
305 	ECORE_TPA_MODE_NONE,
306 	ECORE_TPA_MODE_RSC,
307 	ECORE_TPA_MODE_GRO,
308 	ECORE_TPA_MODE_MAX
309 };
310 
311 struct ecore_sp_vport_start_params {
312 	enum ecore_tpa_mode tpa_mode;
313 	bool remove_inner_vlan;	/* Inner VLAN removal is enabled */
314 	bool tx_switching;	/* Vport supports tx-switching */
315 	bool handle_ptp_pkts;	/* Handle PTP packets */
316 	bool only_untagged;	/* Untagged pkt control */
317 	bool drop_ttl0;		/* Drop packets with TTL = 0 */
318 	u8 max_buffers_per_cqe;
319 	u32 concrete_fid;
320 	u16 opaque_fid;
321 	u8 vport_id;		/* VPORT ID */
322 	u16 mtu;		/* VPORT MTU */
323 	bool zero_placement_offset;
324 	bool check_mac;
325 	bool check_ethtype;
326 
327 	/* Strict behavior on transmission errors */
328 	bool b_err_illegal_vlan_mode;
329 	bool b_err_illegal_inband_mode;
330 	bool b_err_vlan_insert_with_inband;
331 	bool b_err_small_pkt;
332 	bool b_err_big_pkt;
333 	bool b_err_anti_spoof;
334 	bool b_err_ctrl_frame;
335 };
336 
337 /**
338  * @brief ecore_sp_vport_start -
339  *
340  * This ramrod initializes a VPort. An Assert if generated if the Function ID
341  * of the VPort is not enabled.
342  *
343  * @param p_hwfn
344  * @param p_params		VPORT start params
345  *
346  * @return enum _ecore_status_t
347  */
348 enum _ecore_status_t
349 ecore_sp_vport_start(struct ecore_hwfn *p_hwfn,
350 		     struct ecore_sp_vport_start_params *p_params);
351 
352 struct ecore_sp_vport_update_params {
353 	u16			opaque_fid;
354 	u8			vport_id;
355 	u8			update_vport_active_rx_flg;
356 	u8			vport_active_rx_flg;
357 	u8			update_vport_active_tx_flg;
358 	u8			vport_active_tx_flg;
359 	u8			update_inner_vlan_removal_flg;
360 	u8			inner_vlan_removal_flg;
361 	u8			silent_vlan_removal_flg;
362 	u8			update_default_vlan_enable_flg;
363 	u8			default_vlan_enable_flg;
364 	u8			update_default_vlan_flg;
365 	u16			default_vlan;
366 	u8			update_tx_switching_flg;
367 	u8			tx_switching_flg;
368 	u8			update_approx_mcast_flg;
369 	u8			update_anti_spoofing_en_flg;
370 	u8			anti_spoofing_en;
371 	u8			update_accept_any_vlan_flg;
372 	u8			accept_any_vlan;
373 	unsigned long		bins[8];
374 	struct ecore_rss_params	*rss_params;
375 	struct ecore_filter_accept_flags accept_flags;
376 	struct ecore_sge_tpa_params *sge_tpa_params;
377 };
378 
379 /**
380  * @brief ecore_sp_vport_update -
381  *
382  * This ramrod updates the parameters of the VPort. Every field can be updated
383  * independently, according to flags.
384  *
385  * This ramrod is also used to set the VPort state to active after creation.
386  * An Assert is generated if the VPort does not contain an RX queue.
387  *
388  * @param p_hwfn
389  * @param p_params
390  *
391  * @return enum _ecore_status_t
392  */
393 enum _ecore_status_t
394 ecore_sp_vport_update(struct ecore_hwfn *p_hwfn,
395 		      struct ecore_sp_vport_update_params *p_params,
396 		      enum spq_mode comp_mode,
397 		      struct ecore_spq_comp_cb *p_comp_data);
398 /**
399  * @brief ecore_sp_vport_stop -
400  *
401  * This ramrod closes a VPort after all its RX and TX queues are terminated.
402  * An Assert is generated if any queues are left open.
403  *
404  * @param p_hwfn
405  * @param opaque_fid
406  * @param vport_id VPort ID
407  *
408  * @return enum _ecore_status_t
409  */
410 enum _ecore_status_t ecore_sp_vport_stop(struct ecore_hwfn *p_hwfn,
411 					 u16 opaque_fid,
412 					 u8 vport_id);
413 
414 enum _ecore_status_t
415 ecore_sp_eth_filter_ucast(struct ecore_hwfn *p_hwfn,
416 			  u16 opaque_fid,
417 			  struct ecore_filter_ucast *p_filter_cmd,
418 			  enum spq_mode comp_mode,
419 			  struct ecore_spq_comp_cb *p_comp_data);
420 
421 /**
422  * @brief ecore_sp_rx_eth_queues_update -
423  *
424  * This ramrod updates an RX queue. It is used for setting the active state
425  * of the queue and updating the TPA and SGE parameters.
426  *
427  * @note Final phase API.
428  *
429  * @param p_hwfn
430  * @param pp_rxq_handlers	An array of queue handlers to be updated.
431  * @param num_rxqs              number of queues to update.
432  * @param complete_cqe_flg	Post completion to the CQE Ring if set
433  * @param complete_event_flg	Post completion to the Event Ring if set
434  * @param comp_mode
435  * @param p_comp_data
436  *
437  * @return enum _ecore_status_t
438  */
439 
440 enum _ecore_status_t
441 ecore_sp_eth_rx_queues_update(struct ecore_hwfn *p_hwfn,
442 			      void **pp_rxq_handlers,
443 			      u8 num_rxqs,
444 			      u8 complete_cqe_flg,
445 			      u8 complete_event_flg,
446 			      enum spq_mode comp_mode,
447 			      struct ecore_spq_comp_cb *p_comp_data);
448 
449 void __ecore_get_vport_stats(struct ecore_hwfn *p_hwfn,
450 			     struct ecore_ptt *p_ptt,
451 			     struct ecore_eth_stats *stats,
452 			     u16 statistics_bin, bool b_get_port_stats);
453 
454 void ecore_get_vport_stats(struct ecore_dev *p_dev,
455 			   struct ecore_eth_stats *stats);
456 
457 void ecore_reset_vport_stats(struct ecore_dev *p_dev);
458 
459 /**
460  *@brief ecore_arfs_mode_configure -
461  *
462  *Enable or disable rfs mode. It must accept atleast one of tcp or udp true
463  *and atleast one of ipv4 or ipv6 true to enable rfs mode.
464  *
465  *@param p_hwfn
466  *@param p_ptt
467  *@param p_cfg_params		arfs mode configuration parameters.
468  *
469  */
470 void ecore_arfs_mode_configure(struct ecore_hwfn *p_hwfn,
471 			       struct ecore_ptt *p_ptt,
472 			       struct ecore_arfs_config_params *p_cfg_params);
473 #endif
474