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)
65 int dpci_open(struct fsl_mc_io *mc_io,
70 int dpci_close(struct fsl_mc_io *mc_io,
75 * Enable the Order Restoration support
77 #define DPCI_OPT_HAS_OPR 0x000040
80 * Order Point Records are shared for the entire DPCI
82 #define DPCI_OPT_OPR_SHARED 0x000080
85 * struct dpci_cfg - Structure representing DPCI configuration
86 * @options: Any combination of the following options:
89 * @num_of_priorities: Number of receive priorities (queues) for the DPCI;
90 * note, that the number of transmit priorities (queues)
91 * is determined by the number of receive priorities of
92 * the peer DPCI object
96 uint8_t num_of_priorities;
99 int dpci_create(struct fsl_mc_io *mc_io,
102 const struct dpci_cfg *cfg,
105 int dpci_destroy(struct fsl_mc_io *mc_io,
110 int dpci_enable(struct fsl_mc_io *mc_io,
114 int dpci_disable(struct fsl_mc_io *mc_io,
118 int dpci_is_enabled(struct fsl_mc_io *mc_io,
123 int dpci_reset(struct fsl_mc_io *mc_io,
128 * struct dpci_attr - Structure representing DPCI attributes
129 * @id: DPCI object ID
130 * @num_of_priorities: Number of receive priorities
134 uint8_t num_of_priorities;
137 int dpci_get_attributes(struct fsl_mc_io *mc_io,
140 struct dpci_attr *attr);
143 * enum dpci_dest - DPCI destination types
144 * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
145 * and does not generate FQDAN notifications; user is
146 * expected to dequeue from the queue based on polling or
147 * other user-defined method
148 * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
149 * notifications to the specified DPIO; user is expected
150 * to dequeue from the queue only after notification is
152 * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
153 * FQDAN notifications, but is connected to the specified
155 * user is expected to dequeue from the DPCON channel
164 * struct dpci_dest_cfg - Structure representing DPCI destination configuration
165 * @dest_type: Destination type
166 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
167 * @priority: Priority selection within the DPIO or DPCON channel; valid
168 * values are 0-1 or 0-7, depending on the number of priorities
169 * in that channel; not relevant for 'DPCI_DEST_NONE' option
171 struct dpci_dest_cfg {
172 enum dpci_dest dest_type;
177 /** DPCI queue modification options */
180 * Select to modify the user's context associated with the queue
182 #define DPCI_QUEUE_OPT_USER_CTX 0x00000001
185 * Select to modify the queue's destination
187 #define DPCI_QUEUE_OPT_DEST 0x00000002
190 * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
191 * @options: Flags representing the suggested modifications to the queue;
192 * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
193 * @user_ctx: User context value provided in the frame descriptor of each
195 * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
197 * @dest_cfg: Queue destination parameters;
198 * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
200 struct dpci_rx_queue_cfg {
203 struct dpci_dest_cfg dest_cfg;
206 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
210 const struct dpci_rx_queue_cfg *cfg);
213 * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
214 * @user_ctx: User context value provided in the frame descriptor of each
216 * @dest_cfg: Queue destination configuration
217 * @fqid: Virtual FQID value to be used for dequeue operations
219 struct dpci_rx_queue_attr {
221 struct dpci_dest_cfg dest_cfg;
225 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
229 struct dpci_rx_queue_attr *attr);
232 * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
233 * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
234 * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
235 * the selected priority exceeds the number of priorities of the
238 struct dpci_tx_queue_attr {
242 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
246 struct dpci_tx_queue_attr *attr);
248 int dpci_get_api_version(struct fsl_mc_io *mc_io,
251 uint16_t *minor_ver);
253 #endif /* __FSL_DPCI_H */