xref: /openbmc/u-boot/include/fsl-mc/fsl_dprc.h (revision 0bdea7c4)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Freescale Layerscape MC I/O wrapper
4  *
5  * Copyright 2013-2016 Freescale Semiconductor, Inc.
6  * Copyright 2017 NXP
7  */
8 #ifndef _FSL_DPRC_H
9 #define _FSL_DPRC_H
10 
11 /* DPRC Version */
12 #define DPRC_VER_MAJOR				6
13 #define DPRC_VER_MINOR				1
14 
15 /* Command IDs */
16 #define DPRC_CMDID_CLOSE			0x8001
17 #define DPRC_CMDID_OPEN				0x8051
18 #define DPRC_CMDID_CREATE			0x9051
19 
20 #define DPRC_CMDID_GET_ATTR			0x0041
21 #define DPRC_CMDID_RESET_CONT			0x0051
22 #define DPRC_CMDID_GET_API_VERSION              0xa051
23 
24 #define DPRC_CMDID_CREATE_CONT			0x1511
25 #define DPRC_CMDID_DESTROY_CONT			0x1521
26 #define DPRC_CMDID_GET_CONT_ID			0x8301
27 #define DPRC_CMDID_GET_OBJ_COUNT		0x1591
28 #define DPRC_CMDID_GET_OBJ			0x15A1
29 #define DPRC_CMDID_GET_RES_COUNT		0x15B1
30 #define DPRC_CMDID_GET_RES_IDS			0x15C1
31 #define DPRC_CMDID_GET_OBJ_REG			0x15E1
32 
33 #define DPRC_CMDID_CONNECT			0x1671
34 #define DPRC_CMDID_DISCONNECT			0x1681
35 #define DPRC_CMDID_GET_CONNECTION		0x16C1
36 
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)
40 
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)
44 
45 /*                cmd, param, offset, width, type, arg_name */
46 #define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
47 do { \
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]);\
67 } while (0)
68 
69 /*                cmd, param, offset, width, type, arg_name */
70 #define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\
71 do { \
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);\
74 } while (0)
75 
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)
79 
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)
83 
84 /*                cmd, param, offset, width, type, arg_name */
85 #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
86 do { \
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 } while (0)
92 
93 /*                cmd, param, offset, width, type, arg_name */
94 #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
95 	MC_RSP_OP(cmd, 0, 32, 32, int,      obj_count)
96 
97 /*                cmd, param, offset, width, type, arg_name */
98 #define DPRC_CMD_GET_OBJ(cmd, obj_index) \
99 	MC_CMD_OP(cmd, 0, 0,  32, int,	    obj_index)
100 
101 /*                cmd, param, offset, width, type, arg_name */
102 #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
103 do { \
104 	MC_RSP_OP(cmd, 0, 32, 32, int,	    obj_desc->id); \
105 	MC_RSP_OP(cmd, 1, 0,  16, uint16_t, obj_desc->vendor); \
106 	MC_RSP_OP(cmd, 1, 16, 8,  uint8_t,  obj_desc->irq_count); \
107 	MC_RSP_OP(cmd, 1, 24, 8,  uint8_t,  obj_desc->region_count); \
108 	MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
109 	MC_RSP_OP(cmd, 2, 0,  16, uint16_t, obj_desc->ver_major);\
110 	MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
111 	MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
112 	MC_RSP_OP(cmd, 3, 0,  8,  char,	    obj_desc->type[0]);\
113 	MC_RSP_OP(cmd, 3, 8,  8,  char,	    obj_desc->type[1]);\
114 	MC_RSP_OP(cmd, 3, 16, 8,  char,	    obj_desc->type[2]);\
115 	MC_RSP_OP(cmd, 3, 24, 8,  char,	    obj_desc->type[3]);\
116 	MC_RSP_OP(cmd, 3, 32, 8,  char,	    obj_desc->type[4]);\
117 	MC_RSP_OP(cmd, 3, 40, 8,  char,	    obj_desc->type[5]);\
118 	MC_RSP_OP(cmd, 3, 48, 8,  char,	    obj_desc->type[6]);\
119 	MC_RSP_OP(cmd, 3, 56, 8,  char,	    obj_desc->type[7]);\
120 	MC_RSP_OP(cmd, 4, 0,  8,  char,	    obj_desc->type[8]);\
121 	MC_RSP_OP(cmd, 4, 8,  8,  char,	    obj_desc->type[9]);\
122 	MC_RSP_OP(cmd, 4, 16, 8,  char,	    obj_desc->type[10]);\
123 	MC_RSP_OP(cmd, 4, 24, 8,  char,	    obj_desc->type[11]);\
124 	MC_RSP_OP(cmd, 4, 32, 8,  char,	    obj_desc->type[12]);\
125 	MC_RSP_OP(cmd, 4, 40, 8,  char,	    obj_desc->type[13]);\
126 	MC_RSP_OP(cmd, 4, 48, 8,  char,	    obj_desc->type[14]);\
127 	MC_RSP_OP(cmd, 4, 56, 8,  char,	    obj_desc->type[15]);\
128 	MC_RSP_OP(cmd, 5, 0,  8,  char,	    obj_desc->label[0]);\
129 	MC_RSP_OP(cmd, 5, 8,  8,  char,	    obj_desc->label[1]);\
130 	MC_RSP_OP(cmd, 5, 16, 8,  char,	    obj_desc->label[2]);\
131 	MC_RSP_OP(cmd, 5, 24, 8,  char,	    obj_desc->label[3]);\
132 	MC_RSP_OP(cmd, 5, 32, 8,  char,	    obj_desc->label[4]);\
133 	MC_RSP_OP(cmd, 5, 40, 8,  char,	    obj_desc->label[5]);\
134 	MC_RSP_OP(cmd, 5, 48, 8,  char,	    obj_desc->label[6]);\
135 	MC_RSP_OP(cmd, 5, 56, 8,  char,	    obj_desc->label[7]);\
136 	MC_RSP_OP(cmd, 6, 0,  8,  char,	    obj_desc->label[8]);\
137 	MC_RSP_OP(cmd, 6, 8,  8,  char,	    obj_desc->label[9]);\
138 	MC_RSP_OP(cmd, 6, 16, 8,  char,	    obj_desc->label[10]);\
139 	MC_RSP_OP(cmd, 6, 24, 8,  char,	    obj_desc->label[11]);\
140 	MC_RSP_OP(cmd, 6, 32, 8,  char,	    obj_desc->label[12]);\
141 	MC_RSP_OP(cmd, 6, 40, 8,  char,	    obj_desc->label[13]);\
142 	MC_RSP_OP(cmd, 6, 48, 8,  char,	    obj_desc->label[14]);\
143 	MC_RSP_OP(cmd, 6, 56, 8,  char,	    obj_desc->label[15]);\
144 } while (0)
145 
146 /*                cmd, param, offset, width, type, arg_name */
147 #define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \
148 do { \
149 	MC_CMD_OP(cmd, 0, 0,  32, int,	    obj_id);\
150 	MC_CMD_OP(cmd, 1, 0,  8,  char,     obj_type[0]);\
151 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    obj_type[1]);\
152 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    obj_type[2]);\
153 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    obj_type[3]);\
154 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    obj_type[4]);\
155 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    obj_type[5]);\
156 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    obj_type[6]);\
157 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    obj_type[7]);\
158 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    obj_type[8]);\
159 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    obj_type[9]);\
160 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    obj_type[10]);\
161 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    obj_type[11]);\
162 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    obj_type[12]);\
163 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    obj_type[13]);\
164 	MC_CMD_OP(cmd, 2, 48, 8,  char,     obj_type[14]);\
165 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    obj_type[15]);\
166 } while (0)
167 
168 /*                cmd, param, offset, width, type, arg_name */
169 #define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \
170 do { \
171 	MC_RSP_OP(cmd, 0, 32, 32, int,	    obj_desc->id); \
172 	MC_RSP_OP(cmd, 1, 0,  16, uint16_t, obj_desc->vendor); \
173 	MC_RSP_OP(cmd, 1, 16, 8,  uint8_t,  obj_desc->irq_count); \
174 	MC_RSP_OP(cmd, 1, 24, 8,  uint8_t,  obj_desc->region_count); \
175 	MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
176 	MC_RSP_OP(cmd, 2, 0,  16, uint16_t, obj_desc->ver_major);\
177 	MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
178 	MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
179 	MC_RSP_OP(cmd, 3, 0,  8,  char,	    obj_desc->type[0]);\
180 	MC_RSP_OP(cmd, 3, 8,  8,  char,	    obj_desc->type[1]);\
181 	MC_RSP_OP(cmd, 3, 16, 8,  char,	    obj_desc->type[2]);\
182 	MC_RSP_OP(cmd, 3, 24, 8,  char,	    obj_desc->type[3]);\
183 	MC_RSP_OP(cmd, 3, 32, 8,  char,	    obj_desc->type[4]);\
184 	MC_RSP_OP(cmd, 3, 40, 8,  char,	    obj_desc->type[5]);\
185 	MC_RSP_OP(cmd, 3, 48, 8,  char,	    obj_desc->type[6]);\
186 	MC_RSP_OP(cmd, 3, 56, 8,  char,	    obj_desc->type[7]);\
187 	MC_RSP_OP(cmd, 4, 0,  8,  char,	    obj_desc->type[8]);\
188 	MC_RSP_OP(cmd, 4, 8,  8,  char,	    obj_desc->type[9]);\
189 	MC_RSP_OP(cmd, 4, 16, 8,  char,	    obj_desc->type[10]);\
190 	MC_RSP_OP(cmd, 4, 24, 8,  char,	    obj_desc->type[11]);\
191 	MC_RSP_OP(cmd, 4, 32, 8,  char,	    obj_desc->type[12]);\
192 	MC_RSP_OP(cmd, 4, 40, 8,  char,	    obj_desc->type[13]);\
193 	MC_RSP_OP(cmd, 4, 48, 8,  char,	    obj_desc->type[14]);\
194 	MC_RSP_OP(cmd, 4, 56, 8,  char,	    obj_desc->type[15]);\
195 	MC_RSP_OP(cmd, 5, 0,  8,  char,	    obj_desc->label[0]);\
196 	MC_RSP_OP(cmd, 5, 8,  8,  char,	    obj_desc->label[1]);\
197 	MC_RSP_OP(cmd, 5, 16, 8,  char,	    obj_desc->label[2]);\
198 	MC_RSP_OP(cmd, 5, 24, 8,  char,	    obj_desc->label[3]);\
199 	MC_RSP_OP(cmd, 5, 32, 8,  char,	    obj_desc->label[4]);\
200 	MC_RSP_OP(cmd, 5, 40, 8,  char,	    obj_desc->label[5]);\
201 	MC_RSP_OP(cmd, 5, 48, 8,  char,	    obj_desc->label[6]);\
202 	MC_RSP_OP(cmd, 5, 56, 8,  char,	    obj_desc->label[7]);\
203 	MC_RSP_OP(cmd, 6, 0,  8,  char,	    obj_desc->label[8]);\
204 	MC_RSP_OP(cmd, 6, 8,  8,  char,	    obj_desc->label[9]);\
205 	MC_RSP_OP(cmd, 6, 16, 8,  char,	    obj_desc->label[10]);\
206 	MC_RSP_OP(cmd, 6, 24, 8,  char,	    obj_desc->label[11]);\
207 	MC_RSP_OP(cmd, 6, 32, 8,  char,	    obj_desc->label[12]);\
208 	MC_RSP_OP(cmd, 6, 40, 8,  char,	    obj_desc->label[13]);\
209 	MC_RSP_OP(cmd, 6, 48, 8,  char,	    obj_desc->label[14]);\
210 	MC_RSP_OP(cmd, 6, 56, 8,  char,	    obj_desc->label[15]);\
211 } while (0)
212 
213 /*                cmd, param, offset, width, type, arg_name */
214 #define DPRC_CMD_GET_RES_COUNT(cmd, type) \
215 do { \
216 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    type[0]);\
217 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    type[1]);\
218 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    type[2]);\
219 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    type[3]);\
220 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    type[4]);\
221 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    type[5]);\
222 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    type[6]);\
223 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    type[7]);\
224 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    type[8]);\
225 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    type[9]);\
226 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    type[10]);\
227 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    type[11]);\
228 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    type[12]);\
229 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    type[13]);\
230 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    type[14]);\
231 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    type[15]);\
232 } while (0)
233 
234 /*                cmd, param, offset, width, type, arg_name */
235 #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
236 	MC_RSP_OP(cmd, 0, 0,  32, int,	    res_count)
237 
238 /*                cmd, param, offset, width, type, arg_name */
239 #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
240 do { \
241 	MC_CMD_OP(cmd, 0, 42, 7,  enum dprc_iter_status, \
242 					    range_desc->iter_status); \
243 	MC_CMD_OP(cmd, 1, 0,  32, int,	    range_desc->base_id); \
244 	MC_CMD_OP(cmd, 1, 32, 32, int,	    range_desc->last_id);\
245 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    type[0]);\
246 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    type[1]);\
247 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    type[2]);\
248 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    type[3]);\
249 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    type[4]);\
250 	MC_CMD_OP(cmd, 2, 40, 8,  char,     type[5]);\
251 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    type[6]);\
252 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    type[7]);\
253 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    type[8]);\
254 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    type[9]);\
255 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    type[10]);\
256 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    type[11]);\
257 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    type[12]);\
258 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    type[13]);\
259 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    type[14]);\
260 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    type[15]);\
261 } while (0)
262 
263 /*                cmd, param, offset, width, type, arg_name */
264 #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
265 do { \
266 	MC_RSP_OP(cmd, 0, 42, 7,  enum dprc_iter_status, \
267 					    range_desc->iter_status);\
268 	MC_RSP_OP(cmd, 1, 0,  32, int,	    range_desc->base_id); \
269 	MC_RSP_OP(cmd, 1, 32, 32, int,	    range_desc->last_id);\
270 } while (0)
271 
272 /*                cmd, param, offset, width, type, arg_name */
273 #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
274 do { \
275 	MC_CMD_OP(cmd, 0, 0,  32, int,	    obj_id); \
276 	MC_CMD_OP(cmd, 0, 48, 8,  uint8_t,  region_index);\
277 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    obj_type[0]);\
278 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    obj_type[1]);\
279 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    obj_type[2]);\
280 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    obj_type[3]);\
281 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    obj_type[4]);\
282 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    obj_type[5]);\
283 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    obj_type[6]);\
284 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    obj_type[7]);\
285 	MC_CMD_OP(cmd, 4, 0,  8,  char,	    obj_type[8]);\
286 	MC_CMD_OP(cmd, 4, 8,  8,  char,	    obj_type[9]);\
287 	MC_CMD_OP(cmd, 4, 16, 8,  char,	    obj_type[10]);\
288 	MC_CMD_OP(cmd, 4, 24, 8,  char,	    obj_type[11]);\
289 	MC_CMD_OP(cmd, 4, 32, 8,  char,	    obj_type[12]);\
290 	MC_CMD_OP(cmd, 4, 40, 8,  char,	    obj_type[13]);\
291 	MC_CMD_OP(cmd, 4, 48, 8,  char,	    obj_type[14]);\
292 	MC_CMD_OP(cmd, 4, 56, 8,  char,	    obj_type[15]);\
293 } while (0)
294 
295 /*	param, offset, width,	type,		arg_name */
296 #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
297 do { \
298 	MC_RSP_OP(cmd, 1, 0,  32, uint32_t, region_desc->base_offset);\
299 	MC_RSP_OP(cmd, 2, 0,  32, uint32_t, region_desc->size); \
300 	MC_RSP_OP(cmd, 2, 32, 4,  enum dprc_region_type, region_desc->type);\
301 	MC_RSP_OP(cmd, 3, 0,  32, uint32_t, region_desc->flags);\
302 } while (0)
303 
304 /*                cmd, param, offset, width, type, arg_name */
305 #define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
306 do { \
307 	MC_CMD_OP(cmd, 0, 0,  32, int,      obj_id); \
308 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    label[0]);\
309 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    label[1]);\
310 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    label[2]);\
311 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    label[3]);\
312 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    label[4]);\
313 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    label[5]);\
314 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    label[6]);\
315 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    label[7]);\
316 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    label[8]);\
317 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    label[9]);\
318 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    label[10]);\
319 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    label[11]);\
320 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    label[12]);\
321 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    label[13]);\
322 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    label[14]);\
323 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    label[15]);\
324 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    obj_type[0]);\
325 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    obj_type[1]);\
326 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    obj_type[2]);\
327 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    obj_type[3]);\
328 	MC_CMD_OP(cmd, 3, 32, 8,  char,	    obj_type[4]);\
329 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    obj_type[5]);\
330 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    obj_type[6]);\
331 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    obj_type[7]);\
332 	MC_CMD_OP(cmd, 4, 0,  8,  char,	    obj_type[8]);\
333 	MC_CMD_OP(cmd, 4, 8,  8,  char,	    obj_type[9]);\
334 	MC_CMD_OP(cmd, 4, 16, 8,  char,	    obj_type[10]);\
335 	MC_CMD_OP(cmd, 4, 24, 8,  char,	    obj_type[11]);\
336 	MC_CMD_OP(cmd, 4, 32, 8,  char,	    obj_type[12]);\
337 	MC_CMD_OP(cmd, 4, 40, 8,  char,	    obj_type[13]);\
338 	MC_CMD_OP(cmd, 4, 48, 8,  char,	    obj_type[14]);\
339 	MC_CMD_OP(cmd, 4, 56, 8,  char,	    obj_type[15]);\
340 } while (0)
341 
342 /*                cmd, param, offset, width, type, arg_name */
343 #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
344 do { \
345 	MC_CMD_OP(cmd, 0, 0,  32, int,      endpoint1->id); \
346 	MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->if_id); \
347 	MC_CMD_OP(cmd, 1, 0,  32, int,	    endpoint2->id); \
348 	MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->if_id); \
349 	MC_CMD_OP(cmd, 2, 0,  8,  char,     endpoint1->type[0]); \
350 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint1->type[1]); \
351 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint1->type[2]); \
352 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint1->type[3]); \
353 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    endpoint1->type[4]); \
354 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint1->type[5]); \
355 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint1->type[6]); \
356 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint1->type[7]); \
357 	MC_CMD_OP(cmd, 3, 0,  8,  char,	    endpoint1->type[8]); \
358 	MC_CMD_OP(cmd, 3, 8,  8,  char,	    endpoint1->type[9]); \
359 	MC_CMD_OP(cmd, 3, 16, 8,  char,	    endpoint1->type[10]); \
360 	MC_CMD_OP(cmd, 3, 24, 8,  char,	    endpoint1->type[11]); \
361 	MC_CMD_OP(cmd, 3, 32, 8,  char,     endpoint1->type[12]); \
362 	MC_CMD_OP(cmd, 3, 40, 8,  char,	    endpoint1->type[13]); \
363 	MC_CMD_OP(cmd, 3, 48, 8,  char,	    endpoint1->type[14]); \
364 	MC_CMD_OP(cmd, 3, 56, 8,  char,	    endpoint1->type[15]); \
365 	MC_CMD_OP(cmd, 4, 0,  32, uint32_t, cfg->max_rate); \
366 	MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
367 	MC_CMD_OP(cmd, 5, 0,  8,  char,	    endpoint2->type[0]); \
368 	MC_CMD_OP(cmd, 5, 8,  8,  char,	    endpoint2->type[1]); \
369 	MC_CMD_OP(cmd, 5, 16, 8,  char,	    endpoint2->type[2]); \
370 	MC_CMD_OP(cmd, 5, 24, 8,  char,	    endpoint2->type[3]); \
371 	MC_CMD_OP(cmd, 5, 32, 8,  char,	    endpoint2->type[4]); \
372 	MC_CMD_OP(cmd, 5, 40, 8,  char,	    endpoint2->type[5]); \
373 	MC_CMD_OP(cmd, 5, 48, 8,  char,	    endpoint2->type[6]); \
374 	MC_CMD_OP(cmd, 5, 56, 8,  char,	    endpoint2->type[7]); \
375 	MC_CMD_OP(cmd, 6, 0,  8,  char,	    endpoint2->type[8]); \
376 	MC_CMD_OP(cmd, 6, 8,  8,  char,	    endpoint2->type[9]); \
377 	MC_CMD_OP(cmd, 6, 16, 8,  char,	    endpoint2->type[10]); \
378 	MC_CMD_OP(cmd, 6, 24, 8,  char,	    endpoint2->type[11]); \
379 	MC_CMD_OP(cmd, 6, 32, 8,  char,	    endpoint2->type[12]); \
380 	MC_CMD_OP(cmd, 6, 40, 8,  char,	    endpoint2->type[13]); \
381 	MC_CMD_OP(cmd, 6, 48, 8,  char,	    endpoint2->type[14]); \
382 	MC_CMD_OP(cmd, 6, 56, 8,  char,	    endpoint2->type[15]); \
383 } while (0)
384 
385 /*                cmd, param, offset, width, type, arg_name */
386 #define DPRC_CMD_DISCONNECT(cmd, endpoint) \
387 do { \
388 	MC_CMD_OP(cmd, 0, 0,  32, int,	    endpoint->id); \
389 	MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
390 	MC_CMD_OP(cmd, 1, 0,  8,  char,	    endpoint->type[0]); \
391 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    endpoint->type[1]); \
392 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    endpoint->type[2]); \
393 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    endpoint->type[3]); \
394 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    endpoint->type[4]); \
395 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    endpoint->type[5]); \
396 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    endpoint->type[6]); \
397 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    endpoint->type[7]); \
398 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    endpoint->type[8]); \
399 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint->type[9]); \
400 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint->type[10]); \
401 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint->type[11]); \
402 	MC_CMD_OP(cmd, 2, 32, 8,  char,	    endpoint->type[12]); \
403 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint->type[13]); \
404 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint->type[14]); \
405 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint->type[15]); \
406 } while (0)
407 
408 /*                cmd, param, offset, width, type, arg_name */
409 #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
410 do { \
411 	MC_CMD_OP(cmd, 0, 0,  32, int,	    endpoint1->id); \
412 	MC_CMD_OP(cmd, 0, 32, 32, int,	    endpoint1->if_id); \
413 	MC_CMD_OP(cmd, 1, 0,  8,  char,     endpoint1->type[0]); \
414 	MC_CMD_OP(cmd, 1, 8,  8,  char,	    endpoint1->type[1]); \
415 	MC_CMD_OP(cmd, 1, 16, 8,  char,	    endpoint1->type[2]); \
416 	MC_CMD_OP(cmd, 1, 24, 8,  char,	    endpoint1->type[3]); \
417 	MC_CMD_OP(cmd, 1, 32, 8,  char,	    endpoint1->type[4]); \
418 	MC_CMD_OP(cmd, 1, 40, 8,  char,	    endpoint1->type[5]); \
419 	MC_CMD_OP(cmd, 1, 48, 8,  char,	    endpoint1->type[6]); \
420 	MC_CMD_OP(cmd, 1, 56, 8,  char,	    endpoint1->type[7]); \
421 	MC_CMD_OP(cmd, 2, 0,  8,  char,	    endpoint1->type[8]); \
422 	MC_CMD_OP(cmd, 2, 8,  8,  char,	    endpoint1->type[9]); \
423 	MC_CMD_OP(cmd, 2, 16, 8,  char,	    endpoint1->type[10]); \
424 	MC_CMD_OP(cmd, 2, 24, 8,  char,	    endpoint1->type[11]); \
425 	MC_CMD_OP(cmd, 2, 32, 8,  char,     endpoint1->type[12]); \
426 	MC_CMD_OP(cmd, 2, 40, 8,  char,	    endpoint1->type[13]); \
427 	MC_CMD_OP(cmd, 2, 48, 8,  char,	    endpoint1->type[14]); \
428 	MC_CMD_OP(cmd, 2, 56, 8,  char,	    endpoint1->type[15]); \
429 } while (0)
430 
431 /*                cmd, param, offset, width, type, arg_name */
432 #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
433 do { \
434 	MC_RSP_OP(cmd, 3, 0,  32, int,	    endpoint2->id); \
435 	MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
436 	MC_RSP_OP(cmd, 4, 0,  8,  char,	    endpoint2->type[0]); \
437 	MC_RSP_OP(cmd, 4, 8,  8,  char,	    endpoint2->type[1]); \
438 	MC_RSP_OP(cmd, 4, 16, 8,  char,	    endpoint2->type[2]); \
439 	MC_RSP_OP(cmd, 4, 24, 8,  char,	    endpoint2->type[3]); \
440 	MC_RSP_OP(cmd, 4, 32, 8,  char,	    endpoint2->type[4]); \
441 	MC_RSP_OP(cmd, 4, 40, 8,  char,	    endpoint2->type[5]); \
442 	MC_RSP_OP(cmd, 4, 48, 8,  char,	    endpoint2->type[6]); \
443 	MC_RSP_OP(cmd, 4, 56, 8,  char,	    endpoint2->type[7]); \
444 	MC_RSP_OP(cmd, 5, 0,  8,  char,	    endpoint2->type[8]); \
445 	MC_RSP_OP(cmd, 5, 8,  8,  char,	    endpoint2->type[9]); \
446 	MC_RSP_OP(cmd, 5, 16, 8,  char,	    endpoint2->type[10]); \
447 	MC_RSP_OP(cmd, 5, 24, 8,  char,	    endpoint2->type[11]); \
448 	MC_RSP_OP(cmd, 5, 32, 8,  char,	    endpoint2->type[12]); \
449 	MC_RSP_OP(cmd, 5, 40, 8,  char,	    endpoint2->type[13]); \
450 	MC_RSP_OP(cmd, 5, 48, 8,  char,	    endpoint2->type[14]); \
451 	MC_RSP_OP(cmd, 5, 56, 8,  char,	    endpoint2->type[15]); \
452 	MC_RSP_OP(cmd, 6, 0,  32, int,	    state); \
453 } while (0)
454 
455 /* Data Path Resource Container API
456  * Contains DPRC API for managing and querying DPAA resources
457  */
458 
459 struct fsl_mc_io;
460 
461 /**
462  * Set this value as the icid value in dprc_cfg structure when creating a
463  * container, in case the ICID is not selected by the user and should be
464  * allocated by the DPRC from the pool of ICIDs.
465  */
466 #define DPRC_GET_ICID_FROM_POOL			(uint16_t)(~(0))
467 
468 /**
469  * Set this value as the portal_id value in dprc_cfg structure when creating a
470  * container, in case the portal ID is not specifically selected by the
471  * user and should be allocated by the DPRC from the pool of portal ids.
472  */
473 #define DPRC_GET_PORTAL_ID_FROM_POOL	(int)(~(0))
474 
475 /**
476  * dprc_get_container_id() - Get container ID associated with a given portal.
477  * @mc_io:	Pointer to MC portal's I/O object
478  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
479  * @container_id:	Requested container ID
480  *
481  * Return:	'0' on Success; Error code otherwise.
482  */
483 int dprc_get_container_id(struct fsl_mc_io	*mc_io,
484 			  uint32_t		cmd_flags,
485 			  int			*container_id);
486 
487 /**
488  * dprc_open() - Open DPRC object for use
489  * @mc_io:	Pointer to MC portal's I/O object
490  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
491  * @container_id: Container ID to open
492  * @token:	Returned token of DPRC object
493  *
494  * Return:	'0' on Success; Error code otherwise.
495  *
496  * @warning	Required before any operation on the object.
497  */
498 int dprc_open(struct fsl_mc_io	*mc_io,
499 	      uint32_t		cmd_flags,
500 	      int		container_id,
501 	      uint16_t		*token);
502 
503 /**
504  * dprc_close() - Close the control session of the object
505  * @mc_io:	Pointer to MC portal's I/O object
506  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
507  * @token:	Token of DPRC object
508  *
509  * After this function is called, no further operations are
510  * allowed on the object without opening a new control session.
511  *
512  * Return:	'0' on Success; Error code otherwise.
513  */
514 int dprc_close(struct fsl_mc_io	*mc_io,
515 	       uint32_t		cmd_flags,
516 	       uint16_t		token);
517 
518 /**
519  * Container general options
520  *
521  * These options may be selected at container creation by the container creator
522  * and can be retrieved using dprc_get_attributes()
523  */
524 
525 /* Spawn Policy Option allowed - Indicates that the new container is allowed
526  * to spawn and have its own child containers.
527  */
528 #define DPRC_CFG_OPT_SPAWN_ALLOWED		0x00000001
529 
530 /* General Container allocation policy - Indicates that the new container is
531  * allowed to allocate requested resources from its parent container; if not
532  * set, the container is only allowed to use resources in its own pools; Note
533  * that this is a container's global policy, but the parent container may
534  * override it and set specific quota per resource type.
535  */
536 #define DPRC_CFG_OPT_ALLOC_ALLOWED		0x00000002
537 
538 /* Object initialization allowed - software context associated with this
539  * container is allowed to invoke object initialization operations.
540  */
541 #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED		0x00000004
542 
543 /* Topology change allowed - software context associated with this
544  * container is allowed to invoke topology operations, such as attach/detach
545  * of network objects.
546  */
547 #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED	0x00000008
548 
549 
550 /* AIOP - Indicates that container belongs to AIOP. */
551 #define DPRC_CFG_OPT_AIOP			0x00000020
552 
553 /* IRQ Config - Indicates that the container allowed to configure its IRQs.*/
554 #define DPRC_CFG_OPT_IRQ_CFG_ALLOWED		0x00000040
555 
556 /**
557  * struct dprc_cfg - Container configuration options
558  * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
559  *		ICID value is allocated by the DPRC
560  * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
561  *		portal ID is allocated by the DPRC
562  * @options: Combination of 'DPRC_CFG_OPT_<X>' options
563  * @label: Object's label
564  */
565 struct dprc_cfg {
566 	uint16_t icid;
567 	int portal_id;
568 	uint64_t options;
569 	char label[16];
570 };
571 
572 /**
573  * dprc_create_container() - Create child container
574  * @mc_io:	Pointer to MC portal's I/O object
575  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
576  * @token:	Token of DPRC object
577  * @cfg:	Child container configuration
578  * @child_container_id:	Returned child container ID
579  * @child_portal_offset: Returned child portal offset from MC portal base
580  *
581  *
582  * Return:	'0' on Success; Error code otherwise.
583  */
584 int dprc_create_container(struct fsl_mc_io	*mc_io,
585 			  uint32_t		cmd_flags,
586 			  uint16_t		token,
587 			  struct dprc_cfg	*cfg,
588 			  int			*child_container_id,
589 			  uint64_t		*child_portal_offset);
590 
591 /**
592  * dprc_destroy_container() - Destroy child container.
593  * @mc_io:	Pointer to MC portal's I/O object
594  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
595  * @token:	Token of DPRC object
596  * @child_container_id:	ID of the container to destroy
597  *
598  * This function terminates the child container, so following this call the
599  * child container ID becomes invalid.
600  *
601  * Notes:
602  * - All resources and objects of the destroyed container are returned to the
603  * parent container or destroyed if were created be the destroyed container.
604  * - This function destroy all the child containers of the specified
605  *   container prior to destroying the container itself.
606  *
607  * warning: Only the parent container is allowed to destroy a child policy
608  *		Container 0 can't be destroyed
609  *
610  * Return:	'0' on Success; Error code otherwise.
611  *
612  */
613 int dprc_destroy_container(struct fsl_mc_io	*mc_io,
614 			   uint32_t		cmd_flags,
615 			   uint16_t		token,
616 			   int			child_container_id);
617 
618 /**
619  * dprc_reset_container - Reset child container.
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  * @child_container_id:	ID of the container to reset
624  *
625  * In case a software context crashes or becomes non-responsive, the parent
626  * may wish to reset its resources container before the software context is
627  * restarted.
628  *
629  * This routine informs all objects assigned to the child container that the
630  * container is being reset, so they may perform any cleanup operations that are
631  * needed. All objects handles that were owned by the child container shall be
632  * closed.
633  *
634  * Note that such request may be submitted even if the child software context
635  * has not crashed, but the resulting object cleanup operations will not be
636  * aware of that.
637  *
638  * Return:	'0' on Success; Error code otherwise.
639  */
640 int dprc_reset_container(struct fsl_mc_io	*mc_io,
641 			 uint32_t		cmd_flags,
642 			 uint16_t		token,
643 			 int			child_container_id);
644 
645 /**
646  * struct dprc_attributes - Container attributes
647  * @container_id: Container's ID
648  * @icid: Container's ICID
649  * @portal_id: Container's portal ID
650  * @options: Container's options as set at container's creation
651  * @version: DPRC version
652  */
653 struct dprc_attributes {
654 	int container_id;
655 	uint16_t icid;
656 	int portal_id;
657 	uint64_t options;
658 };
659 
660 /**
661  * dprc_get_attributes() - Obtains container attributes
662  * @mc_io:	Pointer to MC portal's I/O object
663  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
664  * @token:	Token of DPRC object
665  * @attributes:	Returned container attributes
666  *
667  * Return:     '0' on Success; Error code otherwise.
668  */
669 int dprc_get_attributes(struct fsl_mc_io	*mc_io,
670 			uint32_t		cmd_flags,
671 			uint16_t		token,
672 			struct dprc_attributes	*attributes);
673 
674 /**
675  * dprc_get_obj_count() - Obtains the number of objects in the DPRC
676  * @mc_io:	Pointer to MC portal's I/O object
677  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
678  * @token:	Token of DPRC object
679  * @obj_count:	Number of objects assigned to the DPRC
680  *
681  * Return:	'0' on Success; Error code otherwise.
682  */
683 int dprc_get_obj_count(struct fsl_mc_io	*mc_io,
684 		       uint32_t		cmd_flags,
685 		       uint16_t		token,
686 		       int			*obj_count);
687 
688 /* Objects Attributes Flags */
689 
690 /* Opened state - Indicates that an object is open by at least one owner */
691 #define DPRC_OBJ_STATE_OPEN		0x00000001
692 /* Plugged state - Indicates that the object is plugged */
693 #define DPRC_OBJ_STATE_PLUGGED		0x00000002
694 
695 /**
696  * Shareability flag - Object flag indicating no memory shareability.
697  *  the object generates memory accesses that are non coherent with other
698  *  masters;
699  *  user is responsible for proper memory handling through IOMMU configuration.
700  */
701 #define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY		0x0001
702 
703 /**
704  * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
705  * @type: Type of object: NULL terminated string
706  * @id: ID of logical object resource
707  * @vendor: Object vendor identifier
708  * @ver_major: Major version number
709  * @ver_minor:  Minor version number
710  * @irq_count: Number of interrupts supported by the object
711  * @region_count: Number of mappable regions supported by the object
712  * @state: Object state: combination of DPRC_OBJ_STATE_ states
713  * @label: Object label
714  * @flags: Object's flags
715  */
716 struct dprc_obj_desc {
717 	char type[16];
718 	int id;
719 	uint16_t vendor;
720 	uint16_t ver_major;
721 	uint16_t ver_minor;
722 	uint8_t irq_count;
723 	uint8_t region_count;
724 	uint32_t state;
725 	char label[16];
726 	uint16_t	flags;
727 };
728 
729 /**
730  * dprc_get_obj() - Get general information on an object
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
734  * @obj_index:	Index of the object to be queried (< obj_count)
735  * @obj_desc:	Returns the requested object descriptor
736  *
737  * The object descriptors are retrieved one by one by incrementing
738  * obj_index up to (not including) the value of obj_count returned
739  * from dprc_get_obj_count(). dprc_get_obj_count() must
740  * be called prior to dprc_get_obj().
741  *
742  * Return:	'0' on Success; Error code otherwise.
743  */
744 int dprc_get_obj(struct fsl_mc_io	*mc_io,
745 		 uint32_t		cmd_flags,
746 		 uint16_t		token,
747 		 int			obj_index,
748 		 struct dprc_obj_desc	*obj_desc);
749 
750 /**
751  * dprc_get_res_count() - Obtains the number of free resources that are
752  *		assigned to this container, by pool type
753  * @mc_io:	Pointer to MC portal's I/O object
754  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
755  * @token:	Token of DPRC object
756  * @type:	pool type
757  * @res_count:	Returned number of free resources of the given
758  *			resource type that are assigned to this DPRC
759  *
760  * Return:	'0' on Success; Error code otherwise.
761  */
762 int dprc_get_res_count(struct fsl_mc_io *mc_io,
763 		       uint32_t	cmd_flags,
764 		       uint16_t		token,
765 		       char		*type,
766 		       int		*res_count);
767 
768 /**
769  * enum dprc_iter_status - Iteration status
770  * @DPRC_ITER_STATUS_FIRST: Perform first iteration
771  * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
772  * @DPRC_ITER_STATUS_LAST: Indicates last iteration
773  */
774 enum dprc_iter_status {
775 	DPRC_ITER_STATUS_FIRST = 0,
776 	DPRC_ITER_STATUS_MORE = 1,
777 	DPRC_ITER_STATUS_LAST = 2
778 };
779 
780 /**
781  * struct dprc_res_ids_range_desc - Resource ID range descriptor
782  * @base_id: Base resource ID of this range
783  * @last_id: Last resource ID of this range
784  * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
785  *	first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
786  *	additional iterations are needed, until the returned marker is
787  *	DPRC_ITER_STATUS_LAST
788  */
789 struct dprc_res_ids_range_desc {
790 	int base_id;
791 	int last_id;
792 	enum dprc_iter_status iter_status;
793 };
794 
795 /**
796  * dprc_get_res_ids() - Obtains IDs of free resources in the container
797  * @mc_io:	Pointer to MC portal's I/O object
798  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
799  * @token:	Token of DPRC object
800  * @type:	pool type
801  * @range_desc:	range descriptor
802  *
803  * Return:	'0' on Success; Error code otherwise.
804  */
805 int dprc_get_res_ids(struct fsl_mc_io			*mc_io,
806 		     uint32_t				cmd_flags,
807 		     uint16_t				token,
808 		     char				*type,
809 		     struct dprc_res_ids_range_desc	*range_desc);
810 
811 /* Region flags */
812 /* Cacheable - Indicates that region should be mapped as cacheable */
813 #define DPRC_REGION_CACHEABLE	0x00000001
814 
815 /**
816  * enum dprc_region_type - Region type
817  * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
818  * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
819  */
820 enum dprc_region_type {
821 	DPRC_REGION_TYPE_MC_PORTAL,
822 	DPRC_REGION_TYPE_QBMAN_PORTAL
823 };
824 
825 /**
826  * struct dprc_region_desc - Mappable region descriptor
827  * @base_offset: Region offset from region's base address.
828  *	For DPMCP and DPRC objects, region base is offset from SoC MC portals
829  *	base address; For DPIO, region base is offset from SoC QMan portals
830  *	base address
831  * @size: Region size (in bytes)
832  * @flags: Region attributes
833  * @type: Portal region type
834  */
835 struct dprc_region_desc {
836 	uint32_t base_offset;
837 	uint32_t size;
838 	uint32_t flags;
839 	enum dprc_region_type type;
840 };
841 
842 /**
843  * dprc_get_obj_region() - Get region information for a specified object.
844  * @mc_io:	Pointer to MC portal's I/O object
845  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
846  * @token:	Token of DPRC object
847  * @obj_type:	Object type as returned in dprc_get_obj()
848  * @obj_id:	Unique object instance as returned in dprc_get_obj()
849  * @region_index: The specific region to query
850  * @region_desc:  Returns the requested region descriptor
851  *
852  * Return:	'0' on Success; Error code otherwise.
853  */
854 int dprc_get_obj_region(struct fsl_mc_io	*mc_io,
855 			uint32_t		cmd_flags,
856 			uint16_t		token,
857 			char			*obj_type,
858 			int			obj_id,
859 			uint8_t			region_index,
860 			struct dprc_region_desc	*region_desc);
861 /**
862  * struct dprc_endpoint - Endpoint description for link connect/disconnect
863  *			operations
864  * @type: Endpoint object type: NULL terminated string
865  * @id: Endpoint object ID
866  * @if_id: Interface ID; should be set for endpoints with multiple
867  *		interfaces ("dpsw", "dpdmux"); for others, always set to 0
868  */
869 struct dprc_endpoint {
870 	char		type[16];
871 	int		id;
872 	uint16_t	if_id;
873 };
874 
875 /**
876  * struct dprc_connection_cfg - Connection configuration.
877  *				Used for virtual connections only
878  * @committed_rate: Committed rate (Mbits/s)
879  * @max_rate: Maximum rate (Mbits/s)
880  */
881 struct dprc_connection_cfg {
882 	uint32_t committed_rate;
883 	uint32_t max_rate;
884 };
885 
886 /**
887  * dprc_connect() - Connect two endpoints to create a network link between them
888  * @mc_io:	Pointer to MC portal's I/O object
889  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
890  * @token:	Token of DPRC object
891  * @endpoint1:	Endpoint 1 configuration parameters
892  * @endpoint2:	Endpoint 2 configuration parameters
893  * @cfg: Connection configuration. The connection configuration is ignored for
894  *	connections made to DPMAC objects, where rate is retrieved from the
895  *	MAC configuration.
896  *
897  * Return:	'0' on Success; Error code otherwise.
898  */
899 int dprc_connect(struct fsl_mc_io			*mc_io,
900 		 uint32_t				cmd_flags,
901 		 uint16_t				token,
902 		 const struct dprc_endpoint		*endpoint1,
903 		 const struct dprc_endpoint		*endpoint2,
904 		 const struct dprc_connection_cfg	*cfg);
905 
906 /**
907  * dprc_disconnect() - Disconnect one endpoint to remove its network connection
908  * @mc_io:	Pointer to MC portal's I/O object
909  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
910  * @token:	Token of DPRC object
911  * @endpoint:	Endpoint configuration parameters
912  *
913  * Return:	'0' on Success; Error code otherwise.
914  */
915 int dprc_disconnect(struct fsl_mc_io		*mc_io,
916 		    uint32_t			cmd_flags,
917 		    uint16_t			token,
918 		    const struct dprc_endpoint	*endpoint);
919 
920 /**
921 * dprc_get_connection() - Get connected endpoint and link status if connection
922 *			exists.
923 * @mc_io:	Pointer to MC portal's I/O object
924 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
925 * @token:	Token of DPRC object
926 * @endpoint1:	Endpoint 1 configuration parameters
927 * @endpoint2:	Returned endpoint 2 configuration parameters
928 * @state:	Returned link state:
929 *           1 - link is up;
930 *           0 - link is down;
931 *           -1 - no connection (endpoint2 information is irrelevant)
932 *
933 * Return:     '0' on Success; -ENAVAIL if connection does not exist.
934 */
935 int dprc_get_connection(struct fsl_mc_io		*mc_io,
936 			uint32_t			cmd_flags,
937 			uint16_t			token,
938 			const struct dprc_endpoint	*endpoint1,
939 			struct dprc_endpoint		*endpoint2,
940 			int				*state);
941 
942 /**
943  * dprc_get_api_version - Retrieve DPRC Major and Minor version info.
944  *
945  * @mc_io:	Pointer to MC portal's I/O object
946  * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
947  * @major_ver:	DPRC major version
948  * @minor_ver:	DPRC minor version
949  *
950  * Return:     '0' on Success; Error code otherwise.
951  */
952 int dprc_get_api_version(struct fsl_mc_io *mc_io,
953 			 u32 cmd_flags,
954 			 u16 *major_ver,
955 			 u16 *minor_ver);
956 
957 #endif /* _FSL_DPRC_H */
958