xref: /dpdk/drivers/net/dpaa2/mc/fsl_dpni.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2016-2020 NXP
5  *
6  */
7 #ifndef __FSL_DPNI_H
8 #define __FSL_DPNI_H
9 
10 #include <fsl_dpkg.h>
11 #include <fsl_dpopr.h>
12 
13 struct fsl_mc_io;
14 
15 /**
16  * Data Path Network Interface API
17  * Contains initialization APIs and runtime control APIs for DPNI
18  */
19 
20 /** General DPNI macros */
21 
22 /**
23  * Maximum number of traffic classes
24  */
25 #define DPNI_MAX_TC				8
26 /**
27  * Maximum number of buffer pools per DPNI
28  */
29 #define DPNI_MAX_DPBP				8
30 /**
31  * Maximum number of storage-profiles per DPNI
32  */
33 #define DPNI_MAX_SP				2
34 
35 /**
36  * All traffic classes considered; see dpni_set_queue()
37  */
38 #define DPNI_ALL_TCS				(uint8_t)(-1)
39 /**
40  * All flows within traffic class considered; see dpni_set_queue()
41  */
42 #define DPNI_ALL_TC_FLOWS			(uint16_t)(-1)
43 
44 /**
45  * Tx traffic is always released to a buffer pool on transmit, there are no
46  * resources allocated to have the frames confirmed back to the source after
47  * transmission.
48  */
49 #define DPNI_OPT_TX_FRM_RELEASE			0x000001
50 /**
51  * Disables support for MAC address filtering for addresses other than primary
52  * MAC address. This affects both unicast and multicast. Promiscuous mode can
53  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
54  * is disabled, only traffic matching the primary MAC address will be accepted.
55  */
56 #define DPNI_OPT_NO_MAC_FILTER			0x000002
57 /**
58  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
59  * traffic class (TC) basis.
60  */
61 #define DPNI_OPT_HAS_POLICING			0x000004
62 /**
63  * Congestion can be managed in several ways, allowing the buffer pool to
64  * deplete on ingress, taildrop on each queue or use congestion groups for sets
65  * of queues. If set, it configures a single congestion groups across all TCs.
66  * If reset, a congestion group is allocated for each TC. Only relevant if the
67  * DPNI has multiple traffic classes.
68  */
69 #define DPNI_OPT_SHARED_CONGESTION		0x000008
70 /**
71  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
72  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
73  * variants. Setting this bit on these SoCs will trigger an error.
74  */
75 #define DPNI_OPT_HAS_KEY_MASKING		0x000010
76 /**
77  * Disables the flow steering table.
78  */
79 #define DPNI_OPT_NO_FS				0x000020
80 
81 /**
82  * Enable the Order Restoration support
83  */
84 #define DPNI_OPT_HAS_OPR				0x000040
85 
86 /**
87  * Order Point Records are shared for the entire TC
88  */
89 #define DPNI_OPT_OPR_PER_TC				0x000080
90 /**
91  * All Tx traffic classes will use a single sender (ignore num_queueus for tx)
92  */
93 #define DPNI_OPT_SINGLE_SENDER			0x000100
94 /**
95  * Define a custom number of congestion groups
96  */
97 #define DPNI_OPT_CUSTOM_CG				0x000200
98 
99 
100 /**
101  * Software sequence maximum layout size
102  */
103 #define DPNI_SW_SEQUENCE_LAYOUT_SIZE 33
104 
105 int dpni_open(struct fsl_mc_io *mc_io,
106 	      uint32_t cmd_flags,
107 	      int dpni_id,
108 	      uint16_t *token);
109 
110 int dpni_close(struct fsl_mc_io *mc_io,
111 	       uint32_t cmd_flags,
112 	       uint16_t token);
113 
114 /**
115  * struct dpni_cfg - Structure representing DPNI configuration
116  * @options: Any combination of the following options:
117  *		DPNI_OPT_TX_FRM_RELEASE
118  *		DPNI_OPT_NO_MAC_FILTER
119  *		DPNI_OPT_HAS_POLICING
120  *		DPNI_OPT_SHARED_CONGESTION
121  *		DPNI_OPT_HAS_KEY_MASKING
122  *		DPNI_OPT_NO_FS
123  *		DPNI_OPT_SINGLE_SENDER
124  * @fs_entries: Number of entries in the flow steering table.
125  *		This table is used to select the ingress queue for
126  *		ingress traffic, targeting a GPP core or another.
127  *		In addition it can be used to discard traffic that
128  *		matches the set rule. It is either an exact match table
129  *		or a TCAM table, depending on DPNI_OPT_ HAS_KEY_MASKING
130  *		bit in OPTIONS field. This field is ignored if
131  *		DPNI_OPT_NO_FS bit is set in OPTIONS field. Otherwise,
132  *		value 0 defaults to 64. Maximum supported value is 1024.
133  *		Note that the total number of entries is limited on the
134  *		SoC to as low as 512 entries if TCAM is used.
135  * @vlan_filter_entries: Number of entries in the VLAN address filtering
136  *		table. This is an exact match table used to filter
137  *		ingress traffic based on VLAN IDs. Value 0 disables VLAN
138  *		filtering. Maximum supported value is 16.
139  * @mac_filter_entries: Number of entries in the MAC address filtering
140  *		table. This is an exact match table and allows both
141  *		unicast and multicast entries. The primary MAC address
142  *		of the network interface is not part of this table,
143  *		this contains only entries in addition to it. This
144  *		field is ignored if DPNI_OPT_ NO_MAC_FILTER is set in
145  *		OPTIONS field. Otherwise, value 0 defaults to 80.
146  *		Maximum supported value is 80.
147  * @num_queues: Number of Tx and Rx queues used for traffic
148  *		distribution. This is orthogonal to QoS and is only
149  *		used to distribute traffic to multiple GPP cores.
150  *		This configuration affects the number of Tx queues
151  *		(logical FQs, all associated with a single CEETM queue),
152  *		Rx queues and Tx confirmation queues, if applicable.
153  *		Value 0 defaults to one queue. Maximum supported value
154  *		is 8.
155  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
156  *		TCs can have different priority levels for the purpose
157  *		of Tx scheduling (see DPNI_SET_TX_PRIORITIES), different
158  *		BPs (DPNI_ SET_POOLS), policers. There are dedicated QM
159  *		queues for traffic classes (including class queues on
160  *		Tx). Value 0 defaults to one TC. Maximum supported value
161  *		is 16. There are maximum 16 TCs for Tx and 8 TCs for Rx.
162  *		When num_tcs>8 Tx will use this value but Rx will have
163  *		only 8 traffic classes.
164  * @num_rx_tcs: if set to other value than zero represents number
165  *		of TCs used for Rx. Maximum value is 8. If set to zero the
166  *		number of Rx TCs will be initialized with the value provided
167  *		in num_tcs parameter.
168  * @qos_entries: Number of entries in the QoS classification table. This
169  *		table is used to select the TC for ingress traffic. It
170  *		is either an exact match or a TCAM table, depending on
171  *		DPNI_OPT_ HAS_KEY_MASKING bit in OPTIONS field. This
172  *		field is ignored if the DPNI has a single TC. Otherwise,
173  *		a value of 0 defaults to 64. Maximum supported value
174  *		is 64.
175  */
176 struct dpni_cfg {
177 	uint32_t options;
178 	uint16_t fs_entries;
179 	uint8_t  vlan_filter_entries;
180 	uint8_t  mac_filter_entries;
181 	uint8_t  num_queues;
182 	uint8_t  num_tcs;
183 	uint8_t  num_rx_tcs;
184 	uint8_t  qos_entries;
185 	uint8_t  num_cgs;
186 };
187 
188 int dpni_create(struct fsl_mc_io *mc_io,
189 		uint16_t dprc_token,
190 		uint32_t cmd_flags,
191 		const struct dpni_cfg *cfg,
192 		uint32_t *obj_id);
193 
194 int dpni_destroy(struct fsl_mc_io *mc_io,
195 		 uint16_t dprc_token,
196 		 uint32_t cmd_flags,
197 		 uint32_t object_id);
198 
199 /**
200  * struct dpni_pools_cfg - Structure representing buffer pools configuration
201  * @num_dpbp:	Number of DPBPs
202  * @pool_options: Buffer assignment options
203  *                This field is a combination of DPNI_POOL_ASSOC_flags
204  * @pools:	Array of buffer pools parameters; The number of valid entries
205  *		must match 'num_dpbp' value
206  * @pools.dpbp_id:     DPBP object ID
207  * @pools.priority:    Priority mask that indicates TC's used with this buffer.
208  *		       I set to 0x00 MC will assume value 0xff.
209  * @pools.buffer_size: Buffer size
210  * @pools.backup_pool: Backup pool
211  */
212 
213 #define DPNI_POOL_ASSOC_QPRI	0
214 #define DPNI_POOL_ASSOC_QDBIN	1
215 
216 struct dpni_pools_cfg {
217 	uint8_t num_dpbp;
218 	uint8_t pool_options;
219 	struct {
220 		int		dpbp_id;
221 		uint8_t		priority_mask;
222 		uint16_t	buffer_size;
223 		int		backup_pool;
224 	} pools[DPNI_MAX_DPBP];
225 };
226 
227 int dpni_set_pools(struct fsl_mc_io *mc_io,
228 		   uint32_t cmd_flags,
229 		   uint16_t token,
230 		   const struct dpni_pools_cfg *cfg);
231 
232 int dpni_enable(struct fsl_mc_io *mc_io,
233 		uint32_t cmd_flags,
234 		uint16_t token);
235 
236 int dpni_disable(struct fsl_mc_io *mc_io,
237 		 uint32_t cmd_flags,
238 		 uint16_t token);
239 
240 int dpni_is_enabled(struct fsl_mc_io *mc_io,
241 		    uint32_t cmd_flags,
242 		    uint16_t token,
243 		    int *en);
244 
245 int dpni_reset(struct fsl_mc_io *mc_io,
246 	       uint32_t cmd_flags,
247 	       uint16_t token);
248 
249 /**
250  * DPNI IRQ Index and Events
251  */
252 
253 /**
254  * IRQ index
255  */
256 #define DPNI_IRQ_INDEX				0
257 /**
258  * IRQ event - indicates a change in link state
259  */
260 #define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
261 
262 int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
263 			uint32_t cmd_flags,
264 			uint16_t token,
265 			uint8_t irq_index,
266 			uint8_t en);
267 
268 int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
269 			uint32_t cmd_flags,
270 			uint16_t token,
271 			uint8_t irq_index,
272 			uint8_t *en);
273 
274 int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
275 		      uint32_t cmd_flags,
276 		      uint16_t token,
277 		      uint8_t irq_index,
278 		      uint32_t mask);
279 
280 int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
281 		      uint32_t cmd_flags,
282 		      uint16_t token,
283 		      uint8_t irq_index,
284 		      uint32_t *mask);
285 
286 int dpni_get_irq_status(struct fsl_mc_io *mc_io,
287 			uint32_t cmd_flags,
288 			uint16_t token,
289 			uint8_t irq_index,
290 			uint32_t *status);
291 
292 int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
293 			  uint32_t cmd_flags,
294 			  uint16_t token,
295 			  uint8_t irq_index,
296 			  uint32_t status);
297 
298 /**
299  * struct dpni_attr - Structure representing DPNI attributes
300  * @options: Any combination of the following options:
301  *		DPNI_OPT_TX_FRM_RELEASE
302  *		DPNI_OPT_NO_MAC_FILTER
303  *		DPNI_OPT_HAS_POLICING
304  *		DPNI_OPT_SHARED_CONGESTION
305  *		DPNI_OPT_HAS_KEY_MASKING
306  *		DPNI_OPT_NO_FS
307  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
308  * @num_rx_tcs: Number of RX traffic classes (TCs), reserved for the DPNI.
309  * @num_tx_tcs: Number of TX traffic classes (TCs), reserved for the DPNI.
310  * @mac_filter_entries: Number of entries in the MAC address filtering
311  *		table.
312  * @vlan_filter_entries: Number of entries in the VLAN address filtering
313  *		table.
314  * @qos_entries: Number of entries in the QoS classification table.
315  * @fs_entries: Number of entries in the flow steering table.
316  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
317  *			than this when adding QoS entries will result
318  *			in an error.
319  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
320  *			key larger than this when composing the hash + FS key
321  *			will result in an error.
322  * @wriop_version: Version of WRIOP HW block.
323  *			The 3 version values are stored on 6, 5, 5 bits
324  *			respectively.
325  *			Values returned:
326  *			- 0x400 - WRIOP version 1.0.0, used on LS2080 and
327  *			variants,
328  *			- 0x421 - WRIOP version 1.1.1, used on LS2088 and
329  *			variants,
330  *			- 0x422 - WRIOP version 1.1.2, used on LS1088 and
331  *			variants.
332  *			- 0xC00 - WRIOP version 3.0.0, used on LX2160 and
333  *			variants.
334  */
335 struct dpni_attr {
336 	uint32_t options;
337 	uint8_t  num_queues;
338 	uint8_t  num_rx_tcs;
339 	uint8_t  num_tx_tcs;
340 	uint8_t  mac_filter_entries;
341 	uint8_t  vlan_filter_entries;
342 	uint8_t  qos_entries;
343 	uint16_t fs_entries;
344 	uint8_t  qos_key_size;
345 	uint8_t  fs_key_size;
346 	uint16_t wriop_version;
347 	uint8_t  num_cgs;
348 };
349 
350 int dpni_get_attributes(struct fsl_mc_io *mc_io,
351 			uint32_t cmd_flags,
352 			uint16_t token,
353 			struct dpni_attr *attr);
354 
355 /**
356  * DPNI errors
357  */
358 
359 /**
360  * Discard error. When set all discarded frames in wriop will be enqueued to
361  * error queue. To be used in dpni_set_errors_behavior() only if error_action
362  * parameter is set to DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE.
363  */
364 #define DPNI_ERROR_DISC		0x80000000
365 
366 /**
367  * Extract out of frame header error
368  */
369 #define DPNI_ERROR_EOFHE	0x00020000
370 /**
371  * Frame length error
372  */
373 #define DPNI_ERROR_FLE		0x00002000
374 /**
375  * Frame physical error
376  */
377 #define DPNI_ERROR_FPE		0x00001000
378 /**
379  * Parsing header error
380  */
381 #define DPNI_ERROR_PHE		0x00000020
382 /**
383  * Parser L3 checksum error
384  */
385 #define DPNI_ERROR_L3CE		0x00000004
386 /**
387  * Parser L3 checksum error
388  */
389 #define DPNI_ERROR_L4CE		0x00000001
390 
391 /**
392  * enum dpni_error_action - Defines DPNI behavior for errors
393  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
394  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
395  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
396  */
397 enum dpni_error_action {
398 	DPNI_ERROR_ACTION_DISCARD = 0,
399 	DPNI_ERROR_ACTION_CONTINUE = 1,
400 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
401 };
402 
403 /**
404  * struct dpni_error_cfg - Structure representing DPNI errors treatment
405  * @errors:			Errors mask; use 'DPNI_ERROR__<X>
406  * @error_action:		The desired action for the errors mask
407  * @set_frame_annotation:	Set to '1' to mark the errors in frame
408  *				annotation status (FAS); relevant only
409  *				for the non-discard action
410  */
411 struct dpni_error_cfg {
412 	uint32_t errors;
413 	enum dpni_error_action error_action;
414 	int set_frame_annotation;
415 };
416 
417 int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
418 			     uint32_t cmd_flags,
419 			     uint16_t token,
420 			     struct dpni_error_cfg *cfg);
421 
422 /**
423  * DPNI buffer layout modification options
424  */
425 
426 /**
427  * Select to modify the time-stamp setting
428  */
429 #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
430 /**
431  * Select to modify the parser-result setting; not applicable for Tx
432  */
433 #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
434 /**
435  * Select to modify the frame-status setting
436  */
437 #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
438 /**
439  * Select to modify the private-data-size setting
440  */
441 #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
442 /**
443  * Select to modify the data-alignment setting
444  */
445 #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
446 /**
447  * Select to modify the data-head-room setting
448  */
449 #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
450 /**
451  * Select to modify the data-tail-room setting
452  */
453 #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
454 /**
455  * Select to modify the sw-opaque value setting
456  */
457 #define DPNI_BUF_LAYOUT_OPT_SW_OPAQUE		0x00000080
458 
459 /**
460  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
461  * @options:		Flags representing the suggested modifications to the
462  *			buffer layout;
463  *			Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
464  * @pass_timestamp:	Pass timestamp value
465  * @pass_parser_result:	Pass parser results
466  * @pass_frame_status:	Pass frame status
467  * @private_data_size:	Size kept for private data (in bytes)
468  * @data_align:		Data alignment
469  * @data_head_room:	Data head room
470  * @data_tail_room:	Data tail room
471  */
472 struct dpni_buffer_layout {
473 	uint32_t options;
474 	int pass_timestamp;
475 	int pass_parser_result;
476 	int pass_frame_status;
477 	int pass_sw_opaque;
478 	uint16_t private_data_size;
479 	uint16_t data_align;
480 	uint16_t data_head_room;
481 	uint16_t data_tail_room;
482 };
483 
484 /**
485  * enum dpni_queue_type - Identifies a type of queue targeted by the command
486  * @DPNI_QUEUE_RX: Rx queue
487  * @DPNI_QUEUE_TX: Tx queue
488  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
489  * @DPNI_QUEUE_RX_ERR: Rx error queue
490  */
491 enum dpni_queue_type {
492 	DPNI_QUEUE_RX,
493 	DPNI_QUEUE_TX,
494 	DPNI_QUEUE_TX_CONFIRM,
495 	DPNI_QUEUE_RX_ERR,
496 };
497 
498 int dpni_get_buffer_layout(struct fsl_mc_io *mc_io,
499 			   uint32_t cmd_flags,
500 			   uint16_t token,
501 			   enum dpni_queue_type qtype,
502 			   struct dpni_buffer_layout *layout);
503 
504 int dpni_set_buffer_layout(struct fsl_mc_io *mc_io,
505 			   uint32_t cmd_flags,
506 			   uint16_t token,
507 			   enum dpni_queue_type qtype,
508 			   const struct dpni_buffer_layout *layout);
509 
510 /**
511  * enum dpni_offload - Identifies a type of offload targeted by the command
512  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
513  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
514  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
515  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
516  * @DPNI_OPT_FLCTYPE_HASH: flow context will be generated by WRIOP for AIOP or
517  *			   for CPU
518  */
519 enum dpni_offload {
520 	DPNI_OFF_RX_L3_CSUM,
521 	DPNI_OFF_RX_L4_CSUM,
522 	DPNI_OFF_TX_L3_CSUM,
523 	DPNI_OFF_TX_L4_CSUM,
524 	DPNI_FLCTYPE_HASH,
525 };
526 
527 int dpni_set_offload(struct fsl_mc_io *mc_io,
528 		     uint32_t cmd_flags,
529 		     uint16_t token,
530 		     enum dpni_offload type,
531 		     uint32_t config);
532 
533 int dpni_get_offload(struct fsl_mc_io *mc_io,
534 		     uint32_t cmd_flags,
535 		     uint16_t token,
536 		     enum dpni_offload type,
537 		     uint32_t *config);
538 
539 int dpni_get_qdid(struct fsl_mc_io *mc_io,
540 		  uint32_t cmd_flags,
541 		  uint16_t token,
542 		  enum dpni_queue_type qtype,
543 		  uint16_t *qdid);
544 
545 int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
546 			    uint32_t cmd_flags,
547 			    uint16_t token,
548 			    uint16_t *data_offset);
549 
550 #define DPNI_STATISTICS_CNT		7
551 
552 /**
553  * union dpni_statistics - Union describing the DPNI statistics
554  * @page_0: Page_0 statistics structure
555  * @page_0.ingress_all_frames: Ingress frame count
556  * @page_0.ingress_all_bytes: Ingress byte count
557  * @page_0.ingress_multicast_frames: Ingress multicast frame count
558  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
559  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
560  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
561  * @page_1: Page_1 statistics structure
562  * @page_1.egress_all_frames: Egress frame count
563  * @page_1.egress_all_bytes: Egress byte count
564  * @page_1.egress_multicast_frames: Egress multicast frame count
565  * @page_1.egress_multicast_bytes: Egress multicast byte count
566  * @page_1.egress_broadcast_frames: Egress broadcast frame count
567  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
568  * @page_2: Page_2 statistics structure
569  * @page_2.ingress_filtered_frames: Ingress filtered frame count
570  * @page_2.ingress_discarded_frames: Ingress discarded frame count
571  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
572  *	lack of buffers
573  * @page_2.egress_discarded_frames: Egress discarded frame count
574  * @page_2.egress_confirmed_frames: Egress confirmed frame count
575  * @page_3: Page_3 statistics structure with values for the selected TC
576  * @page_3.ceetm_dequeue_bytes: Cumulative count of the number of bytes dequeued
577  * @page_3.ceetm_dequeue_frames: Cumulative count of the number of frames
578  *	dequeued
579  * @page_3.ceetm_reject_bytes: Cumulative count of the number of bytes in all
580  *	frames whose enqueue was rejected
581  * @page_3.ceetm_reject_frames: Cumulative count of all frame enqueues rejected
582  * @page_4: congestion point drops for seleted TC
583  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
584  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
585  * @page_5: policer statistics per TC
586  * @page_5.policer_cnt_red: NUmber of red colored frames
587  * @page_5.policer_cnt_yellow: number of yellow colored frames
588  * @page_5.policer_cnt_green: number of green colored frames
589  * @page_5.policer_cnt_re_red: number of recolored red frames
590  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
591  * @page_6.tx_pending_frames_cnt: total number of frames pending in Tx queues
592  * @raw: raw statistics structure, used to index counters
593  */
594 union dpni_statistics {
595 	struct {
596 		uint64_t ingress_all_frames;
597 		uint64_t ingress_all_bytes;
598 		uint64_t ingress_multicast_frames;
599 		uint64_t ingress_multicast_bytes;
600 		uint64_t ingress_broadcast_frames;
601 		uint64_t ingress_broadcast_bytes;
602 	} page_0;
603 	struct {
604 		uint64_t egress_all_frames;
605 		uint64_t egress_all_bytes;
606 		uint64_t egress_multicast_frames;
607 		uint64_t egress_multicast_bytes;
608 		uint64_t egress_broadcast_frames;
609 		uint64_t egress_broadcast_bytes;
610 	} page_1;
611 	struct {
612 		uint64_t ingress_filtered_frames;
613 		uint64_t ingress_discarded_frames;
614 		uint64_t ingress_nobuffer_discards;
615 		uint64_t egress_discarded_frames;
616 		uint64_t egress_confirmed_frames;
617 	} page_2;
618 	struct {
619 		uint64_t ceetm_dequeue_bytes;
620 		uint64_t ceetm_dequeue_frames;
621 		uint64_t ceetm_reject_bytes;
622 		uint64_t ceetm_reject_frames;
623 	} page_3;
624 	struct {
625 		uint64_t cgr_reject_frames;
626 		uint64_t cgr_reject_bytes;
627 	} page_4;
628 	struct {
629 		uint64_t policer_cnt_red;
630 		uint64_t policer_cnt_yellow;
631 		uint64_t policer_cnt_green;
632 		uint64_t policer_cnt_re_red;
633 		uint64_t policer_cnt_re_yellow;
634 	} page_5;
635 	struct {
636 		uint64_t tx_pending_frames_cnt;
637 	} page_6;
638 	struct {
639 		uint64_t counter[DPNI_STATISTICS_CNT];
640 	} raw;
641 };
642 
643 /**
644  * Enable auto-negotiation
645  */
646 #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
647 /**
648  * Enable half-duplex mode
649  */
650 #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
651 /**
652  * Enable pause frames
653  */
654 #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
655 /**
656  * Enable a-symmetric pause frames
657  */
658 #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
659 /**
660  * Enable priority flow control pause frames
661  */
662 #define DPNI_LINK_OPT_PFC_PAUSE	0x0000000000000010ULL
663 
664 /**
665  * Advertise 10MB full duplex
666  */
667 #define DPNI_ADVERTISED_10BASET_FULL           0x0000000000000001ULL
668 /**
669  * Advertise 100MB full duplex
670  */
671 #define DPNI_ADVERTISED_100BASET_FULL          0x0000000000000002ULL
672 /**
673  * Advertise 1GB full duplex
674  */
675 #define DPNI_ADVERTISED_1000BASET_FULL         0x0000000000000004ULL
676 /**
677  * Advertise auto-negotiation enable
678  */
679 #define DPNI_ADVERTISED_AUTONEG                0x0000000000000008ULL
680 /**
681  * Advertise 10GB full duplex
682  */
683 #define DPNI_ADVERTISED_10000BASET_FULL        0x0000000000000010ULL
684 /**
685  * Advertise 2.5GB full duplex
686  */
687 #define DPNI_ADVERTISED_2500BASEX_FULL         0x0000000000000020ULL
688 /**
689  * Advertise 5GB full duplex
690  */
691 #define DPNI_ADVERTISED_5000BASET_FULL         0x0000000000000040ULL
692 
693 
694 /**
695  * struct - Structure representing DPNI link configuration
696  * @rate: Rate
697  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
698  * @advertising: Speeds that are advertised for autoneg (bitmap)
699  */
700 struct dpni_link_cfg {
701 	uint32_t rate;
702 	uint64_t options;
703 	uint64_t advertising;
704 };
705 
706 int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
707 		      uint32_t cmd_flags,
708 		      uint16_t token,
709 		      const struct dpni_link_cfg *cfg);
710 
711 /**
712  * struct dpni_link_state - Structure representing DPNI link state
713  * @rate:	Rate
714  * @options:	Mask of available options; use 'DPNI_LINK_OPT_<X>' values
715  * @up:		Link state; '0' for down, '1' for up
716  * @state_valid: Ignore/Update the state of the link
717  * @supported: Speeds capability of the phy (bitmap)
718  * @advertising: Speeds that are advertised for autoneg (bitmap)
719  */
720 struct dpni_link_state {
721 	uint32_t rate;
722 	uint64_t options;
723 	int up;
724 	int state_valid;
725 	uint64_t supported;
726 	uint64_t advertising;
727 };
728 
729 int dpni_get_link_state(struct fsl_mc_io *mc_io,
730 			uint32_t cmd_flags,
731 			uint16_t token,
732 			struct dpni_link_state *state);
733 
734 /**
735  * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
736  * @rate_limit:		Rate in Mbps
737  * @max_burst_size:	Burst size in bytes (up to 64KB)
738  */
739 struct dpni_tx_shaping_cfg {
740 	uint32_t rate_limit;
741 	uint16_t max_burst_size;
742 };
743 
744 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
745 			uint32_t cmd_flags,
746 			uint16_t token,
747 			const struct dpni_tx_shaping_cfg *tx_cr_shaper,
748 			const struct dpni_tx_shaping_cfg *tx_er_shaper,
749 			int coupled);
750 
751 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
752 			      uint32_t cmd_flags,
753 			      uint16_t token,
754 			      uint16_t max_frame_length);
755 
756 int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
757 			      uint32_t cmd_flags,
758 			      uint16_t token,
759 			      uint16_t *max_frame_length);
760 
761 int dpni_set_mtu(struct fsl_mc_io *mc_io,
762 		 uint32_t cmd_flags,
763 		 uint16_t token,
764 		 uint16_t mtu);
765 
766 int dpni_get_mtu(struct fsl_mc_io *mc_io,
767 		 uint32_t cmd_flags,
768 		 uint16_t token,
769 		 uint16_t *mtu);
770 
771 int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
772 			       uint32_t cmd_flags,
773 			       uint16_t token,
774 			       int en);
775 
776 int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
777 			       uint32_t cmd_flags,
778 			       uint16_t token,
779 			       int *en);
780 
781 int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
782 			     uint32_t cmd_flags,
783 			     uint16_t token,
784 			     int en);
785 
786 int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
787 			     uint32_t cmd_flags,
788 			     uint16_t token,
789 			     int *en);
790 
791 int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
792 			      uint32_t cmd_flags,
793 			      uint16_t token,
794 			      const uint8_t mac_addr[6]);
795 
796 int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
797 			      uint32_t cmd_flags,
798 			      uint16_t token,
799 			      uint8_t mac_addr[6]);
800 
801 int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
802 		      uint32_t cmd_flags,
803 		      uint16_t token,
804 		      const uint8_t mac_addr[6],
805 			  uint8_t flags,
806 			  uint8_t tc_id,
807 			  uint8_t flow_id);
808 
809 int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
810 			 uint32_t cmd_flags,
811 			 uint16_t token,
812 			 const uint8_t mac_addr[6]);
813 
814 int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
815 			   uint32_t cmd_flags,
816 			   uint16_t token,
817 			   int unicast,
818 			   int multicast);
819 
820 int dpni_get_port_mac_addr(struct fsl_mc_io *mc_io,
821 			   uint32_t cmd_flags,
822 			   uint16_t token,
823 			   uint8_t mac_addr[6]);
824 
825 int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io,
826 			    uint32_t cmd_flags,
827 			    uint16_t token,
828 			    int en);
829 
830 /**
831  * Set vlan filter queue action
832  */
833 #define DPNI_VLAN_SET_QUEUE_ACTION 1
834 
835 int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
836 		     uint32_t cmd_flags,
837 		     uint16_t token,
838 		     uint16_t vlan_id,
839 			 uint8_t flags,
840 			 uint8_t tc_id,
841 			 uint8_t flow_id);
842 
843 int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
844 			uint32_t cmd_flags,
845 			uint16_t token,
846 			uint16_t vlan_id);
847 
848 int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
849 			    uint32_t cmd_flags,
850 			    uint16_t token);
851 
852 /**
853  * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
854  * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
855  * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
856  * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
857  */
858 enum dpni_tx_schedule_mode {
859 	DPNI_TX_SCHED_STRICT_PRIORITY = 0,
860 	DPNI_TX_SCHED_WEIGHTED_A,
861 	DPNI_TX_SCHED_WEIGHTED_B,
862 };
863 
864 /**
865  * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
866  * @mode:		Scheduling mode
867  * @delta_bandwidth:	Bandwidth represented in weights from 100 to 10000;
868  *	not applicable for 'strict-priority' mode;
869  */
870 struct dpni_tx_schedule_cfg {
871 	enum dpni_tx_schedule_mode	mode;
872 	uint16_t			delta_bandwidth;
873 };
874 
875 /**
876  * struct dpni_tx_priorities_cfg - Structure representing transmission
877  *					priorities for DPNI TCs
878  * @tc_sched:	An array of traffic-classes
879  * @prio_group_A: Priority of group A
880  * @prio_group_B: Priority of group B
881  * @separate_groups: Treat A and B groups as separate
882  */
883 struct dpni_tx_priorities_cfg {
884 	struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
885 	uint32_t prio_group_A;
886 	uint32_t prio_group_B;
887 	uint8_t separate_groups;
888 };
889 
890 int dpni_set_tx_priorities(struct fsl_mc_io			*mc_io,
891 			   uint32_t				cmd_flags,
892 			   uint16_t				token,
893 			   const struct dpni_tx_priorities_cfg	*cfg);
894 
895 /**
896  * enum dpni_dist_mode - DPNI distribution mode
897  * @DPNI_DIST_MODE_NONE: No distribution
898  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
899  *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
900  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
901  *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
902  */
903 enum dpni_dist_mode {
904 	DPNI_DIST_MODE_NONE = 0,
905 	DPNI_DIST_MODE_HASH = 1,
906 	DPNI_DIST_MODE_FS = 2
907 };
908 
909 /**
910  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
911  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
912  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
913  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
914  */
915 enum dpni_fs_miss_action {
916 	DPNI_FS_MISS_DROP = 0,
917 	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
918 	DPNI_FS_MISS_HASH = 2
919 };
920 
921 /**
922  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
923  * @miss_action:	Miss action selection
924  * @default_flow_id:	Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
925  * @keep_hash_key: used only when miss_action is set to DPNI_FS_MISS_HASH. When
926  *	set to one unclassified frames will be distributed according to previous
927  *	used hash key. If set to zero hash key will be replaced with the key
928  *	provided for flow steering.
929  * @keep_entries: if set to one command will not delete the entries that already
930  *	exist into FS table. Use this option with caution: if the table
931  *	entries	are not compatible with the distribution key the packets
932  *	will not be classified properly.
933  */
934 struct dpni_fs_tbl_cfg {
935 	enum dpni_fs_miss_action miss_action;
936 	uint16_t default_flow_id;
937 	char keep_hash_key;
938 	uint8_t keep_entries;
939 };
940 
941 /**
942  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
943  * @dist_size: Set the distribution size;
944  *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
945  *	112,128,192,224,256,384,448,512,768,896,1024
946  * @dist_mode: Distribution mode
947  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
948  *		the extractions to be used for the distribution key by calling
949  *		dpkg_prepare_key_cfg() relevant only when
950  *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
951  * @fs_cfg: Flow Steering table configuration; only relevant if
952  *		'dist_mode = DPNI_DIST_MODE_FS'
953  */
954 struct dpni_rx_tc_dist_cfg {
955 	uint16_t dist_size;
956 	enum dpni_dist_mode dist_mode;
957 	uint64_t key_cfg_iova;
958 	struct dpni_fs_tbl_cfg fs_cfg;
959 };
960 
961 int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
962 			uint32_t cmd_flags,
963 			uint16_t token,
964 			uint8_t tc_id,
965 			const struct dpni_rx_tc_dist_cfg *cfg);
966 
967 /**
968  * Set to select color aware mode (otherwise - color blind)
969  */
970 #define DPNI_POLICER_OPT_COLOR_AWARE	0x00000001
971 /**
972  * Set to discard frame with RED color
973  */
974 #define DPNI_POLICER_OPT_DISCARD_RED	0x00000002
975 
976 /**
977  * enum dpni_policer_mode - selecting the policer mode
978  * @DPNI_POLICER_MODE_NONE: Policer is disabled
979  * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
980  * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
981  * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
982  */
983 enum dpni_policer_mode {
984 	DPNI_POLICER_MODE_NONE = 0,
985 	DPNI_POLICER_MODE_PASS_THROUGH,
986 	DPNI_POLICER_MODE_RFC_2698,
987 	DPNI_POLICER_MODE_RFC_4115
988 };
989 
990 /**
991  * enum dpni_policer_unit - DPNI policer units
992  * @DPNI_POLICER_UNIT_BYTES: bytes units
993  * @DPNI_POLICER_UNIT_FRAMES: frames units
994  */
995 enum dpni_policer_unit {
996 	DPNI_POLICER_UNIT_BYTES = 0,
997 	DPNI_POLICER_UNIT_FRAMES
998 };
999 
1000 /**
1001  * enum dpni_policer_color - selecting the policer color
1002  * @DPNI_POLICER_COLOR_GREEN: Green color
1003  * @DPNI_POLICER_COLOR_YELLOW: Yellow color
1004  * @DPNI_POLICER_COLOR_RED: Red color
1005  */
1006 enum dpni_policer_color {
1007 	DPNI_POLICER_COLOR_GREEN = 0,
1008 	DPNI_POLICER_COLOR_YELLOW,
1009 	DPNI_POLICER_COLOR_RED
1010 };
1011 
1012 /**
1013  * struct dpni_rx_tc_policing_cfg - Policer configuration
1014  * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
1015  * @mode: policer mode
1016  * @default_color: For pass-through mode the policer re-colors with this
1017  *	color any incoming packets. For Color aware non-pass-through mode:
1018  *	policer re-colors with this color all packets with FD[DROPP]>2.
1019  * @units: Bytes or Packets
1020  * @cir: Committed information rate (CIR) in Kbps or packets/second
1021  * @cbs: Committed burst size (CBS) in bytes or packets
1022  * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
1023  *	 Excess information rate (EIR, rfc4115) in Kbps or packets/second
1024  * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
1025  *       Excess burst size (EBS, rfc4115) in bytes or packets
1026  */
1027 struct dpni_rx_tc_policing_cfg {
1028 	uint32_t options;
1029 	enum dpni_policer_mode mode;
1030 	enum dpni_policer_unit units;
1031 	enum dpni_policer_color default_color;
1032 	uint32_t cir;
1033 	uint32_t cbs;
1034 	uint32_t eir;
1035 	uint32_t ebs;
1036 };
1037 
1038 
1039 int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
1040 			    uint32_t cmd_flags,
1041 			    uint16_t token,
1042 			    uint8_t tc_id,
1043 			    const struct dpni_rx_tc_policing_cfg *cfg);
1044 
1045 int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
1046 			    uint32_t cmd_flags,
1047 			    uint16_t token,
1048 			    uint8_t tc_id,
1049 			    struct dpni_rx_tc_policing_cfg *cfg);
1050 
1051 /**
1052  * enum dpni_congestion_unit - DPNI congestion units
1053  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
1054  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
1055  */
1056 enum dpni_congestion_unit {
1057 	DPNI_CONGESTION_UNIT_BYTES = 0,
1058 	DPNI_CONGESTION_UNIT_FRAMES
1059 };
1060 
1061 /**
1062  * enum dpni_early_drop_mode - DPNI early drop mode
1063  * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
1064  * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
1065  * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
1066  */
1067 enum dpni_early_drop_mode {
1068 	DPNI_EARLY_DROP_MODE_NONE = 0,
1069 	DPNI_EARLY_DROP_MODE_TAIL,
1070 	DPNI_EARLY_DROP_MODE_WRED
1071 };
1072 
1073 /**
1074  * struct dpni_wred_cfg - WRED configuration
1075  * @max_threshold: maximum threshold that packets may be discarded. Above this
1076  *	  threshold all packets are discarded; must be less than 2^39;
1077  *	  approximated to be expressed as (x+256)*2^(y-1) due to HW
1078  *	  implementation.
1079  * @min_threshold: minimum threshold that packets may be discarded at
1080  * @drop_probability: probability that a packet will be discarded (1-100,
1081  *			associated with the max_threshold).
1082  */
1083 struct dpni_wred_cfg {
1084 	uint64_t max_threshold;
1085 	uint64_t min_threshold;
1086 	uint8_t drop_probability;
1087 };
1088 
1089 /**
1090  * struct dpni_early_drop_cfg - early-drop configuration
1091  * @enable: drop enable
1092  * @units: units type
1093  * @green: WRED - 'green' configuration
1094  * @yellow: WRED - 'yellow' configuration
1095  * @red: WRED - 'red' configuration
1096  */
1097 struct dpni_early_drop_cfg {
1098 	uint8_t enable;
1099 	enum dpni_congestion_unit units;
1100 	struct dpni_wred_cfg green;
1101 	struct dpni_wred_cfg yellow;
1102 	struct dpni_wred_cfg red;
1103 };
1104 
1105 void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
1106 			     uint8_t *early_drop_buf);
1107 
1108 void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
1109 			     const uint8_t *early_drop_buf);
1110 
1111 int dpni_set_early_drop(struct fsl_mc_io *mc_io,
1112 			uint32_t cmd_flags,
1113 			uint16_t token,
1114 			enum dpni_queue_type qtype,
1115 			uint8_t tc_id,
1116 			uint64_t early_drop_iova);
1117 
1118 int dpni_get_early_drop(struct fsl_mc_io *mc_io,
1119 			uint32_t cmd_flags,
1120 			uint16_t token,
1121 			enum dpni_queue_type qtype,
1122 			uint8_t tc_id,
1123 			uint64_t early_drop_iova);
1124 
1125 /**
1126  * enum dpni_dest - DPNI destination types
1127  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
1128  *		does not generate FQDAN notifications; user is expected to
1129  *		dequeue from the queue based on polling or other user-defined
1130  *		method
1131  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
1132  *		notifications to the specified DPIO; user is expected to dequeue
1133  *		from the queue only after notification is received
1134  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
1135  *		FQDAN notifications, but is connected to the specified DPCON
1136  *		object; user is expected to dequeue from the DPCON channel
1137  */
1138 enum dpni_dest {
1139 	DPNI_DEST_NONE = 0,
1140 	DPNI_DEST_DPIO = 1,
1141 	DPNI_DEST_DPCON = 2
1142 };
1143 
1144 /**
1145  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
1146  * @dest_type: Destination type
1147  * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
1148  * @priority: Priority selection within the DPIO or DPCON channel; valid values
1149  *		are 0-1 or 0-7, depending on the number of priorities in that
1150  *		channel; not relevant for 'DPNI_DEST_NONE' option
1151  */
1152 struct dpni_dest_cfg {
1153 	enum dpni_dest dest_type;
1154 	int dest_id;
1155 	uint8_t priority;
1156 };
1157 
1158 /* DPNI congestion options */
1159 
1160 /**
1161  * CSCN message is written to message_iova once entering a
1162  * congestion state (see 'threshold_entry')
1163  */
1164 #define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER	0x00000001
1165 /**
1166  * CSCN message is written to message_iova once exiting a
1167  * congestion state (see 'threshold_exit')
1168  */
1169 #define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT		0x00000002
1170 /**
1171  * CSCN write will attempt to allocate into a cache (coherent write);
1172  * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
1173  */
1174 #define DPNI_CONG_OPT_COHERENT_WRITE		0x00000004
1175 /**
1176  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1177  * DPIO/DPCON's WQ channel once entering a congestion state
1178  * (see 'threshold_entry')
1179  */
1180 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER	0x00000008
1181 /**
1182  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
1183  * DPIO/DPCON's WQ channel once exiting a congestion state
1184  * (see 'threshold_exit')
1185  */
1186 #define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT	0x00000010
1187 /**
1188  * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
1189  * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
1190  */
1191 #define DPNI_CONG_OPT_INTR_COALESCING_DISABLED	0x00000020
1192 /**
1193  * This congestion will trigger flow control or priority flow control. This
1194  * will have effect only if flow control is enabled with dpni_set_link_cfg()
1195  */
1196 #define DPNI_CONG_OPT_FLOW_CONTROL	0x00000040
1197 
1198 /**
1199  * enum dpni_congestion_point - Structure representing congestion point
1200  * @DPNI_CP_QUEUE:	Set congestion per queue, identified by QUEUE_TYPE, TC
1201  *			and QUEUE_INDEX
1202  * @DPNI_CP_GROUP:	Set congestion per queue group. Depending on options
1203  *			used to define the DPNI this can be either per
1204  *			TC (default) or per interface
1205  *			(DPNI_OPT_SHARED_CONGESTION set at DPNI create).
1206  *			QUEUE_INDEX is ignored if this type is used.
1207  * @DPNI_CP_CONGESTION_GROUP: Set per congestion group id. This will work
1208  *		only if the DPNI is created with  DPNI_OPT_CUSTOM_CG option
1209  */
1210 
1211 enum dpni_congestion_point {
1212 	DPNI_CP_QUEUE,
1213 	DPNI_CP_GROUP,
1214 	DPNI_CP_CONGESTION_GROUP,
1215 };
1216 
1217 /**
1218  * struct dpni_congestion_notification_cfg - congestion notification
1219  *		configuration
1220  * @units: units type
1221  * @threshold_entry: above this threshold we enter a congestion state.
1222  *	set it to '0' to disable it
1223  * @threshold_exit: below this threshold we exit the congestion state.
1224  * @message_ctx: The context that will be part of the CSCN message
1225  * @message_iova: I/O virtual address (must be in DMA-able memory),
1226  *	must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
1227  *	contained in 'options'
1228  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
1229  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
1230  * @cg_point: Congestion point settings
1231  * @cgid: id of the congestion group. The index is relative to dpni.
1232  */
1233 
1234 struct dpni_congestion_notification_cfg {
1235 	enum dpni_congestion_unit units;
1236 	uint32_t threshold_entry;
1237 	uint32_t threshold_exit;
1238 	uint64_t message_ctx;
1239 	uint64_t message_iova;
1240 	struct dpni_dest_cfg dest_cfg;
1241 	uint16_t notification_mode;
1242 	enum dpni_congestion_point cg_point;
1243 	int cgid;
1244 };
1245 
1246 int dpni_set_congestion_notification(struct fsl_mc_io *mc_io,
1247 				     uint32_t cmd_flags,
1248 				     uint16_t token,
1249 				     enum dpni_queue_type qtype,
1250 				     uint8_t tc_id,
1251 			const struct dpni_congestion_notification_cfg *cfg);
1252 
1253 int dpni_get_congestion_notification(struct fsl_mc_io *mc_io,
1254 				     uint32_t cmd_flags,
1255 				     uint16_t token,
1256 				     enum dpni_queue_type qtype,
1257 				     uint8_t tc_id,
1258 				struct dpni_congestion_notification_cfg *cfg);
1259 
1260 /* DPNI FLC stash options */
1261 
1262 /**
1263  * stashes the whole annotation area (up to 192 bytes)
1264  */
1265 #define DPNI_FLC_STASH_FRAME_ANNOTATION	0x00000001
1266 
1267 /**
1268  * struct dpni_queue - Queue structure
1269  * @destination - Destination structure
1270  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
1271  *	Identifies either a DPIO or a DPCON object.
1272  *	Not relevant for Tx queues.
1273  * @destination.type:	May be one of the following:
1274  *	0 - No destination, queue can be manually
1275  *		queried, but will not push traffic or
1276  *		notifications to a DPIO;
1277  *	1 - The destination is a DPIO. When traffic
1278  *		becomes available in the queue a FQDAN
1279  *		(FQ data available notification) will be
1280  *		generated to selected DPIO;
1281  *	2 - The destination is a DPCON. The queue is
1282  *		associated with a DPCON object for the
1283  *		purpose of scheduling between multiple
1284  *		queues. The DPCON may be independently
1285  *		configured to generate notifications.
1286  *		Not relevant for Tx queues.
1287  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
1288  *	in a DPIO during dequeue to reduce spread of traffic.
1289  *	Only relevant if queues are
1290  *	not affined to a single DPIO.
1291  * @user_context: User data, presented to the user along with any frames
1292  *	from this queue. Not relevant for Tx queues.
1293  * @flc: FD FLow Context structure
1294  * @flc.value: Default FLC value for traffic dequeued from
1295  *      this queue.  Please check description of FD
1296  *      structure for more information.
1297  *      Note that FLC values set using dpni_add_fs_entry,
1298  *      if any, take precedence over values per queue.
1299  * @flc.stash_control: Boolean, indicates whether the 6 lowest
1300  *      - significant bits are used for stash control.
1301  *      significant bits are used for stash control.  If set, the 6
1302  *      least significant bits in value are interpreted as follows:
1303  *      - bits 0-1: indicates the number of 64 byte units of context
1304  *      that are stashed.  FLC value is interpreted as a memory address
1305  *      in this case, excluding the 6 LS bits.
1306  *      - bits 2-3: indicates the number of 64 byte units of frame
1307  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
1308  *      - bits 4-5: indicates the number of 64 byte units of frame
1309  *      data to be stashed.  Frame data is placed at FD[ADDR] +
1310  *      FD[OFFSET].
1311  *      For more details check the Frame Descriptor section in the
1312  *      hardware documentation.
1313  *@cgid :indicate the cgid to set relative to dpni
1314  */
1315 struct dpni_queue {
1316 	struct {
1317 		uint16_t id;
1318 		enum dpni_dest type;
1319 		char hold_active;
1320 		uint8_t priority;
1321 	} destination;
1322 	uint64_t user_context;
1323 	struct {
1324 		uint64_t value;
1325 		char stash_control;
1326 	} flc;
1327 	int cgid;
1328 };
1329 
1330 /**
1331  * struct dpni_queue_id - Queue identification, used for enqueue commands
1332  *				or queue control
1333  * @fqid:	FQID used for enqueueing to and/or configuration of this
1334  *			specific FQ
1335  * @qdbin:	Queueing bin, used to enqueue using QDID, DQBIN, QPRI.
1336  *			Only relevant for Tx queues.
1337  */
1338 struct dpni_queue_id {
1339 	uint32_t fqid;
1340 	uint16_t qdbin;
1341 };
1342 
1343 /**
1344  * enum dpni_confirmation_mode - Defines DPNI options supported for Tx
1345  * confirmation
1346  * @DPNI_CONF_AFFINE: For each Tx queue set associated with a sender there is
1347  * an affine Tx Confirmation queue
1348  * @DPNI_CONF_SINGLE: All Tx queues are associated with a single Tx
1349  * confirmation queue
1350  * @DPNI_CONF_DISABLE: Tx frames are not confirmed.  This must be associated
1351  * with proper FD set-up to have buffers release to a Buffer Pool, otherwise
1352  * buffers will be leaked
1353  */
1354 enum dpni_confirmation_mode {
1355 	DPNI_CONF_AFFINE,
1356 	DPNI_CONF_SINGLE,
1357 	DPNI_CONF_DISABLE,
1358 };
1359 
1360 int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1361 				  uint32_t cmd_flags,
1362 				  uint16_t token,
1363 				  enum dpni_confirmation_mode mode);
1364 
1365 int dpni_get_tx_confirmation_mode(struct fsl_mc_io *mc_io,
1366 				  uint32_t cmd_flags,
1367 				  uint16_t token,
1368 				  enum dpni_confirmation_mode *mode);
1369 
1370 /**
1371  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
1372  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1373  *		key extractions to be used as the QoS criteria by calling
1374  *		dpkg_prepare_key_cfg()
1375  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
1376  *		'0' to use the 'default_tc' in such cases
1377  * @keep_entries: if set to one will not delele existing table entries. This
1378  *		option will work properly only for dpni objects created with
1379  *		DPNI_OPT_HAS_KEY_MASKING option. All previous QoS entries must
1380  *		be compatible with new key composition rule.
1381  *		It is the caller's job to delete incompatible entries before
1382  *		executing this function.
1383  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
1384  */
1385 struct dpni_qos_tbl_cfg {
1386 	uint64_t key_cfg_iova;
1387 	int discard_on_miss;
1388 	int keep_entries;
1389 	uint8_t default_tc;
1390 };
1391 
1392 int dpni_set_qos_table(struct fsl_mc_io *mc_io,
1393 		       uint32_t cmd_flags,
1394 		       uint16_t token,
1395 		       const struct dpni_qos_tbl_cfg *cfg);
1396 
1397 /**
1398  * struct dpni_rule_cfg - Rule configuration for table lookup
1399  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
1400  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
1401  * @key_size: key and mask size (in bytes)
1402  */
1403 struct dpni_rule_cfg {
1404 	uint64_t key_iova;
1405 	uint64_t mask_iova;
1406 	uint8_t key_size;
1407 };
1408 
1409 int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
1410 		       uint32_t cmd_flags,
1411 		       uint16_t token,
1412 		       const struct dpni_rule_cfg *cfg,
1413 		       uint8_t tc_id,
1414 		       uint16_t index,
1415 			   uint8_t flags,
1416 			   uint8_t flow_id);
1417 
1418 int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
1419 			  uint32_t cmd_flags,
1420 			  uint16_t token,
1421 			  const struct dpni_rule_cfg *cfg);
1422 
1423 int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
1424 			 uint32_t cmd_flags,
1425 			 uint16_t token);
1426 
1427 /**
1428  * Discard matching traffic.  If set, this takes precedence over any other
1429  * configuration and matching traffic is always discarded.
1430  */
1431  #define DPNI_FS_OPT_DISCARD            0x1
1432 
1433 /**
1434  * Set FLC value.  If set, flc member of truct dpni_fs_action_cfg is used to
1435  * override the FLC value set per queue.
1436  * For more details check the Frame Descriptor section in the hardware
1437  * documentation.
1438  */
1439 #define DPNI_FS_OPT_SET_FLC            0x2
1440 
1441 /*
1442  * Indicates whether the 6 lowest significant bits of FLC are used for stash
1443  * control.  If set, the 6 least significant bits in value are interpreted as
1444  * follows:
1445  *     - bits 0-1: indicates the number of 64 byte units of context that are
1446  *     stashed.  FLC value is interpreted as a memory address in this case,
1447  *     excluding the 6 LS bits.
1448  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1449  *     to be stashed.  Annotation is placed at FD[ADDR].
1450  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1451  *     stashed.  Frame data is placed at FD[ADDR] + FD[OFFSET].
1452  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1453  */
1454 #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1455 
1456 /**
1457  * struct dpni_fs_action_cfg - Action configuration for table look-up
1458  * @flc: FLC value for traffic matching this rule.  Please check the Frame
1459  * Descriptor section in the hardware documentation for more information.
1460  * @flow_id: Identifies the Rx queue used for matching traffic.  Supported
1461  *     values are in range 0 to num_queue-1.
1462  * @options: Any combination of DPNI_FS_OPT_ values.
1463  */
1464 struct dpni_fs_action_cfg {
1465 	uint64_t flc;
1466 	uint16_t flow_id;
1467 	uint16_t options;
1468 };
1469 
1470 int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1471 		      uint32_t cmd_flags,
1472 		      uint16_t token,
1473 		      uint8_t tc_id,
1474 		      uint16_t index,
1475 		      const struct dpni_rule_cfg *cfg,
1476 		      const struct dpni_fs_action_cfg *action);
1477 
1478 int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1479 			 uint32_t cmd_flags,
1480 			 uint16_t token,
1481 			 uint8_t tc_id,
1482 			 const struct dpni_rule_cfg *cfg);
1483 
1484 int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
1485 			  uint32_t cmd_flags,
1486 			  uint16_t token,
1487 			  uint8_t tc_id);
1488 
1489 int dpni_get_api_version(struct fsl_mc_io *mc_io,
1490 			 uint32_t cmd_flags,
1491 			 uint16_t *major_ver,
1492 			 uint16_t *minor_ver);
1493 
1494 /**
1495  * Set User Context
1496  */
1497 #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
1498 
1499 /**
1500  * Set queue destination configuration
1501  */
1502 #define DPNI_QUEUE_OPT_DEST		0x00000002
1503 
1504 /**
1505  * Set FD[FLC] configuration for traffic on this queue.  Note that FLC values
1506  * set with dpni_add_fs_entry, if any, take precedence over values per queue.
1507  */
1508 #define DPNI_QUEUE_OPT_FLC		0x00000004
1509 
1510 /**
1511  * Set the queue to hold active mode.  This prevents the queue from being
1512  * rescheduled between DPIOs while it carries traffic and is active on one
1513  * DPNI.  Can help reduce reordering when servicing one queue on multiple
1514  * CPUs, but the queue is also less likely to push data to multiple CPUs
1515  * especially when congested.
1516  */
1517 #define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
1518 
1519 #define DPNI_QUEUE_OPT_SET_CGID				0x00000040
1520 #define DPNI_QUEUE_OPT_CLEAR_CGID			0x00000080
1521 
1522 int dpni_set_queue(struct fsl_mc_io *mc_io,
1523 		   uint32_t cmd_flags,
1524 		   uint16_t token,
1525 		   enum dpni_queue_type qtype,
1526 		   uint8_t tc,
1527 		   uint8_t index,
1528 		   uint8_t options,
1529 		   const struct dpni_queue *queue);
1530 
1531 int dpni_get_queue(struct fsl_mc_io *mc_io,
1532 		   uint32_t cmd_flags,
1533 		   uint16_t token,
1534 		   enum dpni_queue_type qtype,
1535 		   uint8_t tc,
1536 		   uint8_t index,
1537 		   struct dpni_queue *queue,
1538 		   struct dpni_queue_id *qid);
1539 
1540 int dpni_get_statistics(struct fsl_mc_io *mc_io,
1541 			uint32_t cmd_flags,
1542 			uint16_t token,
1543 			uint8_t page,
1544 			uint16_t param,
1545 			union dpni_statistics *stat);
1546 
1547 int dpni_reset_statistics(struct fsl_mc_io *mc_io,
1548 			  uint32_t cmd_flags,
1549 			  uint16_t token);
1550 
1551 /**
1552  * struct dpni_taildrop - Structure representing the taildrop
1553  * @enable:	Indicates whether the taildrop is active or not.
1554  * @units:	Indicates the unit of THRESHOLD. Queue taildrop only
1555  *		supports byte units, this field is ignored and
1556  *		assumed = 0 if CONGESTION_POINT is 0.
1557  * @threshold:	Threshold value, in units identified by UNITS field. Value 0
1558  *		cannot be used as a valid taildrop threshold,
1559  *		THRESHOLD must be > 0 if the taildrop is
1560  *		enabled.
1561  * @oal	:	Overhead Accounting Length, a 12-bit, 2's complement value
1562  *		with range (-2048 to +2047) representing a fixed per-frame
1563  *		overhead to be added to the actual length of a frame when
1564  *		performing WRED and tail drop calculations and threshold
1565  *		comparisons.
1566  */
1567 struct dpni_taildrop {
1568 	char enable;
1569 	enum dpni_congestion_unit units;
1570 	uint32_t threshold;
1571 	int16_t oal;
1572 };
1573 
1574 int dpni_set_taildrop(struct fsl_mc_io *mc_io,
1575 		      uint32_t cmd_flags,
1576 		      uint16_t token,
1577 		      enum dpni_congestion_point cg_point,
1578 		      enum dpni_queue_type q_type,
1579 		      uint8_t tc,
1580 		      uint8_t q_index,
1581 		      struct dpni_taildrop *taildrop);
1582 
1583 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
1584 		      uint32_t cmd_flags,
1585 		      uint16_t token,
1586 		      enum dpni_congestion_point cg_point,
1587 		      enum dpni_queue_type q_type,
1588 		      uint8_t tc,
1589 		      uint8_t q_index,
1590 		      struct dpni_taildrop *taildrop);
1591 
1592 int dpni_set_opr(struct fsl_mc_io *mc_io,
1593 		 uint32_t cmd_flags,
1594 		 uint16_t token,
1595 		 uint8_t tc,
1596 		 uint8_t index,
1597 		 uint8_t options,
1598 		 struct opr_cfg *cfg);
1599 
1600 int dpni_get_opr(struct fsl_mc_io *mc_io,
1601 		 uint32_t cmd_flags,
1602 		 uint16_t token,
1603 		 uint8_t tc,
1604 		 uint8_t index,
1605 		 struct opr_cfg *cfg,
1606 		 struct opr_qry *qry);
1607 
1608 /**
1609  * When used for queue_idx in function dpni_set_rx_dist_default_queue will
1610  * signal to dpni to drop all unclassified frames
1611  */
1612 #define DPNI_FS_MISS_DROP		((uint16_t)-1)
1613 
1614 /**
1615  * struct dpni_rx_dist_cfg - distribution configuration
1616  * @dist_size:	distribution size; supported values: 1,2,3,4,6,7,8,
1617  *		12,14,16,24,28,32,48,56,64,96,112,128,192,224,256,384,448,
1618  *		512,768,896,1024
1619  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
1620  *		the extractions to be used for the distribution key by calling
1621  *		dpkg_prepare_key_cfg() relevant only when enable!=0 otherwise
1622  *		it can be '0'
1623  * @enable: enable/disable the distribution.
1624  * @tc: TC id for which distribution is set
1625  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
1626  *		hash is disabled it will be put into this queue id; use
1627  *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
1628  *		used only when flow steering distribution is enabled and hash
1629  *		distribution is disabled
1630  */
1631 struct dpni_rx_dist_cfg {
1632 	uint16_t dist_size;
1633 	uint64_t key_cfg_iova;
1634 	uint8_t enable;
1635 	uint8_t tc;
1636 	uint16_t fs_miss_flow_id;
1637 };
1638 
1639 int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1640 		uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1641 
1642 int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1643 		uint16_t token, const struct dpni_rx_dist_cfg *cfg);
1644 
1645 int dpni_add_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1646 		uint16_t token, uint16_t tpid);
1647 
1648 int dpni_remove_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1649 		uint16_t token, uint16_t tpid);
1650 
1651 /**
1652  * struct dpni_custom_tpid_cfg - custom TPID configuration. Contains custom TPID
1653  *	values used in current dpni object to detect 802.1q frames.
1654  *	@tpid1: first tag. Not used if zero.
1655  *	@tpid2: second tag. Not used if zero.
1656  */
1657 struct dpni_custom_tpid_cfg {
1658 	uint16_t tpid1;
1659 	uint16_t tpid2;
1660 };
1661 
1662 int dpni_get_custom_tpid(struct fsl_mc_io *mc_io, uint32_t cmd_flags,
1663 		uint16_t token, struct dpni_custom_tpid_cfg *tpid);
1664 
1665 /**
1666  * enum dpni_soft_sequence_dest - Enumeration of WRIOP software sequence
1667  *				destinations
1668  * @DPNI_SS_INGRESS: Ingress parser
1669  * @DPNI_SS_EGRESS: Egress parser
1670  */
1671 enum dpni_soft_sequence_dest {
1672 	DPNI_SS_INGRESS = 0,
1673 	DPNI_SS_EGRESS = 1,
1674 };
1675 
1676 /**
1677  * struct dpni_load_ss_cfg - Structure for Software Sequence load configuration
1678  * @dest:	Destination of the Software Sequence: ingress or egress parser
1679  * @ss_size: Size of the Software Sequence
1680  * @ss_offset:	The offset where to load the Software Sequence (0x20-0x7FD)
1681  * @ss_iova: I/O virtual address of the Software Sequence
1682  */
1683 struct dpni_load_ss_cfg {
1684 	enum dpni_soft_sequence_dest dest;
1685 	uint16_t ss_size;
1686 	uint16_t ss_offset;
1687 	uint64_t ss_iova;
1688 };
1689 
1690 /**
1691  * struct dpni_enable_ss_cfg - Structure for software sequence enable
1692  *				configuration
1693  * @dest:	Destination of the Software Sequence: ingress or egress parser
1694  * @hxs: HXS to attach the software sequence to
1695  * @set_start: If the Software Sequence or HDR it is attached to is set as
1696  *		parser start
1697  *		If hxs=DUMMY_LAST_HXS the ss_offset is set directly as parser
1698  *			start else the hdr index code is set as parser start
1699  * @ss_offset: The offset of the Software Sequence to enable or set as parse
1700  *		start
1701  * @param_size: Size of the software sequence parameters
1702  * @param_offset: Offset in the parameter zone for the software sequence
1703  *			parameters
1704  * @param_iova: I/O virtual address of the parameters
1705  */
1706 struct dpni_enable_ss_cfg {
1707 	enum dpni_soft_sequence_dest dest;
1708 	uint16_t hxs;
1709 	uint8_t set_start;
1710 	uint16_t ss_offset;
1711 	uint8_t param_size;
1712 	uint8_t param_offset;
1713 	uint64_t param_iova;
1714 };
1715 
1716 /**
1717  * dpni_load_sw_sequence() - Loads a software sequence in parser memory.
1718  * @mc_io:	Pointer to MC portal's I/O object
1719  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1720  * @token:	Token of DPNI object
1721  * @cfg:	Software sequence load configuration
1722  * Return:	'0' on Success; Error code otherwise.
1723  */
1724 int dpni_load_sw_sequence(struct fsl_mc_io *mc_io,
1725 	      uint32_t cmd_flags,
1726 	      uint16_t token,
1727 		  struct dpni_load_ss_cfg *cfg);
1728 
1729 /**
1730  * dpni_eanble_sw_sequence() - Enables a software sequence in the parser
1731  *				profile
1732  * corresponding to the ingress or egress of the DPNI.
1733  * @mc_io:	Pointer to MC portal's I/O object
1734  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1735  * @token:	Token of DPNI object
1736  * @cfg:	Software sequence enable configuration
1737  * Return:	'0' on Success; Error code otherwise.
1738  */
1739 int dpni_enable_sw_sequence(struct fsl_mc_io *mc_io,
1740 			    uint32_t cmd_flags,
1741 			    uint16_t token,
1742 			    struct dpni_enable_ss_cfg *cfg);
1743 
1744 /**
1745  * struct dpni_sw_sequence_layout - Structure for software sequence enable
1746  *				configuration
1747  * @num_ss:	Number of software sequences returned
1748  * @ss: Array of software sequence entries. The number of valid entries
1749  *			must match 'num_ss' value
1750  */
1751 struct dpni_sw_sequence_layout {
1752 	uint8_t num_ss;
1753 	struct {
1754 		uint16_t ss_offset;
1755 		uint16_t ss_size;
1756 		uint8_t param_offset;
1757 		uint8_t param_size;
1758 	} ss[DPNI_SW_SEQUENCE_LAYOUT_SIZE];
1759 };
1760 
1761 /**
1762  * dpni_get_sw_sequence_layout() - Get the soft sequence layout
1763  * @mc_io:	Pointer to MC portal's I/O object
1764  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
1765  * @token:	Token of DPNI object
1766  * @src:	Source of the layout (WRIOP Rx or Tx)
1767  * @ss_layout_iova:  I/O virtual address of 264 bytes DMA-able memory
1768  *
1769  * warning: After calling this function, call dpni_extract_sw_sequence_layout()
1770  *		to get the layout
1771  *
1772  * Return:	'0' on Success; error code otherwise.
1773  */
1774 int dpni_get_sw_sequence_layout(struct fsl_mc_io *mc_io,
1775 				uint32_t cmd_flags,
1776 				uint16_t token,
1777 				enum dpni_soft_sequence_dest src,
1778 				uint64_t ss_layout_iova);
1779 
1780 /**
1781  * dpni_extract_sw_sequence_layout() - extract the software sequence layout
1782  * @layout:		software sequence layout
1783  * @sw_sequence_layout_buf:	Zeroed 264 bytes of memory before mapping it
1784  *				to DMA
1785  *
1786  * This function has to be called after dpni_get_sw_sequence_layout
1787  *
1788  */
1789 void dpni_extract_sw_sequence_layout(struct dpni_sw_sequence_layout *layout,
1790 				     const uint8_t *sw_sequence_layout_buf);
1791 
1792 #endif /* __FSL_DPNI_H */
1793