xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/freescale/dpaa2/dpni.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
2*4882a593Smuzhiyun /* Copyright 2013-2016 Freescale Semiconductor Inc.
3*4882a593Smuzhiyun  * Copyright 2016 NXP
4*4882a593Smuzhiyun  * Copyright 2020 NXP
5*4882a593Smuzhiyun  */
6*4882a593Smuzhiyun #ifndef __FSL_DPNI_H
7*4882a593Smuzhiyun #define __FSL_DPNI_H
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include "dpkg.h"
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun struct fsl_mc_io;
12*4882a593Smuzhiyun 
13*4882a593Smuzhiyun /**
14*4882a593Smuzhiyun  * Data Path Network Interface API
15*4882a593Smuzhiyun  * Contains initialization APIs and runtime control APIs for DPNI
16*4882a593Smuzhiyun  */
17*4882a593Smuzhiyun 
18*4882a593Smuzhiyun /** General DPNI macros */
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /**
21*4882a593Smuzhiyun  * Maximum number of traffic classes
22*4882a593Smuzhiyun  */
23*4882a593Smuzhiyun #define DPNI_MAX_TC				8
24*4882a593Smuzhiyun /**
25*4882a593Smuzhiyun  * Maximum number of buffer pools per DPNI
26*4882a593Smuzhiyun  */
27*4882a593Smuzhiyun #define DPNI_MAX_DPBP				8
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun /**
30*4882a593Smuzhiyun  * All traffic classes considered; see dpni_set_queue()
31*4882a593Smuzhiyun  */
32*4882a593Smuzhiyun #define DPNI_ALL_TCS				(u8)(-1)
33*4882a593Smuzhiyun /**
34*4882a593Smuzhiyun  * All flows within traffic class considered; see dpni_set_queue()
35*4882a593Smuzhiyun  */
36*4882a593Smuzhiyun #define DPNI_ALL_TC_FLOWS			(u16)(-1)
37*4882a593Smuzhiyun /**
38*4882a593Smuzhiyun  * Generate new flow ID; see dpni_set_queue()
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun #define DPNI_NEW_FLOW_ID			(u16)(-1)
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun /**
43*4882a593Smuzhiyun  * Tx traffic is always released to a buffer pool on transmit, there are no
44*4882a593Smuzhiyun  * resources allocated to have the frames confirmed back to the source after
45*4882a593Smuzhiyun  * transmission.
46*4882a593Smuzhiyun  */
47*4882a593Smuzhiyun #define DPNI_OPT_TX_FRM_RELEASE			0x000001
48*4882a593Smuzhiyun /**
49*4882a593Smuzhiyun  * Disables support for MAC address filtering for addresses other than primary
50*4882a593Smuzhiyun  * MAC address. This affects both unicast and multicast. Promiscuous mode can
51*4882a593Smuzhiyun  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
52*4882a593Smuzhiyun  * is disabled, only traffic matching the primary MAC address will be accepted.
53*4882a593Smuzhiyun  */
54*4882a593Smuzhiyun #define DPNI_OPT_NO_MAC_FILTER			0x000002
55*4882a593Smuzhiyun /**
56*4882a593Smuzhiyun  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
57*4882a593Smuzhiyun  * traffic class (TC) basis.
58*4882a593Smuzhiyun  */
59*4882a593Smuzhiyun #define DPNI_OPT_HAS_POLICING			0x000004
60*4882a593Smuzhiyun /**
61*4882a593Smuzhiyun  * Congestion can be managed in several ways, allowing the buffer pool to
62*4882a593Smuzhiyun  * deplete on ingress, taildrop on each queue or use congestion groups for sets
63*4882a593Smuzhiyun  * of queues. If set, it configures a single congestion groups across all TCs.
64*4882a593Smuzhiyun  * If reset, a congestion group is allocated for each TC. Only relevant if the
65*4882a593Smuzhiyun  * DPNI has multiple traffic classes.
66*4882a593Smuzhiyun  */
67*4882a593Smuzhiyun #define DPNI_OPT_SHARED_CONGESTION		0x000008
68*4882a593Smuzhiyun /**
69*4882a593Smuzhiyun  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
70*4882a593Smuzhiyun  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
71*4882a593Smuzhiyun  * variants. Setting this bit on these SoCs will trigger an error.
72*4882a593Smuzhiyun  */
73*4882a593Smuzhiyun #define DPNI_OPT_HAS_KEY_MASKING		0x000010
74*4882a593Smuzhiyun /**
75*4882a593Smuzhiyun  * Disables the flow steering table.
76*4882a593Smuzhiyun  */
77*4882a593Smuzhiyun #define DPNI_OPT_NO_FS				0x000020
78*4882a593Smuzhiyun /**
79*4882a593Smuzhiyun  * Flow steering table is shared between all traffic classes
80*4882a593Smuzhiyun  */
81*4882a593Smuzhiyun #define DPNI_OPT_SHARED_FS			0x001000
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun int dpni_open(struct fsl_mc_io	*mc_io,
84*4882a593Smuzhiyun 	      u32		cmd_flags,
85*4882a593Smuzhiyun 	      int		dpni_id,
86*4882a593Smuzhiyun 	      u16		*token);
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun int dpni_close(struct fsl_mc_io	*mc_io,
89*4882a593Smuzhiyun 	       u32		cmd_flags,
90*4882a593Smuzhiyun 	       u16		token);
91*4882a593Smuzhiyun 
92*4882a593Smuzhiyun /**
93*4882a593Smuzhiyun  * struct dpni_pools_cfg - Structure representing buffer pools configuration
94*4882a593Smuzhiyun  * @num_dpbp: Number of DPBPs
95*4882a593Smuzhiyun  * @pools: Array of buffer pools parameters; The number of valid entries
96*4882a593Smuzhiyun  *	must match 'num_dpbp' value
97*4882a593Smuzhiyun  * @pools.dpbp_id: DPBP object ID
98*4882a593Smuzhiyun  * @pools.buffer_size: Buffer size
99*4882a593Smuzhiyun  * @pools.backup_pool: Backup pool
100*4882a593Smuzhiyun  */
101*4882a593Smuzhiyun struct dpni_pools_cfg {
102*4882a593Smuzhiyun 	u8		num_dpbp;
103*4882a593Smuzhiyun 	struct {
104*4882a593Smuzhiyun 		int	dpbp_id;
105*4882a593Smuzhiyun 		u16	buffer_size;
106*4882a593Smuzhiyun 		int	backup_pool;
107*4882a593Smuzhiyun 	} pools[DPNI_MAX_DPBP];
108*4882a593Smuzhiyun };
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun int dpni_set_pools(struct fsl_mc_io		*mc_io,
111*4882a593Smuzhiyun 		   u32				cmd_flags,
112*4882a593Smuzhiyun 		   u16				token,
113*4882a593Smuzhiyun 		   const struct dpni_pools_cfg	*cfg);
114*4882a593Smuzhiyun 
115*4882a593Smuzhiyun int dpni_enable(struct fsl_mc_io	*mc_io,
116*4882a593Smuzhiyun 		u32			cmd_flags,
117*4882a593Smuzhiyun 		u16			token);
118*4882a593Smuzhiyun 
119*4882a593Smuzhiyun int dpni_disable(struct fsl_mc_io	*mc_io,
120*4882a593Smuzhiyun 		 u32			cmd_flags,
121*4882a593Smuzhiyun 		 u16			token);
122*4882a593Smuzhiyun 
123*4882a593Smuzhiyun int dpni_is_enabled(struct fsl_mc_io	*mc_io,
124*4882a593Smuzhiyun 		    u32			cmd_flags,
125*4882a593Smuzhiyun 		    u16			token,
126*4882a593Smuzhiyun 		    int			*en);
127*4882a593Smuzhiyun 
128*4882a593Smuzhiyun int dpni_reset(struct fsl_mc_io	*mc_io,
129*4882a593Smuzhiyun 	       u32		cmd_flags,
130*4882a593Smuzhiyun 	       u16		token);
131*4882a593Smuzhiyun 
132*4882a593Smuzhiyun /**
133*4882a593Smuzhiyun  * DPNI IRQ Index and Events
134*4882a593Smuzhiyun  */
135*4882a593Smuzhiyun 
136*4882a593Smuzhiyun /**
137*4882a593Smuzhiyun  * IRQ index
138*4882a593Smuzhiyun  */
139*4882a593Smuzhiyun #define DPNI_IRQ_INDEX				0
140*4882a593Smuzhiyun /**
141*4882a593Smuzhiyun  * IRQ events:
142*4882a593Smuzhiyun  *       indicates a change in link state
143*4882a593Smuzhiyun  *       indicates a change in endpoint
144*4882a593Smuzhiyun  */
145*4882a593Smuzhiyun #define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
146*4882a593Smuzhiyun #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED		0x00000002
147*4882a593Smuzhiyun 
148*4882a593Smuzhiyun int dpni_set_irq_enable(struct fsl_mc_io	*mc_io,
149*4882a593Smuzhiyun 			u32			cmd_flags,
150*4882a593Smuzhiyun 			u16			token,
151*4882a593Smuzhiyun 			u8			irq_index,
152*4882a593Smuzhiyun 			u8			en);
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun int dpni_get_irq_enable(struct fsl_mc_io	*mc_io,
155*4882a593Smuzhiyun 			u32			cmd_flags,
156*4882a593Smuzhiyun 			u16			token,
157*4882a593Smuzhiyun 			u8			irq_index,
158*4882a593Smuzhiyun 			u8			*en);
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun int dpni_set_irq_mask(struct fsl_mc_io	*mc_io,
161*4882a593Smuzhiyun 		      u32		cmd_flags,
162*4882a593Smuzhiyun 		      u16		token,
163*4882a593Smuzhiyun 		      u8		irq_index,
164*4882a593Smuzhiyun 		      u32		mask);
165*4882a593Smuzhiyun 
166*4882a593Smuzhiyun int dpni_get_irq_mask(struct fsl_mc_io	*mc_io,
167*4882a593Smuzhiyun 		      u32		cmd_flags,
168*4882a593Smuzhiyun 		      u16		token,
169*4882a593Smuzhiyun 		      u8		irq_index,
170*4882a593Smuzhiyun 		      u32		*mask);
171*4882a593Smuzhiyun 
172*4882a593Smuzhiyun int dpni_get_irq_status(struct fsl_mc_io	*mc_io,
173*4882a593Smuzhiyun 			u32			cmd_flags,
174*4882a593Smuzhiyun 			u16			token,
175*4882a593Smuzhiyun 			u8			irq_index,
176*4882a593Smuzhiyun 			u32			*status);
177*4882a593Smuzhiyun 
178*4882a593Smuzhiyun int dpni_clear_irq_status(struct fsl_mc_io	*mc_io,
179*4882a593Smuzhiyun 			  u32			cmd_flags,
180*4882a593Smuzhiyun 			  u16			token,
181*4882a593Smuzhiyun 			  u8			irq_index,
182*4882a593Smuzhiyun 			  u32			status);
183*4882a593Smuzhiyun 
184*4882a593Smuzhiyun /**
185*4882a593Smuzhiyun  * struct dpni_attr - Structure representing DPNI attributes
186*4882a593Smuzhiyun  * @options: Any combination of the following options:
187*4882a593Smuzhiyun  *		DPNI_OPT_TX_FRM_RELEASE
188*4882a593Smuzhiyun  *		DPNI_OPT_NO_MAC_FILTER
189*4882a593Smuzhiyun  *		DPNI_OPT_HAS_POLICING
190*4882a593Smuzhiyun  *		DPNI_OPT_SHARED_CONGESTION
191*4882a593Smuzhiyun  *		DPNI_OPT_HAS_KEY_MASKING
192*4882a593Smuzhiyun  *		DPNI_OPT_NO_FS
193*4882a593Smuzhiyun  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
194*4882a593Smuzhiyun  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
195*4882a593Smuzhiyun  * @mac_filter_entries: Number of entries in the MAC address filtering table.
196*4882a593Smuzhiyun  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
197*4882a593Smuzhiyun  * @qos_entries: Number of entries in the QoS classification table.
198*4882a593Smuzhiyun  * @fs_entries: Number of entries in the flow steering table.
199*4882a593Smuzhiyun  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
200*4882a593Smuzhiyun  *		than this when adding QoS entries will result in an error.
201*4882a593Smuzhiyun  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
202*4882a593Smuzhiyun  *		key larger than this when composing the hash + FS key will
203*4882a593Smuzhiyun  *		result in an error.
204*4882a593Smuzhiyun  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
205*4882a593Smuzhiyun  *		on 6, 5, 5 bits respectively.
206*4882a593Smuzhiyun  */
207*4882a593Smuzhiyun struct dpni_attr {
208*4882a593Smuzhiyun 	u32 options;
209*4882a593Smuzhiyun 	u8 num_queues;
210*4882a593Smuzhiyun 	u8 num_tcs;
211*4882a593Smuzhiyun 	u8 mac_filter_entries;
212*4882a593Smuzhiyun 	u8 vlan_filter_entries;
213*4882a593Smuzhiyun 	u8 qos_entries;
214*4882a593Smuzhiyun 	u16 fs_entries;
215*4882a593Smuzhiyun 	u8 qos_key_size;
216*4882a593Smuzhiyun 	u8 fs_key_size;
217*4882a593Smuzhiyun 	u16 wriop_version;
218*4882a593Smuzhiyun };
219*4882a593Smuzhiyun 
220*4882a593Smuzhiyun int dpni_get_attributes(struct fsl_mc_io	*mc_io,
221*4882a593Smuzhiyun 			u32			cmd_flags,
222*4882a593Smuzhiyun 			u16			token,
223*4882a593Smuzhiyun 			struct dpni_attr	*attr);
224*4882a593Smuzhiyun 
225*4882a593Smuzhiyun /**
226*4882a593Smuzhiyun  * DPNI errors
227*4882a593Smuzhiyun  */
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun /**
230*4882a593Smuzhiyun  * Extract out of frame header error
231*4882a593Smuzhiyun  */
232*4882a593Smuzhiyun #define DPNI_ERROR_EOFHE	0x00020000
233*4882a593Smuzhiyun /**
234*4882a593Smuzhiyun  * Frame length error
235*4882a593Smuzhiyun  */
236*4882a593Smuzhiyun #define DPNI_ERROR_FLE		0x00002000
237*4882a593Smuzhiyun /**
238*4882a593Smuzhiyun  * Frame physical error
239*4882a593Smuzhiyun  */
240*4882a593Smuzhiyun #define DPNI_ERROR_FPE		0x00001000
241*4882a593Smuzhiyun /**
242*4882a593Smuzhiyun  * Parsing header error
243*4882a593Smuzhiyun  */
244*4882a593Smuzhiyun #define DPNI_ERROR_PHE		0x00000020
245*4882a593Smuzhiyun /**
246*4882a593Smuzhiyun  * Parser L3 checksum error
247*4882a593Smuzhiyun  */
248*4882a593Smuzhiyun #define DPNI_ERROR_L3CE		0x00000004
249*4882a593Smuzhiyun /**
250*4882a593Smuzhiyun  * Parser L3 checksum error
251*4882a593Smuzhiyun  */
252*4882a593Smuzhiyun #define DPNI_ERROR_L4CE		0x00000001
253*4882a593Smuzhiyun 
254*4882a593Smuzhiyun /**
255*4882a593Smuzhiyun  * enum dpni_error_action - Defines DPNI behavior for errors
256*4882a593Smuzhiyun  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
257*4882a593Smuzhiyun  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
258*4882a593Smuzhiyun  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
259*4882a593Smuzhiyun  */
260*4882a593Smuzhiyun enum dpni_error_action {
261*4882a593Smuzhiyun 	DPNI_ERROR_ACTION_DISCARD = 0,
262*4882a593Smuzhiyun 	DPNI_ERROR_ACTION_CONTINUE = 1,
263*4882a593Smuzhiyun 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
264*4882a593Smuzhiyun };
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun /**
267*4882a593Smuzhiyun  * struct dpni_error_cfg - Structure representing DPNI errors treatment
268*4882a593Smuzhiyun  * @errors: Errors mask; use 'DPNI_ERROR__<X>
269*4882a593Smuzhiyun  * @error_action: The desired action for the errors mask
270*4882a593Smuzhiyun  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
271*4882a593Smuzhiyun  *		status (FAS); relevant only for the non-discard action
272*4882a593Smuzhiyun  */
273*4882a593Smuzhiyun struct dpni_error_cfg {
274*4882a593Smuzhiyun 	u32			errors;
275*4882a593Smuzhiyun 	enum dpni_error_action	error_action;
276*4882a593Smuzhiyun 	int			set_frame_annotation;
277*4882a593Smuzhiyun };
278*4882a593Smuzhiyun 
279*4882a593Smuzhiyun int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
280*4882a593Smuzhiyun 			     u32			cmd_flags,
281*4882a593Smuzhiyun 			     u16			token,
282*4882a593Smuzhiyun 			     struct dpni_error_cfg	*cfg);
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun /**
285*4882a593Smuzhiyun  * DPNI buffer layout modification options
286*4882a593Smuzhiyun  */
287*4882a593Smuzhiyun 
288*4882a593Smuzhiyun /**
289*4882a593Smuzhiyun  * Select to modify the time-stamp setting
290*4882a593Smuzhiyun  */
291*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
292*4882a593Smuzhiyun /**
293*4882a593Smuzhiyun  * Select to modify the parser-result setting; not applicable for Tx
294*4882a593Smuzhiyun  */
295*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
296*4882a593Smuzhiyun /**
297*4882a593Smuzhiyun  * Select to modify the frame-status setting
298*4882a593Smuzhiyun  */
299*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
300*4882a593Smuzhiyun /**
301*4882a593Smuzhiyun  * Select to modify the private-data-size setting
302*4882a593Smuzhiyun  */
303*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
304*4882a593Smuzhiyun /**
305*4882a593Smuzhiyun  * Select to modify the data-alignment setting
306*4882a593Smuzhiyun  */
307*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
308*4882a593Smuzhiyun /**
309*4882a593Smuzhiyun  * Select to modify the data-head-room setting
310*4882a593Smuzhiyun  */
311*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
312*4882a593Smuzhiyun /**
313*4882a593Smuzhiyun  * Select to modify the data-tail-room setting
314*4882a593Smuzhiyun  */
315*4882a593Smuzhiyun #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
316*4882a593Smuzhiyun 
317*4882a593Smuzhiyun /**
318*4882a593Smuzhiyun  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
319*4882a593Smuzhiyun  * @options: Flags representing the suggested modifications to the buffer
320*4882a593Smuzhiyun  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
321*4882a593Smuzhiyun  * @pass_timestamp: Pass timestamp value
322*4882a593Smuzhiyun  * @pass_parser_result: Pass parser results
323*4882a593Smuzhiyun  * @pass_frame_status: Pass frame status
324*4882a593Smuzhiyun  * @private_data_size: Size kept for private data (in bytes)
325*4882a593Smuzhiyun  * @data_align: Data alignment
326*4882a593Smuzhiyun  * @data_head_room: Data head room
327*4882a593Smuzhiyun  * @data_tail_room: Data tail room
328*4882a593Smuzhiyun  */
329*4882a593Smuzhiyun struct dpni_buffer_layout {
330*4882a593Smuzhiyun 	u32	options;
331*4882a593Smuzhiyun 	int	pass_timestamp;
332*4882a593Smuzhiyun 	int	pass_parser_result;
333*4882a593Smuzhiyun 	int	pass_frame_status;
334*4882a593Smuzhiyun 	u16	private_data_size;
335*4882a593Smuzhiyun 	u16	data_align;
336*4882a593Smuzhiyun 	u16	data_head_room;
337*4882a593Smuzhiyun 	u16	data_tail_room;
338*4882a593Smuzhiyun };
339*4882a593Smuzhiyun 
340*4882a593Smuzhiyun /**
341*4882a593Smuzhiyun  * enum dpni_queue_type - Identifies a type of queue targeted by the command
342*4882a593Smuzhiyun  * @DPNI_QUEUE_RX: Rx queue
343*4882a593Smuzhiyun  * @DPNI_QUEUE_TX: Tx queue
344*4882a593Smuzhiyun  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
345*4882a593Smuzhiyun  * @DPNI_QUEUE_RX_ERR: Rx error queue
346*4882a593Smuzhiyun  */enum dpni_queue_type {
347*4882a593Smuzhiyun 	DPNI_QUEUE_RX,
348*4882a593Smuzhiyun 	DPNI_QUEUE_TX,
349*4882a593Smuzhiyun 	DPNI_QUEUE_TX_CONFIRM,
350*4882a593Smuzhiyun 	DPNI_QUEUE_RX_ERR,
351*4882a593Smuzhiyun };
352*4882a593Smuzhiyun 
353*4882a593Smuzhiyun int dpni_get_buffer_layout(struct fsl_mc_io		*mc_io,
354*4882a593Smuzhiyun 			   u32				cmd_flags,
355*4882a593Smuzhiyun 			   u16				token,
356*4882a593Smuzhiyun 			   enum dpni_queue_type		qtype,
357*4882a593Smuzhiyun 			   struct dpni_buffer_layout	*layout);
358*4882a593Smuzhiyun 
359*4882a593Smuzhiyun int dpni_set_buffer_layout(struct fsl_mc_io		   *mc_io,
360*4882a593Smuzhiyun 			   u32				   cmd_flags,
361*4882a593Smuzhiyun 			   u16				   token,
362*4882a593Smuzhiyun 			   enum dpni_queue_type		   qtype,
363*4882a593Smuzhiyun 			   const struct dpni_buffer_layout *layout);
364*4882a593Smuzhiyun 
365*4882a593Smuzhiyun /**
366*4882a593Smuzhiyun  * enum dpni_offload - Identifies a type of offload targeted by the command
367*4882a593Smuzhiyun  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
368*4882a593Smuzhiyun  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
369*4882a593Smuzhiyun  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
370*4882a593Smuzhiyun  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
371*4882a593Smuzhiyun  */
372*4882a593Smuzhiyun enum dpni_offload {
373*4882a593Smuzhiyun 	DPNI_OFF_RX_L3_CSUM,
374*4882a593Smuzhiyun 	DPNI_OFF_RX_L4_CSUM,
375*4882a593Smuzhiyun 	DPNI_OFF_TX_L3_CSUM,
376*4882a593Smuzhiyun 	DPNI_OFF_TX_L4_CSUM,
377*4882a593Smuzhiyun };
378*4882a593Smuzhiyun 
379*4882a593Smuzhiyun int dpni_set_offload(struct fsl_mc_io	*mc_io,
380*4882a593Smuzhiyun 		     u32		cmd_flags,
381*4882a593Smuzhiyun 		     u16		token,
382*4882a593Smuzhiyun 		     enum dpni_offload	type,
383*4882a593Smuzhiyun 		     u32		config);
384*4882a593Smuzhiyun 
385*4882a593Smuzhiyun int dpni_get_offload(struct fsl_mc_io	*mc_io,
386*4882a593Smuzhiyun 		     u32		cmd_flags,
387*4882a593Smuzhiyun 		     u16		token,
388*4882a593Smuzhiyun 		     enum dpni_offload	type,
389*4882a593Smuzhiyun 		     u32		*config);
390*4882a593Smuzhiyun 
391*4882a593Smuzhiyun int dpni_get_qdid(struct fsl_mc_io	*mc_io,
392*4882a593Smuzhiyun 		  u32			cmd_flags,
393*4882a593Smuzhiyun 		  u16			token,
394*4882a593Smuzhiyun 		  enum dpni_queue_type	qtype,
395*4882a593Smuzhiyun 		  u16			*qdid);
396*4882a593Smuzhiyun 
397*4882a593Smuzhiyun int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
398*4882a593Smuzhiyun 			    u32			cmd_flags,
399*4882a593Smuzhiyun 			    u16			token,
400*4882a593Smuzhiyun 			    u16			*data_offset);
401*4882a593Smuzhiyun 
402*4882a593Smuzhiyun #define DPNI_STATISTICS_CNT		7
403*4882a593Smuzhiyun 
404*4882a593Smuzhiyun /**
405*4882a593Smuzhiyun  * union dpni_statistics - Union describing the DPNI statistics
406*4882a593Smuzhiyun  * @page_0: Page_0 statistics structure
407*4882a593Smuzhiyun  * @page_0.ingress_all_frames: Ingress frame count
408*4882a593Smuzhiyun  * @page_0.ingress_all_bytes: Ingress byte count
409*4882a593Smuzhiyun  * @page_0.ingress_multicast_frames: Ingress multicast frame count
410*4882a593Smuzhiyun  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
411*4882a593Smuzhiyun  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
412*4882a593Smuzhiyun  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
413*4882a593Smuzhiyun  * @page_1: Page_1 statistics structure
414*4882a593Smuzhiyun  * @page_1.egress_all_frames: Egress frame count
415*4882a593Smuzhiyun  * @page_1.egress_all_bytes: Egress byte count
416*4882a593Smuzhiyun  * @page_1.egress_multicast_frames: Egress multicast frame count
417*4882a593Smuzhiyun  * @page_1.egress_multicast_bytes: Egress multicast byte count
418*4882a593Smuzhiyun  * @page_1.egress_broadcast_frames: Egress broadcast frame count
419*4882a593Smuzhiyun  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
420*4882a593Smuzhiyun  * @page_2: Page_2 statistics structure
421*4882a593Smuzhiyun  * @page_2.ingress_filtered_frames: Ingress filtered frame count
422*4882a593Smuzhiyun  * @page_2.ingress_discarded_frames: Ingress discarded frame count
423*4882a593Smuzhiyun  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
424*4882a593Smuzhiyun  *	lack of buffers
425*4882a593Smuzhiyun  * @page_2.egress_discarded_frames: Egress discarded frame count
426*4882a593Smuzhiyun  * @page_2.egress_confirmed_frames: Egress confirmed frame count
427*4882a593Smuzhiyun  * @page3: Page_3 statistics structure
428*4882a593Smuzhiyun  * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
429*4882a593Smuzhiyun  *	dequeued from egress FQs
430*4882a593Smuzhiyun  * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
431*4882a593Smuzhiyun  *	dequeued from egress FQs
432*4882a593Smuzhiyun  * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
433*4882a593Smuzhiyun  *	egress frames whose enqueue was rejected
434*4882a593Smuzhiyun  * @page_3.egress_reject_frames: Cumulative count of the number of egress
435*4882a593Smuzhiyun  *	frames whose enqueue was rejected
436*4882a593Smuzhiyun  * @page_4: Page_4 statistics structure: congestion points
437*4882a593Smuzhiyun  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
438*4882a593Smuzhiyun  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
439*4882a593Smuzhiyun  * @page_5: Page_5 statistics structure: policer
440*4882a593Smuzhiyun  * @page_5.policer_cnt_red: NUmber of red colored frames
441*4882a593Smuzhiyun  * @page_5.policer_cnt_yellow: number of yellow colored frames
442*4882a593Smuzhiyun  * @page_5.policer_cnt_green: number of green colored frames
443*4882a593Smuzhiyun  * @page_5.policer_cnt_re_red: number of recolored red frames
444*4882a593Smuzhiyun  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
445*4882a593Smuzhiyun  * @page_6: Page_6 statistics structure
446*4882a593Smuzhiyun  * @page_6.tx_pending_frames: total number of frames pending in egress FQs
447*4882a593Smuzhiyun  * @raw: raw statistics structure, used to index counters
448*4882a593Smuzhiyun  */
449*4882a593Smuzhiyun union dpni_statistics {
450*4882a593Smuzhiyun 	struct {
451*4882a593Smuzhiyun 		u64 ingress_all_frames;
452*4882a593Smuzhiyun 		u64 ingress_all_bytes;
453*4882a593Smuzhiyun 		u64 ingress_multicast_frames;
454*4882a593Smuzhiyun 		u64 ingress_multicast_bytes;
455*4882a593Smuzhiyun 		u64 ingress_broadcast_frames;
456*4882a593Smuzhiyun 		u64 ingress_broadcast_bytes;
457*4882a593Smuzhiyun 	} page_0;
458*4882a593Smuzhiyun 	struct {
459*4882a593Smuzhiyun 		u64 egress_all_frames;
460*4882a593Smuzhiyun 		u64 egress_all_bytes;
461*4882a593Smuzhiyun 		u64 egress_multicast_frames;
462*4882a593Smuzhiyun 		u64 egress_multicast_bytes;
463*4882a593Smuzhiyun 		u64 egress_broadcast_frames;
464*4882a593Smuzhiyun 		u64 egress_broadcast_bytes;
465*4882a593Smuzhiyun 	} page_1;
466*4882a593Smuzhiyun 	struct {
467*4882a593Smuzhiyun 		u64 ingress_filtered_frames;
468*4882a593Smuzhiyun 		u64 ingress_discarded_frames;
469*4882a593Smuzhiyun 		u64 ingress_nobuffer_discards;
470*4882a593Smuzhiyun 		u64 egress_discarded_frames;
471*4882a593Smuzhiyun 		u64 egress_confirmed_frames;
472*4882a593Smuzhiyun 	} page_2;
473*4882a593Smuzhiyun 	struct {
474*4882a593Smuzhiyun 		u64 egress_dequeue_bytes;
475*4882a593Smuzhiyun 		u64 egress_dequeue_frames;
476*4882a593Smuzhiyun 		u64 egress_reject_bytes;
477*4882a593Smuzhiyun 		u64 egress_reject_frames;
478*4882a593Smuzhiyun 	} page_3;
479*4882a593Smuzhiyun 	struct {
480*4882a593Smuzhiyun 		u64 cgr_reject_frames;
481*4882a593Smuzhiyun 		u64 cgr_reject_bytes;
482*4882a593Smuzhiyun 	} page_4;
483*4882a593Smuzhiyun 	struct {
484*4882a593Smuzhiyun 		u64 policer_cnt_red;
485*4882a593Smuzhiyun 		u64 policer_cnt_yellow;
486*4882a593Smuzhiyun 		u64 policer_cnt_green;
487*4882a593Smuzhiyun 		u64 policer_cnt_re_red;
488*4882a593Smuzhiyun 		u64 policer_cnt_re_yellow;
489*4882a593Smuzhiyun 	} page_5;
490*4882a593Smuzhiyun 	struct {
491*4882a593Smuzhiyun 		u64 tx_pending_frames;
492*4882a593Smuzhiyun 	} page_6;
493*4882a593Smuzhiyun 	struct {
494*4882a593Smuzhiyun 		u64 counter[DPNI_STATISTICS_CNT];
495*4882a593Smuzhiyun 	} raw;
496*4882a593Smuzhiyun };
497*4882a593Smuzhiyun 
498*4882a593Smuzhiyun int dpni_get_statistics(struct fsl_mc_io	*mc_io,
499*4882a593Smuzhiyun 			u32			cmd_flags,
500*4882a593Smuzhiyun 			u16			token,
501*4882a593Smuzhiyun 			u8			page,
502*4882a593Smuzhiyun 			union dpni_statistics	*stat);
503*4882a593Smuzhiyun 
504*4882a593Smuzhiyun /**
505*4882a593Smuzhiyun  * Enable auto-negotiation
506*4882a593Smuzhiyun  */
507*4882a593Smuzhiyun #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
508*4882a593Smuzhiyun /**
509*4882a593Smuzhiyun  * Enable half-duplex mode
510*4882a593Smuzhiyun  */
511*4882a593Smuzhiyun #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
512*4882a593Smuzhiyun /**
513*4882a593Smuzhiyun  * Enable pause frames
514*4882a593Smuzhiyun  */
515*4882a593Smuzhiyun #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
516*4882a593Smuzhiyun /**
517*4882a593Smuzhiyun  * Enable a-symmetric pause frames
518*4882a593Smuzhiyun  */
519*4882a593Smuzhiyun #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
520*4882a593Smuzhiyun 
521*4882a593Smuzhiyun /**
522*4882a593Smuzhiyun  * Enable priority flow control pause frames
523*4882a593Smuzhiyun  */
524*4882a593Smuzhiyun #define DPNI_LINK_OPT_PFC_PAUSE		0x0000000000000010ULL
525*4882a593Smuzhiyun 
526*4882a593Smuzhiyun /**
527*4882a593Smuzhiyun  * struct - Structure representing DPNI link configuration
528*4882a593Smuzhiyun  * @rate: Rate
529*4882a593Smuzhiyun  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
530*4882a593Smuzhiyun  */
531*4882a593Smuzhiyun struct dpni_link_cfg {
532*4882a593Smuzhiyun 	u32 rate;
533*4882a593Smuzhiyun 	u64 options;
534*4882a593Smuzhiyun };
535*4882a593Smuzhiyun 
536*4882a593Smuzhiyun int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
537*4882a593Smuzhiyun 		      u32				cmd_flags,
538*4882a593Smuzhiyun 		      u16				token,
539*4882a593Smuzhiyun 		      const struct dpni_link_cfg	*cfg);
540*4882a593Smuzhiyun 
541*4882a593Smuzhiyun int dpni_get_link_cfg(struct fsl_mc_io			*mc_io,
542*4882a593Smuzhiyun 		      u32				cmd_flags,
543*4882a593Smuzhiyun 		      u16				token,
544*4882a593Smuzhiyun 		      struct dpni_link_cfg		*cfg);
545*4882a593Smuzhiyun 
546*4882a593Smuzhiyun /**
547*4882a593Smuzhiyun  * struct dpni_link_state - Structure representing DPNI link state
548*4882a593Smuzhiyun  * @rate: Rate
549*4882a593Smuzhiyun  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
550*4882a593Smuzhiyun  * @up: Link state; '0' for down, '1' for up
551*4882a593Smuzhiyun  */
552*4882a593Smuzhiyun struct dpni_link_state {
553*4882a593Smuzhiyun 	u32	rate;
554*4882a593Smuzhiyun 	u64	options;
555*4882a593Smuzhiyun 	int	up;
556*4882a593Smuzhiyun };
557*4882a593Smuzhiyun 
558*4882a593Smuzhiyun int dpni_get_link_state(struct fsl_mc_io	*mc_io,
559*4882a593Smuzhiyun 			u32			cmd_flags,
560*4882a593Smuzhiyun 			u16			token,
561*4882a593Smuzhiyun 			struct dpni_link_state	*state);
562*4882a593Smuzhiyun 
563*4882a593Smuzhiyun int dpni_set_max_frame_length(struct fsl_mc_io	*mc_io,
564*4882a593Smuzhiyun 			      u32		cmd_flags,
565*4882a593Smuzhiyun 			      u16		token,
566*4882a593Smuzhiyun 			      u16		max_frame_length);
567*4882a593Smuzhiyun 
568*4882a593Smuzhiyun int dpni_get_max_frame_length(struct fsl_mc_io	*mc_io,
569*4882a593Smuzhiyun 			      u32		cmd_flags,
570*4882a593Smuzhiyun 			      u16		token,
571*4882a593Smuzhiyun 			      u16		*max_frame_length);
572*4882a593Smuzhiyun 
573*4882a593Smuzhiyun int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
574*4882a593Smuzhiyun 			       u32		cmd_flags,
575*4882a593Smuzhiyun 			       u16		token,
576*4882a593Smuzhiyun 			       int		en);
577*4882a593Smuzhiyun 
578*4882a593Smuzhiyun int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
579*4882a593Smuzhiyun 			       u32		cmd_flags,
580*4882a593Smuzhiyun 			       u16		token,
581*4882a593Smuzhiyun 			       int		*en);
582*4882a593Smuzhiyun 
583*4882a593Smuzhiyun int dpni_set_unicast_promisc(struct fsl_mc_io	*mc_io,
584*4882a593Smuzhiyun 			     u32		cmd_flags,
585*4882a593Smuzhiyun 			     u16		token,
586*4882a593Smuzhiyun 			     int		en);
587*4882a593Smuzhiyun 
588*4882a593Smuzhiyun int dpni_get_unicast_promisc(struct fsl_mc_io	*mc_io,
589*4882a593Smuzhiyun 			     u32		cmd_flags,
590*4882a593Smuzhiyun 			     u16		token,
591*4882a593Smuzhiyun 			     int		*en);
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
594*4882a593Smuzhiyun 			      u32		cmd_flags,
595*4882a593Smuzhiyun 			      u16		token,
596*4882a593Smuzhiyun 			      const u8		mac_addr[6]);
597*4882a593Smuzhiyun 
598*4882a593Smuzhiyun int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
599*4882a593Smuzhiyun 			      u32		cmd_flags,
600*4882a593Smuzhiyun 			      u16		token,
601*4882a593Smuzhiyun 			      u8		mac_addr[6]);
602*4882a593Smuzhiyun 
603*4882a593Smuzhiyun int dpni_get_port_mac_addr(struct fsl_mc_io	*mc_io,
604*4882a593Smuzhiyun 			   u32			cm_flags,
605*4882a593Smuzhiyun 			   u16			token,
606*4882a593Smuzhiyun 			   u8			mac_addr[6]);
607*4882a593Smuzhiyun 
608*4882a593Smuzhiyun int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
609*4882a593Smuzhiyun 		      u32		cmd_flags,
610*4882a593Smuzhiyun 		      u16		token,
611*4882a593Smuzhiyun 		      const u8		mac_addr[6]);
612*4882a593Smuzhiyun 
613*4882a593Smuzhiyun int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
614*4882a593Smuzhiyun 			 u32			cmd_flags,
615*4882a593Smuzhiyun 			 u16			token,
616*4882a593Smuzhiyun 			 const u8		mac_addr[6]);
617*4882a593Smuzhiyun 
618*4882a593Smuzhiyun int dpni_clear_mac_filters(struct fsl_mc_io	*mc_io,
619*4882a593Smuzhiyun 			   u32			cmd_flags,
620*4882a593Smuzhiyun 			   u16			token,
621*4882a593Smuzhiyun 			   int			unicast,
622*4882a593Smuzhiyun 			   int			multicast);
623*4882a593Smuzhiyun 
624*4882a593Smuzhiyun /**
625*4882a593Smuzhiyun  * enum dpni_dist_mode - DPNI distribution mode
626*4882a593Smuzhiyun  * @DPNI_DIST_MODE_NONE: No distribution
627*4882a593Smuzhiyun  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
628*4882a593Smuzhiyun  *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
629*4882a593Smuzhiyun  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
630*4882a593Smuzhiyun  *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
631*4882a593Smuzhiyun  */
632*4882a593Smuzhiyun enum dpni_dist_mode {
633*4882a593Smuzhiyun 	DPNI_DIST_MODE_NONE = 0,
634*4882a593Smuzhiyun 	DPNI_DIST_MODE_HASH = 1,
635*4882a593Smuzhiyun 	DPNI_DIST_MODE_FS = 2
636*4882a593Smuzhiyun };
637*4882a593Smuzhiyun 
638*4882a593Smuzhiyun /**
639*4882a593Smuzhiyun  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
640*4882a593Smuzhiyun  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
641*4882a593Smuzhiyun  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
642*4882a593Smuzhiyun  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
643*4882a593Smuzhiyun  */
644*4882a593Smuzhiyun enum dpni_fs_miss_action {
645*4882a593Smuzhiyun 	DPNI_FS_MISS_DROP = 0,
646*4882a593Smuzhiyun 	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
647*4882a593Smuzhiyun 	DPNI_FS_MISS_HASH = 2
648*4882a593Smuzhiyun };
649*4882a593Smuzhiyun 
650*4882a593Smuzhiyun /**
651*4882a593Smuzhiyun  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
652*4882a593Smuzhiyun  * @miss_action: Miss action selection
653*4882a593Smuzhiyun  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
654*4882a593Smuzhiyun  */
655*4882a593Smuzhiyun struct dpni_fs_tbl_cfg {
656*4882a593Smuzhiyun 	enum dpni_fs_miss_action	miss_action;
657*4882a593Smuzhiyun 	u16				default_flow_id;
658*4882a593Smuzhiyun };
659*4882a593Smuzhiyun 
660*4882a593Smuzhiyun int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
661*4882a593Smuzhiyun 			 u8 *key_cfg_buf);
662*4882a593Smuzhiyun 
663*4882a593Smuzhiyun /**
664*4882a593Smuzhiyun  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
665*4882a593Smuzhiyun  * @dist_size: Set the distribution size;
666*4882a593Smuzhiyun  *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
667*4882a593Smuzhiyun  *	112,128,192,224,256,384,448,512,768,896,1024
668*4882a593Smuzhiyun  * @dist_mode: Distribution mode
669*4882a593Smuzhiyun  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
670*4882a593Smuzhiyun  *		the extractions to be used for the distribution key by calling
671*4882a593Smuzhiyun  *		dpni_prepare_key_cfg() relevant only when
672*4882a593Smuzhiyun  *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
673*4882a593Smuzhiyun  * @fs_cfg: Flow Steering table configuration; only relevant if
674*4882a593Smuzhiyun  *		'dist_mode = DPNI_DIST_MODE_FS'
675*4882a593Smuzhiyun  */
676*4882a593Smuzhiyun struct dpni_rx_tc_dist_cfg {
677*4882a593Smuzhiyun 	u16			dist_size;
678*4882a593Smuzhiyun 	enum dpni_dist_mode	dist_mode;
679*4882a593Smuzhiyun 	u64			key_cfg_iova;
680*4882a593Smuzhiyun 	struct dpni_fs_tbl_cfg	fs_cfg;
681*4882a593Smuzhiyun };
682*4882a593Smuzhiyun 
683*4882a593Smuzhiyun int dpni_set_rx_tc_dist(struct fsl_mc_io			*mc_io,
684*4882a593Smuzhiyun 			u32					cmd_flags,
685*4882a593Smuzhiyun 			u16					token,
686*4882a593Smuzhiyun 			u8					tc_id,
687*4882a593Smuzhiyun 			const struct dpni_rx_tc_dist_cfg	*cfg);
688*4882a593Smuzhiyun 
689*4882a593Smuzhiyun /**
690*4882a593Smuzhiyun  * When used for fs_miss_flow_id in function dpni_set_rx_dist,
691*4882a593Smuzhiyun  * will signal to dpni to drop all unclassified frames
692*4882a593Smuzhiyun  */
693*4882a593Smuzhiyun #define DPNI_FS_MISS_DROP		((uint16_t)-1)
694*4882a593Smuzhiyun 
695*4882a593Smuzhiyun /**
696*4882a593Smuzhiyun  * struct dpni_rx_dist_cfg - Rx distribution configuration
697*4882a593Smuzhiyun  * @dist_size:	distribution size
698*4882a593Smuzhiyun  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
699*4882a593Smuzhiyun  *		the extractions to be used for the distribution key by calling
700*4882a593Smuzhiyun  *		dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
701*4882a593Smuzhiyun  *		it can be '0'
702*4882a593Smuzhiyun  * @enable: enable/disable the distribution.
703*4882a593Smuzhiyun  * @tc: TC id for which distribution is set
704*4882a593Smuzhiyun  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
705*4882a593Smuzhiyun  *		hash is disabled it will be put into this queue id; use
706*4882a593Smuzhiyun  *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
707*4882a593Smuzhiyun  *		used only when flow steering distribution is enabled and hash
708*4882a593Smuzhiyun  *		distribution is disabled
709*4882a593Smuzhiyun  */
710*4882a593Smuzhiyun struct dpni_rx_dist_cfg {
711*4882a593Smuzhiyun 	u16 dist_size;
712*4882a593Smuzhiyun 	u64 key_cfg_iova;
713*4882a593Smuzhiyun 	u8 enable;
714*4882a593Smuzhiyun 	u8 tc;
715*4882a593Smuzhiyun 	u16 fs_miss_flow_id;
716*4882a593Smuzhiyun };
717*4882a593Smuzhiyun 
718*4882a593Smuzhiyun int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
719*4882a593Smuzhiyun 			u32 cmd_flags,
720*4882a593Smuzhiyun 			u16 token,
721*4882a593Smuzhiyun 			const struct dpni_rx_dist_cfg *cfg);
722*4882a593Smuzhiyun 
723*4882a593Smuzhiyun int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
724*4882a593Smuzhiyun 			  u32 cmd_flags,
725*4882a593Smuzhiyun 			  u16 token,
726*4882a593Smuzhiyun 			  const struct dpni_rx_dist_cfg *cfg);
727*4882a593Smuzhiyun 
728*4882a593Smuzhiyun /**
729*4882a593Smuzhiyun  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
730*4882a593Smuzhiyun  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
731*4882a593Smuzhiyun  *		key extractions to be used as the QoS criteria by calling
732*4882a593Smuzhiyun  *		dpkg_prepare_key_cfg()
733*4882a593Smuzhiyun  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
734*4882a593Smuzhiyun  *		'0' to use the 'default_tc' in such cases
735*4882a593Smuzhiyun  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
736*4882a593Smuzhiyun  */
737*4882a593Smuzhiyun struct dpni_qos_tbl_cfg {
738*4882a593Smuzhiyun 	u64 key_cfg_iova;
739*4882a593Smuzhiyun 	int discard_on_miss;
740*4882a593Smuzhiyun 	u8 default_tc;
741*4882a593Smuzhiyun };
742*4882a593Smuzhiyun 
743*4882a593Smuzhiyun int dpni_set_qos_table(struct fsl_mc_io *mc_io,
744*4882a593Smuzhiyun 		       u32 cmd_flags,
745*4882a593Smuzhiyun 		       u16 token,
746*4882a593Smuzhiyun 		       const struct dpni_qos_tbl_cfg *cfg);
747*4882a593Smuzhiyun 
748*4882a593Smuzhiyun /**
749*4882a593Smuzhiyun  * enum dpni_dest - DPNI destination types
750*4882a593Smuzhiyun  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
751*4882a593Smuzhiyun  *		does not generate FQDAN notifications; user is expected to
752*4882a593Smuzhiyun  *		dequeue from the queue based on polling or other user-defined
753*4882a593Smuzhiyun  *		method
754*4882a593Smuzhiyun  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
755*4882a593Smuzhiyun  *		notifications to the specified DPIO; user is expected to dequeue
756*4882a593Smuzhiyun  *		from the queue only after notification is received
757*4882a593Smuzhiyun  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
758*4882a593Smuzhiyun  *		FQDAN notifications, but is connected to the specified DPCON
759*4882a593Smuzhiyun  *		object; user is expected to dequeue from the DPCON channel
760*4882a593Smuzhiyun  */
761*4882a593Smuzhiyun enum dpni_dest {
762*4882a593Smuzhiyun 	DPNI_DEST_NONE = 0,
763*4882a593Smuzhiyun 	DPNI_DEST_DPIO = 1,
764*4882a593Smuzhiyun 	DPNI_DEST_DPCON = 2
765*4882a593Smuzhiyun };
766*4882a593Smuzhiyun 
767*4882a593Smuzhiyun /**
768*4882a593Smuzhiyun  * struct dpni_queue - Queue structure
769*4882a593Smuzhiyun  * @destination - Destination structure
770*4882a593Smuzhiyun  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
771*4882a593Smuzhiyun  *	Identifies either a DPIO or a DPCON object.
772*4882a593Smuzhiyun  *	Not relevant for Tx queues.
773*4882a593Smuzhiyun  * @destination.type:	May be one of the following:
774*4882a593Smuzhiyun  *	0 - No destination, queue can be manually
775*4882a593Smuzhiyun  *		queried, but will not push traffic or
776*4882a593Smuzhiyun  *		notifications to a DPIO;
777*4882a593Smuzhiyun  *	1 - The destination is a DPIO. When traffic
778*4882a593Smuzhiyun  *		becomes available in the queue a FQDAN
779*4882a593Smuzhiyun  *		(FQ data available notification) will be
780*4882a593Smuzhiyun  *		generated to selected DPIO;
781*4882a593Smuzhiyun  *	2 - The destination is a DPCON. The queue is
782*4882a593Smuzhiyun  *		associated with a DPCON object for the
783*4882a593Smuzhiyun  *		purpose of scheduling between multiple
784*4882a593Smuzhiyun  *		queues. The DPCON may be independently
785*4882a593Smuzhiyun  *		configured to generate notifications.
786*4882a593Smuzhiyun  *		Not relevant for Tx queues.
787*4882a593Smuzhiyun  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
788*4882a593Smuzhiyun  *	in a DPIO during dequeue to reduce spread of traffic.
789*4882a593Smuzhiyun  *	Only relevant if queues are
790*4882a593Smuzhiyun  *	not affined to a single DPIO.
791*4882a593Smuzhiyun  * @user_context: User data, presented to the user along with any frames
792*4882a593Smuzhiyun  *	from this queue. Not relevant for Tx queues.
793*4882a593Smuzhiyun  * @flc: FD FLow Context structure
794*4882a593Smuzhiyun  * @flc.value: Default FLC value for traffic dequeued from
795*4882a593Smuzhiyun  *      this queue.  Please check description of FD
796*4882a593Smuzhiyun  *      structure for more information.
797*4882a593Smuzhiyun  *      Note that FLC values set using dpni_add_fs_entry,
798*4882a593Smuzhiyun  *      if any, take precedence over values per queue.
799*4882a593Smuzhiyun  * @flc.stash_control: Boolean, indicates whether the 6 lowest
800*4882a593Smuzhiyun  *      - significant bits are used for stash control.
801*4882a593Smuzhiyun  *      significant bits are used for stash control.  If set, the 6
802*4882a593Smuzhiyun  *      least significant bits in value are interpreted as follows:
803*4882a593Smuzhiyun  *      - bits 0-1: indicates the number of 64 byte units of context
804*4882a593Smuzhiyun  *      that are stashed.  FLC value is interpreted as a memory address
805*4882a593Smuzhiyun  *      in this case, excluding the 6 LS bits.
806*4882a593Smuzhiyun  *      - bits 2-3: indicates the number of 64 byte units of frame
807*4882a593Smuzhiyun  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
808*4882a593Smuzhiyun  *      - bits 4-5: indicates the number of 64 byte units of frame
809*4882a593Smuzhiyun  *      data to be stashed.  Frame data is placed at FD[ADDR] +
810*4882a593Smuzhiyun  *      FD[OFFSET].
811*4882a593Smuzhiyun  *      For more details check the Frame Descriptor section in the
812*4882a593Smuzhiyun  *      hardware documentation.
813*4882a593Smuzhiyun  */
814*4882a593Smuzhiyun struct dpni_queue {
815*4882a593Smuzhiyun 	struct {
816*4882a593Smuzhiyun 		u16 id;
817*4882a593Smuzhiyun 		enum dpni_dest type;
818*4882a593Smuzhiyun 		char hold_active;
819*4882a593Smuzhiyun 		u8 priority;
820*4882a593Smuzhiyun 	} destination;
821*4882a593Smuzhiyun 	u64 user_context;
822*4882a593Smuzhiyun 	struct {
823*4882a593Smuzhiyun 		u64 value;
824*4882a593Smuzhiyun 		char stash_control;
825*4882a593Smuzhiyun 	} flc;
826*4882a593Smuzhiyun };
827*4882a593Smuzhiyun 
828*4882a593Smuzhiyun /**
829*4882a593Smuzhiyun  * struct dpni_queue_id - Queue identification, used for enqueue commands
830*4882a593Smuzhiyun  *			or queue control
831*4882a593Smuzhiyun  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
832*4882a593Smuzhiyun  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
833*4882a593Smuzhiyun  *		for Tx queues.
834*4882a593Smuzhiyun  */
835*4882a593Smuzhiyun struct dpni_queue_id {
836*4882a593Smuzhiyun 	u32 fqid;
837*4882a593Smuzhiyun 	u16 qdbin;
838*4882a593Smuzhiyun };
839*4882a593Smuzhiyun 
840*4882a593Smuzhiyun /**
841*4882a593Smuzhiyun  * Set User Context
842*4882a593Smuzhiyun  */
843*4882a593Smuzhiyun #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
844*4882a593Smuzhiyun #define DPNI_QUEUE_OPT_DEST		0x00000002
845*4882a593Smuzhiyun #define DPNI_QUEUE_OPT_FLC		0x00000004
846*4882a593Smuzhiyun #define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
847*4882a593Smuzhiyun 
848*4882a593Smuzhiyun int dpni_set_queue(struct fsl_mc_io	*mc_io,
849*4882a593Smuzhiyun 		   u32			cmd_flags,
850*4882a593Smuzhiyun 		   u16			token,
851*4882a593Smuzhiyun 		   enum dpni_queue_type	qtype,
852*4882a593Smuzhiyun 		   u8			tc,
853*4882a593Smuzhiyun 		   u8			index,
854*4882a593Smuzhiyun 		   u8			options,
855*4882a593Smuzhiyun 		   const struct dpni_queue *queue);
856*4882a593Smuzhiyun 
857*4882a593Smuzhiyun int dpni_get_queue(struct fsl_mc_io	*mc_io,
858*4882a593Smuzhiyun 		   u32			cmd_flags,
859*4882a593Smuzhiyun 		   u16			token,
860*4882a593Smuzhiyun 		   enum dpni_queue_type	qtype,
861*4882a593Smuzhiyun 		   u8			tc,
862*4882a593Smuzhiyun 		   u8			index,
863*4882a593Smuzhiyun 		   struct dpni_queue	*queue,
864*4882a593Smuzhiyun 		   struct dpni_queue_id	*qid);
865*4882a593Smuzhiyun 
866*4882a593Smuzhiyun /**
867*4882a593Smuzhiyun  * enum dpni_congestion_unit - DPNI congestion units
868*4882a593Smuzhiyun  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
869*4882a593Smuzhiyun  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
870*4882a593Smuzhiyun  */
871*4882a593Smuzhiyun enum dpni_congestion_unit {
872*4882a593Smuzhiyun 	DPNI_CONGESTION_UNIT_BYTES = 0,
873*4882a593Smuzhiyun 	DPNI_CONGESTION_UNIT_FRAMES
874*4882a593Smuzhiyun };
875*4882a593Smuzhiyun 
876*4882a593Smuzhiyun /**
877*4882a593Smuzhiyun  * enum dpni_congestion_point - Structure representing congestion point
878*4882a593Smuzhiyun  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
879*4882a593Smuzhiyun  *		QUEUE_INDEX
880*4882a593Smuzhiyun  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
881*4882a593Smuzhiyun  *		define the DPNI this can be either per TC (default) or per
882*4882a593Smuzhiyun  *		interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
883*4882a593Smuzhiyun  *		QUEUE_INDEX is ignored if this type is used.
884*4882a593Smuzhiyun  */
885*4882a593Smuzhiyun enum dpni_congestion_point {
886*4882a593Smuzhiyun 	DPNI_CP_QUEUE,
887*4882a593Smuzhiyun 	DPNI_CP_GROUP,
888*4882a593Smuzhiyun };
889*4882a593Smuzhiyun 
890*4882a593Smuzhiyun /**
891*4882a593Smuzhiyun  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
892*4882a593Smuzhiyun  * @dest_type:	Destination type
893*4882a593Smuzhiyun  * @dest_id:	Either DPIO ID or DPCON ID, depending on the destination type
894*4882a593Smuzhiyun  * @priority:	Priority selection within the DPIO or DPCON channel; valid
895*4882a593Smuzhiyun  *		values are 0-1 or 0-7, depending on the number of priorities
896*4882a593Smuzhiyun  *		in that channel; not relevant for 'DPNI_DEST_NONE' option
897*4882a593Smuzhiyun  */
898*4882a593Smuzhiyun struct dpni_dest_cfg {
899*4882a593Smuzhiyun 	enum dpni_dest dest_type;
900*4882a593Smuzhiyun 	int dest_id;
901*4882a593Smuzhiyun 	u8 priority;
902*4882a593Smuzhiyun };
903*4882a593Smuzhiyun 
904*4882a593Smuzhiyun /* DPNI congestion options */
905*4882a593Smuzhiyun 
906*4882a593Smuzhiyun /**
907*4882a593Smuzhiyun  * This congestion will trigger flow control or priority flow control.
908*4882a593Smuzhiyun  * This will have effect only if flow control is enabled with
909*4882a593Smuzhiyun  * dpni_set_link_cfg().
910*4882a593Smuzhiyun  */
911*4882a593Smuzhiyun #define DPNI_CONG_OPT_FLOW_CONTROL		0x00000040
912*4882a593Smuzhiyun 
913*4882a593Smuzhiyun /**
914*4882a593Smuzhiyun  * struct dpni_congestion_notification_cfg - congestion notification
915*4882a593Smuzhiyun  *					configuration
916*4882a593Smuzhiyun  * @units: Units type
917*4882a593Smuzhiyun  * @threshold_entry: Above this threshold we enter a congestion state.
918*4882a593Smuzhiyun  *		set it to '0' to disable it
919*4882a593Smuzhiyun  * @threshold_exit: Below this threshold we exit the congestion state.
920*4882a593Smuzhiyun  * @message_ctx: The context that will be part of the CSCN message
921*4882a593Smuzhiyun  * @message_iova: I/O virtual address (must be in DMA-able memory),
922*4882a593Smuzhiyun  *		must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
923*4882a593Smuzhiyun  *		is contained in 'options'
924*4882a593Smuzhiyun  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
925*4882a593Smuzhiyun  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
926*4882a593Smuzhiyun  */
927*4882a593Smuzhiyun 
928*4882a593Smuzhiyun struct dpni_congestion_notification_cfg {
929*4882a593Smuzhiyun 	enum dpni_congestion_unit units;
930*4882a593Smuzhiyun 	u32 threshold_entry;
931*4882a593Smuzhiyun 	u32 threshold_exit;
932*4882a593Smuzhiyun 	u64 message_ctx;
933*4882a593Smuzhiyun 	u64 message_iova;
934*4882a593Smuzhiyun 	struct dpni_dest_cfg dest_cfg;
935*4882a593Smuzhiyun 	u16 notification_mode;
936*4882a593Smuzhiyun };
937*4882a593Smuzhiyun 
938*4882a593Smuzhiyun int dpni_set_congestion_notification(
939*4882a593Smuzhiyun 			struct fsl_mc_io *mc_io,
940*4882a593Smuzhiyun 			u32 cmd_flags,
941*4882a593Smuzhiyun 			u16 token,
942*4882a593Smuzhiyun 			enum dpni_queue_type qtype,
943*4882a593Smuzhiyun 			u8 tc_id,
944*4882a593Smuzhiyun 			const struct dpni_congestion_notification_cfg *cfg);
945*4882a593Smuzhiyun 
946*4882a593Smuzhiyun /**
947*4882a593Smuzhiyun  * struct dpni_taildrop - Structure representing the taildrop
948*4882a593Smuzhiyun  * @enable:	Indicates whether the taildrop is active or not.
949*4882a593Smuzhiyun  * @units:	Indicates the unit of THRESHOLD. Queue taildrop only supports
950*4882a593Smuzhiyun  *		byte units, this field is ignored and assumed = 0 if
951*4882a593Smuzhiyun  *		CONGESTION_POINT is 0.
952*4882a593Smuzhiyun  * @threshold:	Threshold value, in units identified by UNITS field. Value 0
953*4882a593Smuzhiyun  *		cannot be used as a valid taildrop threshold, THRESHOLD must
954*4882a593Smuzhiyun  *		be > 0 if the taildrop is enabled.
955*4882a593Smuzhiyun  */
956*4882a593Smuzhiyun struct dpni_taildrop {
957*4882a593Smuzhiyun 	char enable;
958*4882a593Smuzhiyun 	enum dpni_congestion_unit units;
959*4882a593Smuzhiyun 	u32 threshold;
960*4882a593Smuzhiyun };
961*4882a593Smuzhiyun 
962*4882a593Smuzhiyun int dpni_set_taildrop(struct fsl_mc_io *mc_io,
963*4882a593Smuzhiyun 		      u32 cmd_flags,
964*4882a593Smuzhiyun 		      u16 token,
965*4882a593Smuzhiyun 		      enum dpni_congestion_point cg_point,
966*4882a593Smuzhiyun 		      enum dpni_queue_type q_type,
967*4882a593Smuzhiyun 		      u8 tc,
968*4882a593Smuzhiyun 		      u8 q_index,
969*4882a593Smuzhiyun 		      struct dpni_taildrop *taildrop);
970*4882a593Smuzhiyun 
971*4882a593Smuzhiyun int dpni_get_taildrop(struct fsl_mc_io *mc_io,
972*4882a593Smuzhiyun 		      u32 cmd_flags,
973*4882a593Smuzhiyun 		      u16 token,
974*4882a593Smuzhiyun 		      enum dpni_congestion_point cg_point,
975*4882a593Smuzhiyun 		      enum dpni_queue_type q_type,
976*4882a593Smuzhiyun 		      u8 tc,
977*4882a593Smuzhiyun 		      u8 q_index,
978*4882a593Smuzhiyun 		      struct dpni_taildrop *taildrop);
979*4882a593Smuzhiyun 
980*4882a593Smuzhiyun /**
981*4882a593Smuzhiyun  * struct dpni_rule_cfg - Rule configuration for table lookup
982*4882a593Smuzhiyun  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
983*4882a593Smuzhiyun  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
984*4882a593Smuzhiyun  * @key_size: key and mask size (in bytes)
985*4882a593Smuzhiyun  */
986*4882a593Smuzhiyun struct dpni_rule_cfg {
987*4882a593Smuzhiyun 	u64	key_iova;
988*4882a593Smuzhiyun 	u64	mask_iova;
989*4882a593Smuzhiyun 	u8	key_size;
990*4882a593Smuzhiyun };
991*4882a593Smuzhiyun 
992*4882a593Smuzhiyun /**
993*4882a593Smuzhiyun  * Discard matching traffic. If set, this takes precedence over any other
994*4882a593Smuzhiyun  * configuration and matching traffic is always discarded.
995*4882a593Smuzhiyun  */
996*4882a593Smuzhiyun  #define DPNI_FS_OPT_DISCARD            0x1
997*4882a593Smuzhiyun 
998*4882a593Smuzhiyun /**
999*4882a593Smuzhiyun  * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
1000*4882a593Smuzhiyun  * override the FLC value set per queue.
1001*4882a593Smuzhiyun  * For more details check the Frame Descriptor section in the hardware
1002*4882a593Smuzhiyun  * documentation.
1003*4882a593Smuzhiyun  */
1004*4882a593Smuzhiyun #define DPNI_FS_OPT_SET_FLC            0x2
1005*4882a593Smuzhiyun 
1006*4882a593Smuzhiyun /**
1007*4882a593Smuzhiyun  * Indicates whether the 6 lowest significant bits of FLC are used for stash
1008*4882a593Smuzhiyun  * control. If set, the 6 least significant bits in value are interpreted as
1009*4882a593Smuzhiyun  * follows:
1010*4882a593Smuzhiyun  *     - bits 0-1: indicates the number of 64 byte units of context that are
1011*4882a593Smuzhiyun  *     stashed. FLC value is interpreted as a memory address in this case,
1012*4882a593Smuzhiyun  *     excluding the 6 LS bits.
1013*4882a593Smuzhiyun  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1014*4882a593Smuzhiyun  *     to be stashed. Annotation is placed at FD[ADDR].
1015*4882a593Smuzhiyun  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1016*4882a593Smuzhiyun  *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1017*4882a593Smuzhiyun  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1018*4882a593Smuzhiyun  */
1019*4882a593Smuzhiyun #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1020*4882a593Smuzhiyun 
1021*4882a593Smuzhiyun /**
1022*4882a593Smuzhiyun  * struct dpni_fs_action_cfg - Action configuration for table look-up
1023*4882a593Smuzhiyun  * @flc:	FLC value for traffic matching this rule. Please check the
1024*4882a593Smuzhiyun  *		Frame Descriptor section in the hardware documentation for
1025*4882a593Smuzhiyun  *		more information.
1026*4882a593Smuzhiyun  * @flow_id:	Identifies the Rx queue used for matching traffic. Supported
1027*4882a593Smuzhiyun  *		values are in range 0 to num_queue-1.
1028*4882a593Smuzhiyun  * @options:	Any combination of DPNI_FS_OPT_ values.
1029*4882a593Smuzhiyun  */
1030*4882a593Smuzhiyun struct dpni_fs_action_cfg {
1031*4882a593Smuzhiyun 	u64 flc;
1032*4882a593Smuzhiyun 	u16 flow_id;
1033*4882a593Smuzhiyun 	u16 options;
1034*4882a593Smuzhiyun };
1035*4882a593Smuzhiyun 
1036*4882a593Smuzhiyun int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1037*4882a593Smuzhiyun 		      u32 cmd_flags,
1038*4882a593Smuzhiyun 		      u16 token,
1039*4882a593Smuzhiyun 		      u8 tc_id,
1040*4882a593Smuzhiyun 		      u16 index,
1041*4882a593Smuzhiyun 		      const struct dpni_rule_cfg *cfg,
1042*4882a593Smuzhiyun 		      const struct dpni_fs_action_cfg *action);
1043*4882a593Smuzhiyun 
1044*4882a593Smuzhiyun int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1045*4882a593Smuzhiyun 			 u32 cmd_flags,
1046*4882a593Smuzhiyun 			 u16 token,
1047*4882a593Smuzhiyun 			 u8 tc_id,
1048*4882a593Smuzhiyun 			 const struct dpni_rule_cfg *cfg);
1049*4882a593Smuzhiyun 
1050*4882a593Smuzhiyun int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1051*4882a593Smuzhiyun 		       u32 cmd_flags,
1052*4882a593Smuzhiyun 		       u16 token,
1053*4882a593Smuzhiyun 		       const struct dpni_rule_cfg *cfg,
1054*4882a593Smuzhiyun 		       u8 tc_id,
1055*4882a593Smuzhiyun 		       u16 index);
1056*4882a593Smuzhiyun 
1057*4882a593Smuzhiyun int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1058*4882a593Smuzhiyun 			  u32 cmd_flags,
1059*4882a593Smuzhiyun 			  u16 token,
1060*4882a593Smuzhiyun 			  const struct dpni_rule_cfg *cfg);
1061*4882a593Smuzhiyun 
1062*4882a593Smuzhiyun int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1063*4882a593Smuzhiyun 			 u32 cmd_flags,
1064*4882a593Smuzhiyun 			 u16 token);
1065*4882a593Smuzhiyun 
1066*4882a593Smuzhiyun int dpni_get_api_version(struct fsl_mc_io *mc_io,
1067*4882a593Smuzhiyun 			 u32 cmd_flags,
1068*4882a593Smuzhiyun 			 u16 *major_ver,
1069*4882a593Smuzhiyun 			 u16 *minor_ver);
1070*4882a593Smuzhiyun /**
1071*4882a593Smuzhiyun  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
1072*4882a593Smuzhiyun  * @rate_limit:		Rate in Mbps
1073*4882a593Smuzhiyun  * @max_burst_size:	Burst size in bytes (up to 64KB)
1074*4882a593Smuzhiyun  */
1075*4882a593Smuzhiyun struct dpni_tx_shaping_cfg {
1076*4882a593Smuzhiyun 	u32 rate_limit;
1077*4882a593Smuzhiyun 	u16 max_burst_size;
1078*4882a593Smuzhiyun };
1079*4882a593Smuzhiyun 
1080*4882a593Smuzhiyun int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
1081*4882a593Smuzhiyun 			u32 cmd_flags,
1082*4882a593Smuzhiyun 			u16 token,
1083*4882a593Smuzhiyun 			const struct dpni_tx_shaping_cfg *tx_cr_shaper,
1084*4882a593Smuzhiyun 			const struct dpni_tx_shaping_cfg *tx_er_shaper,
1085*4882a593Smuzhiyun 			int coupled);
1086*4882a593Smuzhiyun 
1087*4882a593Smuzhiyun /**
1088*4882a593Smuzhiyun  * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
1089*4882a593Smuzhiyun  * @en:		enable single step PTP. When enabled the PTPv1 functionality
1090*4882a593Smuzhiyun  *		will not work. If the field is zero, offset and ch_update
1091*4882a593Smuzhiyun  *		parameters will be ignored
1092*4882a593Smuzhiyun  * @offset:	start offset from the beginning of the frame where
1093*4882a593Smuzhiyun  *		timestamp field is found. The offset must respect all MAC
1094*4882a593Smuzhiyun  *		headers, VLAN tags and other protocol headers
1095*4882a593Smuzhiyun  * @ch_update:	when set UDP checksum will be updated inside packet
1096*4882a593Smuzhiyun  * @peer_delay:	For peer-to-peer transparent clocks add this value to the
1097*4882a593Smuzhiyun  *		correction field in addition to the transient time update.
1098*4882a593Smuzhiyun  *		The value expresses nanoseconds.
1099*4882a593Smuzhiyun  */
1100*4882a593Smuzhiyun struct dpni_single_step_cfg {
1101*4882a593Smuzhiyun 	u8	en;
1102*4882a593Smuzhiyun 	u8	ch_update;
1103*4882a593Smuzhiyun 	u16	offset;
1104*4882a593Smuzhiyun 	u32	peer_delay;
1105*4882a593Smuzhiyun };
1106*4882a593Smuzhiyun 
1107*4882a593Smuzhiyun int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
1108*4882a593Smuzhiyun 			     u32 cmd_flags,
1109*4882a593Smuzhiyun 			     u16 token,
1110*4882a593Smuzhiyun 			     struct dpni_single_step_cfg *ptp_cfg);
1111*4882a593Smuzhiyun 
1112*4882a593Smuzhiyun int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
1113*4882a593Smuzhiyun 			     u32 cmd_flags,
1114*4882a593Smuzhiyun 			     u16 token,
1115*4882a593Smuzhiyun 			     struct dpni_single_step_cfg *ptp_cfg);
1116*4882a593Smuzhiyun 
1117*4882a593Smuzhiyun #endif /* __FSL_DPNI_H */
1118