xref: /openbmc/linux/drivers/net/ethernet/freescale/dpaa2/dpni.h (revision 7ae9fb1b7ecbb5d85d07857943f677fd1a559b18)
134ff6846SIoana Radulescu /* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
234ff6846SIoana Radulescu /* Copyright 2013-2016 Freescale Semiconductor Inc.
334ff6846SIoana Radulescu  * Copyright 2016 NXP
423cd4f27SYangbo Lu  * Copyright 2020 NXP
534ff6846SIoana Radulescu  */
634ff6846SIoana Radulescu #ifndef __FSL_DPNI_H
734ff6846SIoana Radulescu #define __FSL_DPNI_H
834ff6846SIoana Radulescu 
934ff6846SIoana Radulescu #include "dpkg.h"
1034ff6846SIoana Radulescu 
1134ff6846SIoana Radulescu struct fsl_mc_io;
1234ff6846SIoana Radulescu 
134fe72de6SIoana Ciornei /* Data Path Network Interface API
1434ff6846SIoana Radulescu  * Contains initialization APIs and runtime control APIs for DPNI
1534ff6846SIoana Radulescu  */
1634ff6846SIoana Radulescu 
1734ff6846SIoana Radulescu /** General DPNI macros */
1834ff6846SIoana Radulescu 
1934ff6846SIoana Radulescu /**
204fe72de6SIoana Ciornei  * DPNI_MAX_TC - Maximum number of traffic classes
2134ff6846SIoana Radulescu  */
2234ff6846SIoana Radulescu #define DPNI_MAX_TC				8
2334ff6846SIoana Radulescu /**
244fe72de6SIoana Ciornei  * DPNI_MAX_DPBP - Maximum number of buffer pools per DPNI
2534ff6846SIoana Radulescu  */
2634ff6846SIoana Radulescu #define DPNI_MAX_DPBP				8
2734ff6846SIoana Radulescu 
2834ff6846SIoana Radulescu /**
294fe72de6SIoana Ciornei  * DPNI_ALL_TCS - All traffic classes considered; see dpni_set_queue()
3034ff6846SIoana Radulescu  */
3134ff6846SIoana Radulescu #define DPNI_ALL_TCS				(u8)(-1)
3234ff6846SIoana Radulescu /**
334fe72de6SIoana Ciornei  * DPNI_ALL_TC_FLOWS - All flows within traffic class considered; see
344fe72de6SIoana Ciornei  * dpni_set_queue()
3534ff6846SIoana Radulescu  */
3634ff6846SIoana Radulescu #define DPNI_ALL_TC_FLOWS			(u16)(-1)
3734ff6846SIoana Radulescu /**
384fe72de6SIoana Ciornei  * DPNI_NEW_FLOW_ID - Generate new flow ID; see dpni_set_queue()
3934ff6846SIoana Radulescu  */
4034ff6846SIoana Radulescu #define DPNI_NEW_FLOW_ID			(u16)(-1)
4134ff6846SIoana Radulescu 
4234ff6846SIoana Radulescu /**
434fe72de6SIoana Ciornei  * DPNI_OPT_TX_FRM_RELEASE - Tx traffic is always released to a buffer pool on
444fe72de6SIoana Ciornei  * transmit, there are no resources allocated to have the frames confirmed back
454fe72de6SIoana Ciornei  * to the source after transmission.
4634ff6846SIoana Radulescu  */
4734ff6846SIoana Radulescu #define DPNI_OPT_TX_FRM_RELEASE			0x000001
4834ff6846SIoana Radulescu /**
494fe72de6SIoana Ciornei  * DPNI_OPT_NO_MAC_FILTER - Disables support for MAC address filtering for
504fe72de6SIoana Ciornei  * addresses other than primary MAC address. This affects both unicast and
514fe72de6SIoana Ciornei  * multicast. Promiscuous mode can still be enabled/disabled for both unicast
524fe72de6SIoana Ciornei  * and multicast. If promiscuous mode is disabled, only traffic matching the
534fe72de6SIoana Ciornei  * primary MAC address will be accepted.
5434ff6846SIoana Radulescu  */
5534ff6846SIoana Radulescu #define DPNI_OPT_NO_MAC_FILTER			0x000002
5634ff6846SIoana Radulescu /**
574fe72de6SIoana Ciornei  * DPNI_OPT_HAS_POLICING - Allocate policers for this DPNI. They can be used to
584fe72de6SIoana Ciornei  * rate-limit traffic per traffic class (TC) basis.
5934ff6846SIoana Radulescu  */
6034ff6846SIoana Radulescu #define DPNI_OPT_HAS_POLICING			0x000004
6134ff6846SIoana Radulescu /**
624fe72de6SIoana Ciornei  * DPNI_OPT_SHARED_CONGESTION - Congestion can be managed in several ways,
634fe72de6SIoana Ciornei  * allowing the buffer pool to deplete on ingress, taildrop on each queue or
644fe72de6SIoana Ciornei  * use congestion groups for sets of queues. If set, it configures a single
654fe72de6SIoana Ciornei  * congestion groups across all TCs.  If reset, a congestion group is allocated
664fe72de6SIoana Ciornei  * for each TC. Only relevant if the DPNI has multiple traffic classes.
6734ff6846SIoana Radulescu  */
6834ff6846SIoana Radulescu #define DPNI_OPT_SHARED_CONGESTION		0x000008
6934ff6846SIoana Radulescu /**
704fe72de6SIoana Ciornei  * DPNI_OPT_HAS_KEY_MASKING - Enables TCAM for Flow Steering and QoS look-ups.
714fe72de6SIoana Ciornei  * If not specified, all look-ups are exact match. Note that TCAM is not
724fe72de6SIoana Ciornei  * available on LS1088 and its variants. Setting this bit on these SoCs will
734fe72de6SIoana Ciornei  * trigger an error.
7434ff6846SIoana Radulescu  */
7534ff6846SIoana Radulescu #define DPNI_OPT_HAS_KEY_MASKING		0x000010
7634ff6846SIoana Radulescu /**
774fe72de6SIoana Ciornei  * DPNI_OPT_NO_FS - Disables the flow steering table.
7834ff6846SIoana Radulescu  */
7934ff6846SIoana Radulescu #define DPNI_OPT_NO_FS				0x000020
805e29c16fSIonut-robert Aron /**
814fe72de6SIoana Ciornei  * DPNI_OPT_SHARED_FS - Flow steering table is shared between all traffic
824fe72de6SIoana Ciornei  * classes
835e29c16fSIonut-robert Aron  */
845e29c16fSIonut-robert Aron #define DPNI_OPT_SHARED_FS			0x001000
8534ff6846SIoana Radulescu 
8634ff6846SIoana Radulescu int dpni_open(struct fsl_mc_io	*mc_io,
8734ff6846SIoana Radulescu 	      u32		cmd_flags,
8834ff6846SIoana Radulescu 	      int		dpni_id,
8934ff6846SIoana Radulescu 	      u16		*token);
9034ff6846SIoana Radulescu 
9134ff6846SIoana Radulescu int dpni_close(struct fsl_mc_io	*mc_io,
9234ff6846SIoana Radulescu 	       u32		cmd_flags,
9334ff6846SIoana Radulescu 	       u16		token);
9434ff6846SIoana Radulescu 
95*801c76ddSRobert-Ionut Alexa #define DPNI_POOL_ASSOC_QPRI	0
96*801c76ddSRobert-Ionut Alexa #define DPNI_POOL_ASSOC_QDBIN	1
97*801c76ddSRobert-Ionut Alexa 
9834ff6846SIoana Radulescu /**
9934ff6846SIoana Radulescu  * struct dpni_pools_cfg - Structure representing buffer pools configuration
10034ff6846SIoana Radulescu  * @num_dpbp: Number of DPBPs
101*801c76ddSRobert-Ionut Alexa  * @pool_options: Buffer assignment options.
102*801c76ddSRobert-Ionut Alexa  *	This field is a combination of DPNI_POOL_ASSOC_flags
10334ff6846SIoana Radulescu  * @pools: Array of buffer pools parameters; The number of valid entries
10434ff6846SIoana Radulescu  *	must match 'num_dpbp' value
10534ff6846SIoana Radulescu  * @pools.dpbp_id: DPBP object ID
106*801c76ddSRobert-Ionut Alexa  * @pools.priority: Priority mask that indicates TC's used with this buffer.
107*801c76ddSRobert-Ionut Alexa  *	If set to 0x00 MC will assume value 0xff.
10834ff6846SIoana Radulescu  * @pools.buffer_size: Buffer size
10934ff6846SIoana Radulescu  * @pools.backup_pool: Backup pool
11034ff6846SIoana Radulescu  */
11134ff6846SIoana Radulescu struct dpni_pools_cfg {
11234ff6846SIoana Radulescu 	u8		num_dpbp;
113*801c76ddSRobert-Ionut Alexa 	u8		pool_options;
11434ff6846SIoana Radulescu 	struct {
11534ff6846SIoana Radulescu 		int	dpbp_id;
116*801c76ddSRobert-Ionut Alexa 		u8	priority_mask;
11734ff6846SIoana Radulescu 		u16	buffer_size;
11834ff6846SIoana Radulescu 		int	backup_pool;
11934ff6846SIoana Radulescu 	} pools[DPNI_MAX_DPBP];
12034ff6846SIoana Radulescu };
12134ff6846SIoana Radulescu 
12234ff6846SIoana Radulescu int dpni_set_pools(struct fsl_mc_io		*mc_io,
12334ff6846SIoana Radulescu 		   u32				cmd_flags,
12434ff6846SIoana Radulescu 		   u16				token,
12534ff6846SIoana Radulescu 		   const struct dpni_pools_cfg	*cfg);
12634ff6846SIoana Radulescu 
12734ff6846SIoana Radulescu int dpni_enable(struct fsl_mc_io	*mc_io,
12834ff6846SIoana Radulescu 		u32			cmd_flags,
12934ff6846SIoana Radulescu 		u16			token);
13034ff6846SIoana Radulescu 
13134ff6846SIoana Radulescu int dpni_disable(struct fsl_mc_io	*mc_io,
13234ff6846SIoana Radulescu 		 u32			cmd_flags,
13334ff6846SIoana Radulescu 		 u16			token);
13434ff6846SIoana Radulescu 
13534ff6846SIoana Radulescu int dpni_is_enabled(struct fsl_mc_io	*mc_io,
13634ff6846SIoana Radulescu 		    u32			cmd_flags,
13734ff6846SIoana Radulescu 		    u16			token,
13834ff6846SIoana Radulescu 		    int			*en);
13934ff6846SIoana Radulescu 
14034ff6846SIoana Radulescu int dpni_reset(struct fsl_mc_io	*mc_io,
14134ff6846SIoana Radulescu 	       u32		cmd_flags,
14234ff6846SIoana Radulescu 	       u16		token);
14334ff6846SIoana Radulescu 
1444fe72de6SIoana Ciornei /* DPNI IRQ Index and Events */
14534ff6846SIoana Radulescu 
14634ff6846SIoana Radulescu #define DPNI_IRQ_INDEX				0
1474fe72de6SIoana Ciornei 
1484fe72de6SIoana Ciornei /* DPNI_IRQ_EVENT_LINK_CHANGED - indicates a change in link state */
14934ff6846SIoana Radulescu #define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
1504fe72de6SIoana Ciornei 
1514fe72de6SIoana Ciornei /* DPNI_IRQ_EVENT_ENDPOINT_CHANGED - indicates a change in endpoint */
1528398b375SFlorin Chiculita #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED		0x00000002
15334ff6846SIoana Radulescu 
15434ff6846SIoana Radulescu int dpni_set_irq_enable(struct fsl_mc_io	*mc_io,
15534ff6846SIoana Radulescu 			u32			cmd_flags,
15634ff6846SIoana Radulescu 			u16			token,
15734ff6846SIoana Radulescu 			u8			irq_index,
15834ff6846SIoana Radulescu 			u8			en);
15934ff6846SIoana Radulescu 
16034ff6846SIoana Radulescu int dpni_get_irq_enable(struct fsl_mc_io	*mc_io,
16134ff6846SIoana Radulescu 			u32			cmd_flags,
16234ff6846SIoana Radulescu 			u16			token,
16334ff6846SIoana Radulescu 			u8			irq_index,
16434ff6846SIoana Radulescu 			u8			*en);
16534ff6846SIoana Radulescu 
16634ff6846SIoana Radulescu int dpni_set_irq_mask(struct fsl_mc_io	*mc_io,
16734ff6846SIoana Radulescu 		      u32		cmd_flags,
16834ff6846SIoana Radulescu 		      u16		token,
16934ff6846SIoana Radulescu 		      u8		irq_index,
17034ff6846SIoana Radulescu 		      u32		mask);
17134ff6846SIoana Radulescu 
17234ff6846SIoana Radulescu int dpni_get_irq_mask(struct fsl_mc_io	*mc_io,
17334ff6846SIoana Radulescu 		      u32		cmd_flags,
17434ff6846SIoana Radulescu 		      u16		token,
17534ff6846SIoana Radulescu 		      u8		irq_index,
17634ff6846SIoana Radulescu 		      u32		*mask);
17734ff6846SIoana Radulescu 
17834ff6846SIoana Radulescu int dpni_get_irq_status(struct fsl_mc_io	*mc_io,
17934ff6846SIoana Radulescu 			u32			cmd_flags,
18034ff6846SIoana Radulescu 			u16			token,
18134ff6846SIoana Radulescu 			u8			irq_index,
18234ff6846SIoana Radulescu 			u32			*status);
18334ff6846SIoana Radulescu 
18434ff6846SIoana Radulescu int dpni_clear_irq_status(struct fsl_mc_io	*mc_io,
18534ff6846SIoana Radulescu 			  u32			cmd_flags,
18634ff6846SIoana Radulescu 			  u16			token,
18734ff6846SIoana Radulescu 			  u8			irq_index,
18834ff6846SIoana Radulescu 			  u32			status);
18934ff6846SIoana Radulescu 
19034ff6846SIoana Radulescu /**
19134ff6846SIoana Radulescu  * struct dpni_attr - Structure representing DPNI attributes
19234ff6846SIoana Radulescu  * @options: Any combination of the following options:
19334ff6846SIoana Radulescu  *		DPNI_OPT_TX_FRM_RELEASE
19434ff6846SIoana Radulescu  *		DPNI_OPT_NO_MAC_FILTER
19534ff6846SIoana Radulescu  *		DPNI_OPT_HAS_POLICING
19634ff6846SIoana Radulescu  *		DPNI_OPT_SHARED_CONGESTION
19734ff6846SIoana Radulescu  *		DPNI_OPT_HAS_KEY_MASKING
19834ff6846SIoana Radulescu  *		DPNI_OPT_NO_FS
19934ff6846SIoana Radulescu  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
20034ff6846SIoana Radulescu  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
20134ff6846SIoana Radulescu  * @mac_filter_entries: Number of entries in the MAC address filtering table.
20234ff6846SIoana Radulescu  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
20334ff6846SIoana Radulescu  * @qos_entries: Number of entries in the QoS classification table.
20434ff6846SIoana Radulescu  * @fs_entries: Number of entries in the flow steering table.
20534ff6846SIoana Radulescu  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
20634ff6846SIoana Radulescu  *		than this when adding QoS entries will result in an error.
20734ff6846SIoana Radulescu  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
20834ff6846SIoana Radulescu  *		key larger than this when composing the hash + FS key will
20934ff6846SIoana Radulescu  *		result in an error.
21034ff6846SIoana Radulescu  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
21134ff6846SIoana Radulescu  *		on 6, 5, 5 bits respectively.
21234ff6846SIoana Radulescu  */
21334ff6846SIoana Radulescu struct dpni_attr {
21434ff6846SIoana Radulescu 	u32 options;
21534ff6846SIoana Radulescu 	u8 num_queues;
21634ff6846SIoana Radulescu 	u8 num_tcs;
21734ff6846SIoana Radulescu 	u8 mac_filter_entries;
21834ff6846SIoana Radulescu 	u8 vlan_filter_entries;
21934ff6846SIoana Radulescu 	u8 qos_entries;
22034ff6846SIoana Radulescu 	u16 fs_entries;
22134ff6846SIoana Radulescu 	u8 qos_key_size;
22234ff6846SIoana Radulescu 	u8 fs_key_size;
22334ff6846SIoana Radulescu 	u16 wriop_version;
22434ff6846SIoana Radulescu };
22534ff6846SIoana Radulescu 
22634ff6846SIoana Radulescu int dpni_get_attributes(struct fsl_mc_io	*mc_io,
22734ff6846SIoana Radulescu 			u32			cmd_flags,
22834ff6846SIoana Radulescu 			u16			token,
22934ff6846SIoana Radulescu 			struct dpni_attr	*attr);
23034ff6846SIoana Radulescu 
2314fe72de6SIoana Ciornei /* DPNI errors */
23234ff6846SIoana Radulescu 
23334ff6846SIoana Radulescu /**
2344fe72de6SIoana Ciornei  * DPNI_ERROR_EOFHE - Extract out of frame header error
23534ff6846SIoana Radulescu  */
23634ff6846SIoana Radulescu #define DPNI_ERROR_EOFHE	0x00020000
23734ff6846SIoana Radulescu /**
2384fe72de6SIoana Ciornei  * DPNI_ERROR_FLE - Frame length error
23934ff6846SIoana Radulescu  */
24034ff6846SIoana Radulescu #define DPNI_ERROR_FLE		0x00002000
24134ff6846SIoana Radulescu /**
2424fe72de6SIoana Ciornei  * DPNI_ERROR_FPE - Frame physical error
24334ff6846SIoana Radulescu  */
24434ff6846SIoana Radulescu #define DPNI_ERROR_FPE		0x00001000
24534ff6846SIoana Radulescu /**
2464fe72de6SIoana Ciornei  * DPNI_ERROR_PHE - Parsing header error
24734ff6846SIoana Radulescu  */
24834ff6846SIoana Radulescu #define DPNI_ERROR_PHE		0x00000020
24934ff6846SIoana Radulescu /**
2504fe72de6SIoana Ciornei  * DPNI_ERROR_L3CE - Parser L3 checksum error
25134ff6846SIoana Radulescu  */
25234ff6846SIoana Radulescu #define DPNI_ERROR_L3CE		0x00000004
25334ff6846SIoana Radulescu /**
2544fe72de6SIoana Ciornei  * DPNI_ERROR_L4CE - Parser L3 checksum error
25534ff6846SIoana Radulescu  */
25634ff6846SIoana Radulescu #define DPNI_ERROR_L4CE		0x00000001
25734ff6846SIoana Radulescu 
25834ff6846SIoana Radulescu /**
25934ff6846SIoana Radulescu  * enum dpni_error_action - Defines DPNI behavior for errors
26034ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
26134ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
26234ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
26334ff6846SIoana Radulescu  */
26434ff6846SIoana Radulescu enum dpni_error_action {
26534ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_DISCARD = 0,
26634ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_CONTINUE = 1,
26734ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
26834ff6846SIoana Radulescu };
26934ff6846SIoana Radulescu 
27034ff6846SIoana Radulescu /**
27134ff6846SIoana Radulescu  * struct dpni_error_cfg - Structure representing DPNI errors treatment
27234ff6846SIoana Radulescu  * @errors: Errors mask; use 'DPNI_ERROR__<X>
27334ff6846SIoana Radulescu  * @error_action: The desired action for the errors mask
27434ff6846SIoana Radulescu  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
27534ff6846SIoana Radulescu  *		status (FAS); relevant only for the non-discard action
27634ff6846SIoana Radulescu  */
27734ff6846SIoana Radulescu struct dpni_error_cfg {
27834ff6846SIoana Radulescu 	u32			errors;
27934ff6846SIoana Radulescu 	enum dpni_error_action	error_action;
28034ff6846SIoana Radulescu 	int			set_frame_annotation;
28134ff6846SIoana Radulescu };
28234ff6846SIoana Radulescu 
28334ff6846SIoana Radulescu int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
28434ff6846SIoana Radulescu 			     u32			cmd_flags,
28534ff6846SIoana Radulescu 			     u16			token,
28634ff6846SIoana Radulescu 			     struct dpni_error_cfg	*cfg);
28734ff6846SIoana Radulescu 
2884fe72de6SIoana Ciornei /* DPNI buffer layout modification options */
28934ff6846SIoana Radulescu 
29034ff6846SIoana Radulescu /**
2914fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_TIMESTAMP - Select to modify the time-stamp setting
29234ff6846SIoana Radulescu  */
29334ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
29434ff6846SIoana Radulescu /**
2954fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_PARSER_RESULT - Select to modify the parser-result
2964fe72de6SIoana Ciornei  * setting; not applicable for Tx
29734ff6846SIoana Radulescu  */
29834ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
29934ff6846SIoana Radulescu /**
3004fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_FRAME_STATUS - Select to modify the frame-status setting
30134ff6846SIoana Radulescu  */
30234ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
30334ff6846SIoana Radulescu /**
3044fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE - Select to modify the private-data-size setting
30534ff6846SIoana Radulescu  */
30634ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
30734ff6846SIoana Radulescu /**
3084fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_DATA_ALIGN - Select to modify the data-alignment setting
30934ff6846SIoana Radulescu  */
31034ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
31134ff6846SIoana Radulescu /**
3124fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM - Select to modify the data-head-room setting
31334ff6846SIoana Radulescu  */
31434ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
31534ff6846SIoana Radulescu /**
3164fe72de6SIoana Ciornei  * DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM - Select to modify the data-tail-room setting
31734ff6846SIoana Radulescu  */
31834ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
31934ff6846SIoana Radulescu 
32034ff6846SIoana Radulescu /**
32134ff6846SIoana Radulescu  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
32234ff6846SIoana Radulescu  * @options: Flags representing the suggested modifications to the buffer
32334ff6846SIoana Radulescu  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
32434ff6846SIoana Radulescu  * @pass_timestamp: Pass timestamp value
32534ff6846SIoana Radulescu  * @pass_parser_result: Pass parser results
32634ff6846SIoana Radulescu  * @pass_frame_status: Pass frame status
32734ff6846SIoana Radulescu  * @private_data_size: Size kept for private data (in bytes)
32834ff6846SIoana Radulescu  * @data_align: Data alignment
32934ff6846SIoana Radulescu  * @data_head_room: Data head room
33034ff6846SIoana Radulescu  * @data_tail_room: Data tail room
33134ff6846SIoana Radulescu  */
33234ff6846SIoana Radulescu struct dpni_buffer_layout {
33334ff6846SIoana Radulescu 	u32	options;
33434ff6846SIoana Radulescu 	int	pass_timestamp;
33534ff6846SIoana Radulescu 	int	pass_parser_result;
33634ff6846SIoana Radulescu 	int	pass_frame_status;
33734ff6846SIoana Radulescu 	u16	private_data_size;
33834ff6846SIoana Radulescu 	u16	data_align;
33934ff6846SIoana Radulescu 	u16	data_head_room;
34034ff6846SIoana Radulescu 	u16	data_tail_room;
34134ff6846SIoana Radulescu };
34234ff6846SIoana Radulescu 
34334ff6846SIoana Radulescu /**
34434ff6846SIoana Radulescu  * enum dpni_queue_type - Identifies a type of queue targeted by the command
34534ff6846SIoana Radulescu  * @DPNI_QUEUE_RX: Rx queue
34634ff6846SIoana Radulescu  * @DPNI_QUEUE_TX: Tx queue
34734ff6846SIoana Radulescu  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
34834ff6846SIoana Radulescu  * @DPNI_QUEUE_RX_ERR: Rx error queue
3494fe72de6SIoana Ciornei  */
3504fe72de6SIoana Ciornei enum dpni_queue_type {
35134ff6846SIoana Radulescu 	DPNI_QUEUE_RX,
35234ff6846SIoana Radulescu 	DPNI_QUEUE_TX,
35334ff6846SIoana Radulescu 	DPNI_QUEUE_TX_CONFIRM,
35434ff6846SIoana Radulescu 	DPNI_QUEUE_RX_ERR,
35534ff6846SIoana Radulescu };
35634ff6846SIoana Radulescu 
35734ff6846SIoana Radulescu int dpni_get_buffer_layout(struct fsl_mc_io		*mc_io,
35834ff6846SIoana Radulescu 			   u32				cmd_flags,
35934ff6846SIoana Radulescu 			   u16				token,
36034ff6846SIoana Radulescu 			   enum dpni_queue_type		qtype,
36134ff6846SIoana Radulescu 			   struct dpni_buffer_layout	*layout);
36234ff6846SIoana Radulescu 
36334ff6846SIoana Radulescu int dpni_set_buffer_layout(struct fsl_mc_io		   *mc_io,
36434ff6846SIoana Radulescu 			   u32				   cmd_flags,
36534ff6846SIoana Radulescu 			   u16				   token,
36634ff6846SIoana Radulescu 			   enum dpni_queue_type		   qtype,
36734ff6846SIoana Radulescu 			   const struct dpni_buffer_layout *layout);
36834ff6846SIoana Radulescu 
36934ff6846SIoana Radulescu /**
37034ff6846SIoana Radulescu  * enum dpni_offload - Identifies a type of offload targeted by the command
37134ff6846SIoana Radulescu  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
37234ff6846SIoana Radulescu  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
37334ff6846SIoana Radulescu  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
37434ff6846SIoana Radulescu  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
37534ff6846SIoana Radulescu  */
37634ff6846SIoana Radulescu enum dpni_offload {
37734ff6846SIoana Radulescu 	DPNI_OFF_RX_L3_CSUM,
37834ff6846SIoana Radulescu 	DPNI_OFF_RX_L4_CSUM,
37934ff6846SIoana Radulescu 	DPNI_OFF_TX_L3_CSUM,
38034ff6846SIoana Radulescu 	DPNI_OFF_TX_L4_CSUM,
38134ff6846SIoana Radulescu };
38234ff6846SIoana Radulescu 
38334ff6846SIoana Radulescu int dpni_set_offload(struct fsl_mc_io	*mc_io,
38434ff6846SIoana Radulescu 		     u32		cmd_flags,
38534ff6846SIoana Radulescu 		     u16		token,
38634ff6846SIoana Radulescu 		     enum dpni_offload	type,
38734ff6846SIoana Radulescu 		     u32		config);
38834ff6846SIoana Radulescu 
38934ff6846SIoana Radulescu int dpni_get_offload(struct fsl_mc_io	*mc_io,
39034ff6846SIoana Radulescu 		     u32		cmd_flags,
39134ff6846SIoana Radulescu 		     u16		token,
39234ff6846SIoana Radulescu 		     enum dpni_offload	type,
39334ff6846SIoana Radulescu 		     u32		*config);
39434ff6846SIoana Radulescu 
39534ff6846SIoana Radulescu int dpni_get_qdid(struct fsl_mc_io	*mc_io,
39634ff6846SIoana Radulescu 		  u32			cmd_flags,
39734ff6846SIoana Radulescu 		  u16			token,
39834ff6846SIoana Radulescu 		  enum dpni_queue_type	qtype,
39934ff6846SIoana Radulescu 		  u16			*qdid);
40034ff6846SIoana Radulescu 
40134ff6846SIoana Radulescu int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
40234ff6846SIoana Radulescu 			    u32			cmd_flags,
40334ff6846SIoana Radulescu 			    u16			token,
40434ff6846SIoana Radulescu 			    u16			*data_offset);
40534ff6846SIoana Radulescu 
40634ff6846SIoana Radulescu #define DPNI_STATISTICS_CNT		7
40734ff6846SIoana Radulescu 
40834ff6846SIoana Radulescu /**
40934ff6846SIoana Radulescu  * union dpni_statistics - Union describing the DPNI statistics
41034ff6846SIoana Radulescu  * @page_0: Page_0 statistics structure
41134ff6846SIoana Radulescu  * @page_0.ingress_all_frames: Ingress frame count
41234ff6846SIoana Radulescu  * @page_0.ingress_all_bytes: Ingress byte count
41334ff6846SIoana Radulescu  * @page_0.ingress_multicast_frames: Ingress multicast frame count
41434ff6846SIoana Radulescu  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
41534ff6846SIoana Radulescu  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
41634ff6846SIoana Radulescu  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
41734ff6846SIoana Radulescu  * @page_1: Page_1 statistics structure
41834ff6846SIoana Radulescu  * @page_1.egress_all_frames: Egress frame count
41934ff6846SIoana Radulescu  * @page_1.egress_all_bytes: Egress byte count
42034ff6846SIoana Radulescu  * @page_1.egress_multicast_frames: Egress multicast frame count
42134ff6846SIoana Radulescu  * @page_1.egress_multicast_bytes: Egress multicast byte count
42234ff6846SIoana Radulescu  * @page_1.egress_broadcast_frames: Egress broadcast frame count
42334ff6846SIoana Radulescu  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
42434ff6846SIoana Radulescu  * @page_2: Page_2 statistics structure
42534ff6846SIoana Radulescu  * @page_2.ingress_filtered_frames: Ingress filtered frame count
42634ff6846SIoana Radulescu  * @page_2.ingress_discarded_frames: Ingress discarded frame count
42734ff6846SIoana Radulescu  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
42834ff6846SIoana Radulescu  *	lack of buffers
42934ff6846SIoana Radulescu  * @page_2.egress_discarded_frames: Egress discarded frame count
43034ff6846SIoana Radulescu  * @page_2.egress_confirmed_frames: Egress confirmed frame count
4314fe72de6SIoana Ciornei  * @page_3: Page_3 statistics structure
432d84c3a4dSIoana Radulescu  * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
433d84c3a4dSIoana Radulescu  *	dequeued from egress FQs
434d84c3a4dSIoana Radulescu  * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
435d84c3a4dSIoana Radulescu  *	dequeued from egress FQs
436d84c3a4dSIoana Radulescu  * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
437d84c3a4dSIoana Radulescu  *	egress frames whose enqueue was rejected
438d84c3a4dSIoana Radulescu  * @page_3.egress_reject_frames: Cumulative count of the number of egress
439d84c3a4dSIoana Radulescu  *	frames whose enqueue was rejected
440d84c3a4dSIoana Radulescu  * @page_4: Page_4 statistics structure: congestion points
441d84c3a4dSIoana Radulescu  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
442d84c3a4dSIoana Radulescu  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
443d84c3a4dSIoana Radulescu  * @page_5: Page_5 statistics structure: policer
444d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_red: NUmber of red colored frames
445d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_yellow: number of yellow colored frames
446d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_green: number of green colored frames
447d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_re_red: number of recolored red frames
448d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
449d84c3a4dSIoana Radulescu  * @page_6: Page_6 statistics structure
450d84c3a4dSIoana Radulescu  * @page_6.tx_pending_frames: total number of frames pending in egress FQs
45134ff6846SIoana Radulescu  * @raw: raw statistics structure, used to index counters
45234ff6846SIoana Radulescu  */
45334ff6846SIoana Radulescu union dpni_statistics {
45434ff6846SIoana Radulescu 	struct {
45534ff6846SIoana Radulescu 		u64 ingress_all_frames;
45634ff6846SIoana Radulescu 		u64 ingress_all_bytes;
45734ff6846SIoana Radulescu 		u64 ingress_multicast_frames;
45834ff6846SIoana Radulescu 		u64 ingress_multicast_bytes;
45934ff6846SIoana Radulescu 		u64 ingress_broadcast_frames;
46034ff6846SIoana Radulescu 		u64 ingress_broadcast_bytes;
46134ff6846SIoana Radulescu 	} page_0;
46234ff6846SIoana Radulescu 	struct {
46334ff6846SIoana Radulescu 		u64 egress_all_frames;
46434ff6846SIoana Radulescu 		u64 egress_all_bytes;
46534ff6846SIoana Radulescu 		u64 egress_multicast_frames;
46634ff6846SIoana Radulescu 		u64 egress_multicast_bytes;
46734ff6846SIoana Radulescu 		u64 egress_broadcast_frames;
46834ff6846SIoana Radulescu 		u64 egress_broadcast_bytes;
46934ff6846SIoana Radulescu 	} page_1;
47034ff6846SIoana Radulescu 	struct {
47134ff6846SIoana Radulescu 		u64 ingress_filtered_frames;
47234ff6846SIoana Radulescu 		u64 ingress_discarded_frames;
47334ff6846SIoana Radulescu 		u64 ingress_nobuffer_discards;
47434ff6846SIoana Radulescu 		u64 egress_discarded_frames;
47534ff6846SIoana Radulescu 		u64 egress_confirmed_frames;
47634ff6846SIoana Radulescu 	} page_2;
47734ff6846SIoana Radulescu 	struct {
478d84c3a4dSIoana Radulescu 		u64 egress_dequeue_bytes;
479d84c3a4dSIoana Radulescu 		u64 egress_dequeue_frames;
480d84c3a4dSIoana Radulescu 		u64 egress_reject_bytes;
481d84c3a4dSIoana Radulescu 		u64 egress_reject_frames;
482d84c3a4dSIoana Radulescu 	} page_3;
483d84c3a4dSIoana Radulescu 	struct {
484d84c3a4dSIoana Radulescu 		u64 cgr_reject_frames;
485d84c3a4dSIoana Radulescu 		u64 cgr_reject_bytes;
486d84c3a4dSIoana Radulescu 	} page_4;
487d84c3a4dSIoana Radulescu 	struct {
488d84c3a4dSIoana Radulescu 		u64 policer_cnt_red;
489d84c3a4dSIoana Radulescu 		u64 policer_cnt_yellow;
490d84c3a4dSIoana Radulescu 		u64 policer_cnt_green;
491d84c3a4dSIoana Radulescu 		u64 policer_cnt_re_red;
492d84c3a4dSIoana Radulescu 		u64 policer_cnt_re_yellow;
493d84c3a4dSIoana Radulescu 	} page_5;
494d84c3a4dSIoana Radulescu 	struct {
495d84c3a4dSIoana Radulescu 		u64 tx_pending_frames;
496d84c3a4dSIoana Radulescu 	} page_6;
497d84c3a4dSIoana Radulescu 	struct {
49834ff6846SIoana Radulescu 		u64 counter[DPNI_STATISTICS_CNT];
49934ff6846SIoana Radulescu 	} raw;
50034ff6846SIoana Radulescu };
50134ff6846SIoana Radulescu 
50234ff6846SIoana Radulescu int dpni_get_statistics(struct fsl_mc_io	*mc_io,
50334ff6846SIoana Radulescu 			u32			cmd_flags,
50434ff6846SIoana Radulescu 			u16			token,
50534ff6846SIoana Radulescu 			u8			page,
50634ff6846SIoana Radulescu 			union dpni_statistics	*stat);
50734ff6846SIoana Radulescu 
50834ff6846SIoana Radulescu #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
50934ff6846SIoana Radulescu #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
51034ff6846SIoana Radulescu #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
51134ff6846SIoana Radulescu #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
512f395b69fSIoana Ciornei #define DPNI_LINK_OPT_PFC_PAUSE		0x0000000000000010ULL
513f395b69fSIoana Ciornei 
514f395b69fSIoana Ciornei /**
5154fe72de6SIoana Ciornei  * struct dpni_link_cfg - Structure representing DPNI link configuration
51634ff6846SIoana Radulescu  * @rate: Rate
51734ff6846SIoana Radulescu  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
51834ff6846SIoana Radulescu  */
51934ff6846SIoana Radulescu struct dpni_link_cfg {
52034ff6846SIoana Radulescu 	u32 rate;
52134ff6846SIoana Radulescu 	u64 options;
52234ff6846SIoana Radulescu };
52334ff6846SIoana Radulescu 
52434ff6846SIoana Radulescu int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
52534ff6846SIoana Radulescu 		      u32				cmd_flags,
52634ff6846SIoana Radulescu 		      u16				token,
52734ff6846SIoana Radulescu 		      const struct dpni_link_cfg	*cfg);
52834ff6846SIoana Radulescu 
5298eb3cef8SIoana Radulescu int dpni_get_link_cfg(struct fsl_mc_io			*mc_io,
5308eb3cef8SIoana Radulescu 		      u32				cmd_flags,
5318eb3cef8SIoana Radulescu 		      u16				token,
5328eb3cef8SIoana Radulescu 		      struct dpni_link_cfg		*cfg);
5338eb3cef8SIoana Radulescu 
53434ff6846SIoana Radulescu /**
53534ff6846SIoana Radulescu  * struct dpni_link_state - Structure representing DPNI link state
53634ff6846SIoana Radulescu  * @rate: Rate
53734ff6846SIoana Radulescu  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
53834ff6846SIoana Radulescu  * @up: Link state; '0' for down, '1' for up
53934ff6846SIoana Radulescu  */
54034ff6846SIoana Radulescu struct dpni_link_state {
54134ff6846SIoana Radulescu 	u32	rate;
54234ff6846SIoana Radulescu 	u64	options;
54334ff6846SIoana Radulescu 	int	up;
54434ff6846SIoana Radulescu };
54534ff6846SIoana Radulescu 
54634ff6846SIoana Radulescu int dpni_get_link_state(struct fsl_mc_io	*mc_io,
54734ff6846SIoana Radulescu 			u32			cmd_flags,
54834ff6846SIoana Radulescu 			u16			token,
54934ff6846SIoana Radulescu 			struct dpni_link_state	*state);
55034ff6846SIoana Radulescu 
55134ff6846SIoana Radulescu int dpni_set_max_frame_length(struct fsl_mc_io	*mc_io,
55234ff6846SIoana Radulescu 			      u32		cmd_flags,
55334ff6846SIoana Radulescu 			      u16		token,
55434ff6846SIoana Radulescu 			      u16		max_frame_length);
55534ff6846SIoana Radulescu 
55634ff6846SIoana Radulescu int dpni_get_max_frame_length(struct fsl_mc_io	*mc_io,
55734ff6846SIoana Radulescu 			      u32		cmd_flags,
55834ff6846SIoana Radulescu 			      u16		token,
55934ff6846SIoana Radulescu 			      u16		*max_frame_length);
56034ff6846SIoana Radulescu 
56134ff6846SIoana Radulescu int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
56234ff6846SIoana Radulescu 			       u32		cmd_flags,
56334ff6846SIoana Radulescu 			       u16		token,
56434ff6846SIoana Radulescu 			       int		en);
56534ff6846SIoana Radulescu 
56634ff6846SIoana Radulescu int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
56734ff6846SIoana Radulescu 			       u32		cmd_flags,
56834ff6846SIoana Radulescu 			       u16		token,
56934ff6846SIoana Radulescu 			       int		*en);
57034ff6846SIoana Radulescu 
57134ff6846SIoana Radulescu int dpni_set_unicast_promisc(struct fsl_mc_io	*mc_io,
57234ff6846SIoana Radulescu 			     u32		cmd_flags,
57334ff6846SIoana Radulescu 			     u16		token,
57434ff6846SIoana Radulescu 			     int		en);
57534ff6846SIoana Radulescu 
57634ff6846SIoana Radulescu int dpni_get_unicast_promisc(struct fsl_mc_io	*mc_io,
57734ff6846SIoana Radulescu 			     u32		cmd_flags,
57834ff6846SIoana Radulescu 			     u16		token,
57934ff6846SIoana Radulescu 			     int		*en);
58034ff6846SIoana Radulescu 
58134ff6846SIoana Radulescu int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
58234ff6846SIoana Radulescu 			      u32		cmd_flags,
58334ff6846SIoana Radulescu 			      u16		token,
58434ff6846SIoana Radulescu 			      const u8		mac_addr[6]);
58534ff6846SIoana Radulescu 
58634ff6846SIoana Radulescu int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
58734ff6846SIoana Radulescu 			      u32		cmd_flags,
58834ff6846SIoana Radulescu 			      u16		token,
58934ff6846SIoana Radulescu 			      u8		mac_addr[6]);
59034ff6846SIoana Radulescu 
59134ff6846SIoana Radulescu int dpni_get_port_mac_addr(struct fsl_mc_io	*mc_io,
59234ff6846SIoana Radulescu 			   u32			cm_flags,
59334ff6846SIoana Radulescu 			   u16			token,
59434ff6846SIoana Radulescu 			   u8			mac_addr[6]);
59534ff6846SIoana Radulescu 
59634ff6846SIoana Radulescu int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
59734ff6846SIoana Radulescu 		      u32		cmd_flags,
59834ff6846SIoana Radulescu 		      u16		token,
59934ff6846SIoana Radulescu 		      const u8		mac_addr[6]);
60034ff6846SIoana Radulescu 
60134ff6846SIoana Radulescu int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
60234ff6846SIoana Radulescu 			 u32			cmd_flags,
60334ff6846SIoana Radulescu 			 u16			token,
60434ff6846SIoana Radulescu 			 const u8		mac_addr[6]);
60534ff6846SIoana Radulescu 
60634ff6846SIoana Radulescu int dpni_clear_mac_filters(struct fsl_mc_io	*mc_io,
60734ff6846SIoana Radulescu 			   u32			cmd_flags,
60834ff6846SIoana Radulescu 			   u16			token,
60934ff6846SIoana Radulescu 			   int			unicast,
61034ff6846SIoana Radulescu 			   int			multicast);
61134ff6846SIoana Radulescu 
61234ff6846SIoana Radulescu /**
61334ff6846SIoana Radulescu  * enum dpni_dist_mode - DPNI distribution mode
61434ff6846SIoana Radulescu  * @DPNI_DIST_MODE_NONE: No distribution
61534ff6846SIoana Radulescu  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
61634ff6846SIoana Radulescu  *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
61734ff6846SIoana Radulescu  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
61834ff6846SIoana Radulescu  *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
61934ff6846SIoana Radulescu  */
62034ff6846SIoana Radulescu enum dpni_dist_mode {
62134ff6846SIoana Radulescu 	DPNI_DIST_MODE_NONE = 0,
62234ff6846SIoana Radulescu 	DPNI_DIST_MODE_HASH = 1,
62334ff6846SIoana Radulescu 	DPNI_DIST_MODE_FS = 2
62434ff6846SIoana Radulescu };
62534ff6846SIoana Radulescu 
62634ff6846SIoana Radulescu /**
62734ff6846SIoana Radulescu  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
62834ff6846SIoana Radulescu  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
62934ff6846SIoana Radulescu  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
63034ff6846SIoana Radulescu  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
63134ff6846SIoana Radulescu  */
63234ff6846SIoana Radulescu enum dpni_fs_miss_action {
63334ff6846SIoana Radulescu 	DPNI_FS_MISS_DROP = 0,
63434ff6846SIoana Radulescu 	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
63534ff6846SIoana Radulescu 	DPNI_FS_MISS_HASH = 2
63634ff6846SIoana Radulescu };
63734ff6846SIoana Radulescu 
63834ff6846SIoana Radulescu /**
63934ff6846SIoana Radulescu  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
64034ff6846SIoana Radulescu  * @miss_action: Miss action selection
64134ff6846SIoana Radulescu  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
64234ff6846SIoana Radulescu  */
64334ff6846SIoana Radulescu struct dpni_fs_tbl_cfg {
64434ff6846SIoana Radulescu 	enum dpni_fs_miss_action	miss_action;
64534ff6846SIoana Radulescu 	u16				default_flow_id;
64634ff6846SIoana Radulescu };
64734ff6846SIoana Radulescu 
64834ff6846SIoana Radulescu int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
64934ff6846SIoana Radulescu 			 u8 *key_cfg_buf);
65034ff6846SIoana Radulescu 
65134ff6846SIoana Radulescu /**
65234ff6846SIoana Radulescu  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
65334ff6846SIoana Radulescu  * @dist_size: Set the distribution size;
65434ff6846SIoana Radulescu  *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
65534ff6846SIoana Radulescu  *	112,128,192,224,256,384,448,512,768,896,1024
65634ff6846SIoana Radulescu  * @dist_mode: Distribution mode
65734ff6846SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
65834ff6846SIoana Radulescu  *		the extractions to be used for the distribution key by calling
65934ff6846SIoana Radulescu  *		dpni_prepare_key_cfg() relevant only when
66034ff6846SIoana Radulescu  *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
66134ff6846SIoana Radulescu  * @fs_cfg: Flow Steering table configuration; only relevant if
66234ff6846SIoana Radulescu  *		'dist_mode = DPNI_DIST_MODE_FS'
66334ff6846SIoana Radulescu  */
66434ff6846SIoana Radulescu struct dpni_rx_tc_dist_cfg {
66534ff6846SIoana Radulescu 	u16			dist_size;
66634ff6846SIoana Radulescu 	enum dpni_dist_mode	dist_mode;
66734ff6846SIoana Radulescu 	u64			key_cfg_iova;
66834ff6846SIoana Radulescu 	struct dpni_fs_tbl_cfg	fs_cfg;
66934ff6846SIoana Radulescu };
67034ff6846SIoana Radulescu 
67134ff6846SIoana Radulescu int dpni_set_rx_tc_dist(struct fsl_mc_io			*mc_io,
67234ff6846SIoana Radulescu 			u32					cmd_flags,
67334ff6846SIoana Radulescu 			u16					token,
67434ff6846SIoana Radulescu 			u8					tc_id,
67534ff6846SIoana Radulescu 			const struct dpni_rx_tc_dist_cfg	*cfg);
67634ff6846SIoana Radulescu 
67734ff6846SIoana Radulescu /**
6784fe72de6SIoana Ciornei  * DPNI_FS_MISS_DROP - When used for fs_miss_flow_id in function
6794fe72de6SIoana Ciornei  * dpni_set_rx_dist, will signal to dpni to drop all unclassified frames
680df85aeb9SIoana Radulescu  */
681df85aeb9SIoana Radulescu #define DPNI_FS_MISS_DROP		((uint16_t)-1)
682df85aeb9SIoana Radulescu 
683df85aeb9SIoana Radulescu /**
684df85aeb9SIoana Radulescu  * struct dpni_rx_dist_cfg - Rx distribution configuration
685df85aeb9SIoana Radulescu  * @dist_size:	distribution size
686df85aeb9SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
687df85aeb9SIoana Radulescu  *		the extractions to be used for the distribution key by calling
688df85aeb9SIoana Radulescu  *		dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
689df85aeb9SIoana Radulescu  *		it can be '0'
690df85aeb9SIoana Radulescu  * @enable: enable/disable the distribution.
691df85aeb9SIoana Radulescu  * @tc: TC id for which distribution is set
692df85aeb9SIoana Radulescu  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
693df85aeb9SIoana Radulescu  *		hash is disabled it will be put into this queue id; use
694df85aeb9SIoana Radulescu  *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
695df85aeb9SIoana Radulescu  *		used only when flow steering distribution is enabled and hash
696df85aeb9SIoana Radulescu  *		distribution is disabled
697df85aeb9SIoana Radulescu  */
698df85aeb9SIoana Radulescu struct dpni_rx_dist_cfg {
699df85aeb9SIoana Radulescu 	u16 dist_size;
700df85aeb9SIoana Radulescu 	u64 key_cfg_iova;
701df85aeb9SIoana Radulescu 	u8 enable;
702df85aeb9SIoana Radulescu 	u8 tc;
703df85aeb9SIoana Radulescu 	u16 fs_miss_flow_id;
704df85aeb9SIoana Radulescu };
705df85aeb9SIoana Radulescu 
7064aaaf9b9SIoana Radulescu int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
7074aaaf9b9SIoana Radulescu 			u32 cmd_flags,
7084aaaf9b9SIoana Radulescu 			u16 token,
7094aaaf9b9SIoana Radulescu 			const struct dpni_rx_dist_cfg *cfg);
7104aaaf9b9SIoana Radulescu 
711df85aeb9SIoana Radulescu int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
712df85aeb9SIoana Radulescu 			  u32 cmd_flags,
713df85aeb9SIoana Radulescu 			  u16 token,
714df85aeb9SIoana Radulescu 			  const struct dpni_rx_dist_cfg *cfg);
715df85aeb9SIoana Radulescu 
716df85aeb9SIoana Radulescu /**
7176aa90fe2SIoana Radulescu  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
7186aa90fe2SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
7196aa90fe2SIoana Radulescu  *		key extractions to be used as the QoS criteria by calling
7206aa90fe2SIoana Radulescu  *		dpkg_prepare_key_cfg()
7216aa90fe2SIoana Radulescu  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
7226aa90fe2SIoana Radulescu  *		'0' to use the 'default_tc' in such cases
7236aa90fe2SIoana Radulescu  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
7246aa90fe2SIoana Radulescu  */
7256aa90fe2SIoana Radulescu struct dpni_qos_tbl_cfg {
7266aa90fe2SIoana Radulescu 	u64 key_cfg_iova;
7276aa90fe2SIoana Radulescu 	int discard_on_miss;
7286aa90fe2SIoana Radulescu 	u8 default_tc;
7296aa90fe2SIoana Radulescu };
7306aa90fe2SIoana Radulescu 
7316aa90fe2SIoana Radulescu int dpni_set_qos_table(struct fsl_mc_io *mc_io,
7326aa90fe2SIoana Radulescu 		       u32 cmd_flags,
7336aa90fe2SIoana Radulescu 		       u16 token,
7346aa90fe2SIoana Radulescu 		       const struct dpni_qos_tbl_cfg *cfg);
7356aa90fe2SIoana Radulescu 
7366aa90fe2SIoana Radulescu /**
73734ff6846SIoana Radulescu  * enum dpni_dest - DPNI destination types
73834ff6846SIoana Radulescu  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
73934ff6846SIoana Radulescu  *		does not generate FQDAN notifications; user is expected to
74034ff6846SIoana Radulescu  *		dequeue from the queue based on polling or other user-defined
74134ff6846SIoana Radulescu  *		method
74234ff6846SIoana Radulescu  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
74334ff6846SIoana Radulescu  *		notifications to the specified DPIO; user is expected to dequeue
74434ff6846SIoana Radulescu  *		from the queue only after notification is received
74534ff6846SIoana Radulescu  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
74634ff6846SIoana Radulescu  *		FQDAN notifications, but is connected to the specified DPCON
74734ff6846SIoana Radulescu  *		object; user is expected to dequeue from the DPCON channel
74834ff6846SIoana Radulescu  */
74934ff6846SIoana Radulescu enum dpni_dest {
75034ff6846SIoana Radulescu 	DPNI_DEST_NONE = 0,
75134ff6846SIoana Radulescu 	DPNI_DEST_DPIO = 1,
75234ff6846SIoana Radulescu 	DPNI_DEST_DPCON = 2
75334ff6846SIoana Radulescu };
75434ff6846SIoana Radulescu 
75534ff6846SIoana Radulescu /**
75634ff6846SIoana Radulescu  * struct dpni_queue - Queue structure
7574fe72de6SIoana Ciornei  * @destination: - Destination structure
75834ff6846SIoana Radulescu  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
75934ff6846SIoana Radulescu  *	Identifies either a DPIO or a DPCON object.
76034ff6846SIoana Radulescu  *	Not relevant for Tx queues.
76134ff6846SIoana Radulescu  * @destination.type:	May be one of the following:
76234ff6846SIoana Radulescu  *	0 - No destination, queue can be manually
76334ff6846SIoana Radulescu  *		queried, but will not push traffic or
76434ff6846SIoana Radulescu  *		notifications to a DPIO;
76534ff6846SIoana Radulescu  *	1 - The destination is a DPIO. When traffic
76634ff6846SIoana Radulescu  *		becomes available in the queue a FQDAN
76734ff6846SIoana Radulescu  *		(FQ data available notification) will be
76834ff6846SIoana Radulescu  *		generated to selected DPIO;
76934ff6846SIoana Radulescu  *	2 - The destination is a DPCON. The queue is
77034ff6846SIoana Radulescu  *		associated with a DPCON object for the
77134ff6846SIoana Radulescu  *		purpose of scheduling between multiple
77234ff6846SIoana Radulescu  *		queues. The DPCON may be independently
77334ff6846SIoana Radulescu  *		configured to generate notifications.
77434ff6846SIoana Radulescu  *		Not relevant for Tx queues.
77534ff6846SIoana Radulescu  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
77634ff6846SIoana Radulescu  *	in a DPIO during dequeue to reduce spread of traffic.
77734ff6846SIoana Radulescu  *	Only relevant if queues are
77834ff6846SIoana Radulescu  *	not affined to a single DPIO.
77934ff6846SIoana Radulescu  * @user_context: User data, presented to the user along with any frames
78034ff6846SIoana Radulescu  *	from this queue. Not relevant for Tx queues.
78134ff6846SIoana Radulescu  * @flc: FD FLow Context structure
78234ff6846SIoana Radulescu  * @flc.value: Default FLC value for traffic dequeued from
78334ff6846SIoana Radulescu  *      this queue.  Please check description of FD
78434ff6846SIoana Radulescu  *      structure for more information.
78534ff6846SIoana Radulescu  *      Note that FLC values set using dpni_add_fs_entry,
78634ff6846SIoana Radulescu  *      if any, take precedence over values per queue.
78734ff6846SIoana Radulescu  * @flc.stash_control: Boolean, indicates whether the 6 lowest
78834ff6846SIoana Radulescu  *      - significant bits are used for stash control.
78934ff6846SIoana Radulescu  *      significant bits are used for stash control.  If set, the 6
79034ff6846SIoana Radulescu  *      least significant bits in value are interpreted as follows:
79134ff6846SIoana Radulescu  *      - bits 0-1: indicates the number of 64 byte units of context
79234ff6846SIoana Radulescu  *      that are stashed.  FLC value is interpreted as a memory address
79334ff6846SIoana Radulescu  *      in this case, excluding the 6 LS bits.
79434ff6846SIoana Radulescu  *      - bits 2-3: indicates the number of 64 byte units of frame
79534ff6846SIoana Radulescu  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
79634ff6846SIoana Radulescu  *      - bits 4-5: indicates the number of 64 byte units of frame
79734ff6846SIoana Radulescu  *      data to be stashed.  Frame data is placed at FD[ADDR] +
79834ff6846SIoana Radulescu  *      FD[OFFSET].
79934ff6846SIoana Radulescu  *      For more details check the Frame Descriptor section in the
80034ff6846SIoana Radulescu  *      hardware documentation.
80134ff6846SIoana Radulescu  */
80234ff6846SIoana Radulescu struct dpni_queue {
80334ff6846SIoana Radulescu 	struct {
80434ff6846SIoana Radulescu 		u16 id;
80534ff6846SIoana Radulescu 		enum dpni_dest type;
80634ff6846SIoana Radulescu 		char hold_active;
80734ff6846SIoana Radulescu 		u8 priority;
80834ff6846SIoana Radulescu 	} destination;
80934ff6846SIoana Radulescu 	u64 user_context;
81034ff6846SIoana Radulescu 	struct {
81134ff6846SIoana Radulescu 		u64 value;
81234ff6846SIoana Radulescu 		char stash_control;
81334ff6846SIoana Radulescu 	} flc;
81434ff6846SIoana Radulescu };
81534ff6846SIoana Radulescu 
81634ff6846SIoana Radulescu /**
81734ff6846SIoana Radulescu  * struct dpni_queue_id - Queue identification, used for enqueue commands
81834ff6846SIoana Radulescu  *			or queue control
81934ff6846SIoana Radulescu  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
82034ff6846SIoana Radulescu  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
82134ff6846SIoana Radulescu  *		for Tx queues.
82234ff6846SIoana Radulescu  */
82334ff6846SIoana Radulescu struct dpni_queue_id {
82434ff6846SIoana Radulescu 	u32 fqid;
82534ff6846SIoana Radulescu 	u16 qdbin;
82634ff6846SIoana Radulescu };
82734ff6846SIoana Radulescu 
8284fe72de6SIoana Ciornei /* Set User Context */
82934ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
83034ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_DEST		0x00000002
83134ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_FLC		0x00000004
83234ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
83334ff6846SIoana Radulescu 
83434ff6846SIoana Radulescu int dpni_set_queue(struct fsl_mc_io	*mc_io,
83534ff6846SIoana Radulescu 		   u32			cmd_flags,
83634ff6846SIoana Radulescu 		   u16			token,
83734ff6846SIoana Radulescu 		   enum dpni_queue_type	qtype,
83834ff6846SIoana Radulescu 		   u8			tc,
83934ff6846SIoana Radulescu 		   u8			index,
84034ff6846SIoana Radulescu 		   u8			options,
84134ff6846SIoana Radulescu 		   const struct dpni_queue *queue);
84234ff6846SIoana Radulescu 
84334ff6846SIoana Radulescu int dpni_get_queue(struct fsl_mc_io	*mc_io,
84434ff6846SIoana Radulescu 		   u32			cmd_flags,
84534ff6846SIoana Radulescu 		   u16			token,
84634ff6846SIoana Radulescu 		   enum dpni_queue_type	qtype,
84734ff6846SIoana Radulescu 		   u8			tc,
84834ff6846SIoana Radulescu 		   u8			index,
84934ff6846SIoana Radulescu 		   struct dpni_queue	*queue,
85034ff6846SIoana Radulescu 		   struct dpni_queue_id	*qid);
85134ff6846SIoana Radulescu 
85234ff6846SIoana Radulescu /**
85334ff6846SIoana Radulescu  * enum dpni_congestion_unit - DPNI congestion units
85434ff6846SIoana Radulescu  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
85534ff6846SIoana Radulescu  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
85634ff6846SIoana Radulescu  */
85734ff6846SIoana Radulescu enum dpni_congestion_unit {
85834ff6846SIoana Radulescu 	DPNI_CONGESTION_UNIT_BYTES = 0,
85934ff6846SIoana Radulescu 	DPNI_CONGESTION_UNIT_FRAMES
86034ff6846SIoana Radulescu };
86134ff6846SIoana Radulescu 
86234ff6846SIoana Radulescu /**
86334ff6846SIoana Radulescu  * enum dpni_congestion_point - Structure representing congestion point
86434ff6846SIoana Radulescu  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
86534ff6846SIoana Radulescu  *		QUEUE_INDEX
86634ff6846SIoana Radulescu  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
86734ff6846SIoana Radulescu  *		define the DPNI this can be either per TC (default) or per
86834ff6846SIoana Radulescu  *		interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
86934ff6846SIoana Radulescu  *		QUEUE_INDEX is ignored if this type is used.
87034ff6846SIoana Radulescu  */
87134ff6846SIoana Radulescu enum dpni_congestion_point {
87234ff6846SIoana Radulescu 	DPNI_CP_QUEUE,
87334ff6846SIoana Radulescu 	DPNI_CP_GROUP,
87434ff6846SIoana Radulescu };
87534ff6846SIoana Radulescu 
87634ff6846SIoana Radulescu /**
877f395b69fSIoana Ciornei  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
878f395b69fSIoana Ciornei  * @dest_type:	Destination type
879f395b69fSIoana Ciornei  * @dest_id:	Either DPIO ID or DPCON ID, depending on the destination type
880f395b69fSIoana Ciornei  * @priority:	Priority selection within the DPIO or DPCON channel; valid
881f395b69fSIoana Ciornei  *		values are 0-1 or 0-7, depending on the number of priorities
882f395b69fSIoana Ciornei  *		in that channel; not relevant for 'DPNI_DEST_NONE' option
883f395b69fSIoana Ciornei  */
884f395b69fSIoana Ciornei struct dpni_dest_cfg {
885f395b69fSIoana Ciornei 	enum dpni_dest dest_type;
886f395b69fSIoana Ciornei 	int dest_id;
887f395b69fSIoana Ciornei 	u8 priority;
888f395b69fSIoana Ciornei };
889f395b69fSIoana Ciornei 
890f395b69fSIoana Ciornei /* DPNI congestion options */
891f395b69fSIoana Ciornei 
892f395b69fSIoana Ciornei /**
8934fe72de6SIoana Ciornei  * DPNI_CONG_OPT_FLOW_CONTROL - This congestion will trigger flow control or
8944fe72de6SIoana Ciornei  * priority flow control.  This will have effect only if flow control is
8954fe72de6SIoana Ciornei  * enabled with dpni_set_link_cfg().
896f395b69fSIoana Ciornei  */
897f395b69fSIoana Ciornei #define DPNI_CONG_OPT_FLOW_CONTROL		0x00000040
898f395b69fSIoana Ciornei 
899f395b69fSIoana Ciornei /**
900f395b69fSIoana Ciornei  * struct dpni_congestion_notification_cfg - congestion notification
901f395b69fSIoana Ciornei  *					configuration
902f395b69fSIoana Ciornei  * @units: Units type
903f395b69fSIoana Ciornei  * @threshold_entry: Above this threshold we enter a congestion state.
904f395b69fSIoana Ciornei  *		set it to '0' to disable it
905f395b69fSIoana Ciornei  * @threshold_exit: Below this threshold we exit the congestion state.
906f395b69fSIoana Ciornei  * @message_ctx: The context that will be part of the CSCN message
907f395b69fSIoana Ciornei  * @message_iova: I/O virtual address (must be in DMA-able memory),
908f395b69fSIoana Ciornei  *		must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
909f395b69fSIoana Ciornei  *		is contained in 'options'
910f395b69fSIoana Ciornei  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
911f395b69fSIoana Ciornei  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
912f395b69fSIoana Ciornei  */
913f395b69fSIoana Ciornei 
914f395b69fSIoana Ciornei struct dpni_congestion_notification_cfg {
915f395b69fSIoana Ciornei 	enum dpni_congestion_unit units;
916f395b69fSIoana Ciornei 	u32 threshold_entry;
917f395b69fSIoana Ciornei 	u32 threshold_exit;
918f395b69fSIoana Ciornei 	u64 message_ctx;
919f395b69fSIoana Ciornei 	u64 message_iova;
920f395b69fSIoana Ciornei 	struct dpni_dest_cfg dest_cfg;
921f395b69fSIoana Ciornei 	u16 notification_mode;
922f395b69fSIoana Ciornei };
923f395b69fSIoana Ciornei 
924f395b69fSIoana Ciornei int dpni_set_congestion_notification(
925f395b69fSIoana Ciornei 			struct fsl_mc_io *mc_io,
926f395b69fSIoana Ciornei 			u32 cmd_flags,
927f395b69fSIoana Ciornei 			u16 token,
928f395b69fSIoana Ciornei 			enum dpni_queue_type qtype,
929f395b69fSIoana Ciornei 			u8 tc_id,
930f395b69fSIoana Ciornei 			const struct dpni_congestion_notification_cfg *cfg);
931f395b69fSIoana Ciornei 
932f395b69fSIoana Ciornei /**
93334ff6846SIoana Radulescu  * struct dpni_taildrop - Structure representing the taildrop
93434ff6846SIoana Radulescu  * @enable:	Indicates whether the taildrop is active or not.
93534ff6846SIoana Radulescu  * @units:	Indicates the unit of THRESHOLD. Queue taildrop only supports
93634ff6846SIoana Radulescu  *		byte units, this field is ignored and assumed = 0 if
93734ff6846SIoana Radulescu  *		CONGESTION_POINT is 0.
93834ff6846SIoana Radulescu  * @threshold:	Threshold value, in units identified by UNITS field. Value 0
93934ff6846SIoana Radulescu  *		cannot be used as a valid taildrop threshold, THRESHOLD must
94034ff6846SIoana Radulescu  *		be > 0 if the taildrop is enabled.
94134ff6846SIoana Radulescu  */
94234ff6846SIoana Radulescu struct dpni_taildrop {
94334ff6846SIoana Radulescu 	char enable;
94434ff6846SIoana Radulescu 	enum dpni_congestion_unit units;
94534ff6846SIoana Radulescu 	u32 threshold;
94634ff6846SIoana Radulescu };
94734ff6846SIoana Radulescu 
94834ff6846SIoana Radulescu int dpni_set_taildrop(struct fsl_mc_io *mc_io,
94934ff6846SIoana Radulescu 		      u32 cmd_flags,
95034ff6846SIoana Radulescu 		      u16 token,
95134ff6846SIoana Radulescu 		      enum dpni_congestion_point cg_point,
95234ff6846SIoana Radulescu 		      enum dpni_queue_type q_type,
95334ff6846SIoana Radulescu 		      u8 tc,
95434ff6846SIoana Radulescu 		      u8 q_index,
95534ff6846SIoana Radulescu 		      struct dpni_taildrop *taildrop);
95634ff6846SIoana Radulescu 
95734ff6846SIoana Radulescu int dpni_get_taildrop(struct fsl_mc_io *mc_io,
95834ff6846SIoana Radulescu 		      u32 cmd_flags,
95934ff6846SIoana Radulescu 		      u16 token,
96034ff6846SIoana Radulescu 		      enum dpni_congestion_point cg_point,
96134ff6846SIoana Radulescu 		      enum dpni_queue_type q_type,
96234ff6846SIoana Radulescu 		      u8 tc,
96334ff6846SIoana Radulescu 		      u8 q_index,
96434ff6846SIoana Radulescu 		      struct dpni_taildrop *taildrop);
96534ff6846SIoana Radulescu 
96634ff6846SIoana Radulescu /**
96734ff6846SIoana Radulescu  * struct dpni_rule_cfg - Rule configuration for table lookup
96834ff6846SIoana Radulescu  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
96934ff6846SIoana Radulescu  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
97034ff6846SIoana Radulescu  * @key_size: key and mask size (in bytes)
97134ff6846SIoana Radulescu  */
97234ff6846SIoana Radulescu struct dpni_rule_cfg {
97334ff6846SIoana Radulescu 	u64	key_iova;
97434ff6846SIoana Radulescu 	u64	mask_iova;
97534ff6846SIoana Radulescu 	u8	key_size;
97634ff6846SIoana Radulescu };
97734ff6846SIoana Radulescu 
978afb90dbbSIoana Radulescu /**
9794fe72de6SIoana Ciornei  * DPNI_FS_OPT_DISCARD - Discard matching traffic. If set, this takes
9804fe72de6SIoana Ciornei  * precedence over any other configuration and matching traffic is always
9814fe72de6SIoana Ciornei  * discarded.
982afb90dbbSIoana Radulescu  */
983afb90dbbSIoana Radulescu  #define DPNI_FS_OPT_DISCARD            0x1
984afb90dbbSIoana Radulescu 
985afb90dbbSIoana Radulescu /**
9864fe72de6SIoana Ciornei  * DPNI_FS_OPT_SET_FLC - Set FLC value. If set, flc member of struct
9874fe72de6SIoana Ciornei  * dpni_fs_action_cfg is used to override the FLC value set per queue.
988afb90dbbSIoana Radulescu  * For more details check the Frame Descriptor section in the hardware
989afb90dbbSIoana Radulescu  * documentation.
990afb90dbbSIoana Radulescu  */
991afb90dbbSIoana Radulescu #define DPNI_FS_OPT_SET_FLC            0x2
992afb90dbbSIoana Radulescu 
993afb90dbbSIoana Radulescu /**
9944fe72de6SIoana Ciornei  * DPNI_FS_OPT_SET_STASH_CONTROL - Indicates whether the 6 lowest significant
9954fe72de6SIoana Ciornei  * bits of FLC are used for stash control. If set, the 6 least significant bits
9964fe72de6SIoana Ciornei  * in value are interpreted as follows:
997afb90dbbSIoana Radulescu  *     - bits 0-1: indicates the number of 64 byte units of context that are
998afb90dbbSIoana Radulescu  *     stashed. FLC value is interpreted as a memory address in this case,
999afb90dbbSIoana Radulescu  *     excluding the 6 LS bits.
1000afb90dbbSIoana Radulescu  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1001afb90dbbSIoana Radulescu  *     to be stashed. Annotation is placed at FD[ADDR].
1002afb90dbbSIoana Radulescu  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1003afb90dbbSIoana Radulescu  *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1004afb90dbbSIoana Radulescu  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1005afb90dbbSIoana Radulescu  */
1006afb90dbbSIoana Radulescu #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1007afb90dbbSIoana Radulescu 
1008afb90dbbSIoana Radulescu /**
1009afb90dbbSIoana Radulescu  * struct dpni_fs_action_cfg - Action configuration for table look-up
1010afb90dbbSIoana Radulescu  * @flc:	FLC value for traffic matching this rule. Please check the
1011afb90dbbSIoana Radulescu  *		Frame Descriptor section in the hardware documentation for
1012afb90dbbSIoana Radulescu  *		more information.
1013afb90dbbSIoana Radulescu  * @flow_id:	Identifies the Rx queue used for matching traffic. Supported
1014afb90dbbSIoana Radulescu  *		values are in range 0 to num_queue-1.
1015afb90dbbSIoana Radulescu  * @options:	Any combination of DPNI_FS_OPT_ values.
1016afb90dbbSIoana Radulescu  */
1017afb90dbbSIoana Radulescu struct dpni_fs_action_cfg {
1018afb90dbbSIoana Radulescu 	u64 flc;
1019afb90dbbSIoana Radulescu 	u16 flow_id;
1020afb90dbbSIoana Radulescu 	u16 options;
1021afb90dbbSIoana Radulescu };
1022afb90dbbSIoana Radulescu 
1023afb90dbbSIoana Radulescu int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1024afb90dbbSIoana Radulescu 		      u32 cmd_flags,
1025afb90dbbSIoana Radulescu 		      u16 token,
1026afb90dbbSIoana Radulescu 		      u8 tc_id,
1027afb90dbbSIoana Radulescu 		      u16 index,
1028afb90dbbSIoana Radulescu 		      const struct dpni_rule_cfg *cfg,
1029afb90dbbSIoana Radulescu 		      const struct dpni_fs_action_cfg *action);
1030afb90dbbSIoana Radulescu 
1031afb90dbbSIoana Radulescu int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1032afb90dbbSIoana Radulescu 			 u32 cmd_flags,
1033afb90dbbSIoana Radulescu 			 u16 token,
1034afb90dbbSIoana Radulescu 			 u8 tc_id,
1035afb90dbbSIoana Radulescu 			 const struct dpni_rule_cfg *cfg);
1036afb90dbbSIoana Radulescu 
10376aa90fe2SIoana Radulescu int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
10386aa90fe2SIoana Radulescu 		       u32 cmd_flags,
10396aa90fe2SIoana Radulescu 		       u16 token,
10406aa90fe2SIoana Radulescu 		       const struct dpni_rule_cfg *cfg,
10416aa90fe2SIoana Radulescu 		       u8 tc_id,
10426aa90fe2SIoana Radulescu 		       u16 index);
10436aa90fe2SIoana Radulescu 
10446aa90fe2SIoana Radulescu int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
10456aa90fe2SIoana Radulescu 			  u32 cmd_flags,
10466aa90fe2SIoana Radulescu 			  u16 token,
10476aa90fe2SIoana Radulescu 			  const struct dpni_rule_cfg *cfg);
10486aa90fe2SIoana Radulescu 
10496aa90fe2SIoana Radulescu int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
10506aa90fe2SIoana Radulescu 			 u32 cmd_flags,
10516aa90fe2SIoana Radulescu 			 u16 token);
10526aa90fe2SIoana Radulescu 
105334ff6846SIoana Radulescu int dpni_get_api_version(struct fsl_mc_io *mc_io,
105434ff6846SIoana Radulescu 			 u32 cmd_flags,
105534ff6846SIoana Radulescu 			 u16 *major_ver,
105634ff6846SIoana Radulescu 			 u16 *minor_ver);
105739344a89SIoana Ciornei /**
10584fe72de6SIoana Ciornei  * struct dpni_tx_shaping_cfg - Structure representing DPNI tx shaping configuration
105939344a89SIoana Ciornei  * @rate_limit:		Rate in Mbps
106039344a89SIoana Ciornei  * @max_burst_size:	Burst size in bytes (up to 64KB)
106139344a89SIoana Ciornei  */
106239344a89SIoana Ciornei struct dpni_tx_shaping_cfg {
106339344a89SIoana Ciornei 	u32 rate_limit;
106439344a89SIoana Ciornei 	u16 max_burst_size;
106539344a89SIoana Ciornei };
106639344a89SIoana Ciornei 
106739344a89SIoana Ciornei int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
106839344a89SIoana Ciornei 			u32 cmd_flags,
106939344a89SIoana Ciornei 			u16 token,
107039344a89SIoana Ciornei 			const struct dpni_tx_shaping_cfg *tx_cr_shaper,
107139344a89SIoana Ciornei 			const struct dpni_tx_shaping_cfg *tx_er_shaper,
107239344a89SIoana Ciornei 			int coupled);
107334ff6846SIoana Radulescu 
107423cd4f27SYangbo Lu /**
107523cd4f27SYangbo Lu  * struct dpni_single_step_cfg - configure single step PTP (IEEE 1588)
107623cd4f27SYangbo Lu  * @en:		enable single step PTP. When enabled the PTPv1 functionality
107723cd4f27SYangbo Lu  *		will not work. If the field is zero, offset and ch_update
107823cd4f27SYangbo Lu  *		parameters will be ignored
107923cd4f27SYangbo Lu  * @offset:	start offset from the beginning of the frame where
108023cd4f27SYangbo Lu  *		timestamp field is found. The offset must respect all MAC
108123cd4f27SYangbo Lu  *		headers, VLAN tags and other protocol headers
108223cd4f27SYangbo Lu  * @ch_update:	when set UDP checksum will be updated inside packet
108323cd4f27SYangbo Lu  * @peer_delay:	For peer-to-peer transparent clocks add this value to the
108423cd4f27SYangbo Lu  *		correction field in addition to the transient time update.
108523cd4f27SYangbo Lu  *		The value expresses nanoseconds.
10869572594eSRadu Bulie  * @ptp_onestep_reg_base: 1588 SINGLE_STEP register base address. This address
10879572594eSRadu Bulie  *			  is used to update directly the register contents.
10889572594eSRadu Bulie  *			  User has to create an address mapping for it.
10899572594eSRadu Bulie  *
10909572594eSRadu Bulie  *
109123cd4f27SYangbo Lu  */
109223cd4f27SYangbo Lu struct dpni_single_step_cfg {
109323cd4f27SYangbo Lu 	u8	en;
109423cd4f27SYangbo Lu 	u8	ch_update;
109523cd4f27SYangbo Lu 	u16	offset;
109623cd4f27SYangbo Lu 	u32	peer_delay;
10979572594eSRadu Bulie 	u32	ptp_onestep_reg_base;
109823cd4f27SYangbo Lu };
109923cd4f27SYangbo Lu 
110023cd4f27SYangbo Lu int dpni_set_single_step_cfg(struct fsl_mc_io *mc_io,
110123cd4f27SYangbo Lu 			     u32 cmd_flags,
110223cd4f27SYangbo Lu 			     u16 token,
110323cd4f27SYangbo Lu 			     struct dpni_single_step_cfg *ptp_cfg);
110423cd4f27SYangbo Lu 
110523cd4f27SYangbo Lu int dpni_get_single_step_cfg(struct fsl_mc_io *mc_io,
110623cd4f27SYangbo Lu 			     u32 cmd_flags,
110723cd4f27SYangbo Lu 			     u16 token,
110823cd4f27SYangbo Lu 			     struct dpni_single_step_cfg *ptp_cfg);
110923cd4f27SYangbo Lu 
111070b32d82SIonut-robert Aron int dpni_enable_vlan_filter(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
111170b32d82SIonut-robert Aron 			    u32 en);
111270b32d82SIonut-robert Aron 
111370b32d82SIonut-robert Aron int dpni_add_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
111470b32d82SIonut-robert Aron 		     u16 vlan_id, u8 flags, u8 tc_id, u8 flow_id);
111570b32d82SIonut-robert Aron 
111670b32d82SIonut-robert Aron int dpni_remove_vlan_id(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
111770b32d82SIonut-robert Aron 			u16 vlan_id);
111870b32d82SIonut-robert Aron 
111934ff6846SIoana Radulescu #endif /* __FSL_DPNI_H */
1120