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 * struct dpci_peer_attr - Structure representing the peer DPCI attributes
113 * @peer_id: DPCI peer id; if no peer is connected returns (-1)
114 * @num_of_priorities: The pper's number of receive priorities; determines the
115 * number of transmit priorities for the local DPCI object
117 struct dpci_peer_attr {
119 uint8_t num_of_priorities;
122 int dpci_get_peer_attributes(struct fsl_mc_io *mc_io,
125 struct dpci_peer_attr *attr);
127 int dpci_get_link_state(struct fsl_mc_io *mc_io,
133 * enum dpci_dest - DPCI destination types
134 * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
135 * and does not generate FQDAN notifications; user is
136 * expected to dequeue from the queue based on polling or
137 * other user-defined method
138 * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
139 * notifications to the specified DPIO; user is expected
140 * to dequeue from the queue only after notification is
142 * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
143 * FQDAN notifications, but is connected to the specified
145 * user is expected to dequeue from the DPCON channel
154 * struct dpci_dest_cfg - Structure representing DPCI destination configuration
155 * @dest_type: Destination type
156 * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
157 * @priority: Priority selection within the DPIO or DPCON channel; valid
158 * values are 0-1 or 0-7, depending on the number of priorities
159 * in that channel; not relevant for 'DPCI_DEST_NONE' option
161 struct dpci_dest_cfg {
162 enum dpci_dest dest_type;
167 /** DPCI queue modification options */
170 * Select to modify the user's context associated with the queue
172 #define DPCI_QUEUE_OPT_USER_CTX 0x00000001
175 * Select to modify the queue's destination
177 #define DPCI_QUEUE_OPT_DEST 0x00000002
180 * Set the queue to hold active mode.
182 #define DPCI_QUEUE_OPT_HOLD_ACTIVE 0x00000004
185 * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
186 * @options: Flags representing the suggested modifications to the queue;
187 * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
188 * @user_ctx: User context value provided in the frame descriptor of each
190 * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
192 * @dest_cfg: Queue destination parameters;
193 * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
194 * @order_preservation_en: order preservation configuration for the rx queue
195 * valid only if 'DPCI_QUEUE_OPT_HOLD_ACTIVE' is contained in 'options'
197 struct dpci_rx_queue_cfg {
200 struct dpci_dest_cfg dest_cfg;
201 int order_preservation_en;
204 int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
208 const struct dpci_rx_queue_cfg *cfg);
211 * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
212 * @user_ctx: User context value provided in the frame descriptor of each
214 * @dest_cfg: Queue destination configuration
215 * @fqid: Virtual FQID value to be used for dequeue operations
217 struct dpci_rx_queue_attr {
219 struct dpci_dest_cfg dest_cfg;
223 int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
227 struct dpci_rx_queue_attr *attr);
230 * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
231 * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
232 * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
233 * the selected priority exceeds the number of priorities of the
236 struct dpci_tx_queue_attr {
240 int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
244 struct dpci_tx_queue_attr *attr);
246 int dpci_get_api_version(struct fsl_mc_io *mc_io,
249 uint16_t *minor_ver);
251 int dpci_set_opr(struct fsl_mc_io *mc_io,
256 struct opr_cfg *cfg);
258 int dpci_get_opr(struct fsl_mc_io *mc_io,
263 struct opr_qry *qry);
265 #endif /* __FSL_DPCI_H */