1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
4 * Copyright 2017-2019 NXP
10 #include <fsl_dpopr.h>
12 /* Data Path Communication Interface API
13 * Contains initialization APIs and runtime control APIs for DPCI
18 /** General DPCI macros */
21 * Maximum number of Tx/Rx priorities per DPCI object
23 #define DPCI_PRIO_NUM 4
26 * Indicates an invalid frame queue
28 #define DPCI_FQID_NOT_VALID (uint32_t)(-1)
31 * All queues considered; see dpci_set_rx_queue()
33 #define DPCI_ALL_QUEUES (uint8_t)(-1)
35 int dpci_open(struct fsl_mc_io *mc_io,
40 int dpci_close(struct fsl_mc_io *mc_io,
45 * Enable the Order Restoration support
47 #define DPCI_OPT_HAS_OPR 0x000040
50 * Order Point Records are shared for the entire DPCI
52 #define DPCI_OPT_OPR_SHARED 0x000080
55 * struct dpci_cfg - Structure representing DPCI configuration
56 * @options: Any combination of the following options:
59 * @num_of_priorities: Number of receive priorities (queues) for the DPCI;
60 * note, that the number of transmit priorities (queues)
61 * is determined by the number of receive priorities of
62 * the peer DPCI object
66 uint8_t num_of_priorities;
69 int dpci_create(struct fsl_mc_io *mc_io,
72 const struct dpci_cfg *cfg,
75 int dpci_destroy(struct fsl_mc_io *mc_io,
80 int dpci_enable(struct fsl_mc_io *mc_io,
84 int dpci_disable(struct fsl_mc_io *mc_io,
88 int dpci_is_enabled(struct fsl_mc_io *mc_io,
93 int dpci_reset(struct fsl_mc_io *mc_io,
98 * struct dpci_attr - Structure representing DPCI attributes
100 * @num_of_priorities: Number of receive priorities
104 uint8_t num_of_priorities;
107 int dpci_get_attributes(struct fsl_mc_io *mc_io,
110 struct dpci_attr *attr);
113 * enum dpci_dest - DPCI destination types
114 * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
115 * and does not generate FQDAN notifications; user is
116 * expected to dequeue from the queue based on polling or
117 * other user-defined method
118 * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
119 * notifications to the specified DPIO; user is expected
120 * to dequeue from the queue only after notification is
122 * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
123 * FQDAN notifications, but is connected to the specified
125 * user is expected to dequeue from the DPCON channel
134 * struct dpci_dest_cfg - Structure representing DPCI destination configuration
135 * @dest_type: Destination type
136 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
137 * @priority: Priority selection within the DPIO or DPCON channel; valid
138 * values are 0-1 or 0-7, depending on the number of priorities
139 * in that channel; not relevant for 'DPCI_DEST_NONE' option
141 struct dpci_dest_cfg {
142 enum dpci_dest dest_type;
147 /** DPCI queue modification options */
150 * Select to modify the user's context associated with the queue
152 #define DPCI_QUEUE_OPT_USER_CTX 0x00000001
155 * Select to modify the queue's destination
157 #define DPCI_QUEUE_OPT_DEST 0x00000002
160 * Set the queue to hold active mode.
162 #define DPCI_QUEUE_OPT_HOLD_ACTIVE 0x00000004
165 * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
166 * @options: Flags representing the suggested modifications to the queue;
167 * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
168 * @user_ctx: User context value provided in the frame descriptor of each
170 * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
172 * @dest_cfg: Queue destination parameters;
173 * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
174 * @order_preservation_en: order preservation configuration for the rx queue
175 * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options'
177 struct dpci_rx_queue_cfg {
180 struct dpci_dest_cfg dest_cfg;
181 int order_preservation_en;
185 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
189 const struct dpci_rx_queue_cfg *cfg);
192 * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
193 * @user_ctx: User context value provided in the frame descriptor of each
195 * @dest_cfg: Queue destination configuration
196 * @fqid: Virtual FQID value to be used for dequeue operations
198 struct dpci_rx_queue_attr {
200 struct dpci_dest_cfg dest_cfg;
204 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
208 struct dpci_rx_queue_attr *attr);
211 * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
212 * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
213 * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
214 * the selected priority exceeds the number of priorities of the
217 struct dpci_tx_queue_attr {
221 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
225 struct dpci_tx_queue_attr *attr);
227 int dpci_get_api_version(struct fsl_mc_io *mc_io,
230 uint16_t *minor_ver);
233 int dpci_set_opr(struct fsl_mc_io *mc_io,
238 struct opr_cfg *cfg);
241 int dpci_get_opr(struct fsl_mc_io *mc_io,
246 struct opr_qry *qry);
248 #endif /* __FSL_DPCI_H */