xref: /openbmc/linux/drivers/net/ethernet/freescale/dpaa2/dpni.h (revision f395b69f40f580491ef56f2395a98e3189baa53c)
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
434ff6846SIoana Radulescu  */
534ff6846SIoana Radulescu #ifndef __FSL_DPNI_H
634ff6846SIoana Radulescu #define __FSL_DPNI_H
734ff6846SIoana Radulescu 
834ff6846SIoana Radulescu #include "dpkg.h"
934ff6846SIoana Radulescu 
1034ff6846SIoana Radulescu struct fsl_mc_io;
1134ff6846SIoana Radulescu 
1234ff6846SIoana Radulescu /**
1334ff6846SIoana Radulescu  * 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 /**
2034ff6846SIoana Radulescu  * Maximum number of traffic classes
2134ff6846SIoana Radulescu  */
2234ff6846SIoana Radulescu #define DPNI_MAX_TC				8
2334ff6846SIoana Radulescu /**
2434ff6846SIoana Radulescu  * Maximum number of buffer pools per DPNI
2534ff6846SIoana Radulescu  */
2634ff6846SIoana Radulescu #define DPNI_MAX_DPBP				8
2734ff6846SIoana Radulescu 
2834ff6846SIoana Radulescu /**
2934ff6846SIoana Radulescu  * All traffic classes considered; see dpni_set_queue()
3034ff6846SIoana Radulescu  */
3134ff6846SIoana Radulescu #define DPNI_ALL_TCS				(u8)(-1)
3234ff6846SIoana Radulescu /**
3334ff6846SIoana Radulescu  * All flows within traffic class considered; see dpni_set_queue()
3434ff6846SIoana Radulescu  */
3534ff6846SIoana Radulescu #define DPNI_ALL_TC_FLOWS			(u16)(-1)
3634ff6846SIoana Radulescu /**
3734ff6846SIoana Radulescu  * Generate new flow ID; see dpni_set_queue()
3834ff6846SIoana Radulescu  */
3934ff6846SIoana Radulescu #define DPNI_NEW_FLOW_ID			(u16)(-1)
4034ff6846SIoana Radulescu 
4134ff6846SIoana Radulescu /**
4234ff6846SIoana Radulescu  * Tx traffic is always released to a buffer pool on transmit, there are no
4334ff6846SIoana Radulescu  * resources allocated to have the frames confirmed back to the source after
4434ff6846SIoana Radulescu  * transmission.
4534ff6846SIoana Radulescu  */
4634ff6846SIoana Radulescu #define DPNI_OPT_TX_FRM_RELEASE			0x000001
4734ff6846SIoana Radulescu /**
4834ff6846SIoana Radulescu  * Disables support for MAC address filtering for addresses other than primary
4934ff6846SIoana Radulescu  * MAC address. This affects both unicast and multicast. Promiscuous mode can
5034ff6846SIoana Radulescu  * still be enabled/disabled for both unicast and multicast. If promiscuous mode
5134ff6846SIoana Radulescu  * is disabled, only traffic matching the primary MAC address will be accepted.
5234ff6846SIoana Radulescu  */
5334ff6846SIoana Radulescu #define DPNI_OPT_NO_MAC_FILTER			0x000002
5434ff6846SIoana Radulescu /**
5534ff6846SIoana Radulescu  * Allocate policers for this DPNI. They can be used to rate-limit traffic per
5634ff6846SIoana Radulescu  * traffic class (TC) basis.
5734ff6846SIoana Radulescu  */
5834ff6846SIoana Radulescu #define DPNI_OPT_HAS_POLICING			0x000004
5934ff6846SIoana Radulescu /**
6034ff6846SIoana Radulescu  * Congestion can be managed in several ways, allowing the buffer pool to
6134ff6846SIoana Radulescu  * deplete on ingress, taildrop on each queue or use congestion groups for sets
6234ff6846SIoana Radulescu  * of queues. If set, it configures a single congestion groups across all TCs.
6334ff6846SIoana Radulescu  * If reset, a congestion group is allocated for each TC. Only relevant if the
6434ff6846SIoana Radulescu  * DPNI has multiple traffic classes.
6534ff6846SIoana Radulescu  */
6634ff6846SIoana Radulescu #define DPNI_OPT_SHARED_CONGESTION		0x000008
6734ff6846SIoana Radulescu /**
6834ff6846SIoana Radulescu  * Enables TCAM for Flow Steering and QoS look-ups. If not specified, all
6934ff6846SIoana Radulescu  * look-ups are exact match. Note that TCAM is not available on LS1088 and its
7034ff6846SIoana Radulescu  * variants. Setting this bit on these SoCs will trigger an error.
7134ff6846SIoana Radulescu  */
7234ff6846SIoana Radulescu #define DPNI_OPT_HAS_KEY_MASKING		0x000010
7334ff6846SIoana Radulescu /**
7434ff6846SIoana Radulescu  * Disables the flow steering table.
7534ff6846SIoana Radulescu  */
7634ff6846SIoana Radulescu #define DPNI_OPT_NO_FS				0x000020
7734ff6846SIoana Radulescu 
7834ff6846SIoana Radulescu int dpni_open(struct fsl_mc_io	*mc_io,
7934ff6846SIoana Radulescu 	      u32		cmd_flags,
8034ff6846SIoana Radulescu 	      int		dpni_id,
8134ff6846SIoana Radulescu 	      u16		*token);
8234ff6846SIoana Radulescu 
8334ff6846SIoana Radulescu int dpni_close(struct fsl_mc_io	*mc_io,
8434ff6846SIoana Radulescu 	       u32		cmd_flags,
8534ff6846SIoana Radulescu 	       u16		token);
8634ff6846SIoana Radulescu 
8734ff6846SIoana Radulescu /**
8834ff6846SIoana Radulescu  * struct dpni_pools_cfg - Structure representing buffer pools configuration
8934ff6846SIoana Radulescu  * @num_dpbp: Number of DPBPs
9034ff6846SIoana Radulescu  * @pools: Array of buffer pools parameters; The number of valid entries
9134ff6846SIoana Radulescu  *	must match 'num_dpbp' value
9234ff6846SIoana Radulescu  * @pools.dpbp_id: DPBP object ID
9334ff6846SIoana Radulescu  * @pools.buffer_size: Buffer size
9434ff6846SIoana Radulescu  * @pools.backup_pool: Backup pool
9534ff6846SIoana Radulescu  */
9634ff6846SIoana Radulescu struct dpni_pools_cfg {
9734ff6846SIoana Radulescu 	u8		num_dpbp;
9834ff6846SIoana Radulescu 	struct {
9934ff6846SIoana Radulescu 		int	dpbp_id;
10034ff6846SIoana Radulescu 		u16	buffer_size;
10134ff6846SIoana Radulescu 		int	backup_pool;
10234ff6846SIoana Radulescu 	} pools[DPNI_MAX_DPBP];
10334ff6846SIoana Radulescu };
10434ff6846SIoana Radulescu 
10534ff6846SIoana Radulescu int dpni_set_pools(struct fsl_mc_io		*mc_io,
10634ff6846SIoana Radulescu 		   u32				cmd_flags,
10734ff6846SIoana Radulescu 		   u16				token,
10834ff6846SIoana Radulescu 		   const struct dpni_pools_cfg	*cfg);
10934ff6846SIoana Radulescu 
11034ff6846SIoana Radulescu int dpni_enable(struct fsl_mc_io	*mc_io,
11134ff6846SIoana Radulescu 		u32			cmd_flags,
11234ff6846SIoana Radulescu 		u16			token);
11334ff6846SIoana Radulescu 
11434ff6846SIoana Radulescu int dpni_disable(struct fsl_mc_io	*mc_io,
11534ff6846SIoana Radulescu 		 u32			cmd_flags,
11634ff6846SIoana Radulescu 		 u16			token);
11734ff6846SIoana Radulescu 
11834ff6846SIoana Radulescu int dpni_is_enabled(struct fsl_mc_io	*mc_io,
11934ff6846SIoana Radulescu 		    u32			cmd_flags,
12034ff6846SIoana Radulescu 		    u16			token,
12134ff6846SIoana Radulescu 		    int			*en);
12234ff6846SIoana Radulescu 
12334ff6846SIoana Radulescu int dpni_reset(struct fsl_mc_io	*mc_io,
12434ff6846SIoana Radulescu 	       u32		cmd_flags,
12534ff6846SIoana Radulescu 	       u16		token);
12634ff6846SIoana Radulescu 
12734ff6846SIoana Radulescu /**
12834ff6846SIoana Radulescu  * DPNI IRQ Index and Events
12934ff6846SIoana Radulescu  */
13034ff6846SIoana Radulescu 
13134ff6846SIoana Radulescu /**
13234ff6846SIoana Radulescu  * IRQ index
13334ff6846SIoana Radulescu  */
13434ff6846SIoana Radulescu #define DPNI_IRQ_INDEX				0
13534ff6846SIoana Radulescu /**
1368398b375SFlorin Chiculita  * IRQ events:
1378398b375SFlorin Chiculita  *       indicates a change in link state
1388398b375SFlorin Chiculita  *       indicates a change in endpoint
13934ff6846SIoana Radulescu  */
14034ff6846SIoana Radulescu #define DPNI_IRQ_EVENT_LINK_CHANGED		0x00000001
1418398b375SFlorin Chiculita #define DPNI_IRQ_EVENT_ENDPOINT_CHANGED		0x00000002
14234ff6846SIoana Radulescu 
14334ff6846SIoana Radulescu int dpni_set_irq_enable(struct fsl_mc_io	*mc_io,
14434ff6846SIoana Radulescu 			u32			cmd_flags,
14534ff6846SIoana Radulescu 			u16			token,
14634ff6846SIoana Radulescu 			u8			irq_index,
14734ff6846SIoana Radulescu 			u8			en);
14834ff6846SIoana Radulescu 
14934ff6846SIoana Radulescu int dpni_get_irq_enable(struct fsl_mc_io	*mc_io,
15034ff6846SIoana Radulescu 			u32			cmd_flags,
15134ff6846SIoana Radulescu 			u16			token,
15234ff6846SIoana Radulescu 			u8			irq_index,
15334ff6846SIoana Radulescu 			u8			*en);
15434ff6846SIoana Radulescu 
15534ff6846SIoana Radulescu int dpni_set_irq_mask(struct fsl_mc_io	*mc_io,
15634ff6846SIoana Radulescu 		      u32		cmd_flags,
15734ff6846SIoana Radulescu 		      u16		token,
15834ff6846SIoana Radulescu 		      u8		irq_index,
15934ff6846SIoana Radulescu 		      u32		mask);
16034ff6846SIoana Radulescu 
16134ff6846SIoana Radulescu int dpni_get_irq_mask(struct fsl_mc_io	*mc_io,
16234ff6846SIoana Radulescu 		      u32		cmd_flags,
16334ff6846SIoana Radulescu 		      u16		token,
16434ff6846SIoana Radulescu 		      u8		irq_index,
16534ff6846SIoana Radulescu 		      u32		*mask);
16634ff6846SIoana Radulescu 
16734ff6846SIoana Radulescu int dpni_get_irq_status(struct fsl_mc_io	*mc_io,
16834ff6846SIoana Radulescu 			u32			cmd_flags,
16934ff6846SIoana Radulescu 			u16			token,
17034ff6846SIoana Radulescu 			u8			irq_index,
17134ff6846SIoana Radulescu 			u32			*status);
17234ff6846SIoana Radulescu 
17334ff6846SIoana Radulescu int dpni_clear_irq_status(struct fsl_mc_io	*mc_io,
17434ff6846SIoana Radulescu 			  u32			cmd_flags,
17534ff6846SIoana Radulescu 			  u16			token,
17634ff6846SIoana Radulescu 			  u8			irq_index,
17734ff6846SIoana Radulescu 			  u32			status);
17834ff6846SIoana Radulescu 
17934ff6846SIoana Radulescu /**
18034ff6846SIoana Radulescu  * struct dpni_attr - Structure representing DPNI attributes
18134ff6846SIoana Radulescu  * @options: Any combination of the following options:
18234ff6846SIoana Radulescu  *		DPNI_OPT_TX_FRM_RELEASE
18334ff6846SIoana Radulescu  *		DPNI_OPT_NO_MAC_FILTER
18434ff6846SIoana Radulescu  *		DPNI_OPT_HAS_POLICING
18534ff6846SIoana Radulescu  *		DPNI_OPT_SHARED_CONGESTION
18634ff6846SIoana Radulescu  *		DPNI_OPT_HAS_KEY_MASKING
18734ff6846SIoana Radulescu  *		DPNI_OPT_NO_FS
18834ff6846SIoana Radulescu  * @num_queues: Number of Tx and Rx queues used for traffic distribution.
18934ff6846SIoana Radulescu  * @num_tcs: Number of traffic classes (TCs), reserved for the DPNI.
19034ff6846SIoana Radulescu  * @mac_filter_entries: Number of entries in the MAC address filtering table.
19134ff6846SIoana Radulescu  * @vlan_filter_entries: Number of entries in the VLAN address filtering table.
19234ff6846SIoana Radulescu  * @qos_entries: Number of entries in the QoS classification table.
19334ff6846SIoana Radulescu  * @fs_entries: Number of entries in the flow steering table.
19434ff6846SIoana Radulescu  * @qos_key_size: Size, in bytes, of the QoS look-up key. Defining a key larger
19534ff6846SIoana Radulescu  *		than this when adding QoS entries will result in an error.
19634ff6846SIoana Radulescu  * @fs_key_size: Size, in bytes, of the flow steering look-up key. Defining a
19734ff6846SIoana Radulescu  *		key larger than this when composing the hash + FS key will
19834ff6846SIoana Radulescu  *		result in an error.
19934ff6846SIoana Radulescu  * @wriop_version: Version of WRIOP HW block. The 3 version values are stored
20034ff6846SIoana Radulescu  *		on 6, 5, 5 bits respectively.
20134ff6846SIoana Radulescu  */
20234ff6846SIoana Radulescu struct dpni_attr {
20334ff6846SIoana Radulescu 	u32 options;
20434ff6846SIoana Radulescu 	u8 num_queues;
20534ff6846SIoana Radulescu 	u8 num_tcs;
20634ff6846SIoana Radulescu 	u8 mac_filter_entries;
20734ff6846SIoana Radulescu 	u8 vlan_filter_entries;
20834ff6846SIoana Radulescu 	u8 qos_entries;
20934ff6846SIoana Radulescu 	u16 fs_entries;
21034ff6846SIoana Radulescu 	u8 qos_key_size;
21134ff6846SIoana Radulescu 	u8 fs_key_size;
21234ff6846SIoana Radulescu 	u16 wriop_version;
21334ff6846SIoana Radulescu };
21434ff6846SIoana Radulescu 
21534ff6846SIoana Radulescu int dpni_get_attributes(struct fsl_mc_io	*mc_io,
21634ff6846SIoana Radulescu 			u32			cmd_flags,
21734ff6846SIoana Radulescu 			u16			token,
21834ff6846SIoana Radulescu 			struct dpni_attr	*attr);
21934ff6846SIoana Radulescu 
22034ff6846SIoana Radulescu /**
22134ff6846SIoana Radulescu  * DPNI errors
22234ff6846SIoana Radulescu  */
22334ff6846SIoana Radulescu 
22434ff6846SIoana Radulescu /**
22534ff6846SIoana Radulescu  * Extract out of frame header error
22634ff6846SIoana Radulescu  */
22734ff6846SIoana Radulescu #define DPNI_ERROR_EOFHE	0x00020000
22834ff6846SIoana Radulescu /**
22934ff6846SIoana Radulescu  * Frame length error
23034ff6846SIoana Radulescu  */
23134ff6846SIoana Radulescu #define DPNI_ERROR_FLE		0x00002000
23234ff6846SIoana Radulescu /**
23334ff6846SIoana Radulescu  * Frame physical error
23434ff6846SIoana Radulescu  */
23534ff6846SIoana Radulescu #define DPNI_ERROR_FPE		0x00001000
23634ff6846SIoana Radulescu /**
23734ff6846SIoana Radulescu  * Parsing header error
23834ff6846SIoana Radulescu  */
23934ff6846SIoana Radulescu #define DPNI_ERROR_PHE		0x00000020
24034ff6846SIoana Radulescu /**
24134ff6846SIoana Radulescu  * Parser L3 checksum error
24234ff6846SIoana Radulescu  */
24334ff6846SIoana Radulescu #define DPNI_ERROR_L3CE		0x00000004
24434ff6846SIoana Radulescu /**
24534ff6846SIoana Radulescu  * Parser L3 checksum error
24634ff6846SIoana Radulescu  */
24734ff6846SIoana Radulescu #define DPNI_ERROR_L4CE		0x00000001
24834ff6846SIoana Radulescu 
24934ff6846SIoana Radulescu /**
25034ff6846SIoana Radulescu  * enum dpni_error_action - Defines DPNI behavior for errors
25134ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
25234ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
25334ff6846SIoana Radulescu  * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
25434ff6846SIoana Radulescu  */
25534ff6846SIoana Radulescu enum dpni_error_action {
25634ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_DISCARD = 0,
25734ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_CONTINUE = 1,
25834ff6846SIoana Radulescu 	DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
25934ff6846SIoana Radulescu };
26034ff6846SIoana Radulescu 
26134ff6846SIoana Radulescu /**
26234ff6846SIoana Radulescu  * struct dpni_error_cfg - Structure representing DPNI errors treatment
26334ff6846SIoana Radulescu  * @errors: Errors mask; use 'DPNI_ERROR__<X>
26434ff6846SIoana Radulescu  * @error_action: The desired action for the errors mask
26534ff6846SIoana Radulescu  * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
26634ff6846SIoana Radulescu  *		status (FAS); relevant only for the non-discard action
26734ff6846SIoana Radulescu  */
26834ff6846SIoana Radulescu struct dpni_error_cfg {
26934ff6846SIoana Radulescu 	u32			errors;
27034ff6846SIoana Radulescu 	enum dpni_error_action	error_action;
27134ff6846SIoana Radulescu 	int			set_frame_annotation;
27234ff6846SIoana Radulescu };
27334ff6846SIoana Radulescu 
27434ff6846SIoana Radulescu int dpni_set_errors_behavior(struct fsl_mc_io		*mc_io,
27534ff6846SIoana Radulescu 			     u32			cmd_flags,
27634ff6846SIoana Radulescu 			     u16			token,
27734ff6846SIoana Radulescu 			     struct dpni_error_cfg	*cfg);
27834ff6846SIoana Radulescu 
27934ff6846SIoana Radulescu /**
28034ff6846SIoana Radulescu  * DPNI buffer layout modification options
28134ff6846SIoana Radulescu  */
28234ff6846SIoana Radulescu 
28334ff6846SIoana Radulescu /**
28434ff6846SIoana Radulescu  * Select to modify the time-stamp setting
28534ff6846SIoana Radulescu  */
28634ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_TIMESTAMP		0x00000001
28734ff6846SIoana Radulescu /**
28834ff6846SIoana Radulescu  * Select to modify the parser-result setting; not applicable for Tx
28934ff6846SIoana Radulescu  */
29034ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT	0x00000002
29134ff6846SIoana Radulescu /**
29234ff6846SIoana Radulescu  * Select to modify the frame-status setting
29334ff6846SIoana Radulescu  */
29434ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS	0x00000004
29534ff6846SIoana Radulescu /**
29634ff6846SIoana Radulescu  * Select to modify the private-data-size setting
29734ff6846SIoana Radulescu  */
29834ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE	0x00000008
29934ff6846SIoana Radulescu /**
30034ff6846SIoana Radulescu  * Select to modify the data-alignment setting
30134ff6846SIoana Radulescu  */
30234ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN		0x00000010
30334ff6846SIoana Radulescu /**
30434ff6846SIoana Radulescu  * Select to modify the data-head-room setting
30534ff6846SIoana Radulescu  */
30634ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM	0x00000020
30734ff6846SIoana Radulescu /**
30834ff6846SIoana Radulescu  * Select to modify the data-tail-room setting
30934ff6846SIoana Radulescu  */
31034ff6846SIoana Radulescu #define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM	0x00000040
31134ff6846SIoana Radulescu 
31234ff6846SIoana Radulescu /**
31334ff6846SIoana Radulescu  * struct dpni_buffer_layout - Structure representing DPNI buffer layout
31434ff6846SIoana Radulescu  * @options: Flags representing the suggested modifications to the buffer
31534ff6846SIoana Radulescu  *		layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
31634ff6846SIoana Radulescu  * @pass_timestamp: Pass timestamp value
31734ff6846SIoana Radulescu  * @pass_parser_result: Pass parser results
31834ff6846SIoana Radulescu  * @pass_frame_status: Pass frame status
31934ff6846SIoana Radulescu  * @private_data_size: Size kept for private data (in bytes)
32034ff6846SIoana Radulescu  * @data_align: Data alignment
32134ff6846SIoana Radulescu  * @data_head_room: Data head room
32234ff6846SIoana Radulescu  * @data_tail_room: Data tail room
32334ff6846SIoana Radulescu  */
32434ff6846SIoana Radulescu struct dpni_buffer_layout {
32534ff6846SIoana Radulescu 	u32	options;
32634ff6846SIoana Radulescu 	int	pass_timestamp;
32734ff6846SIoana Radulescu 	int	pass_parser_result;
32834ff6846SIoana Radulescu 	int	pass_frame_status;
32934ff6846SIoana Radulescu 	u16	private_data_size;
33034ff6846SIoana Radulescu 	u16	data_align;
33134ff6846SIoana Radulescu 	u16	data_head_room;
33234ff6846SIoana Radulescu 	u16	data_tail_room;
33334ff6846SIoana Radulescu };
33434ff6846SIoana Radulescu 
33534ff6846SIoana Radulescu /**
33634ff6846SIoana Radulescu  * enum dpni_queue_type - Identifies a type of queue targeted by the command
33734ff6846SIoana Radulescu  * @DPNI_QUEUE_RX: Rx queue
33834ff6846SIoana Radulescu  * @DPNI_QUEUE_TX: Tx queue
33934ff6846SIoana Radulescu  * @DPNI_QUEUE_TX_CONFIRM: Tx confirmation queue
34034ff6846SIoana Radulescu  * @DPNI_QUEUE_RX_ERR: Rx error queue
34134ff6846SIoana Radulescu  */enum dpni_queue_type {
34234ff6846SIoana Radulescu 	DPNI_QUEUE_RX,
34334ff6846SIoana Radulescu 	DPNI_QUEUE_TX,
34434ff6846SIoana Radulescu 	DPNI_QUEUE_TX_CONFIRM,
34534ff6846SIoana Radulescu 	DPNI_QUEUE_RX_ERR,
34634ff6846SIoana Radulescu };
34734ff6846SIoana Radulescu 
34834ff6846SIoana Radulescu int dpni_get_buffer_layout(struct fsl_mc_io		*mc_io,
34934ff6846SIoana Radulescu 			   u32				cmd_flags,
35034ff6846SIoana Radulescu 			   u16				token,
35134ff6846SIoana Radulescu 			   enum dpni_queue_type		qtype,
35234ff6846SIoana Radulescu 			   struct dpni_buffer_layout	*layout);
35334ff6846SIoana Radulescu 
35434ff6846SIoana Radulescu int dpni_set_buffer_layout(struct fsl_mc_io		   *mc_io,
35534ff6846SIoana Radulescu 			   u32				   cmd_flags,
35634ff6846SIoana Radulescu 			   u16				   token,
35734ff6846SIoana Radulescu 			   enum dpni_queue_type		   qtype,
35834ff6846SIoana Radulescu 			   const struct dpni_buffer_layout *layout);
35934ff6846SIoana Radulescu 
36034ff6846SIoana Radulescu /**
36134ff6846SIoana Radulescu  * enum dpni_offload - Identifies a type of offload targeted by the command
36234ff6846SIoana Radulescu  * @DPNI_OFF_RX_L3_CSUM: Rx L3 checksum validation
36334ff6846SIoana Radulescu  * @DPNI_OFF_RX_L4_CSUM: Rx L4 checksum validation
36434ff6846SIoana Radulescu  * @DPNI_OFF_TX_L3_CSUM: Tx L3 checksum generation
36534ff6846SIoana Radulescu  * @DPNI_OFF_TX_L4_CSUM: Tx L4 checksum generation
36634ff6846SIoana Radulescu  */
36734ff6846SIoana Radulescu enum dpni_offload {
36834ff6846SIoana Radulescu 	DPNI_OFF_RX_L3_CSUM,
36934ff6846SIoana Radulescu 	DPNI_OFF_RX_L4_CSUM,
37034ff6846SIoana Radulescu 	DPNI_OFF_TX_L3_CSUM,
37134ff6846SIoana Radulescu 	DPNI_OFF_TX_L4_CSUM,
37234ff6846SIoana Radulescu };
37334ff6846SIoana Radulescu 
37434ff6846SIoana Radulescu int dpni_set_offload(struct fsl_mc_io	*mc_io,
37534ff6846SIoana Radulescu 		     u32		cmd_flags,
37634ff6846SIoana Radulescu 		     u16		token,
37734ff6846SIoana Radulescu 		     enum dpni_offload	type,
37834ff6846SIoana Radulescu 		     u32		config);
37934ff6846SIoana Radulescu 
38034ff6846SIoana Radulescu int dpni_get_offload(struct fsl_mc_io	*mc_io,
38134ff6846SIoana Radulescu 		     u32		cmd_flags,
38234ff6846SIoana Radulescu 		     u16		token,
38334ff6846SIoana Radulescu 		     enum dpni_offload	type,
38434ff6846SIoana Radulescu 		     u32		*config);
38534ff6846SIoana Radulescu 
38634ff6846SIoana Radulescu int dpni_get_qdid(struct fsl_mc_io	*mc_io,
38734ff6846SIoana Radulescu 		  u32			cmd_flags,
38834ff6846SIoana Radulescu 		  u16			token,
38934ff6846SIoana Radulescu 		  enum dpni_queue_type	qtype,
39034ff6846SIoana Radulescu 		  u16			*qdid);
39134ff6846SIoana Radulescu 
39234ff6846SIoana Radulescu int dpni_get_tx_data_offset(struct fsl_mc_io	*mc_io,
39334ff6846SIoana Radulescu 			    u32			cmd_flags,
39434ff6846SIoana Radulescu 			    u16			token,
39534ff6846SIoana Radulescu 			    u16			*data_offset);
39634ff6846SIoana Radulescu 
39734ff6846SIoana Radulescu #define DPNI_STATISTICS_CNT		7
39834ff6846SIoana Radulescu 
39934ff6846SIoana Radulescu /**
40034ff6846SIoana Radulescu  * union dpni_statistics - Union describing the DPNI statistics
40134ff6846SIoana Radulescu  * @page_0: Page_0 statistics structure
40234ff6846SIoana Radulescu  * @page_0.ingress_all_frames: Ingress frame count
40334ff6846SIoana Radulescu  * @page_0.ingress_all_bytes: Ingress byte count
40434ff6846SIoana Radulescu  * @page_0.ingress_multicast_frames: Ingress multicast frame count
40534ff6846SIoana Radulescu  * @page_0.ingress_multicast_bytes: Ingress multicast byte count
40634ff6846SIoana Radulescu  * @page_0.ingress_broadcast_frames: Ingress broadcast frame count
40734ff6846SIoana Radulescu  * @page_0.ingress_broadcast_bytes: Ingress broadcast byte count
40834ff6846SIoana Radulescu  * @page_1: Page_1 statistics structure
40934ff6846SIoana Radulescu  * @page_1.egress_all_frames: Egress frame count
41034ff6846SIoana Radulescu  * @page_1.egress_all_bytes: Egress byte count
41134ff6846SIoana Radulescu  * @page_1.egress_multicast_frames: Egress multicast frame count
41234ff6846SIoana Radulescu  * @page_1.egress_multicast_bytes: Egress multicast byte count
41334ff6846SIoana Radulescu  * @page_1.egress_broadcast_frames: Egress broadcast frame count
41434ff6846SIoana Radulescu  * @page_1.egress_broadcast_bytes: Egress broadcast byte count
41534ff6846SIoana Radulescu  * @page_2: Page_2 statistics structure
41634ff6846SIoana Radulescu  * @page_2.ingress_filtered_frames: Ingress filtered frame count
41734ff6846SIoana Radulescu  * @page_2.ingress_discarded_frames: Ingress discarded frame count
41834ff6846SIoana Radulescu  * @page_2.ingress_nobuffer_discards: Ingress discarded frame count due to
41934ff6846SIoana Radulescu  *	lack of buffers
42034ff6846SIoana Radulescu  * @page_2.egress_discarded_frames: Egress discarded frame count
42134ff6846SIoana Radulescu  * @page_2.egress_confirmed_frames: Egress confirmed frame count
422d84c3a4dSIoana Radulescu  * @page3: Page_3 statistics structure
423d84c3a4dSIoana Radulescu  * @page_3.egress_dequeue_bytes: Cumulative count of the number of bytes
424d84c3a4dSIoana Radulescu  *	dequeued from egress FQs
425d84c3a4dSIoana Radulescu  * @page_3.egress_dequeue_frames: Cumulative count of the number of frames
426d84c3a4dSIoana Radulescu  *	dequeued from egress FQs
427d84c3a4dSIoana Radulescu  * @page_3.egress_reject_bytes: Cumulative count of the number of bytes in
428d84c3a4dSIoana Radulescu  *	egress frames whose enqueue was rejected
429d84c3a4dSIoana Radulescu  * @page_3.egress_reject_frames: Cumulative count of the number of egress
430d84c3a4dSIoana Radulescu  *	frames whose enqueue was rejected
431d84c3a4dSIoana Radulescu  * @page_4: Page_4 statistics structure: congestion points
432d84c3a4dSIoana Radulescu  * @page_4.cgr_reject_frames: number of rejected frames due to congestion point
433d84c3a4dSIoana Radulescu  * @page_4.cgr_reject_bytes: number of rejected bytes due to congestion point
434d84c3a4dSIoana Radulescu  * @page_5: Page_5 statistics structure: policer
435d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_red: NUmber of red colored frames
436d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_yellow: number of yellow colored frames
437d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_green: number of green colored frames
438d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_re_red: number of recolored red frames
439d84c3a4dSIoana Radulescu  * @page_5.policer_cnt_re_yellow: number of recolored yellow frames
440d84c3a4dSIoana Radulescu  * @page_6: Page_6 statistics structure
441d84c3a4dSIoana Radulescu  * @page_6.tx_pending_frames: total number of frames pending in egress FQs
44234ff6846SIoana Radulescu  * @raw: raw statistics structure, used to index counters
44334ff6846SIoana Radulescu  */
44434ff6846SIoana Radulescu union dpni_statistics {
44534ff6846SIoana Radulescu 	struct {
44634ff6846SIoana Radulescu 		u64 ingress_all_frames;
44734ff6846SIoana Radulescu 		u64 ingress_all_bytes;
44834ff6846SIoana Radulescu 		u64 ingress_multicast_frames;
44934ff6846SIoana Radulescu 		u64 ingress_multicast_bytes;
45034ff6846SIoana Radulescu 		u64 ingress_broadcast_frames;
45134ff6846SIoana Radulescu 		u64 ingress_broadcast_bytes;
45234ff6846SIoana Radulescu 	} page_0;
45334ff6846SIoana Radulescu 	struct {
45434ff6846SIoana Radulescu 		u64 egress_all_frames;
45534ff6846SIoana Radulescu 		u64 egress_all_bytes;
45634ff6846SIoana Radulescu 		u64 egress_multicast_frames;
45734ff6846SIoana Radulescu 		u64 egress_multicast_bytes;
45834ff6846SIoana Radulescu 		u64 egress_broadcast_frames;
45934ff6846SIoana Radulescu 		u64 egress_broadcast_bytes;
46034ff6846SIoana Radulescu 	} page_1;
46134ff6846SIoana Radulescu 	struct {
46234ff6846SIoana Radulescu 		u64 ingress_filtered_frames;
46334ff6846SIoana Radulescu 		u64 ingress_discarded_frames;
46434ff6846SIoana Radulescu 		u64 ingress_nobuffer_discards;
46534ff6846SIoana Radulescu 		u64 egress_discarded_frames;
46634ff6846SIoana Radulescu 		u64 egress_confirmed_frames;
46734ff6846SIoana Radulescu 	} page_2;
46834ff6846SIoana Radulescu 	struct {
469d84c3a4dSIoana Radulescu 		u64 egress_dequeue_bytes;
470d84c3a4dSIoana Radulescu 		u64 egress_dequeue_frames;
471d84c3a4dSIoana Radulescu 		u64 egress_reject_bytes;
472d84c3a4dSIoana Radulescu 		u64 egress_reject_frames;
473d84c3a4dSIoana Radulescu 	} page_3;
474d84c3a4dSIoana Radulescu 	struct {
475d84c3a4dSIoana Radulescu 		u64 cgr_reject_frames;
476d84c3a4dSIoana Radulescu 		u64 cgr_reject_bytes;
477d84c3a4dSIoana Radulescu 	} page_4;
478d84c3a4dSIoana Radulescu 	struct {
479d84c3a4dSIoana Radulescu 		u64 policer_cnt_red;
480d84c3a4dSIoana Radulescu 		u64 policer_cnt_yellow;
481d84c3a4dSIoana Radulescu 		u64 policer_cnt_green;
482d84c3a4dSIoana Radulescu 		u64 policer_cnt_re_red;
483d84c3a4dSIoana Radulescu 		u64 policer_cnt_re_yellow;
484d84c3a4dSIoana Radulescu 	} page_5;
485d84c3a4dSIoana Radulescu 	struct {
486d84c3a4dSIoana Radulescu 		u64 tx_pending_frames;
487d84c3a4dSIoana Radulescu 	} page_6;
488d84c3a4dSIoana Radulescu 	struct {
48934ff6846SIoana Radulescu 		u64 counter[DPNI_STATISTICS_CNT];
49034ff6846SIoana Radulescu 	} raw;
49134ff6846SIoana Radulescu };
49234ff6846SIoana Radulescu 
49334ff6846SIoana Radulescu int dpni_get_statistics(struct fsl_mc_io	*mc_io,
49434ff6846SIoana Radulescu 			u32			cmd_flags,
49534ff6846SIoana Radulescu 			u16			token,
49634ff6846SIoana Radulescu 			u8			page,
49734ff6846SIoana Radulescu 			union dpni_statistics	*stat);
49834ff6846SIoana Radulescu 
49934ff6846SIoana Radulescu /**
50034ff6846SIoana Radulescu  * Enable auto-negotiation
50134ff6846SIoana Radulescu  */
50234ff6846SIoana Radulescu #define DPNI_LINK_OPT_AUTONEG		0x0000000000000001ULL
50334ff6846SIoana Radulescu /**
50434ff6846SIoana Radulescu  * Enable half-duplex mode
50534ff6846SIoana Radulescu  */
50634ff6846SIoana Radulescu #define DPNI_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
50734ff6846SIoana Radulescu /**
50834ff6846SIoana Radulescu  * Enable pause frames
50934ff6846SIoana Radulescu  */
51034ff6846SIoana Radulescu #define DPNI_LINK_OPT_PAUSE		0x0000000000000004ULL
51134ff6846SIoana Radulescu /**
51234ff6846SIoana Radulescu  * Enable a-symmetric pause frames
51334ff6846SIoana Radulescu  */
51434ff6846SIoana Radulescu #define DPNI_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
51534ff6846SIoana Radulescu 
51634ff6846SIoana Radulescu /**
517*f395b69fSIoana Ciornei  * Enable priority flow control pause frames
518*f395b69fSIoana Ciornei  */
519*f395b69fSIoana Ciornei #define DPNI_LINK_OPT_PFC_PAUSE		0x0000000000000010ULL
520*f395b69fSIoana Ciornei 
521*f395b69fSIoana Ciornei /**
52234ff6846SIoana Radulescu  * struct - Structure representing DPNI link configuration
52334ff6846SIoana Radulescu  * @rate: Rate
52434ff6846SIoana Radulescu  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
52534ff6846SIoana Radulescu  */
52634ff6846SIoana Radulescu struct dpni_link_cfg {
52734ff6846SIoana Radulescu 	u32 rate;
52834ff6846SIoana Radulescu 	u64 options;
52934ff6846SIoana Radulescu };
53034ff6846SIoana Radulescu 
53134ff6846SIoana Radulescu int dpni_set_link_cfg(struct fsl_mc_io			*mc_io,
53234ff6846SIoana Radulescu 		      u32				cmd_flags,
53334ff6846SIoana Radulescu 		      u16				token,
53434ff6846SIoana Radulescu 		      const struct dpni_link_cfg	*cfg);
53534ff6846SIoana Radulescu 
5368eb3cef8SIoana Radulescu int dpni_get_link_cfg(struct fsl_mc_io			*mc_io,
5378eb3cef8SIoana Radulescu 		      u32				cmd_flags,
5388eb3cef8SIoana Radulescu 		      u16				token,
5398eb3cef8SIoana Radulescu 		      struct dpni_link_cfg		*cfg);
5408eb3cef8SIoana Radulescu 
54134ff6846SIoana Radulescu /**
54234ff6846SIoana Radulescu  * struct dpni_link_state - Structure representing DPNI link state
54334ff6846SIoana Radulescu  * @rate: Rate
54434ff6846SIoana Radulescu  * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
54534ff6846SIoana Radulescu  * @up: Link state; '0' for down, '1' for up
54634ff6846SIoana Radulescu  */
54734ff6846SIoana Radulescu struct dpni_link_state {
54834ff6846SIoana Radulescu 	u32	rate;
54934ff6846SIoana Radulescu 	u64	options;
55034ff6846SIoana Radulescu 	int	up;
55134ff6846SIoana Radulescu };
55234ff6846SIoana Radulescu 
55334ff6846SIoana Radulescu int dpni_get_link_state(struct fsl_mc_io	*mc_io,
55434ff6846SIoana Radulescu 			u32			cmd_flags,
55534ff6846SIoana Radulescu 			u16			token,
55634ff6846SIoana Radulescu 			struct dpni_link_state	*state);
55734ff6846SIoana Radulescu 
55834ff6846SIoana Radulescu int dpni_set_max_frame_length(struct fsl_mc_io	*mc_io,
55934ff6846SIoana Radulescu 			      u32		cmd_flags,
56034ff6846SIoana Radulescu 			      u16		token,
56134ff6846SIoana Radulescu 			      u16		max_frame_length);
56234ff6846SIoana Radulescu 
56334ff6846SIoana Radulescu int dpni_get_max_frame_length(struct fsl_mc_io	*mc_io,
56434ff6846SIoana Radulescu 			      u32		cmd_flags,
56534ff6846SIoana Radulescu 			      u16		token,
56634ff6846SIoana Radulescu 			      u16		*max_frame_length);
56734ff6846SIoana Radulescu 
56834ff6846SIoana Radulescu int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
56934ff6846SIoana Radulescu 			       u32		cmd_flags,
57034ff6846SIoana Radulescu 			       u16		token,
57134ff6846SIoana Radulescu 			       int		en);
57234ff6846SIoana Radulescu 
57334ff6846SIoana Radulescu int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
57434ff6846SIoana Radulescu 			       u32		cmd_flags,
57534ff6846SIoana Radulescu 			       u16		token,
57634ff6846SIoana Radulescu 			       int		*en);
57734ff6846SIoana Radulescu 
57834ff6846SIoana Radulescu int dpni_set_unicast_promisc(struct fsl_mc_io	*mc_io,
57934ff6846SIoana Radulescu 			     u32		cmd_flags,
58034ff6846SIoana Radulescu 			     u16		token,
58134ff6846SIoana Radulescu 			     int		en);
58234ff6846SIoana Radulescu 
58334ff6846SIoana Radulescu int dpni_get_unicast_promisc(struct fsl_mc_io	*mc_io,
58434ff6846SIoana Radulescu 			     u32		cmd_flags,
58534ff6846SIoana Radulescu 			     u16		token,
58634ff6846SIoana Radulescu 			     int		*en);
58734ff6846SIoana Radulescu 
58834ff6846SIoana Radulescu int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
58934ff6846SIoana Radulescu 			      u32		cmd_flags,
59034ff6846SIoana Radulescu 			      u16		token,
59134ff6846SIoana Radulescu 			      const u8		mac_addr[6]);
59234ff6846SIoana Radulescu 
59334ff6846SIoana Radulescu int dpni_get_primary_mac_addr(struct fsl_mc_io	*mc_io,
59434ff6846SIoana Radulescu 			      u32		cmd_flags,
59534ff6846SIoana Radulescu 			      u16		token,
59634ff6846SIoana Radulescu 			      u8		mac_addr[6]);
59734ff6846SIoana Radulescu 
59834ff6846SIoana Radulescu int dpni_get_port_mac_addr(struct fsl_mc_io	*mc_io,
59934ff6846SIoana Radulescu 			   u32			cm_flags,
60034ff6846SIoana Radulescu 			   u16			token,
60134ff6846SIoana Radulescu 			   u8			mac_addr[6]);
60234ff6846SIoana Radulescu 
60334ff6846SIoana Radulescu int dpni_add_mac_addr(struct fsl_mc_io	*mc_io,
60434ff6846SIoana Radulescu 		      u32		cmd_flags,
60534ff6846SIoana Radulescu 		      u16		token,
60634ff6846SIoana Radulescu 		      const u8		mac_addr[6]);
60734ff6846SIoana Radulescu 
60834ff6846SIoana Radulescu int dpni_remove_mac_addr(struct fsl_mc_io	*mc_io,
60934ff6846SIoana Radulescu 			 u32			cmd_flags,
61034ff6846SIoana Radulescu 			 u16			token,
61134ff6846SIoana Radulescu 			 const u8		mac_addr[6]);
61234ff6846SIoana Radulescu 
61334ff6846SIoana Radulescu int dpni_clear_mac_filters(struct fsl_mc_io	*mc_io,
61434ff6846SIoana Radulescu 			   u32			cmd_flags,
61534ff6846SIoana Radulescu 			   u16			token,
61634ff6846SIoana Radulescu 			   int			unicast,
61734ff6846SIoana Radulescu 			   int			multicast);
61834ff6846SIoana Radulescu 
61934ff6846SIoana Radulescu /**
62034ff6846SIoana Radulescu  * enum dpni_dist_mode - DPNI distribution mode
62134ff6846SIoana Radulescu  * @DPNI_DIST_MODE_NONE: No distribution
62234ff6846SIoana Radulescu  * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
62334ff6846SIoana Radulescu  *		the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
62434ff6846SIoana Radulescu  * @DPNI_DIST_MODE_FS:  Use explicit flow steering; only relevant if
62534ff6846SIoana Radulescu  *	 the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
62634ff6846SIoana Radulescu  */
62734ff6846SIoana Radulescu enum dpni_dist_mode {
62834ff6846SIoana Radulescu 	DPNI_DIST_MODE_NONE = 0,
62934ff6846SIoana Radulescu 	DPNI_DIST_MODE_HASH = 1,
63034ff6846SIoana Radulescu 	DPNI_DIST_MODE_FS = 2
63134ff6846SIoana Radulescu };
63234ff6846SIoana Radulescu 
63334ff6846SIoana Radulescu /**
63434ff6846SIoana Radulescu  * enum dpni_fs_miss_action -   DPNI Flow Steering miss action
63534ff6846SIoana Radulescu  * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
63634ff6846SIoana Radulescu  * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
63734ff6846SIoana Radulescu  * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
63834ff6846SIoana Radulescu  */
63934ff6846SIoana Radulescu enum dpni_fs_miss_action {
64034ff6846SIoana Radulescu 	DPNI_FS_MISS_DROP = 0,
64134ff6846SIoana Radulescu 	DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
64234ff6846SIoana Radulescu 	DPNI_FS_MISS_HASH = 2
64334ff6846SIoana Radulescu };
64434ff6846SIoana Radulescu 
64534ff6846SIoana Radulescu /**
64634ff6846SIoana Radulescu  * struct dpni_fs_tbl_cfg - Flow Steering table configuration
64734ff6846SIoana Radulescu  * @miss_action: Miss action selection
64834ff6846SIoana Radulescu  * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
64934ff6846SIoana Radulescu  */
65034ff6846SIoana Radulescu struct dpni_fs_tbl_cfg {
65134ff6846SIoana Radulescu 	enum dpni_fs_miss_action	miss_action;
65234ff6846SIoana Radulescu 	u16				default_flow_id;
65334ff6846SIoana Radulescu };
65434ff6846SIoana Radulescu 
65534ff6846SIoana Radulescu int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
65634ff6846SIoana Radulescu 			 u8 *key_cfg_buf);
65734ff6846SIoana Radulescu 
65834ff6846SIoana Radulescu /**
65934ff6846SIoana Radulescu  * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
66034ff6846SIoana Radulescu  * @dist_size: Set the distribution size;
66134ff6846SIoana Radulescu  *	supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
66234ff6846SIoana Radulescu  *	112,128,192,224,256,384,448,512,768,896,1024
66334ff6846SIoana Radulescu  * @dist_mode: Distribution mode
66434ff6846SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
66534ff6846SIoana Radulescu  *		the extractions to be used for the distribution key by calling
66634ff6846SIoana Radulescu  *		dpni_prepare_key_cfg() relevant only when
66734ff6846SIoana Radulescu  *		'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
66834ff6846SIoana Radulescu  * @fs_cfg: Flow Steering table configuration; only relevant if
66934ff6846SIoana Radulescu  *		'dist_mode = DPNI_DIST_MODE_FS'
67034ff6846SIoana Radulescu  */
67134ff6846SIoana Radulescu struct dpni_rx_tc_dist_cfg {
67234ff6846SIoana Radulescu 	u16			dist_size;
67334ff6846SIoana Radulescu 	enum dpni_dist_mode	dist_mode;
67434ff6846SIoana Radulescu 	u64			key_cfg_iova;
67534ff6846SIoana Radulescu 	struct dpni_fs_tbl_cfg	fs_cfg;
67634ff6846SIoana Radulescu };
67734ff6846SIoana Radulescu 
67834ff6846SIoana Radulescu int dpni_set_rx_tc_dist(struct fsl_mc_io			*mc_io,
67934ff6846SIoana Radulescu 			u32					cmd_flags,
68034ff6846SIoana Radulescu 			u16					token,
68134ff6846SIoana Radulescu 			u8					tc_id,
68234ff6846SIoana Radulescu 			const struct dpni_rx_tc_dist_cfg	*cfg);
68334ff6846SIoana Radulescu 
68434ff6846SIoana Radulescu /**
685df85aeb9SIoana Radulescu  * When used for fs_miss_flow_id in function dpni_set_rx_dist,
686df85aeb9SIoana Radulescu  * will signal to dpni to drop all unclassified frames
687df85aeb9SIoana Radulescu  */
688df85aeb9SIoana Radulescu #define DPNI_FS_MISS_DROP		((uint16_t)-1)
689df85aeb9SIoana Radulescu 
690df85aeb9SIoana Radulescu /**
691df85aeb9SIoana Radulescu  * struct dpni_rx_dist_cfg - Rx distribution configuration
692df85aeb9SIoana Radulescu  * @dist_size:	distribution size
693df85aeb9SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
694df85aeb9SIoana Radulescu  *		the extractions to be used for the distribution key by calling
695df85aeb9SIoana Radulescu  *		dpni_prepare_key_cfg(); relevant only when enable!=0 otherwise
696df85aeb9SIoana Radulescu  *		it can be '0'
697df85aeb9SIoana Radulescu  * @enable: enable/disable the distribution.
698df85aeb9SIoana Radulescu  * @tc: TC id for which distribution is set
699df85aeb9SIoana Radulescu  * @fs_miss_flow_id: when packet misses all rules from flow steering table and
700df85aeb9SIoana Radulescu  *		hash is disabled it will be put into this queue id; use
701df85aeb9SIoana Radulescu  *		DPNI_FS_MISS_DROP to drop frames. The value of this field is
702df85aeb9SIoana Radulescu  *		used only when flow steering distribution is enabled and hash
703df85aeb9SIoana Radulescu  *		distribution is disabled
704df85aeb9SIoana Radulescu  */
705df85aeb9SIoana Radulescu struct dpni_rx_dist_cfg {
706df85aeb9SIoana Radulescu 	u16 dist_size;
707df85aeb9SIoana Radulescu 	u64 key_cfg_iova;
708df85aeb9SIoana Radulescu 	u8 enable;
709df85aeb9SIoana Radulescu 	u8 tc;
710df85aeb9SIoana Radulescu 	u16 fs_miss_flow_id;
711df85aeb9SIoana Radulescu };
712df85aeb9SIoana Radulescu 
7134aaaf9b9SIoana Radulescu int dpni_set_rx_fs_dist(struct fsl_mc_io *mc_io,
7144aaaf9b9SIoana Radulescu 			u32 cmd_flags,
7154aaaf9b9SIoana Radulescu 			u16 token,
7164aaaf9b9SIoana Radulescu 			const struct dpni_rx_dist_cfg *cfg);
7174aaaf9b9SIoana Radulescu 
718df85aeb9SIoana Radulescu int dpni_set_rx_hash_dist(struct fsl_mc_io *mc_io,
719df85aeb9SIoana Radulescu 			  u32 cmd_flags,
720df85aeb9SIoana Radulescu 			  u16 token,
721df85aeb9SIoana Radulescu 			  const struct dpni_rx_dist_cfg *cfg);
722df85aeb9SIoana Radulescu 
723df85aeb9SIoana Radulescu /**
7246aa90fe2SIoana Radulescu  * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
7256aa90fe2SIoana Radulescu  * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
7266aa90fe2SIoana Radulescu  *		key extractions to be used as the QoS criteria by calling
7276aa90fe2SIoana Radulescu  *		dpkg_prepare_key_cfg()
7286aa90fe2SIoana Radulescu  * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
7296aa90fe2SIoana Radulescu  *		'0' to use the 'default_tc' in such cases
7306aa90fe2SIoana Radulescu  * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
7316aa90fe2SIoana Radulescu  */
7326aa90fe2SIoana Radulescu struct dpni_qos_tbl_cfg {
7336aa90fe2SIoana Radulescu 	u64 key_cfg_iova;
7346aa90fe2SIoana Radulescu 	int discard_on_miss;
7356aa90fe2SIoana Radulescu 	u8 default_tc;
7366aa90fe2SIoana Radulescu };
7376aa90fe2SIoana Radulescu 
7386aa90fe2SIoana Radulescu int dpni_set_qos_table(struct fsl_mc_io *mc_io,
7396aa90fe2SIoana Radulescu 		       u32 cmd_flags,
7406aa90fe2SIoana Radulescu 		       u16 token,
7416aa90fe2SIoana Radulescu 		       const struct dpni_qos_tbl_cfg *cfg);
7426aa90fe2SIoana Radulescu 
7436aa90fe2SIoana Radulescu /**
74434ff6846SIoana Radulescu  * enum dpni_dest - DPNI destination types
74534ff6846SIoana Radulescu  * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
74634ff6846SIoana Radulescu  *		does not generate FQDAN notifications; user is expected to
74734ff6846SIoana Radulescu  *		dequeue from the queue based on polling or other user-defined
74834ff6846SIoana Radulescu  *		method
74934ff6846SIoana Radulescu  * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
75034ff6846SIoana Radulescu  *		notifications to the specified DPIO; user is expected to dequeue
75134ff6846SIoana Radulescu  *		from the queue only after notification is received
75234ff6846SIoana Radulescu  * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
75334ff6846SIoana Radulescu  *		FQDAN notifications, but is connected to the specified DPCON
75434ff6846SIoana Radulescu  *		object; user is expected to dequeue from the DPCON channel
75534ff6846SIoana Radulescu  */
75634ff6846SIoana Radulescu enum dpni_dest {
75734ff6846SIoana Radulescu 	DPNI_DEST_NONE = 0,
75834ff6846SIoana Radulescu 	DPNI_DEST_DPIO = 1,
75934ff6846SIoana Radulescu 	DPNI_DEST_DPCON = 2
76034ff6846SIoana Radulescu };
76134ff6846SIoana Radulescu 
76234ff6846SIoana Radulescu /**
76334ff6846SIoana Radulescu  * struct dpni_queue - Queue structure
76434ff6846SIoana Radulescu  * @destination - Destination structure
76534ff6846SIoana Radulescu  * @destination.id: ID of the destination, only relevant if DEST_TYPE is > 0.
76634ff6846SIoana Radulescu  *	Identifies either a DPIO or a DPCON object.
76734ff6846SIoana Radulescu  *	Not relevant for Tx queues.
76834ff6846SIoana Radulescu  * @destination.type:	May be one of the following:
76934ff6846SIoana Radulescu  *	0 - No destination, queue can be manually
77034ff6846SIoana Radulescu  *		queried, but will not push traffic or
77134ff6846SIoana Radulescu  *		notifications to a DPIO;
77234ff6846SIoana Radulescu  *	1 - The destination is a DPIO. When traffic
77334ff6846SIoana Radulescu  *		becomes available in the queue a FQDAN
77434ff6846SIoana Radulescu  *		(FQ data available notification) will be
77534ff6846SIoana Radulescu  *		generated to selected DPIO;
77634ff6846SIoana Radulescu  *	2 - The destination is a DPCON. The queue is
77734ff6846SIoana Radulescu  *		associated with a DPCON object for the
77834ff6846SIoana Radulescu  *		purpose of scheduling between multiple
77934ff6846SIoana Radulescu  *		queues. The DPCON may be independently
78034ff6846SIoana Radulescu  *		configured to generate notifications.
78134ff6846SIoana Radulescu  *		Not relevant for Tx queues.
78234ff6846SIoana Radulescu  * @destination.hold_active: Hold active, maintains a queue scheduled for longer
78334ff6846SIoana Radulescu  *	in a DPIO during dequeue to reduce spread of traffic.
78434ff6846SIoana Radulescu  *	Only relevant if queues are
78534ff6846SIoana Radulescu  *	not affined to a single DPIO.
78634ff6846SIoana Radulescu  * @user_context: User data, presented to the user along with any frames
78734ff6846SIoana Radulescu  *	from this queue. Not relevant for Tx queues.
78834ff6846SIoana Radulescu  * @flc: FD FLow Context structure
78934ff6846SIoana Radulescu  * @flc.value: Default FLC value for traffic dequeued from
79034ff6846SIoana Radulescu  *      this queue.  Please check description of FD
79134ff6846SIoana Radulescu  *      structure for more information.
79234ff6846SIoana Radulescu  *      Note that FLC values set using dpni_add_fs_entry,
79334ff6846SIoana Radulescu  *      if any, take precedence over values per queue.
79434ff6846SIoana Radulescu  * @flc.stash_control: Boolean, indicates whether the 6 lowest
79534ff6846SIoana Radulescu  *      - significant bits are used for stash control.
79634ff6846SIoana Radulescu  *      significant bits are used for stash control.  If set, the 6
79734ff6846SIoana Radulescu  *      least significant bits in value are interpreted as follows:
79834ff6846SIoana Radulescu  *      - bits 0-1: indicates the number of 64 byte units of context
79934ff6846SIoana Radulescu  *      that are stashed.  FLC value is interpreted as a memory address
80034ff6846SIoana Radulescu  *      in this case, excluding the 6 LS bits.
80134ff6846SIoana Radulescu  *      - bits 2-3: indicates the number of 64 byte units of frame
80234ff6846SIoana Radulescu  *      annotation to be stashed.  Annotation is placed at FD[ADDR].
80334ff6846SIoana Radulescu  *      - bits 4-5: indicates the number of 64 byte units of frame
80434ff6846SIoana Radulescu  *      data to be stashed.  Frame data is placed at FD[ADDR] +
80534ff6846SIoana Radulescu  *      FD[OFFSET].
80634ff6846SIoana Radulescu  *      For more details check the Frame Descriptor section in the
80734ff6846SIoana Radulescu  *      hardware documentation.
80834ff6846SIoana Radulescu  */
80934ff6846SIoana Radulescu struct dpni_queue {
81034ff6846SIoana Radulescu 	struct {
81134ff6846SIoana Radulescu 		u16 id;
81234ff6846SIoana Radulescu 		enum dpni_dest type;
81334ff6846SIoana Radulescu 		char hold_active;
81434ff6846SIoana Radulescu 		u8 priority;
81534ff6846SIoana Radulescu 	} destination;
81634ff6846SIoana Radulescu 	u64 user_context;
81734ff6846SIoana Radulescu 	struct {
81834ff6846SIoana Radulescu 		u64 value;
81934ff6846SIoana Radulescu 		char stash_control;
82034ff6846SIoana Radulescu 	} flc;
82134ff6846SIoana Radulescu };
82234ff6846SIoana Radulescu 
82334ff6846SIoana Radulescu /**
82434ff6846SIoana Radulescu  * struct dpni_queue_id - Queue identification, used for enqueue commands
82534ff6846SIoana Radulescu  *			or queue control
82634ff6846SIoana Radulescu  * @fqid: FQID used for enqueueing to and/or configuration of this specific FQ
82734ff6846SIoana Radulescu  * @qdbin: Queueing bin, used to enqueue using QDID, DQBIN, QPRI. Only relevant
82834ff6846SIoana Radulescu  *		for Tx queues.
82934ff6846SIoana Radulescu  */
83034ff6846SIoana Radulescu struct dpni_queue_id {
83134ff6846SIoana Radulescu 	u32 fqid;
83234ff6846SIoana Radulescu 	u16 qdbin;
83334ff6846SIoana Radulescu };
83434ff6846SIoana Radulescu 
83534ff6846SIoana Radulescu /**
83634ff6846SIoana Radulescu  * Set User Context
83734ff6846SIoana Radulescu  */
83834ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_USER_CTX		0x00000001
83934ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_DEST		0x00000002
84034ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_FLC		0x00000004
84134ff6846SIoana Radulescu #define DPNI_QUEUE_OPT_HOLD_ACTIVE	0x00000008
84234ff6846SIoana Radulescu 
84334ff6846SIoana Radulescu int dpni_set_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 		   u8			options,
85034ff6846SIoana Radulescu 		   const struct dpni_queue *queue);
85134ff6846SIoana Radulescu 
85234ff6846SIoana Radulescu int dpni_get_queue(struct fsl_mc_io	*mc_io,
85334ff6846SIoana Radulescu 		   u32			cmd_flags,
85434ff6846SIoana Radulescu 		   u16			token,
85534ff6846SIoana Radulescu 		   enum dpni_queue_type	qtype,
85634ff6846SIoana Radulescu 		   u8			tc,
85734ff6846SIoana Radulescu 		   u8			index,
85834ff6846SIoana Radulescu 		   struct dpni_queue	*queue,
85934ff6846SIoana Radulescu 		   struct dpni_queue_id	*qid);
86034ff6846SIoana Radulescu 
86134ff6846SIoana Radulescu /**
86234ff6846SIoana Radulescu  * enum dpni_congestion_unit - DPNI congestion units
86334ff6846SIoana Radulescu  * @DPNI_CONGESTION_UNIT_BYTES: bytes units
86434ff6846SIoana Radulescu  * @DPNI_CONGESTION_UNIT_FRAMES: frames units
86534ff6846SIoana Radulescu  */
86634ff6846SIoana Radulescu enum dpni_congestion_unit {
86734ff6846SIoana Radulescu 	DPNI_CONGESTION_UNIT_BYTES = 0,
86834ff6846SIoana Radulescu 	DPNI_CONGESTION_UNIT_FRAMES
86934ff6846SIoana Radulescu };
87034ff6846SIoana Radulescu 
87134ff6846SIoana Radulescu /**
87234ff6846SIoana Radulescu  * enum dpni_congestion_point - Structure representing congestion point
87334ff6846SIoana Radulescu  * @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
87434ff6846SIoana Radulescu  *		QUEUE_INDEX
87534ff6846SIoana Radulescu  * @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used to
87634ff6846SIoana Radulescu  *		define the DPNI this can be either per TC (default) or per
87734ff6846SIoana Radulescu  *		interface (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
87834ff6846SIoana Radulescu  *		QUEUE_INDEX is ignored if this type is used.
87934ff6846SIoana Radulescu  */
88034ff6846SIoana Radulescu enum dpni_congestion_point {
88134ff6846SIoana Radulescu 	DPNI_CP_QUEUE,
88234ff6846SIoana Radulescu 	DPNI_CP_GROUP,
88334ff6846SIoana Radulescu };
88434ff6846SIoana Radulescu 
88534ff6846SIoana Radulescu /**
886*f395b69fSIoana Ciornei  * struct dpni_dest_cfg - Structure representing DPNI destination parameters
887*f395b69fSIoana Ciornei  * @dest_type:	Destination type
888*f395b69fSIoana Ciornei  * @dest_id:	Either DPIO ID or DPCON ID, depending on the destination type
889*f395b69fSIoana Ciornei  * @priority:	Priority selection within the DPIO or DPCON channel; valid
890*f395b69fSIoana Ciornei  *		values are 0-1 or 0-7, depending on the number of priorities
891*f395b69fSIoana Ciornei  *		in that channel; not relevant for 'DPNI_DEST_NONE' option
892*f395b69fSIoana Ciornei  */
893*f395b69fSIoana Ciornei struct dpni_dest_cfg {
894*f395b69fSIoana Ciornei 	enum dpni_dest dest_type;
895*f395b69fSIoana Ciornei 	int dest_id;
896*f395b69fSIoana Ciornei 	u8 priority;
897*f395b69fSIoana Ciornei };
898*f395b69fSIoana Ciornei 
899*f395b69fSIoana Ciornei /* DPNI congestion options */
900*f395b69fSIoana Ciornei 
901*f395b69fSIoana Ciornei /**
902*f395b69fSIoana Ciornei  * This congestion will trigger flow control or priority flow control.
903*f395b69fSIoana Ciornei  * This will have effect only if flow control is enabled with
904*f395b69fSIoana Ciornei  * dpni_set_link_cfg().
905*f395b69fSIoana Ciornei  */
906*f395b69fSIoana Ciornei #define DPNI_CONG_OPT_FLOW_CONTROL		0x00000040
907*f395b69fSIoana Ciornei 
908*f395b69fSIoana Ciornei /**
909*f395b69fSIoana Ciornei  * struct dpni_congestion_notification_cfg - congestion notification
910*f395b69fSIoana Ciornei  *					configuration
911*f395b69fSIoana Ciornei  * @units: Units type
912*f395b69fSIoana Ciornei  * @threshold_entry: Above this threshold we enter a congestion state.
913*f395b69fSIoana Ciornei  *		set it to '0' to disable it
914*f395b69fSIoana Ciornei  * @threshold_exit: Below this threshold we exit the congestion state.
915*f395b69fSIoana Ciornei  * @message_ctx: The context that will be part of the CSCN message
916*f395b69fSIoana Ciornei  * @message_iova: I/O virtual address (must be in DMA-able memory),
917*f395b69fSIoana Ciornei  *		must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>'
918*f395b69fSIoana Ciornei  *		is contained in 'options'
919*f395b69fSIoana Ciornei  * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
920*f395b69fSIoana Ciornei  * @notification_mode: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
921*f395b69fSIoana Ciornei  */
922*f395b69fSIoana Ciornei 
923*f395b69fSIoana Ciornei struct dpni_congestion_notification_cfg {
924*f395b69fSIoana Ciornei 	enum dpni_congestion_unit units;
925*f395b69fSIoana Ciornei 	u32 threshold_entry;
926*f395b69fSIoana Ciornei 	u32 threshold_exit;
927*f395b69fSIoana Ciornei 	u64 message_ctx;
928*f395b69fSIoana Ciornei 	u64 message_iova;
929*f395b69fSIoana Ciornei 	struct dpni_dest_cfg dest_cfg;
930*f395b69fSIoana Ciornei 	u16 notification_mode;
931*f395b69fSIoana Ciornei };
932*f395b69fSIoana Ciornei 
933*f395b69fSIoana Ciornei int dpni_set_congestion_notification(
934*f395b69fSIoana Ciornei 			struct fsl_mc_io *mc_io,
935*f395b69fSIoana Ciornei 			u32 cmd_flags,
936*f395b69fSIoana Ciornei 			u16 token,
937*f395b69fSIoana Ciornei 			enum dpni_queue_type qtype,
938*f395b69fSIoana Ciornei 			u8 tc_id,
939*f395b69fSIoana Ciornei 			const struct dpni_congestion_notification_cfg *cfg);
940*f395b69fSIoana Ciornei 
941*f395b69fSIoana Ciornei /**
94234ff6846SIoana Radulescu  * struct dpni_taildrop - Structure representing the taildrop
94334ff6846SIoana Radulescu  * @enable:	Indicates whether the taildrop is active or not.
94434ff6846SIoana Radulescu  * @units:	Indicates the unit of THRESHOLD. Queue taildrop only supports
94534ff6846SIoana Radulescu  *		byte units, this field is ignored and assumed = 0 if
94634ff6846SIoana Radulescu  *		CONGESTION_POINT is 0.
94734ff6846SIoana Radulescu  * @threshold:	Threshold value, in units identified by UNITS field. Value 0
94834ff6846SIoana Radulescu  *		cannot be used as a valid taildrop threshold, THRESHOLD must
94934ff6846SIoana Radulescu  *		be > 0 if the taildrop is enabled.
95034ff6846SIoana Radulescu  */
95134ff6846SIoana Radulescu struct dpni_taildrop {
95234ff6846SIoana Radulescu 	char enable;
95334ff6846SIoana Radulescu 	enum dpni_congestion_unit units;
95434ff6846SIoana Radulescu 	u32 threshold;
95534ff6846SIoana Radulescu };
95634ff6846SIoana Radulescu 
95734ff6846SIoana Radulescu int dpni_set_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 int dpni_get_taildrop(struct fsl_mc_io *mc_io,
96734ff6846SIoana Radulescu 		      u32 cmd_flags,
96834ff6846SIoana Radulescu 		      u16 token,
96934ff6846SIoana Radulescu 		      enum dpni_congestion_point cg_point,
97034ff6846SIoana Radulescu 		      enum dpni_queue_type q_type,
97134ff6846SIoana Radulescu 		      u8 tc,
97234ff6846SIoana Radulescu 		      u8 q_index,
97334ff6846SIoana Radulescu 		      struct dpni_taildrop *taildrop);
97434ff6846SIoana Radulescu 
97534ff6846SIoana Radulescu /**
97634ff6846SIoana Radulescu  * struct dpni_rule_cfg - Rule configuration for table lookup
97734ff6846SIoana Radulescu  * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
97834ff6846SIoana Radulescu  * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
97934ff6846SIoana Radulescu  * @key_size: key and mask size (in bytes)
98034ff6846SIoana Radulescu  */
98134ff6846SIoana Radulescu struct dpni_rule_cfg {
98234ff6846SIoana Radulescu 	u64	key_iova;
98334ff6846SIoana Radulescu 	u64	mask_iova;
98434ff6846SIoana Radulescu 	u8	key_size;
98534ff6846SIoana Radulescu };
98634ff6846SIoana Radulescu 
987afb90dbbSIoana Radulescu /**
988afb90dbbSIoana Radulescu  * Discard matching traffic. If set, this takes precedence over any other
989afb90dbbSIoana Radulescu  * configuration and matching traffic is always discarded.
990afb90dbbSIoana Radulescu  */
991afb90dbbSIoana Radulescu  #define DPNI_FS_OPT_DISCARD            0x1
992afb90dbbSIoana Radulescu 
993afb90dbbSIoana Radulescu /**
994afb90dbbSIoana Radulescu  * Set FLC value. If set, flc member of struct dpni_fs_action_cfg is used to
995afb90dbbSIoana Radulescu  * override the FLC value set per queue.
996afb90dbbSIoana Radulescu  * For more details check the Frame Descriptor section in the hardware
997afb90dbbSIoana Radulescu  * documentation.
998afb90dbbSIoana Radulescu  */
999afb90dbbSIoana Radulescu #define DPNI_FS_OPT_SET_FLC            0x2
1000afb90dbbSIoana Radulescu 
1001afb90dbbSIoana Radulescu /**
1002afb90dbbSIoana Radulescu  * Indicates whether the 6 lowest significant bits of FLC are used for stash
1003afb90dbbSIoana Radulescu  * control. If set, the 6 least significant bits in value are interpreted as
1004afb90dbbSIoana Radulescu  * follows:
1005afb90dbbSIoana Radulescu  *     - bits 0-1: indicates the number of 64 byte units of context that are
1006afb90dbbSIoana Radulescu  *     stashed. FLC value is interpreted as a memory address in this case,
1007afb90dbbSIoana Radulescu  *     excluding the 6 LS bits.
1008afb90dbbSIoana Radulescu  *     - bits 2-3: indicates the number of 64 byte units of frame annotation
1009afb90dbbSIoana Radulescu  *     to be stashed. Annotation is placed at FD[ADDR].
1010afb90dbbSIoana Radulescu  *     - bits 4-5: indicates the number of 64 byte units of frame data to be
1011afb90dbbSIoana Radulescu  *     stashed. Frame data is placed at FD[ADDR] + FD[OFFSET].
1012afb90dbbSIoana Radulescu  * This flag is ignored if DPNI_FS_OPT_SET_FLC is not specified.
1013afb90dbbSIoana Radulescu  */
1014afb90dbbSIoana Radulescu #define DPNI_FS_OPT_SET_STASH_CONTROL  0x4
1015afb90dbbSIoana Radulescu 
1016afb90dbbSIoana Radulescu /**
1017afb90dbbSIoana Radulescu  * struct dpni_fs_action_cfg - Action configuration for table look-up
1018afb90dbbSIoana Radulescu  * @flc:	FLC value for traffic matching this rule. Please check the
1019afb90dbbSIoana Radulescu  *		Frame Descriptor section in the hardware documentation for
1020afb90dbbSIoana Radulescu  *		more information.
1021afb90dbbSIoana Radulescu  * @flow_id:	Identifies the Rx queue used for matching traffic. Supported
1022afb90dbbSIoana Radulescu  *		values are in range 0 to num_queue-1.
1023afb90dbbSIoana Radulescu  * @options:	Any combination of DPNI_FS_OPT_ values.
1024afb90dbbSIoana Radulescu  */
1025afb90dbbSIoana Radulescu struct dpni_fs_action_cfg {
1026afb90dbbSIoana Radulescu 	u64 flc;
1027afb90dbbSIoana Radulescu 	u16 flow_id;
1028afb90dbbSIoana Radulescu 	u16 options;
1029afb90dbbSIoana Radulescu };
1030afb90dbbSIoana Radulescu 
1031afb90dbbSIoana Radulescu int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
1032afb90dbbSIoana Radulescu 		      u32 cmd_flags,
1033afb90dbbSIoana Radulescu 		      u16 token,
1034afb90dbbSIoana Radulescu 		      u8 tc_id,
1035afb90dbbSIoana Radulescu 		      u16 index,
1036afb90dbbSIoana Radulescu 		      const struct dpni_rule_cfg *cfg,
1037afb90dbbSIoana Radulescu 		      const struct dpni_fs_action_cfg *action);
1038afb90dbbSIoana Radulescu 
1039afb90dbbSIoana Radulescu int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
1040afb90dbbSIoana Radulescu 			 u32 cmd_flags,
1041afb90dbbSIoana Radulescu 			 u16 token,
1042afb90dbbSIoana Radulescu 			 u8 tc_id,
1043afb90dbbSIoana Radulescu 			 const struct dpni_rule_cfg *cfg);
1044afb90dbbSIoana Radulescu 
10456aa90fe2SIoana Radulescu int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
10466aa90fe2SIoana Radulescu 		       u32 cmd_flags,
10476aa90fe2SIoana Radulescu 		       u16 token,
10486aa90fe2SIoana Radulescu 		       const struct dpni_rule_cfg *cfg,
10496aa90fe2SIoana Radulescu 		       u8 tc_id,
10506aa90fe2SIoana Radulescu 		       u16 index);
10516aa90fe2SIoana Radulescu 
10526aa90fe2SIoana Radulescu int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
10536aa90fe2SIoana Radulescu 			  u32 cmd_flags,
10546aa90fe2SIoana Radulescu 			  u16 token,
10556aa90fe2SIoana Radulescu 			  const struct dpni_rule_cfg *cfg);
10566aa90fe2SIoana Radulescu 
10576aa90fe2SIoana Radulescu int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
10586aa90fe2SIoana Radulescu 			 u32 cmd_flags,
10596aa90fe2SIoana Radulescu 			 u16 token);
10606aa90fe2SIoana Radulescu 
106134ff6846SIoana Radulescu int dpni_get_api_version(struct fsl_mc_io *mc_io,
106234ff6846SIoana Radulescu 			 u32 cmd_flags,
106334ff6846SIoana Radulescu 			 u16 *major_ver,
106434ff6846SIoana Radulescu 			 u16 *minor_ver);
106534ff6846SIoana Radulescu 
106634ff6846SIoana Radulescu #endif /* __FSL_DPNI_H */
1067