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