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