1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
3 * Copyright 2013-2016 Freescale Semiconductor Inc.
11 /* Data Path Communication Interface API
12 * Contains initialization APIs and runtime control APIs for DPCI
17 /** General DPCI macros */
20 * Maximum number of Tx/Rx priorities per DPCI object
22 #define DPCI_PRIO_NUM 4
25 * Indicates an invalid frame queue
27 #define DPCI_FQID_NOT_VALID (uint32_t)(-1)
30 * All queues considered; see dpci_set_rx_queue()
32 #define DPCI_ALL_QUEUES (uint8_t)(-1)
34 int dpci_open(struct fsl_mc_io *mc_io,
39 int dpci_close(struct fsl_mc_io *mc_io,
44 * Enable the Order Restoration support
46 #define DPCI_OPT_HAS_OPR 0x000040
49 * Order Point Records are shared for the entire DPCI
51 #define DPCI_OPT_OPR_SHARED 0x000080
54 * struct dpci_cfg - Structure representing DPCI configuration
55 * @options: Any combination of the following options:
58 * @num_of_priorities: Number of receive priorities (queues) for the DPCI;
59 * note, that the number of transmit priorities (queues)
60 * is determined by the number of receive priorities of
61 * the peer DPCI object
65 uint8_t num_of_priorities;
68 int dpci_create(struct fsl_mc_io *mc_io,
71 const struct dpci_cfg *cfg,
74 int dpci_destroy(struct fsl_mc_io *mc_io,
79 int dpci_enable(struct fsl_mc_io *mc_io,
83 int dpci_disable(struct fsl_mc_io *mc_io,
87 int dpci_is_enabled(struct fsl_mc_io *mc_io,
92 int dpci_reset(struct fsl_mc_io *mc_io,
97 * struct dpci_attr - Structure representing DPCI attributes
99 * @num_of_priorities: Number of receive priorities
103 uint8_t num_of_priorities;
106 int dpci_get_attributes(struct fsl_mc_io *mc_io,
109 struct dpci_attr *attr);
112 * enum dpci_dest - DPCI destination types
113 * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
114 * and does not generate FQDAN notifications; user is
115 * expected to dequeue from the queue based on polling or
116 * other user-defined method
117 * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
118 * notifications to the specified DPIO; user is expected
119 * to dequeue from the queue only after notification is
121 * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
122 * FQDAN notifications, but is connected to the specified
124 * user is expected to dequeue from the DPCON channel
133 * struct dpci_dest_cfg - Structure representing DPCI destination configuration
134 * @dest_type: Destination type
135 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
136 * @priority: Priority selection within the DPIO or DPCON channel; valid
137 * values are 0-1 or 0-7, depending on the number of priorities
138 * in that channel; not relevant for 'DPCI_DEST_NONE' option
140 struct dpci_dest_cfg {
141 enum dpci_dest dest_type;
146 /** DPCI queue modification options */
149 * Select to modify the user's context associated with the queue
151 #define DPCI_QUEUE_OPT_USER_CTX 0x00000001
154 * Select to modify the queue's destination
156 #define DPCI_QUEUE_OPT_DEST 0x00000002
159 * Set the queue to hold active mode.
161 #define DPCI_QUEUE_OPT_HOLD_ACTIVE 0x00000004
164 * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
165 * @options: Flags representing the suggested modifications to the queue;
166 * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
167 * @user_ctx: User context value provided in the frame descriptor of each
169 * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
171 * @dest_cfg: Queue destination parameters;
172 * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
173 * @order_preservation_en: order preservation configuration for the rx queue
174 * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options'
176 struct dpci_rx_queue_cfg {
179 struct dpci_dest_cfg dest_cfg;
180 int order_preservation_en;
183 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
187 const struct dpci_rx_queue_cfg *cfg);
190 * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
191 * @user_ctx: User context value provided in the frame descriptor of each
193 * @dest_cfg: Queue destination configuration
194 * @fqid: Virtual FQID value to be used for dequeue operations
196 struct dpci_rx_queue_attr {
198 struct dpci_dest_cfg dest_cfg;
202 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
206 struct dpci_rx_queue_attr *attr);
209 * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
210 * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
211 * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
212 * the selected priority exceeds the number of priorities of the
215 struct dpci_tx_queue_attr {
219 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
223 struct dpci_tx_queue_attr *attr);
225 int dpci_get_api_version(struct fsl_mc_io *mc_io,
228 uint16_t *minor_ver);
230 int dpci_set_opr(struct fsl_mc_io *mc_io,
235 struct opr_cfg *cfg);
237 int dpci_get_opr(struct fsl_mc_io *mc_io,
242 struct opr_qry *qry);
244 #endif /* __FSL_DPCI_H */