xref: /dpdk/drivers/bus/fslmc/mc/fsl_dpci.h (revision 1094dd940ec0cc4e3ce2c5cd94807350855a17f9)
1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
2  *
3  * Copyright 2013-2016 Freescale Semiconductor Inc.
4  * Copyright 2017-2019 NXP
5  *
6  */
7 #ifndef __FSL_DPCI_H
8 #define __FSL_DPCI_H
9 
10 #include <fsl_dpopr.h>
11 
12 #include <rte_compat.h>
13 
14 /* Data Path Communication Interface API
15  * Contains initialization APIs and runtime control APIs for DPCI
16  */
17 
18 struct fsl_mc_io;
19 
20 /** General DPCI macros */
21 
22 /**
23  * Maximum number of Tx/Rx priorities per DPCI object
24  */
25 #define DPCI_PRIO_NUM		4
26 
27 /**
28  * Indicates an invalid frame queue
29  */
30 #define DPCI_FQID_NOT_VALID	(uint32_t)(-1)
31 
32 /**
33  * All queues considered; see dpci_set_rx_queue()
34  */
35 #define DPCI_ALL_QUEUES		(uint8_t)(-1)
36 
37 int dpci_open(struct fsl_mc_io *mc_io,
38 	      uint32_t cmd_flags,
39 	      int dpci_id,
40 	      uint16_t *token);
41 
42 int dpci_close(struct fsl_mc_io *mc_io,
43 	       uint32_t cmd_flags,
44 	       uint16_t token);
45 
46 /**
47  * Enable the Order Restoration support
48  */
49 #define DPCI_OPT_HAS_OPR					0x000040
50 
51 /**
52  * Order Point Records are shared for the entire DPCI
53  */
54 #define DPCI_OPT_OPR_SHARED					0x000080
55 
56 /**
57  * struct dpci_cfg - Structure representing DPCI configuration
58  * @options: Any combination of the following options:
59  *		DPCI_OPT_HAS_OPR
60  *		DPCI_OPT_OPR_SHARED
61  * @num_of_priorities:	Number of receive priorities (queues) for the DPCI;
62  *			note, that the number of transmit priorities (queues)
63  *			is determined by the number of receive priorities of
64  *			the peer DPCI object
65  */
66 struct dpci_cfg {
67 	uint32_t options;
68 	uint8_t num_of_priorities;
69 };
70 
71 int dpci_create(struct fsl_mc_io *mc_io,
72 		uint16_t dprc_token,
73 		uint32_t cmd_flags,
74 		const struct dpci_cfg *cfg,
75 		uint32_t *obj_id);
76 
77 int dpci_destroy(struct fsl_mc_io *mc_io,
78 		 uint16_t dprc_token,
79 		 uint32_t cmd_flags,
80 		 uint32_t object_id);
81 
82 int dpci_enable(struct fsl_mc_io *mc_io,
83 		uint32_t cmd_flags,
84 		uint16_t token);
85 
86 int dpci_disable(struct fsl_mc_io *mc_io,
87 		 uint32_t cmd_flags,
88 		 uint16_t token);
89 
90 int dpci_is_enabled(struct fsl_mc_io *mc_io,
91 		    uint32_t cmd_flags,
92 		    uint16_t token,
93 		    int *en);
94 
95 int dpci_reset(struct fsl_mc_io *mc_io,
96 	       uint32_t cmd_flags,
97 	       uint16_t token);
98 
99 /**
100  * struct dpci_attr - Structure representing DPCI attributes
101  * @id:			DPCI object ID
102  * @num_of_priorities:	Number of receive priorities
103  */
104 struct dpci_attr {
105 	int id;
106 	uint8_t num_of_priorities;
107 };
108 
109 int dpci_get_attributes(struct fsl_mc_io *mc_io,
110 			uint32_t cmd_flags,
111 			uint16_t token,
112 			struct dpci_attr *attr);
113 
114 /**
115  * enum dpci_dest - DPCI destination types
116  * @DPCI_DEST_NONE:	Unassigned destination; The queue is set in parked mode
117  *			and does not generate FQDAN notifications; user is
118  *			expected to dequeue from the queue based on polling or
119  *			other user-defined method
120  * @DPCI_DEST_DPIO:	The queue is set in schedule mode and generates FQDAN
121  *			notifications to the specified DPIO; user is expected
122  *			to dequeue from the queue only after notification is
123  *			received
124  * @DPCI_DEST_DPCON:	The queue is set in schedule mode and does not generate
125  *			FQDAN notifications, but is connected to the specified
126  *			DPCON object;
127  *			user is expected to dequeue from the DPCON channel
128  */
129 enum dpci_dest {
130 	DPCI_DEST_NONE = 0,
131 	DPCI_DEST_DPIO = 1,
132 	DPCI_DEST_DPCON = 2
133 };
134 
135 /**
136  * struct dpci_dest_cfg - Structure representing DPCI destination configuration
137  * @dest_type:	Destination type
138  * @dest_id:	Either DPIO ID or DPCON ID, depending on the destination type
139  * @priority:	Priority selection within the DPIO or DPCON channel; valid
140  *		values are 0-1 or 0-7, depending on the number of priorities
141  *		in that	channel; not relevant for 'DPCI_DEST_NONE' option
142  */
143 struct dpci_dest_cfg {
144 	enum dpci_dest dest_type;
145 	int dest_id;
146 	uint8_t priority;
147 };
148 
149 /** DPCI queue modification options */
150 
151 /**
152  * Select to modify the user's context associated with the queue
153  */
154 #define DPCI_QUEUE_OPT_USER_CTX		0x00000001
155 
156 /**
157  * Select to modify the queue's destination
158  */
159 #define DPCI_QUEUE_OPT_DEST		0x00000002
160 
161 /**
162  * Set the queue to hold active mode.
163  */
164 #define DPCI_QUEUE_OPT_HOLD_ACTIVE	0x00000004
165 
166 /**
167  * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
168  * @options:	Flags representing the suggested modifications to the queue;
169  *		Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
170  * @user_ctx:	User context value provided in the frame descriptor of each
171  *		dequeued frame;
172  *		valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
173  *		'options'
174  * @dest_cfg:	Queue destination parameters;
175  *		valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
176  * @order_preservation_en: order preservation configuration for the rx queue
177  * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options'
178  */
179 struct dpci_rx_queue_cfg {
180 	uint32_t options;
181 	uint64_t user_ctx;
182 	struct dpci_dest_cfg dest_cfg;
183 	int order_preservation_en;
184 };
185 
186 __rte_internal
187 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
188 		      uint32_t cmd_flags,
189 		      uint16_t token,
190 		      uint8_t priority,
191 		      const struct dpci_rx_queue_cfg *cfg);
192 
193 /**
194  * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
195  * @user_ctx:	User context value provided in the frame descriptor of each
196  *		dequeued frame
197  * @dest_cfg:	Queue destination configuration
198  * @fqid:	Virtual FQID value to be used for dequeue operations
199  */
200 struct dpci_rx_queue_attr {
201 	uint64_t user_ctx;
202 	struct dpci_dest_cfg dest_cfg;
203 	uint32_t fqid;
204 };
205 
206 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
207 		      uint32_t cmd_flags,
208 		      uint16_t token,
209 		      uint8_t priority,
210 		      struct dpci_rx_queue_attr	*attr);
211 
212 /**
213  * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
214  * @fqid:	Virtual FQID to be used for sending frames to peer DPCI;
215  *		returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
216  *		the selected priority exceeds the number of priorities of the
217  *		peer DPCI object
218  */
219 struct dpci_tx_queue_attr {
220 	uint32_t fqid;
221 };
222 
223 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
224 		      uint32_t cmd_flags,
225 		      uint16_t token,
226 		      uint8_t priority,
227 		      struct dpci_tx_queue_attr *attr);
228 
229 int dpci_get_api_version(struct fsl_mc_io *mc_io,
230 			 uint32_t cmd_flags,
231 			 uint16_t *major_ver,
232 			 uint16_t *minor_ver);
233 
234 __rte_internal
235 int dpci_set_opr(struct fsl_mc_io *mc_io,
236 		 uint32_t cmd_flags,
237 		 uint16_t token,
238 		 uint8_t index,
239 		 uint8_t options,
240 		 struct opr_cfg *cfg);
241 
242 __rte_internal
243 int dpci_get_opr(struct fsl_mc_io *mc_io,
244 		 uint32_t cmd_flags,
245 		 uint16_t token,
246 		 uint8_t index,
247 		 struct opr_cfg *cfg,
248 		 struct opr_qry *qry);
249 
250 #endif /* __FSL_DPCI_H */
251