2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2016 Freescale Semiconductor Inc.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of the above-listed copyright holders nor the
17 * names of any contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
22 * ALTERNATIVELY, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") as published by the Free Software
24 * Foundation, either version 2 of that License or (at your option) any
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
42 /* Data Path Communication Interface API
43 * Contains initialization APIs and runtime control APIs for DPCI
48 /** General DPCI macros */
51 * Maximum number of Tx/Rx priorities per DPCI object
53 #define DPCI_PRIO_NUM 2
56 * Indicates an invalid frame queue
58 #define DPCI_FQID_NOT_VALID (uint32_t)(-1)
61 * All queues considered; see dpci_set_rx_queue()
63 #define DPCI_ALL_QUEUES (uint8_t)(-1)
66 * dpci_open() - Open a control session for the specified object
67 * @mc_io: Pointer to MC portal's I/O object
68 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
69 * @dpci_id: DPCI unique ID
70 * @token: Returned token; use in subsequent API calls
72 * This function can be used to open a control session for an
73 * already created object; an object may have been declared in
74 * the DPL or by calling the dpci_create() function.
75 * This function returns a unique authentication token,
76 * associated with the specific object ID and the specific MC
77 * portal; this token must be used in all subsequent commands for
78 * this specific object.
80 * Return: '0' on Success; Error code otherwise.
82 int dpci_open(struct fsl_mc_io *mc_io,
88 * dpci_close() - Close the control session of the object
89 * @mc_io: Pointer to MC portal's I/O object
90 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
91 * @token: Token of DPCI object
93 * After this function is called, no further operations are
94 * allowed on the object without opening a new control session.
96 * Return: '0' on Success; Error code otherwise.
98 int dpci_close(struct fsl_mc_io *mc_io,
103 * Enable the Order Restoration support
105 #define DPCI_OPT_HAS_OPR 0x000040
108 * Order Point Records are shared for the entire DPCI
110 #define DPCI_OPT_OPR_SHARED 0x000080
113 * struct dpci_cfg - Structure representing DPCI configuration
114 * @options: Any combination of the following options:
116 * DPCI_OPT_OPR_SHARED
117 * @num_of_priorities: Number of receive priorities (queues) for the DPCI;
118 * note, that the number of transmit priorities (queues)
119 * is determined by the number of receive priorities of
120 * the peer DPCI object
124 uint8_t num_of_priorities;
128 * dpci_create() - Create the DPCI object.
129 * @mc_io: Pointer to MC portal's I/O object
130 * @dprc_token: Parent container token; '0' for default container
131 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
132 * @cfg: Configuration structure
133 * @obj_id: returned object id
135 * Create the DPCI object, allocate required resources and perform required
138 * The object can be created either by declaring it in the
139 * DPL file, or by calling this function.
141 * The function accepts an authentication token of a parent
142 * container that this object should be assigned to. The token
143 * can be '0' so the object will be assigned to the default container.
144 * The newly created object can be opened with the returned
145 * object id and using the container's associated tokens and MC portals.
147 * Return: '0' on Success; Error code otherwise.
149 int dpci_create(struct fsl_mc_io *mc_io,
152 const struct dpci_cfg *cfg,
156 * dpci_destroy() - Destroy the DPCI object and release all its resources.
157 * @mc_io: Pointer to MC portal's I/O object
158 * @dprc_token: Parent container token; '0' for default container
159 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
160 * @object_id: The object id; it must be a valid id within the container that
161 * created this object;
163 * The function accepts the authentication token of the parent container that
164 * created the object (not the one that currently owns the object). The object
165 * is searched within parent using the provided 'object_id'.
166 * All tokens to the object must be closed before calling destroy.
168 * Return: '0' on Success; error code otherwise.
170 int dpci_destroy(struct fsl_mc_io *mc_io,
176 * dpci_enable() - Enable the DPCI, allow sending and receiving frames.
177 * @mc_io: Pointer to MC portal's I/O object
178 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
179 * @token: Token of DPCI object
181 * Return: '0' on Success; Error code otherwise.
183 int dpci_enable(struct fsl_mc_io *mc_io,
188 * dpci_disable() - Disable the DPCI, stop sending and receiving frames.
189 * @mc_io: Pointer to MC portal's I/O object
190 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
191 * @token: Token of DPCI object
193 * Return: '0' on Success; Error code otherwise.
195 int dpci_disable(struct fsl_mc_io *mc_io,
200 * dpci_is_enabled() - Check if the DPCI is enabled.
201 * @mc_io: Pointer to MC portal's I/O object
202 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
203 * @token: Token of DPCI object
204 * @en: Returns '1' if object is enabled; '0' otherwise
206 * Return: '0' on Success; Error code otherwise.
208 int dpci_is_enabled(struct fsl_mc_io *mc_io,
214 * dpci_reset() - Reset the DPCI, returns the object to initial state.
215 * @mc_io: Pointer to MC portal's I/O object
216 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
217 * @token: Token of DPCI object
219 * Return: '0' on Success; Error code otherwise.
221 int dpci_reset(struct fsl_mc_io *mc_io,
226 * struct dpci_attr - Structure representing DPCI attributes
227 * @id: DPCI object ID
228 * @num_of_priorities: Number of receive priorities
232 uint8_t num_of_priorities;
236 * dpci_get_attributes() - Retrieve DPCI attributes.
237 * @mc_io: Pointer to MC portal's I/O object
238 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
239 * @token: Token of DPCI object
240 * @attr: Returned object's attributes
242 * Return: '0' on Success; Error code otherwise.
244 int dpci_get_attributes(struct fsl_mc_io *mc_io,
247 struct dpci_attr *attr);
250 * enum dpci_dest - DPCI destination types
251 * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
252 * and does not generate FQDAN notifications; user is
253 * expected to dequeue from the queue based on polling or
254 * other user-defined method
255 * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
256 * notifications to the specified DPIO; user is expected
257 * to dequeue from the queue only after notification is
259 * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
260 * FQDAN notifications, but is connected to the specified
262 * user is expected to dequeue from the DPCON channel
271 * struct dpci_dest_cfg - Structure representing DPCI destination configuration
272 * @dest_type: Destination type
273 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
274 * @priority: Priority selection within the DPIO or DPCON channel; valid
275 * values are 0-1 or 0-7, depending on the number of priorities
276 * in that channel; not relevant for 'DPCI_DEST_NONE' option
278 struct dpci_dest_cfg {
279 enum dpci_dest dest_type;
284 /** DPCI queue modification options */
287 * Select to modify the user's context associated with the queue
289 #define DPCI_QUEUE_OPT_USER_CTX 0x00000001
292 * Select to modify the queue's destination
294 #define DPCI_QUEUE_OPT_DEST 0x00000002
297 * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
298 * @options: Flags representing the suggested modifications to the queue;
299 * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
300 * @user_ctx: User context value provided in the frame descriptor of each
302 * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
304 * @dest_cfg: Queue destination parameters;
305 * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
307 struct dpci_rx_queue_cfg {
310 struct dpci_dest_cfg dest_cfg;
314 * dpci_set_rx_queue() - Set Rx queue configuration
315 * @mc_io: Pointer to MC portal's I/O object
316 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
317 * @token: Token of DPCI object
318 * @priority: Select the queue relative to number of
319 * priorities configured at DPCI creation; use
320 * DPCI_ALL_QUEUES to configure all Rx queues
322 * @cfg: Rx queue configuration
324 * Return: '0' on Success; Error code otherwise.
326 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
330 const struct dpci_rx_queue_cfg *cfg);
333 * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
334 * @user_ctx: User context value provided in the frame descriptor of each
336 * @dest_cfg: Queue destination configuration
337 * @fqid: Virtual FQID value to be used for dequeue operations
339 struct dpci_rx_queue_attr {
341 struct dpci_dest_cfg dest_cfg;
346 * dpci_get_rx_queue() - Retrieve Rx queue attributes.
347 * @mc_io: Pointer to MC portal's I/O object
348 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
349 * @token: Token of DPCI object
350 * @priority: Select the queue relative to number of
351 * priorities configured at DPCI creation
352 * @attr: Returned Rx queue attributes
354 * Return: '0' on Success; Error code otherwise.
356 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
360 struct dpci_rx_queue_attr *attr);
363 * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
364 * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
365 * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
366 * the selected priority exceeds the number of priorities of the
369 struct dpci_tx_queue_attr {
374 * dpci_get_tx_queue() - Retrieve Tx queue attributes.
375 * @mc_io: Pointer to MC portal's I/O object
376 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
377 * @token: Token of DPCI object
378 * @priority: Select the queue relative to number of
379 * priorities of the peer DPCI object
380 * @attr: Returned Tx queue attributes
382 * Return: '0' on Success; Error code otherwise.
384 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
388 struct dpci_tx_queue_attr *attr);
391 * dpci_get_api_version() - Get communication interface API version
392 * @mc_io: Pointer to MC portal's I/O object
393 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
394 * @major_ver: Major version of data path communication interface API
395 * @minor_ver: Minor version of data path communication interface API
397 * Return: '0' on Success; Error code otherwise.
399 int dpci_get_api_version(struct fsl_mc_io *mc_io,
402 uint16_t *minor_ver);
404 #endif /* __FSL_DPCI_H */