1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright 2013-2016 Freescale Semiconductor, Inc.
11 #define DPIO_VER_MAJOR 4
12 #define DPIO_VER_MINOR 2
15 #define DPIO_CMDID_CLOSE 0x8001
16 #define DPIO_CMDID_OPEN 0x8031
17 #define DPIO_CMDID_CREATE 0x9031
18 #define DPIO_CMDID_DESTROY 0x9831
19 #define DPIO_CMDID_GET_API_VERSION 0xa031
21 #define DPIO_CMDID_ENABLE 0x0021
22 #define DPIO_CMDID_DISABLE 0x0031
23 #define DPIO_CMDID_GET_ATTR 0x0041
24 #define DPIO_CMDID_RESET 0x0051
26 /* cmd, param, offset, width, type, arg_name */
27 #define DPIO_CMD_OPEN(cmd, dpio_id) \
28 MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
30 /* cmd, param, offset, width, type, arg_name */
31 #define DPIO_CMD_CREATE(cmd, cfg) \
33 MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
35 MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
38 /* cmd, param, offset, width, type, arg_name */
39 #define DPIO_RSP_GET_ATTR(cmd, attr) \
41 MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
42 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
43 MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
44 MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
45 MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
46 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
47 MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
50 /* Data Path I/O Portal API
51 * Contains initialization APIs and runtime control APIs for DPIO
57 * dpio_open() - Open a control session for the specified object
58 * @mc_io: Pointer to MC portal's I/O object
59 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
60 * @dpio_id: DPIO unique ID
61 * @token: Returned token; use in subsequent API calls
63 * This function can be used to open a control session for an
64 * already created object; an object may have been declared in
65 * the DPL or by calling the dpio_create() function.
66 * This function returns a unique authentication token,
67 * associated with the specific object ID and the specific MC
68 * portal; this token must be used in all subsequent commands for
69 * this specific object.
71 * Return: '0' on Success; Error code otherwise.
73 int dpio_open(struct fsl_mc_io *mc_io,
79 * dpio_close() - Close the control session of the object
80 * @mc_io: Pointer to MC portal's I/O object
81 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
82 * @token: Token of DPIO object
84 * Return: '0' on Success; Error code otherwise.
86 int dpio_close(struct fsl_mc_io *mc_io,
91 * enum dpio_channel_mode - DPIO notification channel mode
92 * @DPIO_NO_CHANNEL: No support for notification channel
93 * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
94 * dedicated channel in the DPIO; user should point the queue's
95 * destination in the relevant interface to this DPIO
97 enum dpio_channel_mode {
99 DPIO_LOCAL_CHANNEL = 1,
103 * struct dpio_cfg - Structure representing DPIO configuration
104 * @channel_mode: Notification channel mode
105 * @num_priorities: Number of priorities for the notification channel (1-8);
106 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
109 enum dpio_channel_mode channel_mode;
110 uint8_t num_priorities;
114 * dpio_create() - Create the DPIO object.
115 * @mc_io: Pointer to MC portal's I/O object
116 * @token: Authentication token.
117 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
118 * @cfg: Configuration structure
119 * @obj_id: Returned obj_id; use in subsequent API calls
121 * Create the DPIO object, allocate required resources and
122 * perform required initialization.
124 * The object can be created either by declaring it in the
125 * DPL file, or by calling this function.
127 * This function returns a unique authentication token,
128 * associated with the specific object ID and the specific MC
129 * portal; this token must be used in all subsequent calls to
130 * this specific object. For objects that are created using the
131 * DPL file, call dpio_open() function to get an authentication
134 * Return: '0' on Success; Error code otherwise.
136 int dpio_create(struct fsl_mc_io *mc_io,
139 const struct dpio_cfg *cfg,
143 * dpio_destroy() - Destroy the DPIO object and release all its resources.
144 * @mc_io: Pointer to MC portal's I/O object
145 * @token: Authentication token.
146 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
147 * @obj_id: Object ID of DPIO
149 * Return: '0' on Success; Error code otherwise
151 int dpio_destroy(struct fsl_mc_io *mc_io,
157 * dpio_enable() - Enable the DPIO, allow I/O portal operations.
158 * @mc_io: Pointer to MC portal's I/O object
159 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
160 * @token: Token of DPIO object
162 * Return: '0' on Success; Error code otherwise
164 int dpio_enable(struct fsl_mc_io *mc_io,
169 * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
170 * @mc_io: Pointer to MC portal's I/O object
171 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
172 * @token: Token of DPIO object
174 * Return: '0' on Success; Error code otherwise
176 int dpio_disable(struct fsl_mc_io *mc_io,
181 * dpio_reset() - Reset the DPIO, returns the object to initial state.
182 * @mc_io: Pointer to MC portal's I/O object
183 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
184 * @token: Token of DPIO object
186 * Return: '0' on Success; Error code otherwise.
188 int dpio_reset(struct fsl_mc_io *mc_io,
193 * struct dpio_attr - Structure representing DPIO attributes
194 * @id: DPIO object ID
195 * @version: DPIO version
196 * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
197 * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
198 * @qbman_portal_id: Software portal ID
199 * @channel_mode: Notification channel mode
200 * @num_priorities: Number of priorities for the notification channel (1-8);
201 * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
202 * @qbman_version: QBMAN version
206 uint64_t qbman_portal_ce_offset;
207 uint64_t qbman_portal_ci_offset;
208 uint16_t qbman_portal_id;
209 enum dpio_channel_mode channel_mode;
210 uint8_t num_priorities;
211 uint32_t qbman_version;
215 * dpio_get_attributes() - Retrieve DPIO attributes
216 * @mc_io: Pointer to MC portal's I/O object
217 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
218 * @token: Token of DPIO object
219 * @attr: Returned object's attributes
221 * Return: '0' on Success; Error code otherwise
223 int dpio_get_attributes(struct fsl_mc_io *mc_io,
226 struct dpio_attr *attr);
229 * dpio_get_api_version - Retrieve DPIO Major and Minor version info.
231 * @mc_io: Pointer to MC portal's I/O object
232 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
233 * @major_ver: DPIO major version
234 * @minor_ver: DPIO minor version
236 * Return: '0' on Success; Error code otherwise.
238 int dpio_get_api_version(struct fsl_mc_io *mc_io,
243 #endif /* _FSL_DPIO_H */