2 * Freescale Layerscape MC I/O wrapper
4 * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5 * Author: German Rivera <German.Rivera@freescale.com>
7 * SPDX-License-Identifier: GPL-2.0+
13 #define DPRC_VER_MAJOR 5
14 #define DPRC_VER_MINOR 0
17 #define DPRC_CMDID_CLOSE 0x800
18 #define DPRC_CMDID_OPEN 0x805
19 #define DPRC_CMDID_CREATE 0x905
21 #define DPRC_CMDID_GET_ATTR 0x004
22 #define DPRC_CMDID_RESET_CONT 0x005
24 #define DPRC_CMDID_CREATE_CONT 0x151
25 #define DPRC_CMDID_DESTROY_CONT 0x152
26 #define DPRC_CMDID_GET_CONT_ID 0x830
27 #define DPRC_CMDID_GET_OBJ_COUNT 0x159
28 #define DPRC_CMDID_GET_OBJ 0x15A
29 #define DPRC_CMDID_GET_RES_COUNT 0x15B
30 #define DPRC_CMDID_GET_RES_IDS 0x15C
31 #define DPRC_CMDID_GET_OBJ_REG 0x15E
33 #define DPRC_CMDID_CONNECT 0x167
34 #define DPRC_CMDID_DISCONNECT 0x168
35 #define DPRC_CMDID_GET_CONNECTION 0x16C
37 /* cmd, param, offset, width, type, arg_name */
38 #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
39 MC_RSP_OP(cmd, 0, 0, 32, int, container_id)
41 /* cmd, param, offset, width, type, arg_name */
42 #define DPRC_CMD_OPEN(cmd, container_id) \
43 MC_CMD_OP(cmd, 0, 0, 32, int, container_id)
45 /* cmd, param, offset, width, type, arg_name */
46 #define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
48 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->icid); \
49 MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->options); \
50 MC_CMD_OP(cmd, 1, 32, 32, int, cfg->portal_id); \
51 MC_CMD_OP(cmd, 2, 0, 8, char, cfg->label[0]);\
52 MC_CMD_OP(cmd, 2, 8, 8, char, cfg->label[1]);\
53 MC_CMD_OP(cmd, 2, 16, 8, char, cfg->label[2]);\
54 MC_CMD_OP(cmd, 2, 24, 8, char, cfg->label[3]);\
55 MC_CMD_OP(cmd, 2, 32, 8, char, cfg->label[4]);\
56 MC_CMD_OP(cmd, 2, 40, 8, char, cfg->label[5]);\
57 MC_CMD_OP(cmd, 2, 48, 8, char, cfg->label[6]);\
58 MC_CMD_OP(cmd, 2, 56, 8, char, cfg->label[7]);\
59 MC_CMD_OP(cmd, 3, 0, 8, char, cfg->label[8]);\
60 MC_CMD_OP(cmd, 3, 8, 8, char, cfg->label[9]);\
61 MC_CMD_OP(cmd, 3, 16, 8, char, cfg->label[10]);\
62 MC_CMD_OP(cmd, 3, 24, 8, char, cfg->label[11]);\
63 MC_CMD_OP(cmd, 3, 32, 8, char, cfg->label[12]);\
64 MC_CMD_OP(cmd, 3, 40, 8, char, cfg->label[13]);\
65 MC_CMD_OP(cmd, 3, 48, 8, char, cfg->label[14]);\
66 MC_CMD_OP(cmd, 3, 56, 8, char, cfg->label[15]);\
69 /* cmd, param, offset, width, type, arg_name */
70 #define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\
72 MC_RSP_OP(cmd, 1, 0, 32, int, child_container_id); \
73 MC_RSP_OP(cmd, 2, 0, 64, uint64_t, child_portal_offset);\
76 /* cmd, param, offset, width, type, arg_name */
77 #define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \
78 MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
80 /* cmd, param, offset, width, type, arg_name */
81 #define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \
82 MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
84 /* cmd, param, offset, width, type, arg_name */
85 #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
87 MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \
88 MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
89 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
90 MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \
91 MC_RSP_OP(cmd, 2, 0, 16, uint16_t, attr->version.major);\
92 MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\
95 /* cmd, param, offset, width, type, arg_name */
96 #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
97 MC_RSP_OP(cmd, 0, 32, 32, int, obj_count)
99 /* cmd, param, offset, width, type, arg_name */
100 #define DPRC_CMD_GET_OBJ(cmd, obj_index) \
101 MC_CMD_OP(cmd, 0, 0, 32, int, obj_index)
103 /* cmd, param, offset, width, type, arg_name */
104 #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
106 MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
107 MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
108 MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
109 MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
110 MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
111 MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
112 MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
113 MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
114 MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
115 MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
116 MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
117 MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
118 MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
119 MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
120 MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
121 MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
122 MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
123 MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
124 MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
125 MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
126 MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
127 MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
128 MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
129 MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
130 MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
131 MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
132 MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
133 MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
134 MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
135 MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
136 MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
137 MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
138 MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
139 MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
140 MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
141 MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
142 MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
143 MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
144 MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
147 /* cmd, param, offset, width, type, arg_name */
148 #define DPRC_CMD_GET_RES_COUNT(cmd, type) \
150 MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
151 MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
152 MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
153 MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
154 MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
155 MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
156 MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
157 MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
158 MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
159 MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
160 MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
161 MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
162 MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
163 MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
164 MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
165 MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
168 /* cmd, param, offset, width, type, arg_name */
169 #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
170 MC_RSP_OP(cmd, 0, 0, 32, int, res_count)
172 /* cmd, param, offset, width, type, arg_name */
173 #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
175 MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
176 range_desc->iter_status); \
177 MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
178 MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
179 MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\
180 MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\
181 MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\
182 MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\
183 MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\
184 MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\
185 MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\
186 MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\
187 MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\
188 MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\
189 MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\
190 MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\
191 MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\
192 MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\
193 MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\
194 MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\
197 /* cmd, param, offset, width, type, arg_name */
198 #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
200 MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
201 range_desc->iter_status);\
202 MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
203 MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
206 /* cmd, param, offset, width, type, arg_name */
207 #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
209 MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
210 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\
211 MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
212 MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
213 MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
214 MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
215 MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
216 MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
217 MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
218 MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
219 MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
220 MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
221 MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
222 MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
223 MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
224 MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
225 MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
226 MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
229 /* param, offset, width, type, arg_name */
230 #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
232 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\
233 MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \
234 MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\
235 MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\
238 /* cmd, param, offset, width, type, arg_name */
239 #define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
241 MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
242 MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\
243 MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\
244 MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\
245 MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\
246 MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\
247 MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\
248 MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\
249 MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\
250 MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\
251 MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\
252 MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\
253 MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\
254 MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\
255 MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\
256 MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\
257 MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\
258 MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
259 MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
260 MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
261 MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
262 MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
263 MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
264 MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
265 MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
266 MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
267 MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
268 MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
269 MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
270 MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
271 MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
272 MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
273 MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
276 /* cmd, param, offset, width, type, arg_name */
277 #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
279 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
280 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
281 MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
282 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, endpoint2->if_id); \
283 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
284 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
285 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
286 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \
287 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \
288 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \
289 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \
290 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \
291 MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \
292 MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \
293 MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \
294 MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \
295 MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \
296 MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \
297 MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \
298 MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \
299 MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \
300 MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
301 MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \
302 MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \
303 MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \
304 MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \
305 MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \
306 MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \
307 MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \
308 MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \
309 MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \
310 MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \
311 MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \
312 MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \
313 MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \
314 MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \
315 MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \
316 MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \
319 /* cmd, param, offset, width, type, arg_name */
320 #define DPRC_CMD_DISCONNECT(cmd, endpoint) \
322 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \
323 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
324 MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \
325 MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \
326 MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \
327 MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \
328 MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \
329 MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \
330 MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \
331 MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \
332 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \
333 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \
334 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \
335 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \
336 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \
337 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \
338 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \
339 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \
342 /* cmd, param, offset, width, type, arg_name */
343 #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
345 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
346 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
347 MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
348 MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
349 MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
350 MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \
351 MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \
352 MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \
353 MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \
354 MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \
355 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \
356 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \
357 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \
358 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \
359 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \
360 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \
361 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \
362 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \
365 /* cmd, param, offset, width, type, arg_name */
366 #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
368 MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \
369 MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
370 MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \
371 MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \
372 MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \
373 MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \
374 MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \
375 MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \
376 MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \
377 MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \
378 MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \
379 MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \
380 MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \
381 MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \
382 MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \
383 MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \
384 MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \
385 MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \
386 MC_RSP_OP(cmd, 6, 0, 32, int, state); \
389 /* Data Path Resource Container API
390 * Contains DPRC API for managing and querying DPAA resources
396 * Set this value as the icid value in dprc_cfg structure when creating a
397 * container, in case the ICID is not selected by the user and should be
398 * allocated by the DPRC from the pool of ICIDs.
400 #define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0))
403 * Set this value as the portal_id value in dprc_cfg structure when creating a
404 * container, in case the portal ID is not specifically selected by the
405 * user and should be allocated by the DPRC from the pool of portal ids.
407 #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
410 * dprc_get_container_id() - Get container ID associated with a given portal.
411 * @mc_io: Pointer to MC portal's I/O object
412 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
413 * @container_id: Requested container ID
415 * Return: '0' on Success; Error code otherwise.
417 int dprc_get_container_id(struct fsl_mc_io *mc_io,
422 * dprc_open() - Open DPRC object for use
423 * @mc_io: Pointer to MC portal's I/O object
424 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
425 * @container_id: Container ID to open
426 * @token: Returned token of DPRC object
428 * Return: '0' on Success; Error code otherwise.
430 * @warning Required before any operation on the object.
432 int dprc_open(struct fsl_mc_io *mc_io,
438 * dprc_close() - Close the control session of the object
439 * @mc_io: Pointer to MC portal's I/O object
440 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
441 * @token: Token of DPRC object
443 * After this function is called, no further operations are
444 * allowed on the object without opening a new control session.
446 * Return: '0' on Success; Error code otherwise.
448 int dprc_close(struct fsl_mc_io *mc_io,
453 * Container general options
455 * These options may be selected at container creation by the container creator
456 * and can be retrieved using dprc_get_attributes()
459 /* Spawn Policy Option allowed - Indicates that the new container is allowed
460 * to spawn and have its own child containers.
462 #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
464 /* General Container allocation policy - Indicates that the new container is
465 * allowed to allocate requested resources from its parent container; if not
466 * set, the container is only allowed to use resources in its own pools; Note
467 * that this is a container's global policy, but the parent container may
468 * override it and set specific quota per resource type.
470 #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
472 /* Object initialization allowed - software context associated with this
473 * container is allowed to invoke object initialization operations.
475 #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
477 /* Topology change allowed - software context associated with this
478 * container is allowed to invoke topology operations, such as attach/detach
479 * of network objects.
481 #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
483 /* IOMMU bypass - indicates whether objects of this container are permitted
484 * to bypass the IOMMU.
486 #define DPRC_CFG_OPT_IOMMU_BYPASS 0x00000010
488 /* AIOP - Indicates that container belongs to AIOP. */
489 #define DPRC_CFG_OPT_AIOP 0x00000020
492 * struct dprc_cfg - Container configuration options
493 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
494 * ICID value is allocated by the DPRC
495 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
496 * portal ID is allocated by the DPRC
497 * @options: Combination of 'DPRC_CFG_OPT_<X>' options
498 * @label: Object's label
508 * dprc_create_container() - Create child container
509 * @mc_io: Pointer to MC portal's I/O object
510 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
511 * @token: Token of DPRC object
512 * @cfg: Child container configuration
513 * @child_container_id: Returned child container ID
514 * @child_portal_offset: Returned child portal offset from MC portal base
517 * Return: '0' on Success; Error code otherwise.
519 int dprc_create_container(struct fsl_mc_io *mc_io,
522 struct dprc_cfg *cfg,
523 int *child_container_id,
524 uint64_t *child_portal_offset);
527 * dprc_destroy_container() - Destroy child container.
528 * @mc_io: Pointer to MC portal's I/O object
529 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
530 * @token: Token of DPRC object
531 * @child_container_id: ID of the container to destroy
533 * This function terminates the child container, so following this call the
534 * child container ID becomes invalid.
537 * - All resources and objects of the destroyed container are returned to the
538 * parent container or destroyed if were created be the destroyed container.
539 * - This function destroy all the child containers of the specified
540 * container prior to destroying the container itself.
542 * warning: Only the parent container is allowed to destroy a child policy
543 * Container 0 can't be destroyed
545 * Return: '0' on Success; Error code otherwise.
548 int dprc_destroy_container(struct fsl_mc_io *mc_io,
551 int child_container_id);
554 * dprc_reset_container - Reset child container.
555 * @mc_io: Pointer to MC portal's I/O object
556 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
557 * @token: Token of DPRC object
558 * @child_container_id: ID of the container to reset
560 * In case a software context crashes or becomes non-responsive, the parent
561 * may wish to reset its resources container before the software context is
564 * This routine informs all objects assigned to the child container that the
565 * container is being reset, so they may perform any cleanup operations that are
566 * needed. All objects handles that were owned by the child container shall be
569 * Note that such request may be submitted even if the child software context
570 * has not crashed, but the resulting object cleanup operations will not be
573 * Return: '0' on Success; Error code otherwise.
575 int dprc_reset_container(struct fsl_mc_io *mc_io,
578 int child_container_id);
581 * struct dprc_attributes - Container attributes
582 * @container_id: Container's ID
583 * @icid: Container's ICID
584 * @portal_id: Container's portal ID
585 * @options: Container's options as set at container's creation
586 * @version: DPRC version
588 struct dprc_attributes {
594 * struct version - DPRC version
595 * @major: DPRC major version
596 * @minor: DPRC minor version
605 * dprc_get_attributes() - Obtains container attributes
606 * @mc_io: Pointer to MC portal's I/O object
607 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
608 * @token: Token of DPRC object
609 * @attributes: Returned container attributes
611 * Return: '0' on Success; Error code otherwise.
613 int dprc_get_attributes(struct fsl_mc_io *mc_io,
616 struct dprc_attributes *attributes);
619 * dprc_get_obj_count() - Obtains the number of objects in the DPRC
620 * @mc_io: Pointer to MC portal's I/O object
621 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
622 * @token: Token of DPRC object
623 * @obj_count: Number of objects assigned to the DPRC
625 * Return: '0' on Success; Error code otherwise.
627 int dprc_get_obj_count(struct fsl_mc_io *mc_io,
632 /* Objects Attributes Flags */
634 /* Opened state - Indicates that an object is open by at least one owner */
635 #define DPRC_OBJ_STATE_OPEN 0x00000001
636 /* Plugged state - Indicates that the object is plugged */
637 #define DPRC_OBJ_STATE_PLUGGED 0x00000002
640 * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
641 * @type: Type of object: NULL terminated string
642 * @id: ID of logical object resource
643 * @vendor: Object vendor identifier
644 * @ver_major: Major version number
645 * @ver_minor: Minor version number
646 * @irq_count: Number of interrupts supported by the object
647 * @region_count: Number of mappable regions supported by the object
648 * @state: Object state: combination of DPRC_OBJ_STATE_ states
649 * @label: Object label
651 struct dprc_obj_desc {
658 uint8_t region_count;
664 * dprc_get_obj() - Get general information on an object
665 * @mc_io: Pointer to MC portal's I/O object
666 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
667 * @token: Token of DPRC object
668 * @obj_index: Index of the object to be queried (< obj_count)
669 * @obj_desc: Returns the requested object descriptor
671 * The object descriptors are retrieved one by one by incrementing
672 * obj_index up to (not including) the value of obj_count returned
673 * from dprc_get_obj_count(). dprc_get_obj_count() must
674 * be called prior to dprc_get_obj().
676 * Return: '0' on Success; Error code otherwise.
678 int dprc_get_obj(struct fsl_mc_io *mc_io,
682 struct dprc_obj_desc *obj_desc);
685 * dprc_get_res_count() - Obtains the number of free resources that are
686 * assigned to this container, by pool type
687 * @mc_io: Pointer to MC portal's I/O object
688 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
689 * @token: Token of DPRC object
691 * @res_count: Returned number of free resources of the given
692 * resource type that are assigned to this DPRC
694 * Return: '0' on Success; Error code otherwise.
696 int dprc_get_res_count(struct fsl_mc_io *mc_io,
703 * enum dprc_iter_status - Iteration status
704 * @DPRC_ITER_STATUS_FIRST: Perform first iteration
705 * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
706 * @DPRC_ITER_STATUS_LAST: Indicates last iteration
708 enum dprc_iter_status {
709 DPRC_ITER_STATUS_FIRST = 0,
710 DPRC_ITER_STATUS_MORE = 1,
711 DPRC_ITER_STATUS_LAST = 2
715 * struct dprc_res_ids_range_desc - Resource ID range descriptor
716 * @base_id: Base resource ID of this range
717 * @last_id: Last resource ID of this range
718 * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
719 * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
720 * additional iterations are needed, until the returned marker is
721 * DPRC_ITER_STATUS_LAST
723 struct dprc_res_ids_range_desc {
726 enum dprc_iter_status iter_status;
730 * dprc_get_res_ids() - Obtains IDs of free resources in the container
731 * @mc_io: Pointer to MC portal's I/O object
732 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
733 * @token: Token of DPRC object
735 * @range_desc: range descriptor
737 * Return: '0' on Success; Error code otherwise.
739 int dprc_get_res_ids(struct fsl_mc_io *mc_io,
743 struct dprc_res_ids_range_desc *range_desc);
746 /* Cacheable - Indicates that region should be mapped as cacheable */
747 #define DPRC_REGION_CACHEABLE 0x00000001
750 * enum dprc_region_type - Region type
751 * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
752 * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
754 enum dprc_region_type {
755 DPRC_REGION_TYPE_MC_PORTAL,
756 DPRC_REGION_TYPE_QBMAN_PORTAL
760 * struct dprc_region_desc - Mappable region descriptor
761 * @base_offset: Region offset from region's base address.
762 * For DPMCP and DPRC objects, region base is offset from SoC MC portals
763 * base address; For DPIO, region base is offset from SoC QMan portals
765 * @size: Region size (in bytes)
766 * @flags: Region attributes
767 * @type: Portal region type
769 struct dprc_region_desc {
770 uint32_t base_offset;
773 enum dprc_region_type type;
777 * dprc_get_obj_region() - Get region information for a specified object.
778 * @mc_io: Pointer to MC portal's I/O object
779 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
780 * @token: Token of DPRC object
781 * @obj_type: Object type as returned in dprc_get_obj()
782 * @obj_id: Unique object instance as returned in dprc_get_obj()
783 * @region_index: The specific region to query
784 * @region_desc: Returns the requested region descriptor
786 * Return: '0' on Success; Error code otherwise.
788 int dprc_get_obj_region(struct fsl_mc_io *mc_io,
793 uint8_t region_index,
794 struct dprc_region_desc *region_desc);
796 * struct dprc_endpoint - Endpoint description for link connect/disconnect
798 * @type: Endpoint object type: NULL terminated string
799 * @id: Endpoint object ID
800 * @if_id: Interface ID; should be set for endpoints with multiple
801 * interfaces ("dpsw", "dpdmux"); for others, always set to 0
803 struct dprc_endpoint {
810 * struct dprc_connection_cfg - Connection configuration.
811 * Used for virtual connections only
812 * @committed_rate: Committed rate (Mbits/s)
813 * @max_rate: Maximum rate (Mbits/s)
815 struct dprc_connection_cfg {
816 uint32_t committed_rate;
821 * dprc_connect() - Connect two endpoints to create a network link between them
822 * @mc_io: Pointer to MC portal's I/O object
823 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
824 * @token: Token of DPRC object
825 * @endpoint1: Endpoint 1 configuration parameters
826 * @endpoint2: Endpoint 2 configuration parameters
827 * @cfg: Connection configuration. The connection configuration is ignored for
828 * connections made to DPMAC objects, where rate is retrieved from the
831 * Return: '0' on Success; Error code otherwise.
833 int dprc_connect(struct fsl_mc_io *mc_io,
836 const struct dprc_endpoint *endpoint1,
837 const struct dprc_endpoint *endpoint2,
838 const struct dprc_connection_cfg *cfg);
841 * dprc_disconnect() - Disconnect one endpoint to remove its network connection
842 * @mc_io: Pointer to MC portal's I/O object
843 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
844 * @token: Token of DPRC object
845 * @endpoint: Endpoint configuration parameters
847 * Return: '0' on Success; Error code otherwise.
849 int dprc_disconnect(struct fsl_mc_io *mc_io,
852 const struct dprc_endpoint *endpoint);
855 * dprc_get_connection() - Get connected endpoint and link status if connection
857 * @mc_io: Pointer to MC portal's I/O object
858 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
859 * @token: Token of DPRC object
860 * @endpoint1: Endpoint 1 configuration parameters
861 * @endpoint2: Returned endpoint 2 configuration parameters
862 * @state: Returned link state: 1 - link is up, 0 - link is down
864 * Return: '0' on Success; -ENAVAIL if connection does not exist.
866 int dprc_get_connection(struct fsl_mc_io *mc_io,
869 const struct dprc_endpoint *endpoint1,
870 struct dprc_endpoint *endpoint2,
873 #endif /* _FSL_DPRC_H */