xref: /dpdk/drivers/net/dpaa2/mc/fsl_dpni.h (revision 591200ef6f32b56adc367ebe3647cc3dbe9362db)
1131a75b6SHemant Agrawal /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2e6b82573SHemant Agrawal  *
3e6b82573SHemant Agrawal  * Copyright 2013-2016 Freescale Semiconductor Inc.
4*591200efSGagandeep Singh  * Copyright 2016-2023 NXP
5e6b82573SHemant Agrawal  *
6e6b82573SHemant Agrawal  */
7e6b82573SHemant Agrawal #ifndef __FSL_DPNI_H
8e6b82573SHemant Agrawal #define __FSL_DPNI_H
9e6b82573SHemant Agrawal 
10e6b82573SHemant Agrawal #include <fsl_dpkg.h>
1125fea082SHemant Agrawal #include <fsl_dpopr.h>
12e6b82573SHemant Agrawal 
13e6b82573SHemant Agrawal struct fsl_mc_io;
14e6b82573SHemant Agrawal 
15e6b82573SHemant Agrawal /**
16e6b82573SHemant Agrawal  * Data Path Network Interface API
17e6b82573SHemant Agrawal  * Contains initialization APIs and runtime control APIs for DPNI
18e6b82573SHemant Agrawal  */
19e6b82573SHemant Agrawal 
20e6b82573SHemant Agrawal /** General DPNI macros */
21e6b82573SHemant Agrawal 
22e6b82573SHemant Agrawal /**
232cb2abf3SHemant Agrawal  * Maximum size of a key
242cb2abf3SHemant Agrawal  */
252cb2abf3SHemant Agrawal #define DPNI_MAX_KEY_SIZE		56
262cb2abf3SHemant Agrawal 
272cb2abf3SHemant Agrawal /**
28e6b82573SHemant Agrawal  * Maximum number of traffic classes
29e6b82573SHemant Agrawal  */
30e6b82573SHemant Agrawal #define DPNI_MAX_TC				8
31e6b82573SHemant Agrawal /**
32e6b82573SHemant Agrawal  * Maximum number of buffer pools per DPNI
33e6b82573SHemant Agrawal  */
34e6b82573SHemant Agrawal #define DPNI_MAX_DPBP				8
35e6b82573SHemant Agrawal /**
36e6b82573SHemant Agrawal  * Maximum number of storage-profiles per DPNI
37e6b82573SHemant Agrawal  */
38e6b82573SHemant Agrawal #define DPNI_MAX_SP				2
39f48cd6c6SNipun Gupta /**
40f48cd6c6SNipun Gupta  * Maximum number of Tx channels per DPNI
41f48cd6c6SNipun Gupta  */
42f48cd6c6SNipun Gupta #define DPNI_MAX_CHANNELS		16
43e6b82573SHemant Agrawal 
44e6b82573SHemant Agrawal /**
45e6b82573SHemant Agrawal  * All traffic classes considered; see dpni_set_queue()
46e6b82573SHemant Agrawal  */
47e6b82573SHemant Agrawal #define DPNI_ALL_TCS				(uint8_t)(-1)
48e6b82573SHemant Agrawal /**
49e6b82573SHemant Agrawal  * All flows within traffic class considered; see dpni_set_queue()
50e6b82573SHemant Agrawal  */
51e6b82573SHemant Agrawal #define DPNI_ALL_TC_FLOWS			(uint16_t)(-1)
527ae777d0SHemant Agrawal 
53e6b82573SHemant Agrawal /**
54e6b82573SHemant Agrawal  * Tx traffic is always released to a buffer pool on transmit, there are no
55e6b82573SHemant Agrawal  * resources allocated to have the frames confirmed back to the source after
56e6b82573SHemant Agrawal  * transmission.
57e6b82573SHemant Agrawal  */
58e6b82573SHemant Agrawal #define DPNI_OPT_TX_FRM_RELEASE			0x000001
59e6b82573SHemant Agrawal /**
60e6b82573SHemant Agrawal  * Disables support for MAC address filtering for addresses other than primary
61e6b82573SHemant Agrawal  * MAC address. This affects both unicast and multicast. Promiscuous mode can
62e6b82573SHemant Agrawal  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
63e6b82573SHemant Agrawal  * is disabled, only traffic matching the primary MAC address will be accepted.
64e6b82573SHemant Agrawal  */
65e6b82573SHemant Agrawal #define DPNI_OPT_NO_MAC_FILTER			0x000002
66e6b82573SHemant Agrawal /**
67e6b82573SHemant Agrawal  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
68e6b82573SHemant Agrawal  * traffic class (TC) basis.
69e6b82573SHemant Agrawal  */
70e6b82573SHemant Agrawal #define DPNI_OPT_HAS_POLICING			0x000004
71e6b82573SHemant Agrawal /**
72e6b82573SHemant Agrawal  * Congestion can be managed in several ways, allowing the buffer pool to
73e6b82573SHemant Agrawal  * deplete on ingress, taildrop on each queue or use congestion groups for sets
74e6b82573SHemant Agrawal  * of queues. If set, it configures a single congestion groups across all TCs.
75e6b82573SHemant Agrawal  * If reset, a congestion group is allocated for each TC. Only relevant if the
76e6b82573SHemant Agrawal  * DPNI has multiple traffic classes.
77e6b82573SHemant Agrawal  */
78e6b82573SHemant Agrawal #define DPNI_OPT_SHARED_CONGESTION		0x000008
79e6b82573SHemant Agrawal /**
80e6b82573SHemant Agrawal  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
81e6b82573SHemant Agrawal  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
82e6b82573SHemant Agrawal  * variants. Setting this bit on these SoCs will trigger an error.
83e6b82573SHemant Agrawal  */
84e6b82573SHemant Agrawal #define DPNI_OPT_HAS_KEY_MASKING		0x000010
85e6b82573SHemant Agrawal /**
86e6b82573SHemant Agrawal  * Disables the flow steering table.
87e6b82573SHemant Agrawal  */
88e6b82573SHemant Agrawal #define DPNI_OPT_NO_FS				0x000020
89e6b82573SHemant Agrawal 
9025fea082SHemant Agrawal /**
9125fea082SHemant Agrawal  * Enable the Order Restoration support
9225fea082SHemant Agrawal  */
9325fea082SHemant Agrawal #define DPNI_OPT_HAS_OPR				0x000040
9425fea082SHemant Agrawal 
9525fea082SHemant Agrawal /**
9625fea082SHemant Agrawal  * Order Point Records are shared for the entire TC
9725fea082SHemant Agrawal  */
9825fea082SHemant Agrawal #define DPNI_OPT_OPR_PER_TC				0x000080
9925fea082SHemant Agrawal /**
1007be78d02SJosh Soref  * All Tx traffic classes will use a single sender (ignore num_queues for tx)
10125fea082SHemant Agrawal  */
10225fea082SHemant Agrawal #define DPNI_OPT_SINGLE_SENDER			0x000100
10355984a9bSShreyansh Jain /**
10455984a9bSShreyansh Jain  * Define a custom number of congestion groups
10555984a9bSShreyansh Jain  */
10655984a9bSShreyansh Jain #define DPNI_OPT_CUSTOM_CG				0x000200
1072cb2abf3SHemant Agrawal /**
1082cb2abf3SHemant Agrawal  * Define a custom number of order point records
1092cb2abf3SHemant Agrawal  */
1102cb2abf3SHemant Agrawal #define DPNI_OPT_CUSTOM_OPR				0x000400
1112cb2abf3SHemant Agrawal /**
1122cb2abf3SHemant Agrawal  * Hash key is shared between all traffic classes
1132cb2abf3SHemant Agrawal  */
1142cb2abf3SHemant Agrawal #define DPNI_OPT_SHARED_HASH_KEY		0x000800
1152cb2abf3SHemant Agrawal /**
1162cb2abf3SHemant Agrawal  * Flow steering table is shared between all traffic classes
1172cb2abf3SHemant Agrawal  */
1182cb2abf3SHemant Agrawal #define DPNI_OPT_SHARED_FS				0x001000
119*591200efSGagandeep Singh /*
120*591200efSGagandeep Singh  * Fq frame data, context and annotations stashing disable.
121*591200efSGagandeep Singh  * The stashing is enabled by default.
122*591200efSGagandeep Singh  */
123*591200efSGagandeep Singh #define DPNI_OPT_STASHING_DIS			0x002000
124a712067dSSunil Kumar Kori /**
125a712067dSSunil Kumar Kori  * Software sequence maximum layout size
126a712067dSSunil Kumar Kori  */
127a712067dSSunil Kumar Kori #define DPNI_SW_SEQUENCE_LAYOUT_SIZE 33
128a712067dSSunil Kumar Kori 
129f48cd6c6SNipun Gupta /**
130f48cd6c6SNipun Gupta  * Build a parameter from dpni channel and trafiic class. This parameter
131f48cd6c6SNipun Gupta  * will be used to configure / query information from dpni objects created
132f48cd6c6SNipun Gupta  * to support multiple channels.
133f48cd6c6SNipun Gupta  */
134f48cd6c6SNipun Gupta #define DPNI_BUILD_PARAM(channel, tc_id)	(((channel) << 8) | (tc_id))
135f48cd6c6SNipun Gupta 
136e6b82573SHemant Agrawal int dpni_open(struct fsl_mc_io *mc_io,
137e6b82573SHemant Agrawal 	      uint32_t cmd_flags,
138e6b82573SHemant Agrawal 	      int dpni_id,
139e6b82573SHemant Agrawal 	      uint16_t *token);
140e6b82573SHemant Agrawal 
141e6b82573SHemant Agrawal int dpni_close(struct fsl_mc_io *mc_io,
142e6b82573SHemant Agrawal 	       uint32_t cmd_flags,
143e6b82573SHemant Agrawal 	       uint16_t token);
144e6b82573SHemant Agrawal 
145e6b82573SHemant Agrawal /**
146e6b82573SHemant Agrawal  * struct dpni_cfg - Structure representing DPNI configuration
147e6b82573SHemant Agrawal  * @options: Any combination of the following options:
148e6b82573SHemant Agrawal  *		DPNI_OPT_TX_FRM_RELEASE
149e6b82573SHemant Agrawal  *		DPNI_OPT_NO_MAC_FILTER
150e6b82573SHemant Agrawal  *		DPNI_OPT_HAS_POLICING
151e6b82573SHemant Agrawal  *		DPNI_OPT_SHARED_CONGESTION
152e6b82573SHemant Agrawal  *		DPNI_OPT_HAS_KEY_MASKING
153e6b82573SHemant Agrawal  *		DPNI_OPT_NO_FS
15425fea082SHemant Agrawal  *		DPNI_OPT_SINGLE_SENDER
155*591200efSGagandeep Singh  *		DPNI_OPT_STASHING_DIS
156e6b82573SHemant Agrawal  * @fs_entries: Number of entries in the flow steering table.
157e6b82573SHemant Agrawal  *		This table is used to select the ingress queue for
158e6b82573SHemant Agrawal  *		ingress traffic, targeting a GPP core or another.
159e6b82573SHemant Agrawal  *		In addition it can be used to discard traffic that
160e6b82573SHemant Agrawal  *		matches the set rule. It is either an exact match table
161e6b82573SHemant Agrawal  *		or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
162e6b82573SHemant Agrawal  *		bit in OPTIONS field. This field is ignored if
163e6b82573SHemant Agrawal  *		DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
164e6b82573SHemant Agrawal  *		value 0 defaults to 64. Maximum supported value is 1024.
165e6b82573SHemant Agrawal  *		Note that the total number of entries is limited on the
166e6b82573SHemant Agrawal  *		SoC to as low as 512 entries if TCAM is used.
167e6b82573SHemant Agrawal  * @vlan_filter_entries: Number of entries in the VLAN address filtering
168e6b82573SHemant Agrawal  *		table. This is an exact match table used to filter
169e6b82573SHemant Agrawal  *		ingress traffic based on VLAN IDs. Value 0 disables VLAN
170e6b82573SHemant Agrawal  *		filtering. Maximum supported value is 16.
171e6b82573SHemant Agrawal  * @mac_filter_entries: Number of entries in the MAC address filtering
172e6b82573SHemant Agrawal  *		table. This is an exact match table and allows both
173e6b82573SHemant Agrawal  *		unicast and multicast entries. The primary MAC address
174e6b82573SHemant Agrawal  *		of the network interface is not part of this table,
175e6b82573SHemant Agrawal  *		this contains only entries in addition to it. This
176e6b82573SHemant Agrawal  *		field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
177e6b82573SHemant Agrawal  *		OPTIONS field. Otherwise, value 0 defaults to 80.
178e6b82573SHemant Agrawal  *		Maximum supported value is 80.
179e6b82573SHemant Agrawal  * @num_queues: Number of Tx and Rx queues used for traffic
180e6b82573SHemant Agrawal  *		distribution. This is orthogonal to QoS and is only
181e6b82573SHemant Agrawal  *		used to distribute traffic to multiple GPP cores.
182e6b82573SHemant Agrawal  *		This configuration affects the number of Tx queues
183e6b82573SHemant Agrawal  *		(logical FQs, all associated with a single CEETM queue),
184e6b82573SHemant Agrawal  *		Rx queues and Tx confirmation queues, if applicable.
185e6b82573SHemant Agrawal  *		Value 0 defaults to one queue. Maximum supported value
186e6b82573SHemant Agrawal  *		is 8.
187e6b82573SHemant Agrawal  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
188e6b82573SHemant Agrawal  *		TCs can have different priority levels for the purpose
18925fea082SHemant Agrawal  *		of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
190e6b82573SHemant Agrawal  *		BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
191e6b82573SHemant Agrawal  *		queues for traffic classes (including class queues on
192e6b82573SHemant Agrawal  *		Tx). Value 0 defaults to one TC. Maximum supported value
19325fea082SHemant Agrawal  *		is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
19425fea082SHemant Agrawal  *		When num_tcs>8 Tx will use this value but Rx will have
19525fea082SHemant Agrawal  *		only 8 traffic classes.
19625fea082SHemant Agrawal  * @num_rx_tcs: if set to other value than zero represents number
19725fea082SHemant Agrawal  *		of TCs used for Rx. Maximum value is 8. If set to zero the
19825fea082SHemant Agrawal  *		number of Rx TCs will be initialized with the value provided
19925fea082SHemant Agrawal  *		in num_tcs parameter.
200e6b82573SHemant Agrawal  * @qos_entries: Number of entries in the QoS classification table. This
201e6b82573SHemant Agrawal  *		table is used to select the TC for ingress traffic. It
202e6b82573SHemant Agrawal  *		is either an exact match or a TCAM table, depending on
203e6b82573SHemant Agrawal  *		DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
204e6b82573SHemant Agrawal  *		field is ignored if the DPNI has a single TC. Otherwise,
205e6b82573SHemant Agrawal  *		a value of 0 defaults to 64. Maximum supported value
206e6b82573SHemant Agrawal  *		is 64.
207f48cd6c6SNipun Gupta  * @num_channels: Number of egress channels used by this dpni object. If
208f48cd6c6SNipun Gupta  *		set to zero the dpni object will use a single CEETM channel.
209e6b82573SHemant Agrawal  */
21025fea082SHemant Agrawal struct dpni_cfg {
211e6b82573SHemant Agrawal 	uint32_t options;
212e6b82573SHemant Agrawal 	uint16_t fs_entries;
213e6b82573SHemant Agrawal 	uint8_t  vlan_filter_entries;
214e6b82573SHemant Agrawal 	uint8_t  mac_filter_entries;
215e6b82573SHemant Agrawal 	uint8_t  num_queues;
216e6b82573SHemant Agrawal 	uint8_t  num_tcs;
21725fea082SHemant Agrawal 	uint8_t  num_rx_tcs;
218e6b82573SHemant Agrawal 	uint8_t  qos_entries;
21955984a9bSShreyansh Jain 	uint8_t  num_cgs;
2202cb2abf3SHemant Agrawal 	uint16_t num_opr;
2212cb2abf3SHemant Agrawal 	uint8_t  dist_key_size;
222f48cd6c6SNipun Gupta 	uint8_t  num_channels;
223e6b82573SHemant Agrawal };
224e6b82573SHemant Agrawal 
225e6b82573SHemant Agrawal int dpni_create(struct fsl_mc_io *mc_io,
226e6b82573SHemant Agrawal 		uint16_t dprc_token,
227e6b82573SHemant Agrawal 		uint32_t cmd_flags,
228e6b82573SHemant Agrawal 		const struct dpni_cfg *cfg,
229e6b82573SHemant Agrawal 		uint32_t *obj_id);
230e6b82573SHemant Agrawal 
231e6b82573SHemant Agrawal int dpni_destroy(struct fsl_mc_io *mc_io,
232e6b82573SHemant Agrawal 		 uint16_t dprc_token,
233e6b82573SHemant Agrawal 		 uint32_t cmd_flags,
234e6b82573SHemant Agrawal 		 uint32_t object_id);
235e6b82573SHemant Agrawal 
236e6b82573SHemant Agrawal /**
237e6b82573SHemant Agrawal  * struct dpni_pools_cfg - Structure representing buffer pools configuration
238e6b82573SHemant Agrawal  * @num_dpbp:	Number of DPBPs
23996f7bfe8SSachin Saxena  * @pool_options: Buffer assignment options
24096f7bfe8SSachin Saxena  *                This field is a combination of DPNI_POOL_ASSOC_flags
241e6b82573SHemant Agrawal  * @pools:	Array of buffer pools parameters; The number of valid entries
242e6b82573SHemant Agrawal  *		must match 'num_dpbp' value
24325fea082SHemant Agrawal  * @pools.dpbp_id:     DPBP object ID
24425fea082SHemant Agrawal  * @pools.priority:    Priority mask that indicates TC's used with this buffer.
24525fea082SHemant Agrawal  *		       I set to 0x00 MC will assume value 0xff.
24625fea082SHemant Agrawal  * @pools.buffer_size: Buffer size
24725fea082SHemant Agrawal  * @pools.backup_pool: Backup pool
248e6b82573SHemant Agrawal  */
24996f7bfe8SSachin Saxena 
25096f7bfe8SSachin Saxena #define DPNI_POOL_ASSOC_QPRI	0
25196f7bfe8SSachin Saxena #define DPNI_POOL_ASSOC_QDBIN	1
25296f7bfe8SSachin Saxena 
253e6b82573SHemant Agrawal struct dpni_pools_cfg {
254e6b82573SHemant Agrawal 	uint8_t num_dpbp;
25596f7bfe8SSachin Saxena 	uint8_t pool_options;
256e6b82573SHemant Agrawal 	struct {
257e6b82573SHemant Agrawal 		int		dpbp_id;
25816bbc98aSShreyansh Jain 		uint8_t		priority_mask;
259e6b82573SHemant Agrawal 		uint16_t	buffer_size;
260e6b82573SHemant Agrawal 		int		backup_pool;
261e6b82573SHemant Agrawal 	} pools[DPNI_MAX_DPBP];
262e6b82573SHemant Agrawal };
263e6b82573SHemant Agrawal 
264e6b82573SHemant Agrawal int dpni_set_pools(struct fsl_mc_io *mc_io,
265e6b82573SHemant Agrawal 		   uint32_t cmd_flags,
266e6b82573SHemant Agrawal 		   uint16_t token,
267e6b82573SHemant Agrawal 		   const struct dpni_pools_cfg *cfg);
268e6b82573SHemant Agrawal 
269e6b82573SHemant Agrawal int dpni_enable(struct fsl_mc_io *mc_io,
270e6b82573SHemant Agrawal 		uint32_t cmd_flags,
271e6b82573SHemant Agrawal 		uint16_t token);
272e6b82573SHemant Agrawal 
273e6b82573SHemant Agrawal int dpni_disable(struct fsl_mc_io *mc_io,
274e6b82573SHemant Agrawal 		 uint32_t cmd_flags,
275e6b82573SHemant Agrawal 		 uint16_t token);
276e6b82573SHemant Agrawal 
277e6b82573SHemant Agrawal int dpni_is_enabled(struct fsl_mc_io *mc_io,
278e6b82573SHemant Agrawal 		    uint32_t cmd_flags,
279e6b82573SHemant Agrawal 		    uint16_t token,
280e6b82573SHemant Agrawal 		    int *en);
281e6b82573SHemant Agrawal 
282e6b82573SHemant Agrawal int dpni_reset(struct fsl_mc_io *mc_io,
283e6b82573SHemant Agrawal 	       uint32_t cmd_flags,
284e6b82573SHemant Agrawal 	       uint16_t token);
285e6b82573SHemant Agrawal 
286e6b82573SHemant Agrawal /**
287c5acbb5eSHemant Agrawal  * DPNI IRQ Index and Events
288c5acbb5eSHemant Agrawal  */
289c5acbb5eSHemant Agrawal 
290c5acbb5eSHemant Agrawal /**
291c5acbb5eSHemant Agrawal  * IRQ index
292c5acbb5eSHemant Agrawal  */
293c5acbb5eSHemant Agrawal #define DPNI_IRQ_INDEX				0
294c5acbb5eSHemant Agrawal /**
295c5acbb5eSHemant Agrawal  * IRQ event - indicates a change in link state
296c5acbb5eSHemant Agrawal  */
297c5acbb5eSHemant Agrawal #define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
298c5acbb5eSHemant Agrawal 
299c5acbb5eSHemant Agrawal int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
300c5acbb5eSHemant Agrawal 			uint32_t cmd_flags,
301c5acbb5eSHemant Agrawal 			uint16_t token,
302c5acbb5eSHemant Agrawal 			uint8_t irq_index,
303c5acbb5eSHemant Agrawal 			uint8_t en);
304c5acbb5eSHemant Agrawal 
305c5acbb5eSHemant Agrawal int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
306c5acbb5eSHemant Agrawal 			uint32_t cmd_flags,
307c5acbb5eSHemant Agrawal 			uint16_t token,
308c5acbb5eSHemant Agrawal 			uint8_t irq_index,
309c5acbb5eSHemant Agrawal 			uint8_t *en);
310c5acbb5eSHemant Agrawal 
311c5acbb5eSHemant Agrawal int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
312c5acbb5eSHemant Agrawal 		      uint32_t cmd_flags,
313c5acbb5eSHemant Agrawal 		      uint16_t token,
314c5acbb5eSHemant Agrawal 		      uint8_t irq_index,
315c5acbb5eSHemant Agrawal 		      uint32_t mask);
316c5acbb5eSHemant Agrawal 
317c5acbb5eSHemant Agrawal int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
318c5acbb5eSHemant Agrawal 		      uint32_t cmd_flags,
319c5acbb5eSHemant Agrawal 		      uint16_t token,
320c5acbb5eSHemant Agrawal 		      uint8_t irq_index,
321c5acbb5eSHemant Agrawal 		      uint32_t *mask);
322c5acbb5eSHemant Agrawal 
323c5acbb5eSHemant Agrawal int dpni_get_irq_status(struct fsl_mc_io *mc_io,
324c5acbb5eSHemant Agrawal 			uint32_t cmd_flags,
325c5acbb5eSHemant Agrawal 			uint16_t token,
326c5acbb5eSHemant Agrawal 			uint8_t irq_index,
327c5acbb5eSHemant Agrawal 			uint32_t *status);
328c5acbb5eSHemant Agrawal 
329c5acbb5eSHemant Agrawal int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
330c5acbb5eSHemant Agrawal 			  uint32_t cmd_flags,
331c5acbb5eSHemant Agrawal 			  uint16_t token,
332c5acbb5eSHemant Agrawal 			  uint8_t irq_index,
333c5acbb5eSHemant Agrawal 			  uint32_t status);
334c5acbb5eSHemant Agrawal 
335c5acbb5eSHemant Agrawal /**
336e6b82573SHemant Agrawal  * struct dpni_attr - Structure representing DPNI attributes
337e6b82573SHemant Agrawal  * @options: Any combination of the following options:
338e6b82573SHemant Agrawal  *		DPNI_OPT_TX_FRM_RELEASE
339e6b82573SHemant Agrawal  *		DPNI_OPT_NO_MAC_FILTER
340e6b82573SHemant Agrawal  *		DPNI_OPT_HAS_POLICING
341e6b82573SHemant Agrawal  *		DPNI_OPT_SHARED_CONGESTION
342e6b82573SHemant Agrawal  *		DPNI_OPT_HAS_KEY_MASKING
343e6b82573SHemant Agrawal  *		DPNI_OPT_NO_FS
344*591200efSGagandeep Singh  *		DPNI_OPT_STASHING_DIS
345e6b82573SHemant Agrawal  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
34616bbc98aSShreyansh Jain  * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
34716bbc98aSShreyansh Jain  * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
348e6b82573SHemant Agrawal  * @mac_filter_entries: Number of entries in the MAC address filtering
349e6b82573SHemant Agrawal  *		table.
350e6b82573SHemant Agrawal  * @vlan_filter_entries: Number of entries in the VLAN address filtering
351e6b82573SHemant Agrawal  *		table.
352e6b82573SHemant Agrawal  * @qos_entries: Number of entries in the QoS classification table.
353e6b82573SHemant Agrawal  * @fs_entries: Number of entries in the flow steering table.
354e6b82573SHemant Agrawal  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
355e6b82573SHemant Agrawal  *			than this when adding QoS entries will result
356e6b82573SHemant Agrawal  *			in an error.
357e6b82573SHemant Agrawal  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
358e6b82573SHemant Agrawal  *			key larger than this when composing the hash + FS key
359e6b82573SHemant Agrawal  *			will result in an error.
360e6b82573SHemant Agrawal  * @wriop_version: Version of WRIOP HW block.
361e6b82573SHemant Agrawal  *			The 3 version values are stored on 6, 5, 5 bits
362e6b82573SHemant Agrawal  *			respectively.
363e6b82573SHemant Agrawal  *			Values returned:
364e6b82573SHemant Agrawal  *			- 0x400 - WRIOP version 1.0.0, used on LS2080 and
365e6b82573SHemant Agrawal  *			variants,
366e6b82573SHemant Agrawal  *			- 0x421 - WRIOP version 1.1.1, used on LS2088 and
367e6b82573SHemant Agrawal  *			variants,
368e6b82573SHemant Agrawal  *			- 0x422 - WRIOP version 1.1.2, used on LS1088 and
369e6b82573SHemant Agrawal  *			variants.
37025fea082SHemant Agrawal  *			- 0xC00 - WRIOP version 3.0.0, used on LX2160 and
37125fea082SHemant Agrawal  *			variants.
372e6b82573SHemant Agrawal  */
373e6b82573SHemant Agrawal struct dpni_attr {
374e6b82573SHemant Agrawal 	uint32_t options;
375e6b82573SHemant Agrawal 	uint8_t  num_queues;
37616bbc98aSShreyansh Jain 	uint8_t  num_rx_tcs;
37716bbc98aSShreyansh Jain 	uint8_t  num_tx_tcs;
378e6b82573SHemant Agrawal 	uint8_t  mac_filter_entries;
379e6b82573SHemant Agrawal 	uint8_t  vlan_filter_entries;
380e6b82573SHemant Agrawal 	uint8_t  qos_entries;
381e6b82573SHemant Agrawal 	uint16_t fs_entries;
38201690f8fSRohit Raj 	uint16_t num_opr;
383e6b82573SHemant Agrawal 	uint8_t  qos_key_size;
384e6b82573SHemant Agrawal 	uint8_t  fs_key_size;
385e6b82573SHemant Agrawal 	uint16_t wriop_version;
38655984a9bSShreyansh Jain 	uint8_t  num_cgs;
387f48cd6c6SNipun Gupta 	uint8_t  num_channels;
388e6b82573SHemant Agrawal };
389e6b82573SHemant Agrawal 
390e6b82573SHemant Agrawal int dpni_get_attributes(struct fsl_mc_io *mc_io,
391e6b82573SHemant Agrawal 			uint32_t cmd_flags,
392e6b82573SHemant Agrawal 			uint16_t token,
393e6b82573SHemant Agrawal 			struct dpni_attr *attr);
394e6b82573SHemant Agrawal 
395e6b82573SHemant Agrawal /**
396e6b82573SHemant Agrawal  * DPNI errors
397e6b82573SHemant Agrawal  */
398e6b82573SHemant Agrawal 
399e6b82573SHemant Agrawal /**
40025fea082SHemant Agrawal  * Discard error. When set all discarded frames in wriop will be enqueued to
40125fea082SHemant Agrawal  * error queue. To be used in dpni_set_errors_behavior() only if error_action
40225fea082SHemant Agrawal  * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
40325fea082SHemant Agrawal  */
40425fea082SHemant Agrawal #define DPNI_ERROR_DISC			0x80000000
40525fea082SHemant Agrawal 
40625fea082SHemant Agrawal /**
407e6b82573SHemant Agrawal  * Extract out of frame header error
408e6b82573SHemant Agrawal  */
4092cb2abf3SHemant Agrawal #define DPNI_ERROR_MS			0x40000000
4102cb2abf3SHemant Agrawal #define DPNI_ERROR_PTP			0x08000000
4112cb2abf3SHemant Agrawal /* Ethernet multicast frame */
4122cb2abf3SHemant Agrawal #define DPNI_ERROR_MC			0x04000000
4132cb2abf3SHemant Agrawal /* Ethernet broadcast frame */
4142cb2abf3SHemant Agrawal #define DPNI_ERROR_BC			0x02000000
4152cb2abf3SHemant Agrawal #define DPNI_ERROR_KSE			0x00040000
416e6b82573SHemant Agrawal #define DPNI_ERROR_EOFHE		0x00020000
4172cb2abf3SHemant Agrawal #define DPNI_ERROR_MNLE			0x00010000
4182cb2abf3SHemant Agrawal #define DPNI_ERROR_TIDE			0x00008000
4192cb2abf3SHemant Agrawal #define DPNI_ERROR_PIEE			0x00004000
420e6b82573SHemant Agrawal /**
421e6b82573SHemant Agrawal  * Frame length error
422e6b82573SHemant Agrawal  */
423e6b82573SHemant Agrawal #define DPNI_ERROR_FLE			0x00002000
424e6b82573SHemant Agrawal /**
425e6b82573SHemant Agrawal  * Frame physical error
426e6b82573SHemant Agrawal  */
427e6b82573SHemant Agrawal #define DPNI_ERROR_FPE			0x00001000
4282cb2abf3SHemant Agrawal #define DPNI_ERROR_PTE			0x00000080
4292cb2abf3SHemant Agrawal #define DPNI_ERROR_ISP			0x00000040
430e6b82573SHemant Agrawal /**
431e6b82573SHemant Agrawal  * Parsing header error
432e6b82573SHemant Agrawal  */
433e6b82573SHemant Agrawal #define DPNI_ERROR_PHE			0x00000020
4342cb2abf3SHemant Agrawal 
4352cb2abf3SHemant Agrawal #define DPNI_ERROR_BLE			0x00000010
436e6b82573SHemant Agrawal /**
437e6b82573SHemant Agrawal  * Parser L3 checksum error
438e6b82573SHemant Agrawal  */
4392cb2abf3SHemant Agrawal #define DPNI_ERROR_L3CV			0x00000008
4402cb2abf3SHemant Agrawal 
441e6b82573SHemant Agrawal #define DPNI_ERROR_L3CE			0x00000004
442e6b82573SHemant Agrawal /**
4432cb2abf3SHemant Agrawal  * Parser L4 checksum error
444e6b82573SHemant Agrawal  */
4452cb2abf3SHemant Agrawal #define DPNI_ERROR_L4CV			0x00000002
446e6b82573SHemant Agrawal 
4472cb2abf3SHemant Agrawal #define DPNI_ERROR_L4CE			0x00000001
448e6b82573SHemant Agrawal /**
449e6b82573SHemant Agrawal  * enum dpni_error_action - Defines DPNI behavior for errors
450e6b82573SHemant Agrawal  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
451e6b82573SHemant Agrawal  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
452e6b82573SHemant Agrawal  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
453e6b82573SHemant Agrawal  */
454e6b82573SHemant Agrawal enum dpni_error_action {
455e6b82573SHemant Agrawal 	DPNI_ERROR_ACTION_DISCARD = 0,
456e6b82573SHemant Agrawal 	DPNI_ERROR_ACTION_CONTINUE = 1,
457e6b82573SHemant Agrawal 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
458e6b82573SHemant Agrawal };
459e6b82573SHemant Agrawal 
460e6b82573SHemant Agrawal /**
461e6b82573SHemant Agrawal  * struct dpni_error_cfg - Structure representing DPNI errors treatment
462e6b82573SHemant Agrawal  * @errors:			Errors mask; use 'DPNI_ERROR__<X>
463e6b82573SHemant Agrawal  * @error_action:		The desired action for the errors mask
46416bbc98aSShreyansh Jain  * @set_frame_annotation:	Set to '1' to mark the errors in frame
46516bbc98aSShreyansh Jain  *				annotation status (FAS); relevant only
46616bbc98aSShreyansh Jain  *				for the non-discard action
467e6b82573SHemant Agrawal  */
468e6b82573SHemant Agrawal struct dpni_error_cfg {
469e6b82573SHemant Agrawal 	uint32_t errors;
470e6b82573SHemant Agrawal 	enum dpni_error_action error_action;
471e6b82573SHemant Agrawal 	int set_frame_annotation;
472e6b82573SHemant Agrawal };
473e6b82573SHemant Agrawal 
474e6b82573SHemant Agrawal int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
475e6b82573SHemant Agrawal 			     uint32_t cmd_flags,
476e6b82573SHemant Agrawal 			     uint16_t token,
477e6b82573SHemant Agrawal 			     struct dpni_error_cfg *cfg);
478e6b82573SHemant Agrawal 
479e6b82573SHemant Agrawal /**
480e6b82573SHemant Agrawal  * DPNI buffer layout modification options
481e6b82573SHemant Agrawal  */
482e6b82573SHemant Agrawal 
483e6b82573SHemant Agrawal /**
484e6b82573SHemant Agrawal  * Select to modify the time-stamp setting
485e6b82573SHemant Agrawal  */
486e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
487e6b82573SHemant Agrawal /**
488e6b82573SHemant Agrawal  * Select to modify the parser-result setting; not applicable for Tx
489e6b82573SHemant Agrawal  */
490e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
491e6b82573SHemant Agrawal /**
492e6b82573SHemant Agrawal  * Select to modify the frame-status setting
493e6b82573SHemant Agrawal  */
494e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
495e6b82573SHemant Agrawal /**
496e6b82573SHemant Agrawal  * Select to modify the private-data-size setting
497e6b82573SHemant Agrawal  */
498e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
499e6b82573SHemant Agrawal /**
500e6b82573SHemant Agrawal  * Select to modify the data-alignment setting
501e6b82573SHemant Agrawal  */
502e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
503e6b82573SHemant Agrawal /**
504e6b82573SHemant Agrawal  * Select to modify the data-head-room setting
505e6b82573SHemant Agrawal  */
506e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
507e6b82573SHemant Agrawal /**
508e6b82573SHemant Agrawal  * Select to modify the data-tail-room setting
509e6b82573SHemant Agrawal  */
510e6b82573SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
51125fea082SHemant Agrawal /**
51225fea082SHemant Agrawal  * Select to modify the sw-opaque value setting
51325fea082SHemant Agrawal  */
51425fea082SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE		0x00000080
5152cb2abf3SHemant Agrawal /**
5162cb2abf3SHemant Agrawal  * Select to disable Scatter Gather and use single buffer
5172cb2abf3SHemant Agrawal  */
5182cb2abf3SHemant Agrawal #define DPNI_BUF_LAYOUT_OPT_NO_SG		0x00000100
519e6b82573SHemant Agrawal 
520e6b82573SHemant Agrawal /**
521e6b82573SHemant Agrawal  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
52216bbc98aSShreyansh Jain  * @options:		Flags representing the suggested modifications to the
52316bbc98aSShreyansh Jain  *			buffer layout;
52416bbc98aSShreyansh Jain  *			Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
525e6b82573SHemant Agrawal  * @pass_timestamp:	Pass timestamp value
526e6b82573SHemant Agrawal  * @pass_parser_result:	Pass parser results
527e6b82573SHemant Agrawal  * @pass_frame_status:	Pass frame status
528e6b82573SHemant Agrawal  * @private_data_size:	Size kept for private data (in bytes)
529e6b82573SHemant Agrawal  * @data_align:		Data alignment
530e6b82573SHemant Agrawal  * @data_head_room:	Data head room
531e6b82573SHemant Agrawal  * @data_tail_room:	Data tail room
532e6b82573SHemant Agrawal  */
533e6b82573SHemant Agrawal struct dpni_buffer_layout {
534e6b82573SHemant Agrawal 	uint32_t options;
535e6b82573SHemant Agrawal 	int pass_timestamp;
536e6b82573SHemant Agrawal 	int pass_parser_result;
537e6b82573SHemant Agrawal 	int pass_frame_status;
53825fea082SHemant Agrawal 	int pass_sw_opaque;
539e6b82573SHemant Agrawal 	uint16_t private_data_size;
540e6b82573SHemant Agrawal 	uint16_t data_align;
541e6b82573SHemant Agrawal 	uint16_t data_head_room;
542e6b82573SHemant Agrawal 	uint16_t data_tail_room;
543e6b82573SHemant Agrawal };
544e6b82573SHemant Agrawal 
545e6b82573SHemant Agrawal /**
546e6b82573SHemant Agrawal  * enum dpni_queue_type - Identifies a type of queue targeted by the command
547e6b82573SHemant Agrawal  * @DPNI_QUEUE_RX: Rx queue
548e6b82573SHemant Agrawal  * @DPNI_QUEUE_TX: Tx queue
549e6b82573SHemant Agrawal  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
550e6b82573SHemant Agrawal  * @DPNI_QUEUE_RX_ERR: Rx error queue
55116bbc98aSShreyansh Jain  */
55216bbc98aSShreyansh Jain enum dpni_queue_type {
553e6b82573SHemant Agrawal 	DPNI_QUEUE_RX,
554e6b82573SHemant Agrawal 	DPNI_QUEUE_TX,
555e6b82573SHemant Agrawal 	DPNI_QUEUE_TX_CONFIRM,
556e6b82573SHemant Agrawal 	DPNI_QUEUE_RX_ERR,
557e6b82573SHemant Agrawal };
558e6b82573SHemant Agrawal 
559e6b82573SHemant Agrawal int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
560e6b82573SHemant Agrawal 			   uint32_t cmd_flags,
561e6b82573SHemant Agrawal 			   uint16_t token,
562e6b82573SHemant Agrawal 			   enum dpni_queue_type qtype,
563e6b82573SHemant Agrawal 			   struct dpni_buffer_layout *layout);
564e6b82573SHemant Agrawal 
565e6b82573SHemant Agrawal int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
566e6b82573SHemant Agrawal 			   uint32_t cmd_flags,
567e6b82573SHemant Agrawal 			   uint16_t token,
568e6b82573SHemant Agrawal 			   enum dpni_queue_type qtype,
569e6b82573SHemant Agrawal 			   const struct dpni_buffer_layout *layout);
570e6b82573SHemant Agrawal 
571e6b82573SHemant Agrawal /**
572e6b82573SHemant Agrawal  * enum dpni_offload - Identifies a type of offload targeted by the command
573e6b82573SHemant Agrawal  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
574e6b82573SHemant Agrawal  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
575e6b82573SHemant Agrawal  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
576e6b82573SHemant Agrawal  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
57716bbc98aSShreyansh Jain  * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
57816bbc98aSShreyansh Jain  *			   for CPU
579e6b82573SHemant Agrawal  */
580e6b82573SHemant Agrawal enum dpni_offload {
581e6b82573SHemant Agrawal 	DPNI_OFF_RX_L3_CSUM,
582e6b82573SHemant Agrawal 	DPNI_OFF_RX_L4_CSUM,
583e6b82573SHemant Agrawal 	DPNI_OFF_TX_L3_CSUM,
584e6b82573SHemant Agrawal 	DPNI_OFF_TX_L4_CSUM,
58516bbc98aSShreyansh Jain 	DPNI_FLCTYPE_HASH,
586*591200efSGagandeep Singh 	DPNI_HEADER_STASHING,
587*591200efSGagandeep Singh 	DPNI_PAYLOAD_STASHING,
588e6b82573SHemant Agrawal };
589e6b82573SHemant Agrawal 
590e6b82573SHemant Agrawal int dpni_set_offload(struct fsl_mc_io *mc_io,
591e6b82573SHemant Agrawal 		     uint32_t cmd_flags,
592e6b82573SHemant Agrawal 		     uint16_t token,
593e6b82573SHemant Agrawal 		     enum dpni_offload type,
594e6b82573SHemant Agrawal 		     uint32_t config);
595e6b82573SHemant Agrawal 
596e6b82573SHemant Agrawal int dpni_get_offload(struct fsl_mc_io *mc_io,
597e6b82573SHemant Agrawal 		     uint32_t cmd_flags,
598e6b82573SHemant Agrawal 		     uint16_t token,
599e6b82573SHemant Agrawal 		     enum dpni_offload type,
600e6b82573SHemant Agrawal 		     uint32_t *config);
601e6b82573SHemant Agrawal 
602e6b82573SHemant Agrawal int dpni_get_qdid(struct fsl_mc_io *mc_io,
603e6b82573SHemant Agrawal 		  uint32_t cmd_flags,
604e6b82573SHemant Agrawal 		  uint16_t token,
605e6b82573SHemant Agrawal 		  enum dpni_queue_type qtype,
606e6b82573SHemant Agrawal 		  uint16_t *qdid);
607e6b82573SHemant Agrawal 
608*591200efSGagandeep Singh int dpni_get_qdid_ex(struct fsl_mc_io *mc_io,
609*591200efSGagandeep Singh 		  uint32_t cmd_flags,
610*591200efSGagandeep Singh 		  uint16_t token,
611*591200efSGagandeep Singh 		  enum dpni_queue_type qtype,
612*591200efSGagandeep Singh 		  uint16_t *qdid);
613*591200efSGagandeep Singh 
614*591200efSGagandeep Singh /**
615*591200efSGagandeep Singh  * struct dpni_sp_info - Structure representing DPNI storage-profile information
616*591200efSGagandeep Singh  * (relevant only for DPNI owned by AIOP)
617*591200efSGagandeep Singh  * @spids: array of storage-profiles
618*591200efSGagandeep Singh  */
619*591200efSGagandeep Singh struct dpni_sp_info {
620*591200efSGagandeep Singh 	uint16_t spids[DPNI_MAX_SP];
621*591200efSGagandeep Singh };
622*591200efSGagandeep Singh 
623*591200efSGagandeep Singh int dpni_get_sp_info(struct fsl_mc_io *mc_io,
624*591200efSGagandeep Singh 		     uint32_t cmd_flags,
625*591200efSGagandeep Singh 		     uint16_t token,
626*591200efSGagandeep Singh 		     struct dpni_sp_info *sp_info);
627*591200efSGagandeep Singh 
62816bbc98aSShreyansh Jain int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
62916bbc98aSShreyansh Jain 			    uint32_t cmd_flags,
63016bbc98aSShreyansh Jain 			    uint16_t token,
63116bbc98aSShreyansh Jain 			    uint16_t *data_offset);
63216bbc98aSShreyansh Jain 
633e6b82573SHemant Agrawal #define DPNI_STATISTICS_CNT		7
634e6b82573SHemant Agrawal 
635e6b82573SHemant Agrawal /**
63625fea082SHemant Agrawal  * union dpni_statistics - Union describing the DPNI statistics
63725fea082SHemant Agrawal  * @page_0: Page_0 statistics structure
63825fea082SHemant Agrawal  * @page_0.ingress_all_frames: Ingress frame count
63925fea082SHemant Agrawal  * @page_0.ingress_all_bytes: Ingress byte count
64025fea082SHemant Agrawal  * @page_0.ingress_multicast_frames: Ingress multicast frame count
64125fea082SHemant Agrawal  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
64225fea082SHemant Agrawal  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
64325fea082SHemant Agrawal  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
64425fea082SHemant Agrawal  * @page_1: Page_1 statistics structure
64525fea082SHemant Agrawal  * @page_1.egress_all_frames: Egress frame count
64625fea082SHemant Agrawal  * @page_1.egress_all_bytes: Egress byte count
64725fea082SHemant Agrawal  * @page_1.egress_multicast_frames: Egress multicast frame count
64825fea082SHemant Agrawal  * @page_1.egress_multicast_bytes: Egress multicast byte count
64925fea082SHemant Agrawal  * @page_1.egress_broadcast_frames: Egress broadcast frame count
65025fea082SHemant Agrawal  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
65125fea082SHemant Agrawal  * @page_2: Page_2 statistics structure
65225fea082SHemant Agrawal  * @page_2.ingress_filtered_frames: Ingress filtered frame count
65325fea082SHemant Agrawal  * @page_2.ingress_discarded_frames: Ingress discarded frame count
65425fea082SHemant Agrawal  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
65525fea082SHemant Agrawal  *	lack of buffers
65625fea082SHemant Agrawal  * @page_2.egress_discarded_frames: Egress discarded frame count
65725fea082SHemant Agrawal  * @page_2.egress_confirmed_frames: Egress confirmed frame count
65825fea082SHemant Agrawal  * @page_3: Page_3 statistics structure with values for the selected TC
65925fea082SHemant Agrawal  * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
66025fea082SHemant Agrawal  * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
66125fea082SHemant Agrawal  *	dequeued
66225fea082SHemant Agrawal  * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
66325fea082SHemant Agrawal  *	frames whose enqueue was rejected
66425fea082SHemant Agrawal  * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
6657be78d02SJosh Soref  * @page_4: congestion point drops for selected TC
66625fea082SHemant Agrawal  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
66725fea082SHemant Agrawal  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
66825fea082SHemant Agrawal  * @page_5: policer statistics per TC
66925fea082SHemant Agrawal  * @page_5.policer_cnt_red: NUmber of red colored frames
67025fea082SHemant Agrawal  * @page_5.policer_cnt_yellow: number of yellow colored frames
67125fea082SHemant Agrawal  * @page_5.policer_cnt_green: number of green colored frames
67225fea082SHemant Agrawal  * @page_5.policer_cnt_re_red: number of recolored red frames
67325fea082SHemant Agrawal  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
67496f7bfe8SSachin Saxena  * @page_6.tx_pending_frames_cnt: total number of frames pending in Tx queues
67525fea082SHemant Agrawal  * @raw: raw statistics structure, used to index counters
676e6b82573SHemant Agrawal  */
67725fea082SHemant Agrawal union dpni_statistics {
678e6b82573SHemant Agrawal 	struct {
679e6b82573SHemant Agrawal 		uint64_t ingress_all_frames;
680e6b82573SHemant Agrawal 		uint64_t ingress_all_bytes;
681e6b82573SHemant Agrawal 		uint64_t ingress_multicast_frames;
682e6b82573SHemant Agrawal 		uint64_t ingress_multicast_bytes;
683e6b82573SHemant Agrawal 		uint64_t ingress_broadcast_frames;
684e6b82573SHemant Agrawal 		uint64_t ingress_broadcast_bytes;
685e6b82573SHemant Agrawal 	} page_0;
686e6b82573SHemant Agrawal 	struct {
687e6b82573SHemant Agrawal 		uint64_t egress_all_frames;
688e6b82573SHemant Agrawal 		uint64_t egress_all_bytes;
689e6b82573SHemant Agrawal 		uint64_t egress_multicast_frames;
690e6b82573SHemant Agrawal 		uint64_t egress_multicast_bytes;
691e6b82573SHemant Agrawal 		uint64_t egress_broadcast_frames;
692e6b82573SHemant Agrawal 		uint64_t egress_broadcast_bytes;
693e6b82573SHemant Agrawal 	} page_1;
694e6b82573SHemant Agrawal 	struct {
695e6b82573SHemant Agrawal 		uint64_t ingress_filtered_frames;
696e6b82573SHemant Agrawal 		uint64_t ingress_discarded_frames;
697e6b82573SHemant Agrawal 		uint64_t ingress_nobuffer_discards;
698e6b82573SHemant Agrawal 		uint64_t egress_discarded_frames;
699e6b82573SHemant Agrawal 		uint64_t egress_confirmed_frames;
700e6b82573SHemant Agrawal 	} page_2;
70116bbc98aSShreyansh Jain 	struct {
70216bbc98aSShreyansh Jain 		uint64_t ceetm_dequeue_bytes;
70316bbc98aSShreyansh Jain 		uint64_t ceetm_dequeue_frames;
70416bbc98aSShreyansh Jain 		uint64_t ceetm_reject_bytes;
70516bbc98aSShreyansh Jain 		uint64_t ceetm_reject_frames;
70616bbc98aSShreyansh Jain 	} page_3;
70725fea082SHemant Agrawal 	struct {
70825fea082SHemant Agrawal 		uint64_t cgr_reject_frames;
70925fea082SHemant Agrawal 		uint64_t cgr_reject_bytes;
71025fea082SHemant Agrawal 	} page_4;
71125fea082SHemant Agrawal 	struct {
71225fea082SHemant Agrawal 		uint64_t policer_cnt_red;
71325fea082SHemant Agrawal 		uint64_t policer_cnt_yellow;
71425fea082SHemant Agrawal 		uint64_t policer_cnt_green;
71525fea082SHemant Agrawal 		uint64_t policer_cnt_re_red;
71625fea082SHemant Agrawal 		uint64_t policer_cnt_re_yellow;
71725fea082SHemant Agrawal 	} page_5;
718e6b82573SHemant Agrawal 	struct {
71996f7bfe8SSachin Saxena 		uint64_t tx_pending_frames_cnt;
72096f7bfe8SSachin Saxena 	} page_6;
72196f7bfe8SSachin Saxena 	struct {
722e6b82573SHemant Agrawal 		uint64_t counter[DPNI_STATISTICS_CNT];
723e6b82573SHemant Agrawal 	} raw;
724e6b82573SHemant Agrawal };
725e6b82573SHemant Agrawal 
726e6b82573SHemant Agrawal /**
727e6b82573SHemant Agrawal  * Enable auto-negotiation
728e6b82573SHemant Agrawal  */
729e6b82573SHemant Agrawal #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
730e6b82573SHemant Agrawal /**
731e6b82573SHemant Agrawal  * Enable half-duplex mode
732e6b82573SHemant Agrawal  */
733e6b82573SHemant Agrawal #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
734e6b82573SHemant Agrawal /**
735e6b82573SHemant Agrawal  * Enable pause frames
736e6b82573SHemant Agrawal  */
737e6b82573SHemant Agrawal #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
738e6b82573SHemant Agrawal /**
739e6b82573SHemant Agrawal  * Enable a-symmetric pause frames
740e6b82573SHemant Agrawal  */
741e6b82573SHemant Agrawal #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
74216bbc98aSShreyansh Jain /**
74316bbc98aSShreyansh Jain  * Enable priority flow control pause frames
74416bbc98aSShreyansh Jain  */
74516bbc98aSShreyansh Jain #define DPNI_LINK_OPT_PFC_PAUSE	0x0000000000000010ULL
746e6b82573SHemant Agrawal 
747e6b82573SHemant Agrawal /**
74855984a9bSShreyansh Jain  * Advertise 10MB full duplex
74955984a9bSShreyansh Jain  */
75055984a9bSShreyansh Jain #define DPNI_ADVERTISED_10BASET_FULL           0x0000000000000001ULL
75155984a9bSShreyansh Jain /**
75255984a9bSShreyansh Jain  * Advertise 100MB full duplex
75355984a9bSShreyansh Jain  */
75455984a9bSShreyansh Jain #define DPNI_ADVERTISED_100BASET_FULL          0x0000000000000002ULL
75555984a9bSShreyansh Jain /**
75655984a9bSShreyansh Jain  * Advertise 1GB full duplex
75755984a9bSShreyansh Jain  */
75855984a9bSShreyansh Jain #define DPNI_ADVERTISED_1000BASET_FULL         0x0000000000000004ULL
75955984a9bSShreyansh Jain /**
76055984a9bSShreyansh Jain  * Advertise auto-negotiation enable
76155984a9bSShreyansh Jain  */
76255984a9bSShreyansh Jain #define DPNI_ADVERTISED_AUTONEG                0x0000000000000008ULL
76355984a9bSShreyansh Jain /**
76455984a9bSShreyansh Jain  * Advertise 10GB full duplex
76555984a9bSShreyansh Jain  */
76655984a9bSShreyansh Jain #define DPNI_ADVERTISED_10000BASET_FULL        0x0000000000000010ULL
76755984a9bSShreyansh Jain /**
76855984a9bSShreyansh Jain  * Advertise 2.5GB full duplex
76955984a9bSShreyansh Jain  */
77055984a9bSShreyansh Jain #define DPNI_ADVERTISED_2500BASEX_FULL         0x0000000000000020ULL
77155984a9bSShreyansh Jain /**
77255984a9bSShreyansh Jain  * Advertise 5GB full duplex
77355984a9bSShreyansh Jain  */
77455984a9bSShreyansh Jain #define DPNI_ADVERTISED_5000BASET_FULL         0x0000000000000040ULL
77555984a9bSShreyansh Jain 
77655984a9bSShreyansh Jain 
77755984a9bSShreyansh Jain /**
778977d0006SHemant Agrawal  * struct - Structure representing DPNI link configuration
779977d0006SHemant Agrawal  * @rate: Rate
780977d0006SHemant Agrawal  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
78125fea082SHemant Agrawal  * @advertising: Speeds that are advertised for autoneg (bitmap)
782977d0006SHemant Agrawal  */
783977d0006SHemant Agrawal struct dpni_link_cfg {
784977d0006SHemant Agrawal 	uint32_t rate;
785977d0006SHemant Agrawal 	uint64_t options;
78625fea082SHemant Agrawal 	uint64_t advertising;
787977d0006SHemant Agrawal };
788977d0006SHemant Agrawal 
789977d0006SHemant Agrawal int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
790977d0006SHemant Agrawal 		      uint32_t cmd_flags,
791977d0006SHemant Agrawal 		      uint16_t token,
792977d0006SHemant Agrawal 		      const struct dpni_link_cfg *cfg);
793977d0006SHemant Agrawal 
79472100f0dSGagandeep Singh int dpni_get_link_cfg(struct fsl_mc_io *mc_io,
79572100f0dSGagandeep Singh 		      uint32_t cmd_flags,
79672100f0dSGagandeep Singh 		      uint16_t token,
79772100f0dSGagandeep Singh 		      struct dpni_link_cfg *cfg);
79872100f0dSGagandeep Singh 
799977d0006SHemant Agrawal /**
800e6b82573SHemant Agrawal  * struct dpni_link_state - Structure representing DPNI link state
801e6b82573SHemant Agrawal  * @rate:	Rate
802e6b82573SHemant Agrawal  * @options:	Mask of available options; use 'DPNI_LINK_OPT_<X>' values
803e6b82573SHemant Agrawal  * @up:		Link state; '0' for down, '1' for up
80425fea082SHemant Agrawal  * @state_valid: Ignore/Update the state of the link
80525fea082SHemant Agrawal  * @supported: Speeds capability of the phy (bitmap)
80625fea082SHemant Agrawal  * @advertising: Speeds that are advertised for autoneg (bitmap)
807e6b82573SHemant Agrawal  */
808e6b82573SHemant Agrawal struct dpni_link_state {
809e6b82573SHemant Agrawal 	uint32_t rate;
810e6b82573SHemant Agrawal 	uint64_t options;
811e6b82573SHemant Agrawal 	int up;
81225fea082SHemant Agrawal 	int state_valid;
81325fea082SHemant Agrawal 	uint64_t supported;
81425fea082SHemant Agrawal 	uint64_t advertising;
815e6b82573SHemant Agrawal };
816e6b82573SHemant Agrawal 
817e6b82573SHemant Agrawal int dpni_get_link_state(struct fsl_mc_io *mc_io,
818e6b82573SHemant Agrawal 			uint32_t cmd_flags,
819e6b82573SHemant Agrawal 			uint16_t token,
820e6b82573SHemant Agrawal 			struct dpni_link_state *state);
821e6b82573SHemant Agrawal 
822ac624068SGagandeep Singh /**
823ac624068SGagandeep Singh  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
8242cb2abf3SHemant Agrawal  * @rate_limit:		Rate in Mbits/s
825ac624068SGagandeep Singh  * @max_burst_size:	Burst size in bytes (up to 64KB)
826ac624068SGagandeep Singh  */
827ac624068SGagandeep Singh struct dpni_tx_shaping_cfg {
828ac624068SGagandeep Singh 	uint32_t rate_limit;
829ac624068SGagandeep Singh 	uint16_t max_burst_size;
830ac624068SGagandeep Singh };
831ac624068SGagandeep Singh 
832f48cd6c6SNipun Gupta /**
833f48cd6c6SNipun Gupta  * Build the parameter for dpni_set_tx_shaping() call
834f48cd6c6SNipun Gupta  * @oal:		Overhead accounting length. 11bit value added to the size of
835f48cd6c6SNipun Gupta  *			each frame. Used only for LNI shaping. If set to zero, will use default
836f48cd6c6SNipun Gupta  *			value of 24. Ignored if shaping_lni is set to zero.
837f48cd6c6SNipun Gupta  * @shaping_lni:	1 for LNI shaping (configure whole throughput of the dpni object)
838f48cd6c6SNipun Gupta  *			0 for channel shaping (configure shaping for individual channels)
839f48cd6c6SNipun Gupta  *			Set to one only if dpni is connected to a dpmac object.
840f48cd6c6SNipun Gupta  * @channel_id:		Channel to be configured. Ignored shaping_lni is set to 1
841f48cd6c6SNipun Gupta  * @coupled:		Committed and excess rates are coupled
842f48cd6c6SNipun Gupta  */
843f48cd6c6SNipun Gupta #define DPNI_TX_SHAPING_PARAM(oal, shaping_lni, channel_id, coupled)	( \
844f48cd6c6SNipun Gupta 		((uint32_t)(((oal) & 0x7ff) << 16)) | \
845f48cd6c6SNipun Gupta 		((uint32_t)((channel_id) & 0xff) << 8) | \
846f48cd6c6SNipun Gupta 		((uint32_t)(!!shaping_lni) << 1) | \
847f48cd6c6SNipun Gupta 		((uint32_t)!!coupled))
848f48cd6c6SNipun Gupta 
849ac624068SGagandeep Singh int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
850ac624068SGagandeep Singh 			uint32_t cmd_flags,
851ac624068SGagandeep Singh 			uint16_t token,
852ac624068SGagandeep Singh 			const struct dpni_tx_shaping_cfg *tx_cr_shaper,
853ac624068SGagandeep Singh 			const struct dpni_tx_shaping_cfg *tx_er_shaper,
854f48cd6c6SNipun Gupta 			uint32_t param);
855ac624068SGagandeep Singh 
856e6b82573SHemant Agrawal int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
857e6b82573SHemant Agrawal 			      uint32_t cmd_flags,
858e6b82573SHemant Agrawal 			      uint16_t token,
859e6b82573SHemant Agrawal 			      uint16_t max_frame_length);
860e6b82573SHemant Agrawal 
861e6b82573SHemant Agrawal int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
862e6b82573SHemant Agrawal 			      uint32_t cmd_flags,
863e6b82573SHemant Agrawal 			      uint16_t token,
864e6b82573SHemant Agrawal 			      uint16_t *max_frame_length);
865e6b82573SHemant Agrawal 
86616bbc98aSShreyansh Jain int dpni_set_mtu(struct fsl_mc_io *mc_io,
86716bbc98aSShreyansh Jain 		 uint32_t cmd_flags,
86816bbc98aSShreyansh Jain 		 uint16_t token,
86916bbc98aSShreyansh Jain 		 uint16_t mtu);
87016bbc98aSShreyansh Jain 
87116bbc98aSShreyansh Jain int dpni_get_mtu(struct fsl_mc_io *mc_io,
87216bbc98aSShreyansh Jain 		 uint32_t cmd_flags,
87316bbc98aSShreyansh Jain 		 uint16_t token,
87416bbc98aSShreyansh Jain 		 uint16_t *mtu);
87516bbc98aSShreyansh Jain 
8765d5aeeedSHemant Agrawal int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
8775d5aeeedSHemant Agrawal 			       uint32_t cmd_flags,
8785d5aeeedSHemant Agrawal 			       uint16_t token,
8795d5aeeedSHemant Agrawal 			       int en);
8805d5aeeedSHemant Agrawal 
8815d5aeeedSHemant Agrawal int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
8825d5aeeedSHemant Agrawal 			       uint32_t cmd_flags,
8835d5aeeedSHemant Agrawal 			       uint16_t token,
8845d5aeeedSHemant Agrawal 			       int *en);
885e6b82573SHemant Agrawal 
886e6b82573SHemant Agrawal int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
887e6b82573SHemant Agrawal 			     uint32_t cmd_flags,
888e6b82573SHemant Agrawal 			     uint16_t token,
889e6b82573SHemant Agrawal 			     int en);
890e6b82573SHemant Agrawal 
891e6b82573SHemant Agrawal int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
892e6b82573SHemant Agrawal 			     uint32_t cmd_flags,
893e6b82573SHemant Agrawal 			     uint16_t token,
894e6b82573SHemant Agrawal 			     int *en);
895e6b82573SHemant Agrawal 
896e6b82573SHemant Agrawal int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
897e6b82573SHemant Agrawal 			      uint32_t cmd_flags,
898e6b82573SHemant Agrawal 			      uint16_t token,
899e6b82573SHemant Agrawal 			      const uint8_t mac_addr[6]);
900e6b82573SHemant Agrawal 
901e6b82573SHemant Agrawal int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
902e6b82573SHemant Agrawal 			      uint32_t cmd_flags,
903e6b82573SHemant Agrawal 			      uint16_t token,
904e6b82573SHemant Agrawal 			      uint8_t mac_addr[6]);
905e6b82573SHemant Agrawal 
9062cb2abf3SHemant Agrawal /**
9072cb2abf3SHemant Agrawal  * Set mac addr queue action
9082cb2abf3SHemant Agrawal  */
9092cb2abf3SHemant Agrawal #define DPNI_MAC_SET_QUEUE_ACTION 1
9102cb2abf3SHemant Agrawal 
911b4d97b7dSHemant Agrawal int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
912b4d97b7dSHemant Agrawal 		      uint32_t cmd_flags,
913b4d97b7dSHemant Agrawal 		      uint16_t token,
91496f7bfe8SSachin Saxena 		      const uint8_t mac_addr[6],
91596f7bfe8SSachin Saxena 			  uint8_t flags,
91696f7bfe8SSachin Saxena 			  uint8_t tc_id,
91796f7bfe8SSachin Saxena 			  uint8_t flow_id);
918b4d97b7dSHemant Agrawal 
919b4d97b7dSHemant Agrawal int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
920b4d97b7dSHemant Agrawal 			 uint32_t cmd_flags,
921b4d97b7dSHemant Agrawal 			 uint16_t token,
922b4d97b7dSHemant Agrawal 			 const uint8_t mac_addr[6]);
923b4d97b7dSHemant Agrawal 
924b4d97b7dSHemant Agrawal int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
925b4d97b7dSHemant Agrawal 			   uint32_t cmd_flags,
926b4d97b7dSHemant Agrawal 			   uint16_t token,
927b4d97b7dSHemant Agrawal 			   int unicast,
928b4d97b7dSHemant Agrawal 			   int multicast);
929e6b82573SHemant Agrawal 
930e6b82573SHemant Agrawal int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
931e6b82573SHemant Agrawal 			   uint32_t cmd_flags,
932e6b82573SHemant Agrawal 			   uint16_t token,
933e6b82573SHemant Agrawal 			   uint8_t mac_addr[6]);
934e6b82573SHemant Agrawal 
9353ce294f2SHemant Agrawal int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
9363ce294f2SHemant Agrawal 			    uint32_t cmd_flags,
9373ce294f2SHemant Agrawal 			    uint16_t token,
9383ce294f2SHemant Agrawal 			    int en);
9393ce294f2SHemant Agrawal 
94096f7bfe8SSachin Saxena /**
94196f7bfe8SSachin Saxena  * Set vlan filter queue action
94296f7bfe8SSachin Saxena  */
94396f7bfe8SSachin Saxena #define DPNI_VLAN_SET_QUEUE_ACTION 1
94496f7bfe8SSachin Saxena 
9453ce294f2SHemant Agrawal int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
9463ce294f2SHemant Agrawal 		     uint32_t cmd_flags,
9473ce294f2SHemant Agrawal 		     uint16_t token,
94896f7bfe8SSachin Saxena 		     uint16_t vlan_id,
94996f7bfe8SSachin Saxena 			 uint8_t flags,
95096f7bfe8SSachin Saxena 			 uint8_t tc_id,
95196f7bfe8SSachin Saxena 			 uint8_t flow_id);
9523ce294f2SHemant Agrawal 
9533ce294f2SHemant Agrawal int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
9543ce294f2SHemant Agrawal 			uint32_t cmd_flags,
9553ce294f2SHemant Agrawal 			uint16_t token,
9563ce294f2SHemant Agrawal 			uint16_t vlan_id);
9573ce294f2SHemant Agrawal 
9583ce294f2SHemant Agrawal int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
9593ce294f2SHemant Agrawal 			    uint32_t cmd_flags,
9603ce294f2SHemant Agrawal 			    uint16_t token);
9613ce294f2SHemant Agrawal 
9623ce294f2SHemant Agrawal /**
963ac624068SGagandeep Singh  * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
964ac624068SGagandeep Singh  * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
965ac624068SGagandeep Singh  * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
966ac624068SGagandeep Singh  * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
967ac624068SGagandeep Singh  */
968ac624068SGagandeep Singh enum dpni_tx_schedule_mode {
969ac624068SGagandeep Singh 	DPNI_TX_SCHED_STRICT_PRIORITY = 0,
970ac624068SGagandeep Singh 	DPNI_TX_SCHED_WEIGHTED_A,
971ac624068SGagandeep Singh 	DPNI_TX_SCHED_WEIGHTED_B,
972ac624068SGagandeep Singh };
973ac624068SGagandeep Singh 
974ac624068SGagandeep Singh /**
975ac624068SGagandeep Singh  * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
976ac624068SGagandeep Singh  * @mode:		Scheduling mode
977ac624068SGagandeep Singh  * @delta_bandwidth:	Bandwidth represented in weights from 100 to 10000;
978ac624068SGagandeep Singh  *	not applicable for 'strict-priority' mode;
979ac624068SGagandeep Singh  */
980ac624068SGagandeep Singh struct dpni_tx_schedule_cfg {
981ac624068SGagandeep Singh 	enum dpni_tx_schedule_mode	mode;
982ac624068SGagandeep Singh 	uint16_t			delta_bandwidth;
983ac624068SGagandeep Singh };
984ac624068SGagandeep Singh 
985ac624068SGagandeep Singh /**
986ac624068SGagandeep Singh  * struct dpni_tx_priorities_cfg - Structure representing transmission
987ac624068SGagandeep Singh  *					priorities for DPNI TCs
988f48cd6c6SNipun Gupta  * @channel_idx: channel to perform the configuration
989ac624068SGagandeep Singh  * @tc_sched:	An array of traffic-classes
990ac624068SGagandeep Singh  * @prio_group_A: Priority of group A
991ac624068SGagandeep Singh  * @prio_group_B: Priority of group B
992ac624068SGagandeep Singh  * @separate_groups: Treat A and B groups as separate
993ac624068SGagandeep Singh  */
994ac624068SGagandeep Singh struct dpni_tx_priorities_cfg {
995f48cd6c6SNipun Gupta 	uint8_t channel_idx;
996ac624068SGagandeep Singh 	struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
997ac624068SGagandeep Singh 	uint32_t prio_group_A;
998ac624068SGagandeep Singh 	uint32_t prio_group_B;
999ac624068SGagandeep Singh 	uint8_t separate_groups;
1000ac624068SGagandeep Singh };
1001ac624068SGagandeep Singh 
1002ac624068SGagandeep Singh int dpni_set_tx_priorities(struct fsl_mc_io			*mc_io,
1003ac624068SGagandeep Singh 			   uint32_t				cmd_flags,
1004ac624068SGagandeep Singh 			   uint16_t				token,
1005ac624068SGagandeep Singh 			   const struct dpni_tx_priorities_cfg	*cfg);
1006ac624068SGagandeep Singh 
1007ac624068SGagandeep Singh /**
1008e6b82573SHemant Agrawal  * enum dpni_dist_mode - DPNI distribution mode
1009e6b82573SHemant Agrawal  * @DPNI_DIST_MODE_NONE: No distribution
1010e6b82573SHemant Agrawal  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
1011e6b82573SHemant Agrawal  *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
1012e6b82573SHemant Agrawal  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
1013e6b82573SHemant Agrawal  *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
1014e6b82573SHemant Agrawal  */
1015e6b82573SHemant Agrawal enum dpni_dist_mode {
1016e6b82573SHemant Agrawal 	DPNI_DIST_MODE_NONE = 0,
1017e6b82573SHemant Agrawal 	DPNI_DIST_MODE_HASH = 1,
1018e6b82573SHemant Agrawal 	DPNI_DIST_MODE_FS = 2
1019e6b82573SHemant Agrawal };
1020e6b82573SHemant Agrawal 
1021e6b82573SHemant Agrawal /**
1022e6b82573SHemant Agrawal  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
1023e6b82573SHemant Agrawal  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
1024e6b82573SHemant Agrawal  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
1025e6b82573SHemant Agrawal  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
1026e6b82573SHemant Agrawal  */
1027e6b82573SHemant Agrawal enum dpni_fs_miss_action {
1028e6b82573SHemant Agrawal 	DPNI_FS_MISS_DROP = 0,
1029e6b82573SHemant Agrawal 	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
1030e6b82573SHemant Agrawal 	DPNI_FS_MISS_HASH = 2
1031e6b82573SHemant Agrawal };
1032e6b82573SHemant Agrawal 
1033e6b82573SHemant Agrawal /**
1034e6b82573SHemant Agrawal  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
1035e6b82573SHemant Agrawal  * @miss_action:	Miss action selection
1036e6b82573SHemant Agrawal  * @default_flow_id:	Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
103725fea082SHemant Agrawal  * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
103825fea082SHemant Agrawal  *	set to one unclassified frames will be distributed according to previous
103925fea082SHemant Agrawal  *	used hash key. If set to zero hash key will be replaced with the key
104025fea082SHemant Agrawal  *	provided for flow steering.
104125fea082SHemant Agrawal  * @keep_entries: if set to one command will not delete the entries that already
104225fea082SHemant Agrawal  *	exist into FS table. Use this option with caution: if the table
104325fea082SHemant Agrawal  *	entries	are not compatible with the distribution key the packets
104425fea082SHemant Agrawal  *	will not be classified properly.
1045e6b82573SHemant Agrawal  */
1046e6b82573SHemant Agrawal struct dpni_fs_tbl_cfg {
1047e6b82573SHemant Agrawal 	enum dpni_fs_miss_action miss_action;
1048e6b82573SHemant Agrawal 	uint16_t default_flow_id;
104916bbc98aSShreyansh Jain 	char keep_hash_key;
105025fea082SHemant Agrawal 	uint8_t keep_entries;
1051e6b82573SHemant Agrawal };
1052e6b82573SHemant Agrawal 
1053e6b82573SHemant Agrawal /**
1054e6b82573SHemant Agrawal  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
1055e6b82573SHemant Agrawal  * @dist_size: Set the distribution size;
1056e6b82573SHemant Agrawal  *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
1057e6b82573SHemant Agrawal  *	112,128,192,224,256,384,448,512,768,896,1024
1058e6b82573SHemant Agrawal  * @dist_mode: Distribution mode
1059e6b82573SHemant Agrawal  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1060e6b82573SHemant Agrawal  *		the extractions to be used for the distribution key by calling
106116bbc98aSShreyansh Jain  *		dpkg_prepare_key_cfg() relevant only when
1062e6b82573SHemant Agrawal  *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
1063e6b82573SHemant Agrawal  * @fs_cfg: Flow Steering table configuration; only relevant if
1064e6b82573SHemant Agrawal  *		'dist_mode = DPNI_DIST_MODE_FS'
1065e6b82573SHemant Agrawal  */
1066e6b82573SHemant Agrawal struct dpni_rx_tc_dist_cfg {
1067e6b82573SHemant Agrawal 	uint16_t dist_size;
1068e6b82573SHemant Agrawal 	enum dpni_dist_mode dist_mode;
1069e6b82573SHemant Agrawal 	uint64_t key_cfg_iova;
1070e6b82573SHemant Agrawal 	struct dpni_fs_tbl_cfg fs_cfg;
1071e6b82573SHemant Agrawal };
1072e6b82573SHemant Agrawal 
1073e6b82573SHemant Agrawal int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
1074e6b82573SHemant Agrawal 			uint32_t cmd_flags,
1075e6b82573SHemant Agrawal 			uint16_t token,
1076e6b82573SHemant Agrawal 			uint8_t tc_id,
1077e6b82573SHemant Agrawal 			const struct dpni_rx_tc_dist_cfg *cfg);
107816bbc98aSShreyansh Jain 
10797ae777d0SHemant Agrawal /**
1080ac624068SGagandeep Singh  * Set to select color aware mode (otherwise - color blind)
1081ac624068SGagandeep Singh  */
1082ac624068SGagandeep Singh #define DPNI_POLICER_OPT_COLOR_AWARE	0x00000001
1083ac624068SGagandeep Singh /**
1084ac624068SGagandeep Singh  * Set to discard frame with RED color
1085ac624068SGagandeep Singh  */
1086ac624068SGagandeep Singh #define DPNI_POLICER_OPT_DISCARD_RED	0x00000002
1087ac624068SGagandeep Singh 
1088ac624068SGagandeep Singh /**
1089ac624068SGagandeep Singh  * enum dpni_policer_mode - selecting the policer mode
1090ac624068SGagandeep Singh  * @DPNI_POLICER_MODE_NONE: Policer is disabled
1091ac624068SGagandeep Singh  * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
1092ac624068SGagandeep Singh  * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
1093ac624068SGagandeep Singh  * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
1094ac624068SGagandeep Singh  */
1095ac624068SGagandeep Singh enum dpni_policer_mode {
1096ac624068SGagandeep Singh 	DPNI_POLICER_MODE_NONE = 0,
1097ac624068SGagandeep Singh 	DPNI_POLICER_MODE_PASS_THROUGH,
1098ac624068SGagandeep Singh 	DPNI_POLICER_MODE_RFC_2698,
1099ac624068SGagandeep Singh 	DPNI_POLICER_MODE_RFC_4115
1100ac624068SGagandeep Singh };
1101ac624068SGagandeep Singh 
1102ac624068SGagandeep Singh /**
1103ac624068SGagandeep Singh  * enum dpni_policer_unit - DPNI policer units
1104ac624068SGagandeep Singh  * @DPNI_POLICER_UNIT_BYTES: bytes units
1105ac624068SGagandeep Singh  * @DPNI_POLICER_UNIT_FRAMES: frames units
1106ac624068SGagandeep Singh  */
1107ac624068SGagandeep Singh enum dpni_policer_unit {
1108ac624068SGagandeep Singh 	DPNI_POLICER_UNIT_BYTES = 0,
1109ac624068SGagandeep Singh 	DPNI_POLICER_UNIT_FRAMES
1110ac624068SGagandeep Singh };
1111ac624068SGagandeep Singh 
1112ac624068SGagandeep Singh /**
1113ac624068SGagandeep Singh  * enum dpni_policer_color - selecting the policer color
1114ac624068SGagandeep Singh  * @DPNI_POLICER_COLOR_GREEN: Green color
1115ac624068SGagandeep Singh  * @DPNI_POLICER_COLOR_YELLOW: Yellow color
1116ac624068SGagandeep Singh  * @DPNI_POLICER_COLOR_RED: Red color
1117ac624068SGagandeep Singh  */
1118ac624068SGagandeep Singh enum dpni_policer_color {
1119ac624068SGagandeep Singh 	DPNI_POLICER_COLOR_GREEN = 0,
1120ac624068SGagandeep Singh 	DPNI_POLICER_COLOR_YELLOW,
1121ac624068SGagandeep Singh 	DPNI_POLICER_COLOR_RED
1122ac624068SGagandeep Singh };
1123ac624068SGagandeep Singh 
1124ac624068SGagandeep Singh /**
1125ac624068SGagandeep Singh  * struct dpni_rx_tc_policing_cfg - Policer configuration
1126ac624068SGagandeep Singh  * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
1127ac624068SGagandeep Singh  * @mode: policer mode
1128ac624068SGagandeep Singh  * @default_color: For pass-through mode the policer re-colors with this
1129ac624068SGagandeep Singh  *	color any incoming packets. For Color aware non-pass-through mode:
1130ac624068SGagandeep Singh  *	policer re-colors with this color all packets with FD[DROPP]>2.
1131ac624068SGagandeep Singh  * @units: Bytes or Packets
1132ac624068SGagandeep Singh  * @cir: Committed information rate (CIR) in Kbps or packets/second
1133ac624068SGagandeep Singh  * @cbs: Committed burst size (CBS) in bytes or packets
1134ac624068SGagandeep Singh  * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
1135ac624068SGagandeep Singh  *	 Excess information rate (EIR, rfc4115) in Kbps or packets/second
1136ac624068SGagandeep Singh  * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
1137ac624068SGagandeep Singh  *       Excess burst size (EBS, rfc4115) in bytes or packets
1138ac624068SGagandeep Singh  */
1139ac624068SGagandeep Singh struct dpni_rx_tc_policing_cfg {
1140ac624068SGagandeep Singh 	uint32_t options;
1141ac624068SGagandeep Singh 	enum dpni_policer_mode mode;
1142ac624068SGagandeep Singh 	enum dpni_policer_unit units;
1143ac624068SGagandeep Singh 	enum dpni_policer_color default_color;
1144ac624068SGagandeep Singh 	uint32_t cir;
1145ac624068SGagandeep Singh 	uint32_t cbs;
1146ac624068SGagandeep Singh 	uint32_t eir;
1147ac624068SGagandeep Singh 	uint32_t ebs;
1148ac624068SGagandeep Singh };
1149ac624068SGagandeep Singh 
1150ac624068SGagandeep Singh 
1151ac624068SGagandeep Singh int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
1152ac624068SGagandeep Singh 			    uint32_t cmd_flags,
1153ac624068SGagandeep Singh 			    uint16_t token,
1154ac624068SGagandeep Singh 			    uint8_t tc_id,
1155ac624068SGagandeep Singh 			    const struct dpni_rx_tc_policing_cfg *cfg);
1156ac624068SGagandeep Singh 
1157ac624068SGagandeep Singh int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
1158ac624068SGagandeep Singh 			    uint32_t cmd_flags,
1159ac624068SGagandeep Singh 			    uint16_t token,
1160ac624068SGagandeep Singh 			    uint8_t tc_id,
1161ac624068SGagandeep Singh 			    struct dpni_rx_tc_policing_cfg *cfg);
1162ac624068SGagandeep Singh 
1163ac624068SGagandeep Singh /**
11647ae777d0SHemant Agrawal  * enum dpni_congestion_unit - DPNI congestion units
11657ae777d0SHemant Agrawal  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
11667ae777d0SHemant Agrawal  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
11677ae777d0SHemant Agrawal  */
11687ae777d0SHemant Agrawal enum dpni_congestion_unit {
11697ae777d0SHemant Agrawal 	DPNI_CONGESTION_UNIT_BYTES = 0,
11707ae777d0SHemant Agrawal 	DPNI_CONGESTION_UNIT_FRAMES
11717ae777d0SHemant Agrawal };
11727ae777d0SHemant Agrawal 
1173e6b82573SHemant Agrawal /**
1174ac624068SGagandeep Singh  * enum dpni_early_drop_mode - DPNI early drop mode
1175ac624068SGagandeep Singh  * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
1176ac624068SGagandeep Singh  * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
1177ac624068SGagandeep Singh  * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
1178ac624068SGagandeep Singh  */
1179ac624068SGagandeep Singh enum dpni_early_drop_mode {
1180ac624068SGagandeep Singh 	DPNI_EARLY_DROP_MODE_NONE = 0,
1181ac624068SGagandeep Singh 	DPNI_EARLY_DROP_MODE_TAIL,
1182ac624068SGagandeep Singh 	DPNI_EARLY_DROP_MODE_WRED
1183ac624068SGagandeep Singh };
1184ac624068SGagandeep Singh 
1185ac624068SGagandeep Singh /**
1186ac624068SGagandeep Singh  * struct dpni_wred_cfg - WRED configuration
1187ac624068SGagandeep Singh  * @max_threshold: maximum threshold that packets may be discarded. Above this
1188ac624068SGagandeep Singh  *	  threshold all packets are discarded; must be less than 2^39;
1189ac624068SGagandeep Singh  *	  approximated to be expressed as (x+256)*2^(y-1) due to HW
1190ac624068SGagandeep Singh  *	  implementation.
1191ac624068SGagandeep Singh  * @min_threshold: minimum threshold that packets may be discarded at
1192ac624068SGagandeep Singh  * @drop_probability: probability that a packet will be discarded (1-100,
1193ac624068SGagandeep Singh  *			associated with the max_threshold).
1194ac624068SGagandeep Singh  */
1195ac624068SGagandeep Singh struct dpni_wred_cfg {
1196ac624068SGagandeep Singh 	uint64_t max_threshold;
1197ac624068SGagandeep Singh 	uint64_t min_threshold;
1198ac624068SGagandeep Singh 	uint8_t drop_probability;
1199ac624068SGagandeep Singh };
1200ac624068SGagandeep Singh 
1201ac624068SGagandeep Singh /**
1202ac624068SGagandeep Singh  * struct dpni_early_drop_cfg - early-drop configuration
1203ac624068SGagandeep Singh  * @enable: drop enable
1204ac624068SGagandeep Singh  * @units: units type
1205ac624068SGagandeep Singh  * @green: WRED - 'green' configuration
1206ac624068SGagandeep Singh  * @yellow: WRED - 'yellow' configuration
1207ac624068SGagandeep Singh  * @red: WRED - 'red' configuration
1208ac624068SGagandeep Singh  */
1209ac624068SGagandeep Singh struct dpni_early_drop_cfg {
1210ac624068SGagandeep Singh 	uint8_t enable;
1211ac624068SGagandeep Singh 	enum dpni_congestion_unit units;
1212ac624068SGagandeep Singh 	struct dpni_wred_cfg green;
1213ac624068SGagandeep Singh 	struct dpni_wred_cfg yellow;
1214ac624068SGagandeep Singh 	struct dpni_wred_cfg red;
1215ac624068SGagandeep Singh };
1216ac624068SGagandeep Singh 
1217ac624068SGagandeep Singh void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
1218ac624068SGagandeep Singh 			     uint8_t *early_drop_buf);
1219ac624068SGagandeep Singh 
1220ac624068SGagandeep Singh void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
1221ac624068SGagandeep Singh 			     const uint8_t *early_drop_buf);
1222ac624068SGagandeep Singh 
1223ac624068SGagandeep Singh int dpni_set_early_drop(struct fsl_mc_io *mc_io,
1224ac624068SGagandeep Singh 			uint32_t cmd_flags,
1225ac624068SGagandeep Singh 			uint16_t token,
1226ac624068SGagandeep Singh 			enum dpni_queue_type qtype,
1227f48cd6c6SNipun Gupta 			uint16_t param,
1228ac624068SGagandeep Singh 			uint64_t early_drop_iova);
1229ac624068SGagandeep Singh 
1230ac624068SGagandeep Singh int dpni_get_early_drop(struct fsl_mc_io *mc_io,
1231ac624068SGagandeep Singh 			uint32_t cmd_flags,
1232ac624068SGagandeep Singh 			uint16_t token,
1233ac624068SGagandeep Singh 			enum dpni_queue_type qtype,
1234f48cd6c6SNipun Gupta 			uint16_t param,
1235ac624068SGagandeep Singh 			uint64_t early_drop_iova);
1236ac624068SGagandeep Singh 
1237ac624068SGagandeep Singh /**
1238e6b82573SHemant Agrawal  * enum dpni_dest - DPNI destination types
1239e6b82573SHemant Agrawal  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1240e6b82573SHemant Agrawal  *		does not generate FQDAN notifications; user is expected to
1241e6b82573SHemant Agrawal  *		dequeue from the queue based on polling or other user-defined
1242e6b82573SHemant Agrawal  *		method
1243e6b82573SHemant Agrawal  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1244e6b82573SHemant Agrawal  *		notifications to the specified DPIO; user is expected to dequeue
1245e6b82573SHemant Agrawal  *		from the queue only after notification is received
1246e6b82573SHemant Agrawal  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1247e6b82573SHemant Agrawal  *		FQDAN notifications, but is connected to the specified DPCON
1248e6b82573SHemant Agrawal  *		object; user is expected to dequeue from the DPCON channel
1249e6b82573SHemant Agrawal  */
1250e6b82573SHemant Agrawal enum dpni_dest {
1251e6b82573SHemant Agrawal 	DPNI_DEST_NONE = 0,
1252e6b82573SHemant Agrawal 	DPNI_DEST_DPIO = 1,
1253e6b82573SHemant Agrawal 	DPNI_DEST_DPCON = 2
1254e6b82573SHemant Agrawal };
1255e6b82573SHemant Agrawal 
12567ae777d0SHemant Agrawal /**
12577ae777d0SHemant Agrawal  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
12587ae777d0SHemant Agrawal  * @dest_type: Destination type
12597ae777d0SHemant Agrawal  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
12607ae777d0SHemant Agrawal  * @priority: Priority selection within the DPIO or DPCON channel; valid values
12617ae777d0SHemant Agrawal  *		are 0-1 or 0-7, depending on the number of priorities in that
12627ae777d0SHemant Agrawal  *		channel; not relevant for 'DPNI_DEST_NONE' option
12637ae777d0SHemant Agrawal  */
12647ae777d0SHemant Agrawal struct dpni_dest_cfg {
12657ae777d0SHemant Agrawal 	enum dpni_dest dest_type;
12667ae777d0SHemant Agrawal 	int dest_id;
12677ae777d0SHemant Agrawal 	uint8_t priority;
12687ae777d0SHemant Agrawal };
12697ae777d0SHemant Agrawal 
12707ae777d0SHemant Agrawal /* DPNI congestion options */
12717ae777d0SHemant Agrawal 
12727ae777d0SHemant Agrawal /**
12737ae777d0SHemant Agrawal  * CSCN message is written to message_iova once entering a
12747ae777d0SHemant Agrawal  * congestion state (see 'threshold_entry')
12757ae777d0SHemant Agrawal  */
12767ae777d0SHemant Agrawal #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER	0x00000001
12777ae777d0SHemant Agrawal /**
12787ae777d0SHemant Agrawal  * CSCN message is written to message_iova once exiting a
12797ae777d0SHemant Agrawal  * congestion state (see 'threshold_exit')
12807ae777d0SHemant Agrawal  */
12817ae777d0SHemant Agrawal #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT		0x00000002
12827ae777d0SHemant Agrawal /**
12837ae777d0SHemant Agrawal  * CSCN write will attempt to allocate into a cache (coherent write);
12847ae777d0SHemant Agrawal  * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
12857ae777d0SHemant Agrawal  */
12867ae777d0SHemant Agrawal #define DPNI_CONG_OPT_COHERENT_WRITE		0x00000004
12877ae777d0SHemant Agrawal /**
12887ae777d0SHemant Agrawal  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
12897ae777d0SHemant Agrawal  * DPIO/DPCON's WQ channel once entering a congestion state
12907ae777d0SHemant Agrawal  * (see 'threshold_entry')
12917ae777d0SHemant Agrawal  */
12927ae777d0SHemant Agrawal #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER	0x00000008
12937ae777d0SHemant Agrawal /**
12947ae777d0SHemant Agrawal  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
12957ae777d0SHemant Agrawal  * DPIO/DPCON's WQ channel once exiting a congestion state
12967ae777d0SHemant Agrawal  * (see 'threshold_exit')
12977ae777d0SHemant Agrawal  */
12987ae777d0SHemant Agrawal #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT	0x00000010
12997ae777d0SHemant Agrawal /**
13007ae777d0SHemant Agrawal  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
13017ae777d0SHemant Agrawal  * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
13027ae777d0SHemant Agrawal  */
13037ae777d0SHemant Agrawal #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED	0x00000020
130416bbc98aSShreyansh Jain /**
130516bbc98aSShreyansh Jain  * This congestion will trigger flow control or priority flow control. This
130616bbc98aSShreyansh Jain  * will have effect only if flow control is enabled with dpni_set_link_cfg()
130716bbc98aSShreyansh Jain  */
130816bbc98aSShreyansh Jain #define DPNI_CONG_OPT_FLOW_CONTROL	0x00000040
13097ae777d0SHemant Agrawal 
13107ae777d0SHemant Agrawal /**
131155984a9bSShreyansh Jain  * enum dpni_congestion_point - Structure representing congestion point
131255984a9bSShreyansh Jain  * @DPNI_CP_QUEUE:	Set congestion per queue, identified by QUEUE_TYPE, TC
131355984a9bSShreyansh Jain  *			and QUEUE_INDEX
131455984a9bSShreyansh Jain  * @DPNI_CP_GROUP:	Set congestion per queue group. Depending on options
131555984a9bSShreyansh Jain  *			used to define the DPNI this can be either per
131655984a9bSShreyansh Jain  *			TC (default) or per interface
131755984a9bSShreyansh Jain  *			(DPNI_OPT_SHARED_CONGESTION set at DPNI create).
131855984a9bSShreyansh Jain  *			QUEUE_INDEX is ignored if this type is used.
131955984a9bSShreyansh Jain  * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
132055984a9bSShreyansh Jain  *		only if the DPNI is created with  DPNI_OPT_CUSTOM_CG option
132155984a9bSShreyansh Jain  */
132255984a9bSShreyansh Jain 
132355984a9bSShreyansh Jain enum dpni_congestion_point {
132455984a9bSShreyansh Jain 	DPNI_CP_QUEUE,
132555984a9bSShreyansh Jain 	DPNI_CP_GROUP,
132655984a9bSShreyansh Jain 	DPNI_CP_CONGESTION_GROUP,
132755984a9bSShreyansh Jain };
132855984a9bSShreyansh Jain 
132955984a9bSShreyansh Jain /**
13307ae777d0SHemant Agrawal  * struct dpni_congestion_notification_cfg - congestion notification
13317ae777d0SHemant Agrawal  *		configuration
13327ae777d0SHemant Agrawal  * @units: units type
13337ae777d0SHemant Agrawal  * @threshold_entry: above this threshold we enter a congestion state.
13347ae777d0SHemant Agrawal  *	set it to '0' to disable it
13357ae777d0SHemant Agrawal  * @threshold_exit: below this threshold we exit the congestion state.
13367ae777d0SHemant Agrawal  * @message_ctx: The context that will be part of the CSCN message
13377ae777d0SHemant Agrawal  * @message_iova: I/O virtual address (must be in DMA-able memory),
13387ae777d0SHemant Agrawal  *	must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
13397ae777d0SHemant Agrawal  *	contained in 'options'
13407ae777d0SHemant Agrawal  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
13417ae777d0SHemant Agrawal  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
134255984a9bSShreyansh Jain  * @cg_point: Congestion point settings
134355984a9bSShreyansh Jain  * @cgid: id of the congestion group. The index is relative to dpni.
13447ae777d0SHemant Agrawal  */
13457ae777d0SHemant Agrawal 
13467ae777d0SHemant Agrawal struct dpni_congestion_notification_cfg {
13477ae777d0SHemant Agrawal 	enum dpni_congestion_unit units;
13487ae777d0SHemant Agrawal 	uint32_t threshold_entry;
13497ae777d0SHemant Agrawal 	uint32_t threshold_exit;
13507ae777d0SHemant Agrawal 	uint64_t message_ctx;
13517ae777d0SHemant Agrawal 	uint64_t message_iova;
13527ae777d0SHemant Agrawal 	struct dpni_dest_cfg dest_cfg;
13537ae777d0SHemant Agrawal 	uint16_t notification_mode;
135455984a9bSShreyansh Jain 	enum dpni_congestion_point cg_point;
135555984a9bSShreyansh Jain 	int cgid;
13567ae777d0SHemant Agrawal };
13577ae777d0SHemant Agrawal 
135816bbc98aSShreyansh Jain int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
13597ae777d0SHemant Agrawal 				     uint32_t cmd_flags,
13607ae777d0SHemant Agrawal 				     uint16_t token,
13617ae777d0SHemant Agrawal 				     enum dpni_queue_type qtype,
1362f48cd6c6SNipun Gupta 				     uint16_t param,
13637ae777d0SHemant Agrawal 				     const struct dpni_congestion_notification_cfg *cfg);
13647ae777d0SHemant Agrawal 
13657ae777d0SHemant Agrawal int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
13667ae777d0SHemant Agrawal 				     uint32_t cmd_flags,
13677ae777d0SHemant Agrawal 				     uint16_t token,
13687ae777d0SHemant Agrawal 				     enum dpni_queue_type qtype,
1369f48cd6c6SNipun Gupta 				     uint16_t param,
13707ae777d0SHemant Agrawal 				     struct dpni_congestion_notification_cfg *cfg);
13717ae777d0SHemant Agrawal 
137216bbc98aSShreyansh Jain /* DPNI FLC stash options */
137316bbc98aSShreyansh Jain 
137416bbc98aSShreyansh Jain /**
137516bbc98aSShreyansh Jain  * stashes the whole annotation area (up to 192 bytes)
137616bbc98aSShreyansh Jain  */
137716bbc98aSShreyansh Jain #define DPNI_FLC_STASH_FRAME_ANNOTATION	0x00000001
1378e6b82573SHemant Agrawal 
1379e6b82573SHemant Agrawal /**
1380e6b82573SHemant Agrawal  * struct dpni_queue - Queue structure
138125fea082SHemant Agrawal  * @destination - Destination structure
138225fea082SHemant Agrawal  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1383e6b82573SHemant Agrawal  *	Identifies either a DPIO or a DPCON object.
1384e6b82573SHemant Agrawal  *	Not relevant for Tx queues.
138525fea082SHemant Agrawal  * @destination.type:	May be one of the following:
1386e6b82573SHemant Agrawal  *	0 - No destination, queue can be manually
1387e6b82573SHemant Agrawal  *		queried, but will not push traffic or
1388e6b82573SHemant Agrawal  *		notifications to a DPIO;
1389e6b82573SHemant Agrawal  *	1 - The destination is a DPIO. When traffic
1390e6b82573SHemant Agrawal  *		becomes available in the queue a FQDAN
1391e6b82573SHemant Agrawal  *		(FQ data available notification) will be
1392e6b82573SHemant Agrawal  *		generated to selected DPIO;
1393e6b82573SHemant Agrawal  *	2 - The destination is a DPCON. The queue is
1394e6b82573SHemant Agrawal  *		associated with a DPCON object for the
1395e6b82573SHemant Agrawal  *		purpose of scheduling between multiple
1396e6b82573SHemant Agrawal  *		queues. The DPCON may be independently
1397e6b82573SHemant Agrawal  *		configured to generate notifications.
1398e6b82573SHemant Agrawal  *		Not relevant for Tx queues.
139925fea082SHemant Agrawal  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1400e6b82573SHemant Agrawal  *	in a DPIO during dequeue to reduce spread of traffic.
1401e6b82573SHemant Agrawal  *	Only relevant if queues are
1402e6b82573SHemant Agrawal  *	not affined to a single DPIO.
140325fea082SHemant Agrawal  * @user_context: User data, presented to the user along with any frames
140425fea082SHemant Agrawal  *	from this queue. Not relevant for Tx queues.
140525fea082SHemant Agrawal  * @flc: FD FLow Context structure
140625fea082SHemant Agrawal  * @flc.value: Default FLC value for traffic dequeued from
140716bbc98aSShreyansh Jain  *      this queue.  Please check description of FD
140816bbc98aSShreyansh Jain  *      structure for more information.
140916bbc98aSShreyansh Jain  *      Note that FLC values set using dpni_add_fs_entry,
141016bbc98aSShreyansh Jain  *      if any, take precedence over values per queue.
141125fea082SHemant Agrawal  * @flc.stash_control: Boolean, indicates whether the 6 lowest
141216bbc98aSShreyansh Jain  *      - significant bits are used for stash control.
141316bbc98aSShreyansh Jain  *      significant bits are used for stash control.  If set, the 6
141416bbc98aSShreyansh Jain  *      least significant bits in value are interpreted as follows:
141516bbc98aSShreyansh Jain  *      - bits 0-1: indicates the number of 64 byte units of context
141616bbc98aSShreyansh Jain  *      that are stashed.  FLC value is interpreted as a memory address
141716bbc98aSShreyansh Jain  *      in this case, excluding the 6 LS bits.
141816bbc98aSShreyansh Jain  *      - bits 2-3: indicates the number of 64 byte units of frame
141916bbc98aSShreyansh Jain  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
142016bbc98aSShreyansh Jain  *      - bits 4-5: indicates the number of 64 byte units of frame
142116bbc98aSShreyansh Jain  *      data to be stashed.  Frame data is placed at FD[ADDR] +
142216bbc98aSShreyansh Jain  *      FD[OFFSET].
142316bbc98aSShreyansh Jain  *      For more details check the Frame Descriptor section in the
142416bbc98aSShreyansh Jain  *      hardware documentation.
142555984a9bSShreyansh Jain  *@cgid :indicate the cgid to set relative to dpni
1426e6b82573SHemant Agrawal  */
142725fea082SHemant Agrawal struct dpni_queue {
142825fea082SHemant Agrawal 	struct {
142925fea082SHemant Agrawal 		uint16_t id;
143025fea082SHemant Agrawal 		enum dpni_dest type;
143125fea082SHemant Agrawal 		char hold_active;
143225fea082SHemant Agrawal 		uint8_t priority;
143325fea082SHemant Agrawal 	} destination;
143425fea082SHemant Agrawal 	uint64_t user_context;
1435e6b82573SHemant Agrawal 	struct {
1436e6b82573SHemant Agrawal 		uint64_t value;
1437e6b82573SHemant Agrawal 		char stash_control;
1438e6b82573SHemant Agrawal 	} flc;
143955984a9bSShreyansh Jain 	int cgid;
1440e6b82573SHemant Agrawal };
1441e6b82573SHemant Agrawal 
1442e6b82573SHemant Agrawal /**
1443e6b82573SHemant Agrawal  * struct dpni_queue_id - Queue identification, used for enqueue commands
1444e6b82573SHemant Agrawal  *				or queue control
1445e6b82573SHemant Agrawal  * @fqid:	FQID used for enqueueing to and/or configuration of this
1446e6b82573SHemant Agrawal  *			specific FQ
1447e6b82573SHemant Agrawal  * @qdbin:	Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1448e6b82573SHemant Agrawal  *			Only relevant for Tx queues.
1449e6b82573SHemant Agrawal  */
1450e6b82573SHemant Agrawal struct dpni_queue_id {
1451e6b82573SHemant Agrawal 	uint32_t fqid;
1452e6b82573SHemant Agrawal 	uint16_t qdbin;
1453e6b82573SHemant Agrawal };
1454e6b82573SHemant Agrawal 
1455e6b82573SHemant Agrawal /**
1456e6b82573SHemant Agrawal  * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1457e6b82573SHemant Agrawal  * confirmation
1458e6b82573SHemant Agrawal  * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1459e6b82573SHemant Agrawal  * an affine Tx Confirmation queue
1460e6b82573SHemant Agrawal  * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1461e6b82573SHemant Agrawal  * confirmation queue
1462e6b82573SHemant Agrawal  * @DPNI_CONF_DISABLE: Tx frames are not confirmed.  This must be associated
1463e6b82573SHemant Agrawal  * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1464e6b82573SHemant Agrawal  * buffers will be leaked
1465e6b82573SHemant Agrawal  */
1466e6b82573SHemant Agrawal enum dpni_confirmation_mode {
1467e6b82573SHemant Agrawal 	DPNI_CONF_AFFINE,
1468e6b82573SHemant Agrawal 	DPNI_CONF_SINGLE,
1469e6b82573SHemant Agrawal 	DPNI_CONF_DISABLE,
1470e6b82573SHemant Agrawal };
1471e6b82573SHemant Agrawal 
1472e6b82573SHemant Agrawal int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1473e6b82573SHemant Agrawal 				  uint32_t cmd_flags,
1474e6b82573SHemant Agrawal 				  uint16_t token,
1475*591200efSGagandeep Singh 				  uint8_t ceetm_ch_idx,
1476e6b82573SHemant Agrawal 				  enum dpni_confirmation_mode mode);
1477e6b82573SHemant Agrawal 
147816bbc98aSShreyansh Jain int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
147916bbc98aSShreyansh Jain 				  uint32_t cmd_flags,
148016bbc98aSShreyansh Jain 				  uint16_t token,
1481*591200efSGagandeep Singh 				  uint8_t ceetm_ch_idx,
1482*591200efSGagandeep Singh 				  enum dpni_confirmation_mode *mode);
1483*591200efSGagandeep Singh 
1484*591200efSGagandeep Singh int dpni_set_queue_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1485*591200efSGagandeep Singh 				  uint32_t cmd_flags,
1486*591200efSGagandeep Singh 				  uint16_t token,
1487*591200efSGagandeep Singh 				  uint8_t ceetm_ch_idx, uint8_t index,
1488*591200efSGagandeep Singh 				  enum dpni_confirmation_mode mode);
1489*591200efSGagandeep Singh 
1490*591200efSGagandeep Singh int dpni_get_queue_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1491*591200efSGagandeep Singh 				  uint32_t cmd_flags,
1492*591200efSGagandeep Singh 				  uint16_t token,
1493*591200efSGagandeep Singh 				  uint8_t ceetm_ch_idx, uint8_t index,
149416bbc98aSShreyansh Jain 				  enum dpni_confirmation_mode *mode);
149516bbc98aSShreyansh Jain 
1496fe2b986aSSunil Kumar Kori /**
1497fe2b986aSSunil Kumar Kori  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1498fe2b986aSSunil Kumar Kori  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1499fe2b986aSSunil Kumar Kori  *		key extractions to be used as the QoS criteria by calling
1500fe2b986aSSunil Kumar Kori  *		dpkg_prepare_key_cfg()
1501fe2b986aSSunil Kumar Kori  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1502fe2b986aSSunil Kumar Kori  *		'0' to use the 'default_tc' in such cases
15037be78d02SJosh Soref  * @keep_entries: if set to one will not delete existing table entries. This
1504fe2b986aSSunil Kumar Kori  *		option will work properly only for dpni objects created with
1505fe2b986aSSunil Kumar Kori  *		DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1506fe2b986aSSunil Kumar Kori  *		be compatible with new key composition rule.
1507fe2b986aSSunil Kumar Kori  *		It is the caller's job to delete incompatible entries before
1508fe2b986aSSunil Kumar Kori  *		executing this function.
1509fe2b986aSSunil Kumar Kori  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1510fe2b986aSSunil Kumar Kori  */
1511fe2b986aSSunil Kumar Kori struct dpni_qos_tbl_cfg {
1512fe2b986aSSunil Kumar Kori 	uint64_t key_cfg_iova;
1513fe2b986aSSunil Kumar Kori 	int discard_on_miss;
1514fe2b986aSSunil Kumar Kori 	int keep_entries;
1515fe2b986aSSunil Kumar Kori 	uint8_t default_tc;
1516fe2b986aSSunil Kumar Kori };
1517fe2b986aSSunil Kumar Kori 
1518fe2b986aSSunil Kumar Kori int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1519fe2b986aSSunil Kumar Kori 		       uint32_t cmd_flags,
1520fe2b986aSSunil Kumar Kori 		       uint16_t token,
1521fe2b986aSSunil Kumar Kori 		       const struct dpni_qos_tbl_cfg *cfg);
1522fe2b986aSSunil Kumar Kori 
1523fe2b986aSSunil Kumar Kori /**
1524fe2b986aSSunil Kumar Kori  * struct dpni_rule_cfg - Rule configuration for table lookup
1525fe2b986aSSunil Kumar Kori  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1526fe2b986aSSunil Kumar Kori  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1527fe2b986aSSunil Kumar Kori  * @key_size: key and mask size (in bytes)
1528fe2b986aSSunil Kumar Kori  */
1529fe2b986aSSunil Kumar Kori struct dpni_rule_cfg {
1530fe2b986aSSunil Kumar Kori 	uint64_t key_iova;
1531fe2b986aSSunil Kumar Kori 	uint64_t mask_iova;
1532fe2b986aSSunil Kumar Kori 	uint8_t key_size;
1533fe2b986aSSunil Kumar Kori };
1534fe2b986aSSunil Kumar Kori 
1535fe2b986aSSunil Kumar Kori int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1536fe2b986aSSunil Kumar Kori 		       uint32_t cmd_flags,
1537fe2b986aSSunil Kumar Kori 		       uint16_t token,
1538fe2b986aSSunil Kumar Kori 		       const struct dpni_rule_cfg *cfg,
1539fe2b986aSSunil Kumar Kori 		       uint8_t tc_id,
154096f7bfe8SSachin Saxena 		       uint16_t index,
154196f7bfe8SSachin Saxena 			   uint8_t flags,
154296f7bfe8SSachin Saxena 			   uint8_t flow_id);
1543fe2b986aSSunil Kumar Kori 
1544fe2b986aSSunil Kumar Kori int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1545fe2b986aSSunil Kumar Kori 			  uint32_t cmd_flags,
1546fe2b986aSSunil Kumar Kori 			  uint16_t token,
1547fe2b986aSSunil Kumar Kori 			  const struct dpni_rule_cfg *cfg);
1548fe2b986aSSunil Kumar Kori 
1549fe2b986aSSunil Kumar Kori int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1550fe2b986aSSunil Kumar Kori 			 uint32_t cmd_flags,
1551fe2b986aSSunil Kumar Kori 			 uint16_t token);
1552fe2b986aSSunil Kumar Kori 
1553fe2b986aSSunil Kumar Kori /**
1554fe2b986aSSunil Kumar Kori  * Discard matching traffic.  If set, this takes precedence over any other
1555fe2b986aSSunil Kumar Kori  * configuration and matching traffic is always discarded.
1556fe2b986aSSunil Kumar Kori  */
1557fe2b986aSSunil Kumar Kori  #define DPNI_FS_OPT_DISCARD            0x1
1558fe2b986aSSunil Kumar Kori 
1559fe2b986aSSunil Kumar Kori /**
1560fe2b986aSSunil Kumar Kori  * Set FLC value.  If set, flc member of truct dpni_fs_action_cfg is used to
1561fe2b986aSSunil Kumar Kori  * override the FLC value set per queue.
1562fe2b986aSSunil Kumar Kori  * For more details check the Frame Descriptor section in the hardware
1563fe2b986aSSunil Kumar Kori  * documentation.
1564fe2b986aSSunil Kumar Kori  */
1565fe2b986aSSunil Kumar Kori #define DPNI_FS_OPT_SET_FLC            0x2
1566fe2b986aSSunil Kumar Kori 
1567fe2b986aSSunil Kumar Kori /*
1568fe2b986aSSunil Kumar Kori  * Indicates whether the 6 lowest significant bits of FLC are used for stash
1569fe2b986aSSunil Kumar Kori  * control.  If set, the 6 least significant bits in value are interpreted as
1570fe2b986aSSunil Kumar Kori  * follows:
1571fe2b986aSSunil Kumar Kori  *     - bits 0-1: indicates the number of 64 byte units of context that are
1572fe2b986aSSunil Kumar Kori  *     stashed.  FLC value is interpreted as a memory address in this case,
1573fe2b986aSSunil Kumar Kori  *     excluding the 6 LS bits.
1574fe2b986aSSunil Kumar Kori  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1575fe2b986aSSunil Kumar Kori  *     to be stashed.  Annotation is placed at FD[ADDR].
1576fe2b986aSSunil Kumar Kori  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1577fe2b986aSSunil Kumar Kori  *     stashed.  Frame data is placed at FD[ADDR] + FD[OFFSET].
1578fe2b986aSSunil Kumar Kori  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1579fe2b986aSSunil Kumar Kori  */
1580fe2b986aSSunil Kumar Kori #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1581fe2b986aSSunil Kumar Kori 
1582fe2b986aSSunil Kumar Kori /**
1583028d1dfdSJun Yang  * Redirect matching traffic to Rx part of another dpni object. The frame
1584028d1dfdSJun Yang  * will be classified according to new qos and flow steering rules from
1585028d1dfdSJun Yang  * target dpni object.
1586028d1dfdSJun Yang  */
1587028d1dfdSJun Yang #define DPNI_FS_OPT_REDIRECT_TO_DPNI_RX		0x08
1588028d1dfdSJun Yang 
1589028d1dfdSJun Yang /**
1590028d1dfdSJun Yang  * Redirect matching traffic into Tx queue of another dpni object. The
1591028d1dfdSJun Yang  * frame will be transmitted directly
1592028d1dfdSJun Yang  */
1593028d1dfdSJun Yang #define DPNI_FS_OPT_REDIRECT_TO_DPNI_TX		0x10
1594028d1dfdSJun Yang 
1595028d1dfdSJun Yang /**
1596fe2b986aSSunil Kumar Kori  * struct dpni_fs_action_cfg - Action configuration for table look-up
1597fe2b986aSSunil Kumar Kori  * @flc: FLC value for traffic matching this rule.  Please check the Frame
1598fe2b986aSSunil Kumar Kori  * Descriptor section in the hardware documentation for more information.
1599fe2b986aSSunil Kumar Kori  * @flow_id: Identifies the Rx queue used for matching traffic.  Supported
1600fe2b986aSSunil Kumar Kori  *     values are in range 0 to num_queue-1.
1601028d1dfdSJun Yang  * @redirect_obj_token: token that identifies the object where frame is
16027be78d02SJosh Soref  * redirected when this rule is hit. This parameter is used only when one of the
1603028d1dfdSJun Yang  * flags DPNI_FS_OPT_REDIRECT_TO_DPNI_RX or DPNI_FS_OPT_REDIRECT_TO_DPNI_TX is
1604028d1dfdSJun Yang  * set.
1605028d1dfdSJun Yang  * The token is obtained using dpni_open() API call. The object must stay
1606028d1dfdSJun Yang  * open during the operation to ensure the fact that application has access
1607028d1dfdSJun Yang  * on it. If the object is destroyed of closed next actions will take place:
1608028d1dfdSJun Yang  * - if DPNI_FS_OPT_DISCARD is set the frame will be discarded by current dpni
1609028d1dfdSJun Yang  * - if DPNI_FS_OPT_DISCARD is cleared the frame will be enqueued in queue with
1610028d1dfdSJun Yang  *   index provided in flow_id parameter.
1611fe2b986aSSunil Kumar Kori  * @options: Any combination of DPNI_FS_OPT_ values.
1612fe2b986aSSunil Kumar Kori  */
1613fe2b986aSSunil Kumar Kori struct dpni_fs_action_cfg {
1614fe2b986aSSunil Kumar Kori 	uint64_t flc;
1615fe2b986aSSunil Kumar Kori 	uint16_t flow_id;
16162cb2abf3SHemant Agrawal 	uint16_t redirect_obj_token;
1617fe2b986aSSunil Kumar Kori 	uint16_t options;
1618fe2b986aSSunil Kumar Kori };
1619fe2b986aSSunil Kumar Kori 
1620fe2b986aSSunil Kumar Kori int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1621fe2b986aSSunil Kumar Kori 		      uint32_t cmd_flags,
1622fe2b986aSSunil Kumar Kori 		      uint16_t token,
1623fe2b986aSSunil Kumar Kori 		      uint8_t tc_id,
1624fe2b986aSSunil Kumar Kori 		      uint16_t index,
1625fe2b986aSSunil Kumar Kori 		      const struct dpni_rule_cfg *cfg,
1626fe2b986aSSunil Kumar Kori 		      const struct dpni_fs_action_cfg *action);
1627fe2b986aSSunil Kumar Kori 
1628fe2b986aSSunil Kumar Kori int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1629fe2b986aSSunil Kumar Kori 			 uint32_t cmd_flags,
1630fe2b986aSSunil Kumar Kori 			 uint16_t token,
1631fe2b986aSSunil Kumar Kori 			 uint8_t tc_id,
1632fe2b986aSSunil Kumar Kori 			 const struct dpni_rule_cfg *cfg);
1633fe2b986aSSunil Kumar Kori 
1634fe2b986aSSunil Kumar Kori int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1635fe2b986aSSunil Kumar Kori 			  uint32_t cmd_flags,
1636fe2b986aSSunil Kumar Kori 			  uint16_t token,
1637fe2b986aSSunil Kumar Kori 			  uint8_t tc_id);
1638fe2b986aSSunil Kumar Kori 
1639e6b82573SHemant Agrawal int dpni_get_api_version(struct fsl_mc_io *mc_io,
1640e6b82573SHemant Agrawal 			 uint32_t cmd_flags,
1641e6b82573SHemant Agrawal 			 uint16_t *major_ver,
1642e6b82573SHemant Agrawal 			 uint16_t *minor_ver);
1643e6b82573SHemant Agrawal 
1644e6b82573SHemant Agrawal /**
1645e6b82573SHemant Agrawal  * Set User Context
1646e6b82573SHemant Agrawal  */
1647e6b82573SHemant Agrawal #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
1648e6b82573SHemant Agrawal 
1649e6b82573SHemant Agrawal /**
1650e6b82573SHemant Agrawal  * Set queue destination configuration
1651e6b82573SHemant Agrawal  */
1652e6b82573SHemant Agrawal #define DPNI_QUEUE_OPT_DEST		0x00000002
1653e6b82573SHemant Agrawal 
1654e6b82573SHemant Agrawal /**
1655e6b82573SHemant Agrawal  * Set FD[FLC] configuration for traffic on this queue.  Note that FLC values
1656e6b82573SHemant Agrawal  * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1657e6b82573SHemant Agrawal  */
1658e6b82573SHemant Agrawal #define DPNI_QUEUE_OPT_FLC		0x00000004
1659e6b82573SHemant Agrawal 
1660e6b82573SHemant Agrawal /**
1661e6b82573SHemant Agrawal  * Set the queue to hold active mode.  This prevents the queue from being
1662e6b82573SHemant Agrawal  * rescheduled between DPIOs while it carries traffic and is active on one
1663e6b82573SHemant Agrawal  * DPNI.  Can help reduce reordering when servicing one queue on multiple
1664e6b82573SHemant Agrawal  * CPUs, but the queue is also less likely to push data to multiple CPUs
1665e6b82573SHemant Agrawal  * especially when congested.
1666e6b82573SHemant Agrawal  */
1667e6b82573SHemant Agrawal #define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
1668e6b82573SHemant Agrawal 
166955984a9bSShreyansh Jain #define DPNI_QUEUE_OPT_SET_CGID				0x00000040
167055984a9bSShreyansh Jain #define DPNI_QUEUE_OPT_CLEAR_CGID			0x00000080
167155984a9bSShreyansh Jain 
1672e6b82573SHemant Agrawal int dpni_set_queue(struct fsl_mc_io *mc_io,
1673e6b82573SHemant Agrawal 		   uint32_t cmd_flags,
1674e6b82573SHemant Agrawal 		   uint16_t token,
1675e6b82573SHemant Agrawal 		   enum dpni_queue_type qtype,
1676f48cd6c6SNipun Gupta 		   uint16_t param,
1677e6b82573SHemant Agrawal 		   uint8_t index,
1678e6b82573SHemant Agrawal 		   uint8_t options,
1679e6b82573SHemant Agrawal 		   const struct dpni_queue *queue);
1680e6b82573SHemant Agrawal 
1681e6b82573SHemant Agrawal int dpni_get_queue(struct fsl_mc_io *mc_io,
1682e6b82573SHemant Agrawal 		   uint32_t cmd_flags,
1683e6b82573SHemant Agrawal 		   uint16_t token,
1684e6b82573SHemant Agrawal 		   enum dpni_queue_type qtype,
1685f48cd6c6SNipun Gupta 		   uint16_t param,
1686e6b82573SHemant Agrawal 		   uint8_t index,
1687e6b82573SHemant Agrawal 		   struct dpni_queue *queue,
1688e6b82573SHemant Agrawal 		   struct dpni_queue_id *qid);
1689e6b82573SHemant Agrawal 
1690e6b82573SHemant Agrawal int dpni_get_statistics(struct fsl_mc_io *mc_io,
1691e6b82573SHemant Agrawal 			uint32_t cmd_flags,
1692e6b82573SHemant Agrawal 			uint16_t token,
1693e6b82573SHemant Agrawal 			uint8_t page,
169455984a9bSShreyansh Jain 			uint16_t param,
1695e6b82573SHemant Agrawal 			union dpni_statistics *stat);
1696e6b82573SHemant Agrawal 
1697e6b82573SHemant Agrawal int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1698e6b82573SHemant Agrawal 			  uint32_t cmd_flags,
1699e6b82573SHemant Agrawal 			  uint16_t token);
1700e6b82573SHemant Agrawal 
170123d6a87eSHemant Agrawal /**
170223d6a87eSHemant Agrawal  * struct dpni_taildrop - Structure representing the taildrop
170323d6a87eSHemant Agrawal  * @enable:	Indicates whether the taildrop is active or not.
170423d6a87eSHemant Agrawal  * @units:	Indicates the unit of THRESHOLD. Queue taildrop only
170523d6a87eSHemant Agrawal  *		supports byte units, this field is ignored and
170623d6a87eSHemant Agrawal  *		assumed = 0 if CONGESTION_POINT is 0.
170723d6a87eSHemant Agrawal  * @threshold:	Threshold value, in units identified by UNITS field. Value 0
170823d6a87eSHemant Agrawal  *		cannot be used as a valid taildrop threshold,
170923d6a87eSHemant Agrawal  *		THRESHOLD must be > 0 if the taildrop is
171023d6a87eSHemant Agrawal  *		enabled.
171116bbc98aSShreyansh Jain  * @oal	:	Overhead Accounting Length, a 12-bit, 2's complement value
171216bbc98aSShreyansh Jain  *		with range (-2048 to +2047) representing a fixed per-frame
171316bbc98aSShreyansh Jain  *		overhead to be added to the actual length of a frame when
171416bbc98aSShreyansh Jain  *		performing WRED and tail drop calculations and threshold
171516bbc98aSShreyansh Jain  *		comparisons.
171623d6a87eSHemant Agrawal  */
171723d6a87eSHemant Agrawal struct dpni_taildrop {
171823d6a87eSHemant Agrawal 	char enable;
171923d6a87eSHemant Agrawal 	enum dpni_congestion_unit units;
172023d6a87eSHemant Agrawal 	uint32_t threshold;
172116bbc98aSShreyansh Jain 	int16_t oal;
172223d6a87eSHemant Agrawal };
172323d6a87eSHemant Agrawal 
172423d6a87eSHemant Agrawal int dpni_set_taildrop(struct fsl_mc_io *mc_io,
172523d6a87eSHemant Agrawal 		      uint32_t cmd_flags,
172623d6a87eSHemant Agrawal 		      uint16_t token,
172723d6a87eSHemant Agrawal 		      enum dpni_congestion_point cg_point,
172823d6a87eSHemant Agrawal 		      enum dpni_queue_type q_type,
1729f48cd6c6SNipun Gupta 		      uint16_t param,
173023d6a87eSHemant Agrawal 		      uint8_t q_index,
173123d6a87eSHemant Agrawal 		      struct dpni_taildrop *taildrop);
173223d6a87eSHemant Agrawal 
173323d6a87eSHemant Agrawal int dpni_get_taildrop(struct fsl_mc_io *mc_io,
173423d6a87eSHemant Agrawal 		      uint32_t cmd_flags,
173523d6a87eSHemant Agrawal 		      uint16_t token,
173623d6a87eSHemant Agrawal 		      enum dpni_congestion_point cg_point,
173723d6a87eSHemant Agrawal 		      enum dpni_queue_type q_type,
173823d6a87eSHemant Agrawal 		      uint8_t tc,
173923d6a87eSHemant Agrawal 		      uint8_t q_index,
174023d6a87eSHemant Agrawal 		      struct dpni_taildrop *taildrop);
174125fea082SHemant Agrawal 
174225fea082SHemant Agrawal int dpni_set_opr(struct fsl_mc_io *mc_io,
174325fea082SHemant Agrawal 		 uint32_t cmd_flags,
174425fea082SHemant Agrawal 		 uint16_t token,
174525fea082SHemant Agrawal 		 uint8_t tc,
174625fea082SHemant Agrawal 		 uint8_t index,
174725fea082SHemant Agrawal 		 uint8_t options,
17482cb2abf3SHemant Agrawal 		 struct opr_cfg *cfg,
17492cb2abf3SHemant Agrawal 		 uint8_t opr_id);
175025fea082SHemant Agrawal 
175125fea082SHemant Agrawal int dpni_get_opr(struct fsl_mc_io *mc_io,
175225fea082SHemant Agrawal 		 uint32_t cmd_flags,
175325fea082SHemant Agrawal 		 uint16_t token,
175425fea082SHemant Agrawal 		 uint8_t tc,
175525fea082SHemant Agrawal 		 uint8_t index,
175625fea082SHemant Agrawal 		 struct opr_cfg *cfg,
17572cb2abf3SHemant Agrawal 		 struct opr_qry *qry,
17582cb2abf3SHemant Agrawal 		 uint8_t flags,
17592cb2abf3SHemant Agrawal 		 uint8_t opr_id);
176025fea082SHemant Agrawal 
1761fe2b986aSSunil Kumar Kori /**
1762a712067dSSunil Kumar Kori  * enum dpni_soft_sequence_dest - Enumeration of WRIOP software sequence
1763a712067dSSunil Kumar Kori  *				destinations
1764a712067dSSunil Kumar Kori  * @DPNI_SS_INGRESS: Ingress parser
1765a712067dSSunil Kumar Kori  * @DPNI_SS_EGRESS: Egress parser
1766a712067dSSunil Kumar Kori  */
1767a712067dSSunil Kumar Kori enum dpni_soft_sequence_dest {
1768a712067dSSunil Kumar Kori 	DPNI_SS_INGRESS = 0,
1769a712067dSSunil Kumar Kori 	DPNI_SS_EGRESS = 1,
1770a712067dSSunil Kumar Kori };
1771a712067dSSunil Kumar Kori 
1772a712067dSSunil Kumar Kori /**
1773a712067dSSunil Kumar Kori  * struct dpni_load_ss_cfg - Structure for Software Sequence load configuration
1774a712067dSSunil Kumar Kori  * @dest:	Destination of the Software Sequence: ingress or egress parser
1775a712067dSSunil Kumar Kori  * @ss_size: Size of the Software Sequence
1776a712067dSSunil Kumar Kori  * @ss_offset:	The offset where to load the Software Sequence (0x20-0x7FD)
1777a712067dSSunil Kumar Kori  * @ss_iova: I/O virtual address of the Software Sequence
1778a712067dSSunil Kumar Kori  */
1779a712067dSSunil Kumar Kori struct dpni_load_ss_cfg {
1780a712067dSSunil Kumar Kori 	enum dpni_soft_sequence_dest dest;
1781a712067dSSunil Kumar Kori 	uint16_t ss_size;
1782a712067dSSunil Kumar Kori 	uint16_t ss_offset;
1783a712067dSSunil Kumar Kori 	uint64_t ss_iova;
1784a712067dSSunil Kumar Kori };
1785a712067dSSunil Kumar Kori 
1786a712067dSSunil Kumar Kori /**
1787a712067dSSunil Kumar Kori  * struct dpni_enable_ss_cfg - Structure for software sequence enable
1788a712067dSSunil Kumar Kori  *				configuration
1789a712067dSSunil Kumar Kori  * @dest:	Destination of the Software Sequence: ingress or egress parser
1790a712067dSSunil Kumar Kori  * @hxs: HXS to attach the software sequence to
1791a712067dSSunil Kumar Kori  * @set_start: If the Software Sequence or HDR it is attached to is set as
1792a712067dSSunil Kumar Kori  *		parser start
1793a712067dSSunil Kumar Kori  *		If hxs=DUMMY_LAST_HXS the ss_offset is set directly as parser
1794a712067dSSunil Kumar Kori  *			start else the hdr index code is set as parser start
1795a712067dSSunil Kumar Kori  * @ss_offset: The offset of the Software Sequence to enable or set as parse
1796a712067dSSunil Kumar Kori  *		start
1797a712067dSSunil Kumar Kori  * @param_size: Size of the software sequence parameters
1798a712067dSSunil Kumar Kori  * @param_offset: Offset in the parameter zone for the software sequence
1799a712067dSSunil Kumar Kori  *			parameters
1800a712067dSSunil Kumar Kori  * @param_iova: I/O virtual address of the parameters
1801a712067dSSunil Kumar Kori  */
1802a712067dSSunil Kumar Kori struct dpni_enable_ss_cfg {
1803a712067dSSunil Kumar Kori 	enum dpni_soft_sequence_dest dest;
1804a712067dSSunil Kumar Kori 	uint16_t hxs;
1805a712067dSSunil Kumar Kori 	uint8_t set_start;
1806a712067dSSunil Kumar Kori 	uint16_t ss_offset;
1807a712067dSSunil Kumar Kori 	uint8_t param_size;
1808a712067dSSunil Kumar Kori 	uint8_t param_offset;
1809a712067dSSunil Kumar Kori 	uint64_t param_iova;
1810a712067dSSunil Kumar Kori };
1811a712067dSSunil Kumar Kori 
1812a712067dSSunil Kumar Kori /**
1813a712067dSSunil Kumar Kori  * dpni_load_sw_sequence() - Loads a software sequence in parser memory.
1814a712067dSSunil Kumar Kori  * @mc_io:	Pointer to MC portal's I/O object
1815a712067dSSunil Kumar Kori  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1816a712067dSSunil Kumar Kori  * @token:	Token of DPNI object
1817a712067dSSunil Kumar Kori  * @cfg:	Software sequence load configuration
1818a712067dSSunil Kumar Kori  * Return:	'0' on Success; Error code otherwise.
1819a712067dSSunil Kumar Kori  */
1820a712067dSSunil Kumar Kori int dpni_load_sw_sequence(struct fsl_mc_io *mc_io,
1821a712067dSSunil Kumar Kori 	      uint32_t cmd_flags,
1822a712067dSSunil Kumar Kori 	      uint16_t token,
1823a712067dSSunil Kumar Kori 		  struct dpni_load_ss_cfg *cfg);
1824a712067dSSunil Kumar Kori 
1825a712067dSSunil Kumar Kori /**
18267be78d02SJosh Soref  * dpni_enable_sw_sequence() - Enables a software sequence in the parser
1827a712067dSSunil Kumar Kori  *				profile
1828a712067dSSunil Kumar Kori  * corresponding to the ingress or egress of the DPNI.
1829a712067dSSunil Kumar Kori  * @mc_io:	Pointer to MC portal's I/O object
1830a712067dSSunil Kumar Kori  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1831a712067dSSunil Kumar Kori  * @token:	Token of DPNI object
1832a712067dSSunil Kumar Kori  * @cfg:	Software sequence enable configuration
1833a712067dSSunil Kumar Kori  * Return:	'0' on Success; Error code otherwise.
1834a712067dSSunil Kumar Kori  */
1835a712067dSSunil Kumar Kori int dpni_enable_sw_sequence(struct fsl_mc_io *mc_io,
1836a712067dSSunil Kumar Kori 			    uint32_t cmd_flags,
1837a712067dSSunil Kumar Kori 			    uint16_t token,
1838a712067dSSunil Kumar Kori 			    struct dpni_enable_ss_cfg *cfg);
1839a712067dSSunil Kumar Kori 
1840a712067dSSunil Kumar Kori /**
1841a712067dSSunil Kumar Kori  * struct dpni_sw_sequence_layout - Structure for software sequence enable
1842a712067dSSunil Kumar Kori  *				configuration
1843a712067dSSunil Kumar Kori  * @num_ss:	Number of software sequences returned
1844a712067dSSunil Kumar Kori  * @ss: Array of software sequence entries. The number of valid entries
1845a712067dSSunil Kumar Kori  *			must match 'num_ss' value
1846a712067dSSunil Kumar Kori  */
1847a712067dSSunil Kumar Kori struct dpni_sw_sequence_layout {
1848a712067dSSunil Kumar Kori 	uint8_t num_ss;
1849a712067dSSunil Kumar Kori 	struct {
1850a712067dSSunil Kumar Kori 		uint16_t ss_offset;
1851a712067dSSunil Kumar Kori 		uint16_t ss_size;
1852a712067dSSunil Kumar Kori 		uint8_t param_offset;
1853a712067dSSunil Kumar Kori 		uint8_t param_size;
1854a712067dSSunil Kumar Kori 	} ss[DPNI_SW_SEQUENCE_LAYOUT_SIZE];
1855a712067dSSunil Kumar Kori };
1856a712067dSSunil Kumar Kori 
1857a712067dSSunil Kumar Kori /**
1858a712067dSSunil Kumar Kori  * dpni_get_sw_sequence_layout() - Get the soft sequence layout
1859a712067dSSunil Kumar Kori  * @mc_io:	Pointer to MC portal's I/O object
1860a712067dSSunil Kumar Kori  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1861a712067dSSunil Kumar Kori  * @token:	Token of DPNI object
1862a712067dSSunil Kumar Kori  * @src:	Source of the layout (WRIOP Rx or Tx)
1863a712067dSSunil Kumar Kori  * @ss_layout_iova:  I/O virtual address of 264 bytes DMA-able memory
1864a712067dSSunil Kumar Kori  *
1865a712067dSSunil Kumar Kori  * warning: After calling this function, call dpni_extract_sw_sequence_layout()
1866a712067dSSunil Kumar Kori  *		to get the layout
1867a712067dSSunil Kumar Kori  *
1868a712067dSSunil Kumar Kori  * Return:	'0' on Success; error code otherwise.
1869a712067dSSunil Kumar Kori  */
1870a712067dSSunil Kumar Kori int dpni_get_sw_sequence_layout(struct fsl_mc_io *mc_io,
1871a712067dSSunil Kumar Kori 				uint32_t cmd_flags,
1872a712067dSSunil Kumar Kori 				uint16_t token,
1873a712067dSSunil Kumar Kori 				enum dpni_soft_sequence_dest src,
1874a712067dSSunil Kumar Kori 				uint64_t ss_layout_iova);
1875a712067dSSunil Kumar Kori 
1876a712067dSSunil Kumar Kori /**
1877a712067dSSunil Kumar Kori  * dpni_extract_sw_sequence_layout() - extract the software sequence layout
1878a712067dSSunil Kumar Kori  * @layout:	software sequence layout
18792cb2abf3SHemant Agrawal  * @sw_sequence_layout_buf:Zeroed 264 bytes of memory before mapping it to DMA
1880a712067dSSunil Kumar Kori  *
1881a712067dSSunil Kumar Kori  * This function has to be called after dpni_get_sw_sequence_layout
1882a712067dSSunil Kumar Kori  */
1883a712067dSSunil Kumar Kori void dpni_extract_sw_sequence_layout(struct dpni_sw_sequence_layout *layout,
1884a712067dSSunil Kumar Kori 				     const uint8_t *sw_sequence_layout_buf);
1885a712067dSSunil Kumar Kori 
18862cb2abf3SHemant Agrawal /**
1887*591200efSGagandeep Singh  * When used for queue_idx in function dpni_set_rx_dist_default_queue will signal to dpni
1888*591200efSGagandeep Singh  * to drop all unclassified frames
1889*591200efSGagandeep Singh  */
1890*591200efSGagandeep Singh #define DPNI_FS_MISS_DROP		((uint16_t)-1)
1891*591200efSGagandeep Singh 
1892*591200efSGagandeep Singh /**
1893*591200efSGagandeep Singh  * struct dpni_rx_dist_cfg - distribution configuration
1894*591200efSGagandeep Singh  * @dist_size:	distribution size; supported values: 1,2,3,4,6,7,8,
1895*591200efSGagandeep Singh  *		12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1896*591200efSGagandeep Singh  *		512,768,896,1024
1897*591200efSGagandeep Singh  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1898*591200efSGagandeep Singh  *		the extractions to be used for the distribution key by calling
1899*591200efSGagandeep Singh  *		dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise it can be '0'
1900*591200efSGagandeep Singh  * @enable: enable/disable the distribution.
1901*591200efSGagandeep Singh  * @tc: TC id for which distribution is set
1902*591200efSGagandeep Singh  * @fs_miss_flow_id: when packet misses all rules from flow steering table and hash is
1903*591200efSGagandeep Singh  *		disabled it will be put into this queue id; use DPNI_FS_MISS_DROP to drop
1904*591200efSGagandeep Singh  *		frames. The value of this field is used only when flow steering distribution
1905*591200efSGagandeep Singh  *		is enabled and hash distribution is disabled
1906*591200efSGagandeep Singh  */
1907*591200efSGagandeep Singh struct dpni_rx_dist_cfg {
1908*591200efSGagandeep Singh 	uint16_t dist_size;
1909*591200efSGagandeep Singh 	uint64_t key_cfg_iova;
1910*591200efSGagandeep Singh 	uint8_t enable;
1911*591200efSGagandeep Singh 	uint8_t tc;
1912*591200efSGagandeep Singh 	uint16_t fs_miss_flow_id;
1913*591200efSGagandeep Singh };
1914*591200efSGagandeep Singh 
1915*591200efSGagandeep Singh int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
1916*591200efSGagandeep Singh 		const struct dpni_rx_dist_cfg *cfg);
1917*591200efSGagandeep Singh 
1918*591200efSGagandeep Singh int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
1919*591200efSGagandeep Singh 		const struct dpni_rx_dist_cfg *cfg);
1920*591200efSGagandeep Singh 
1921*591200efSGagandeep Singh int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
1922*591200efSGagandeep Singh 		uint16_t tpid);
1923*591200efSGagandeep Singh 
1924*591200efSGagandeep Singh int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
1925*591200efSGagandeep Singh 		uint16_t tpid);
1926*591200efSGagandeep Singh 
1927*591200efSGagandeep Singh /**
1928*591200efSGagandeep Singh  * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID values
1929*591200efSGagandeep Singh  *		used in current dpni object to detect 802.1q frames.
1930*591200efSGagandeep Singh  *	@tpid1: first tag. Not used if zero.
1931*591200efSGagandeep Singh  *	@tpid2: second tag. Not used if zero.
1932*591200efSGagandeep Singh  */
1933*591200efSGagandeep Singh struct dpni_custom_tpid_cfg {
1934*591200efSGagandeep Singh 	uint16_t tpid1;
1935*591200efSGagandeep Singh 	uint16_t tpid2;
1936*591200efSGagandeep Singh };
1937*591200efSGagandeep Singh 
1938*591200efSGagandeep Singh int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
1939*591200efSGagandeep Singh 		struct dpni_custom_tpid_cfg *tpid);
1940*591200efSGagandeep Singh /*
19412cb2abf3SHemant Agrawal  * struct dpni_ptp_cfg - configure single step PTP (IEEE 1588)
19422cb2abf3SHemant Agrawal  *	@en: enable single step PTP. When enabled the PTPv1 functionality will
19432cb2abf3SHemant Agrawal  *		not work. If the field is zero, offset and ch_update parameters
19442cb2abf3SHemant Agrawal  *		will be ignored
19452cb2abf3SHemant Agrawal  *	@offset: start offset from the beginning of the frame where timestamp
19462cb2abf3SHemant Agrawal  *		field is found. The offset must respect all MAC headers, VLAN
19472cb2abf3SHemant Agrawal  *	tags and other protocol headers
19482cb2abf3SHemant Agrawal  *	@ch_update: when set UDP checksum will be updated inside packet
19492cb2abf3SHemant Agrawal  *	@peer_delay: For peer-to-peer transparent clocks add this value to the
19502cb2abf3SHemant Agrawal  *		correction field in addition to the transient time update. The
19512cb2abf3SHemant Agrawal  *		value expresses nanoseconds.
19522cb2abf3SHemant Agrawal  */
19532cb2abf3SHemant Agrawal struct dpni_single_step_cfg {
19542cb2abf3SHemant Agrawal 	uint8_t en;
19552cb2abf3SHemant Agrawal 	uint8_t ch_update;
19562cb2abf3SHemant Agrawal 	uint16_t offset;
19572cb2abf3SHemant Agrawal 	uint32_t peer_delay;
1958*591200efSGagandeep Singh 	uint32_t ptp_onestep_reg_base;
19592cb2abf3SHemant Agrawal };
19602cb2abf3SHemant Agrawal 
19612cb2abf3SHemant Agrawal int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
19622cb2abf3SHemant Agrawal 		uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
19632cb2abf3SHemant Agrawal 
19642cb2abf3SHemant Agrawal int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
19652cb2abf3SHemant Agrawal 		uint16_t token, struct dpni_single_step_cfg *ptp_cfg);
19662cb2abf3SHemant Agrawal 
19672cb2abf3SHemant Agrawal /**
19682cb2abf3SHemant Agrawal  * loopback_en field is valid when calling function dpni_set_port_cfg
19692cb2abf3SHemant Agrawal  */
19702cb2abf3SHemant Agrawal #define DPNI_PORT_CFG_LOOPBACK		0x01
19712cb2abf3SHemant Agrawal 
19722cb2abf3SHemant Agrawal /**
19732cb2abf3SHemant Agrawal  * struct dpni_port_cfg - custom configuration for dpni physical port
19742cb2abf3SHemant Agrawal  *	@loopback_en: port loopback enabled
19752cb2abf3SHemant Agrawal  */
19762cb2abf3SHemant Agrawal struct dpni_port_cfg {
19772cb2abf3SHemant Agrawal 	int loopback_en;
19782cb2abf3SHemant Agrawal };
19792cb2abf3SHemant Agrawal 
19802cb2abf3SHemant Agrawal int dpni_set_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
19812cb2abf3SHemant Agrawal 		uint16_t token, uint32_t flags, struct dpni_port_cfg *port_cfg);
19822cb2abf3SHemant Agrawal 
19832cb2abf3SHemant Agrawal int dpni_get_port_cfg(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
19842cb2abf3SHemant Agrawal 		uint16_t token, struct dpni_port_cfg *port_cfg);
19852cb2abf3SHemant Agrawal 
1986*591200efSGagandeep Singh enum dpni_table_type {
1987*591200efSGagandeep Singh 	DPNI_FS_TABLE = 1,
1988*591200efSGagandeep Singh 	DPNI_MAC_TABLE = 2,
1989*591200efSGagandeep Singh 	DPNI_QOS_TABLE = 3,
1990*591200efSGagandeep Singh 	DPNI_VLAN_TABLE = 4,
199172100f0dSGagandeep Singh };
199272100f0dSGagandeep Singh 
1993*591200efSGagandeep Singh int dpni_dump_table(struct fsl_mc_io *mc_io,
1994*591200efSGagandeep Singh 			 uint32_t cmd_flags,
1995*591200efSGagandeep Singh 			 uint16_t token,
1996*591200efSGagandeep Singh 			 uint16_t table_type,
1997*591200efSGagandeep Singh 			 uint16_t table_index,
1998*591200efSGagandeep Singh 			 uint64_t iova_addr,
1999*591200efSGagandeep Singh 			 uint32_t iova_size,
2000*591200efSGagandeep Singh 			 uint16_t *num_entries);
200172100f0dSGagandeep Singh 
200272100f0dSGagandeep Singh /**
2003*591200efSGagandeep Singh  * SP Profile on Ingress DPNI
200472100f0dSGagandeep Singh  */
2005*591200efSGagandeep Singh #define DPNI_SP_PROFILE_INGRESS 0x1
2006*591200efSGagandeep Singh /**
2007*591200efSGagandeep Singh  * SP Profile on Egress DPNI
2008*591200efSGagandeep Singh  */
2009*591200efSGagandeep Singh #define DPNI_SP_PROFILE_EGRESS	0x2
201072100f0dSGagandeep Singh 
2011*591200efSGagandeep Singh int dpni_set_sp_profile(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
2012*591200efSGagandeep Singh 		uint8_t sp_profile[], uint8_t type);
2013*591200efSGagandeep Singh 
2014*591200efSGagandeep Singh int dpni_sp_enable(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token,
2015*591200efSGagandeep Singh 		uint8_t type, uint8_t en);
201672100f0dSGagandeep Singh 
2017e6b82573SHemant Agrawal #endif /* __FSL_DPNI_H */
2018