blob: 535c789c95e68d420a735d6ccfed5819b26cea3f [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07001/*
2 * Freescale Layerscape MC I/O wrapper
3 *
4 * Copyright (C) 2013-2015 Freescale Semiconductor, Inc.
5 * Author: German Rivera <German.Rivera@freescale.com>
6 *
7 * SPDX-License-Identifier: GPL-2.0+
8 */
9#ifndef _FSL_DPRC_H
10#define _FSL_DPRC_H
11
12/* DPRC Version */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053013#define DPRC_VER_MAJOR 5
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053014#define DPRC_VER_MINOR 1
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070015
16/* Command IDs */
17#define DPRC_CMDID_CLOSE 0x800
18#define DPRC_CMDID_OPEN 0x805
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053019#define DPRC_CMDID_CREATE 0x905
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070020
21#define DPRC_CMDID_GET_ATTR 0x004
22#define DPRC_CMDID_RESET_CONT 0x005
23
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053024#define DPRC_CMDID_CREATE_CONT 0x151
25#define DPRC_CMDID_DESTROY_CONT 0x152
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070026#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
32
33#define DPRC_CMDID_CONNECT 0x167
34#define DPRC_CMDID_DISCONNECT 0x168
35#define DPRC_CMDID_GET_CONNECTION 0x16C
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 */
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053046#define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
47do { \
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)\
71do { \
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 */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070081#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) \
86do { \
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);\
93} while (0)
94
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)
98
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)
102
103/* cmd, param, offset, width, type, arg_name */
104#define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
105do { \
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);\
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530113 MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
114 MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
115 MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
116 MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
117 MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
118 MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
119 MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
120 MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
121 MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
122 MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
123 MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
124 MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
125 MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
126 MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
127 MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
128 MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
129 MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
130 MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
131 MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
132 MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
133 MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
134 MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
135 MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
136 MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
137 MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
138 MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
139 MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
140 MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
141 MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
142 MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
143 MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
144 MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
145 MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
146} while (0)
147
148/* cmd, param, offset, width, type, arg_name */
149#define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \
150do { \
151 MC_CMD_OP(cmd, 0, 0, 32, int, obj_id);\
152 MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\
153 MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\
154 MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\
155 MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\
156 MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\
157 MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\
158 MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\
159 MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\
160 MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\
161 MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\
162 MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\
163 MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\
164 MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\
165 MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\
166 MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\
167 MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\
168} while (0)
169
170/* cmd, param, offset, width, type, arg_name */
171#define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \
172do { \
173 MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
174 MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
175 MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
176 MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
177 MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
178 MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
179 MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
180 MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700181 MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
182 MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
183 MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
184 MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
185 MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
186 MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
187 MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
188 MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
189 MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
190 MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
191 MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
192 MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
193 MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
194 MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
195 MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
196 MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530197 MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
198 MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
199 MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
200 MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
201 MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
202 MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
203 MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
204 MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
205 MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
206 MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
207 MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
208 MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
209 MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
210 MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
211 MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
212 MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700213} while (0)
214
215/* cmd, param, offset, width, type, arg_name */
216#define DPRC_CMD_GET_RES_COUNT(cmd, type) \
217do { \
218 MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
219 MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
220 MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
221 MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
222 MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
223 MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
224 MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
225 MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
226 MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
227 MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
228 MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
229 MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
230 MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
231 MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
232 MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
233 MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
234} while (0)
235
236/* cmd, param, offset, width, type, arg_name */
237#define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
238 MC_RSP_OP(cmd, 0, 0, 32, int, res_count)
239
240/* cmd, param, offset, width, type, arg_name */
241#define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
242do { \
243 MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
244 range_desc->iter_status); \
245 MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
246 MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
247 MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\
248 MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\
249 MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\
250 MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\
251 MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\
252 MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\
253 MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\
254 MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\
255 MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\
256 MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\
257 MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\
258 MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\
259 MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\
260 MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\
261 MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\
262 MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\
263} while (0)
264
265/* cmd, param, offset, width, type, arg_name */
266#define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
267do { \
268 MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
269 range_desc->iter_status);\
270 MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
271 MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
272} while (0)
273
274/* cmd, param, offset, width, type, arg_name */
275#define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
276do { \
277 MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
278 MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\
279 MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
280 MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
281 MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
282 MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
283 MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
284 MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
285 MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
286 MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
287 MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
288 MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
289 MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
290 MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
291 MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
292 MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
293 MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
294 MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
295} while (0)
296
297/* param, offset, width, type, arg_name */
298#define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
299do { \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530300 MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700301 MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530302 MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\
303 MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700304} while (0)
305
306/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530307#define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530308do { \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530309 MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530310 MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\
311 MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\
312 MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\
313 MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\
314 MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\
315 MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\
316 MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\
317 MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\
318 MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\
319 MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\
320 MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\
321 MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\
322 MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\
323 MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\
324 MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\
325 MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530326 MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
327 MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
328 MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
329 MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
330 MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
331 MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
332 MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
333 MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
334 MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
335 MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
336 MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
337 MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
338 MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
339 MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
340 MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
341 MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530342} while (0)
343
344/* cmd, param, offset, width, type, arg_name */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530345#define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700346do { \
347 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530348 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700349 MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530350 MC_CMD_OP(cmd, 1, 32, 16, uint16_t, endpoint2->if_id); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700351 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
352 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
353 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
354 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \
355 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \
356 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \
357 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \
358 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \
359 MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \
360 MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \
361 MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \
362 MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \
363 MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \
364 MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \
365 MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \
366 MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530367 MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \
368 MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700369 MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \
370 MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \
371 MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \
372 MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \
373 MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \
374 MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \
375 MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \
376 MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \
377 MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \
378 MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \
379 MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \
380 MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \
381 MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \
382 MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \
383 MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \
384 MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \
385} while (0)
386
387/* cmd, param, offset, width, type, arg_name */
388#define DPRC_CMD_DISCONNECT(cmd, endpoint) \
389do { \
390 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530391 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700392 MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \
393 MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \
394 MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \
395 MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \
396 MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \
397 MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \
398 MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \
399 MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \
400 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \
401 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \
402 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \
403 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \
404 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \
405 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \
406 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \
407 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \
408} while (0)
409
410/* cmd, param, offset, width, type, arg_name */
411#define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
412do { \
413 MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530414 MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700415 MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
416 MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
417 MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
418 MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \
419 MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \
420 MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \
421 MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \
422 MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \
423 MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \
424 MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \
425 MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \
426 MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \
427 MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \
428 MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \
429 MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \
430 MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \
431} while (0)
432
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700433/* cmd, param, offset, width, type, arg_name */
434#define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
435do { \
436 MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530437 MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700438 MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \
439 MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \
440 MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \
441 MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \
442 MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \
443 MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \
444 MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \
445 MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \
446 MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \
447 MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \
448 MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \
449 MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \
450 MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \
451 MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \
452 MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \
453 MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \
454 MC_RSP_OP(cmd, 6, 0, 32, int, state); \
455} while (0)
456
457/* Data Path Resource Container API
458 * Contains DPRC API for managing and querying DPAA resources
459 */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530460
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700461struct fsl_mc_io;
462
463/**
464 * Set this value as the icid value in dprc_cfg structure when creating a
465 * container, in case the ICID is not selected by the user and should be
466 * allocated by the DPRC from the pool of ICIDs.
467 */
468#define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0))
469
470/**
471 * Set this value as the portal_id value in dprc_cfg structure when creating a
472 * container, in case the portal ID is not specifically selected by the
473 * user and should be allocated by the DPRC from the pool of portal ids.
474 */
475#define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
476
477/**
478 * dprc_get_container_id() - Get container ID associated with a given portal.
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530479 * @mc_io: Pointer to MC portal's I/O object
480 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700481 * @container_id: Requested container ID
482 *
483 * Return: '0' on Success; Error code otherwise.
484 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530485int dprc_get_container_id(struct fsl_mc_io *mc_io,
486 uint32_t cmd_flags,
487 int *container_id);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700488
489/**
490 * dprc_open() - Open DPRC object for use
491 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530492 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700493 * @container_id: Container ID to open
494 * @token: Returned token of DPRC object
495 *
496 * Return: '0' on Success; Error code otherwise.
497 *
498 * @warning Required before any operation on the object.
499 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530500int dprc_open(struct fsl_mc_io *mc_io,
501 uint32_t cmd_flags,
502 int container_id,
503 uint16_t *token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700504
505/**
506 * dprc_close() - Close the control session of the object
507 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530508 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700509 * @token: Token of DPRC object
510 *
511 * After this function is called, no further operations are
512 * allowed on the object without opening a new control session.
513 *
514 * Return: '0' on Success; Error code otherwise.
515 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530516int dprc_close(struct fsl_mc_io *mc_io,
517 uint32_t cmd_flags,
518 uint16_t token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700519
520/**
521 * Container general options
522 *
523 * These options may be selected at container creation by the container creator
524 * and can be retrieved using dprc_get_attributes()
525 */
526
527/* Spawn Policy Option allowed - Indicates that the new container is allowed
528 * to spawn and have its own child containers.
529 */
530#define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
531
532/* General Container allocation policy - Indicates that the new container is
533 * allowed to allocate requested resources from its parent container; if not
534 * set, the container is only allowed to use resources in its own pools; Note
535 * that this is a container's global policy, but the parent container may
536 * override it and set specific quota per resource type.
537 */
538#define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
539
540/* Object initialization allowed - software context associated with this
541 * container is allowed to invoke object initialization operations.
542 */
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530543#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700544
545/* Topology change allowed - software context associated with this
546 * container is allowed to invoke topology operations, such as attach/detach
547 * of network objects.
548 */
549#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
550
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700551
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530552/* AIOP - Indicates that container belongs to AIOP. */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700553#define DPRC_CFG_OPT_AIOP 0x00000020
554
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530555/* IRQ Config - Indicates that the container allowed to configure its IRQs.*/
556#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
557
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700558/**
559 * struct dprc_cfg - Container configuration options
560 * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
561 * ICID value is allocated by the DPRC
562 * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
563 * portal ID is allocated by the DPRC
564 * @options: Combination of 'DPRC_CFG_OPT_<X>' options
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530565 * @label: Object's label
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700566 */
567struct dprc_cfg {
568 uint16_t icid;
569 int portal_id;
570 uint64_t options;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530571 char label[16];
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700572};
573
574/**
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530575 * dprc_create_container() - Create child container
576 * @mc_io: Pointer to MC portal's I/O object
577 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
578 * @token: Token of DPRC object
579 * @cfg: Child container configuration
580 * @child_container_id: Returned child container ID
581 * @child_portal_offset: Returned child portal offset from MC portal base
582 *
583 *
584 * Return: '0' on Success; Error code otherwise.
585 */
586int dprc_create_container(struct fsl_mc_io *mc_io,
587 uint32_t cmd_flags,
588 uint16_t token,
589 struct dprc_cfg *cfg,
590 int *child_container_id,
591 uint64_t *child_portal_offset);
592
593/**
594 * dprc_destroy_container() - Destroy child container.
595 * @mc_io: Pointer to MC portal's I/O object
596 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
597 * @token: Token of DPRC object
598 * @child_container_id: ID of the container to destroy
599 *
600 * This function terminates the child container, so following this call the
601 * child container ID becomes invalid.
602 *
603 * Notes:
604 * - All resources and objects of the destroyed container are returned to the
605 * parent container or destroyed if were created be the destroyed container.
606 * - This function destroy all the child containers of the specified
607 * container prior to destroying the container itself.
608 *
609 * warning: Only the parent container is allowed to destroy a child policy
610 * Container 0 can't be destroyed
611 *
612 * Return: '0' on Success; Error code otherwise.
613 *
614 */
615int dprc_destroy_container(struct fsl_mc_io *mc_io,
616 uint32_t cmd_flags,
617 uint16_t token,
618 int child_container_id);
619
620/**
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700621 * dprc_reset_container - Reset child container.
622 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530623 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700624 * @token: Token of DPRC object
625 * @child_container_id: ID of the container to reset
626 *
627 * In case a software context crashes or becomes non-responsive, the parent
628 * may wish to reset its resources container before the software context is
629 * restarted.
630 *
631 * This routine informs all objects assigned to the child container that the
632 * container is being reset, so they may perform any cleanup operations that are
633 * needed. All objects handles that were owned by the child container shall be
634 * closed.
635 *
636 * Note that such request may be submitted even if the child software context
637 * has not crashed, but the resulting object cleanup operations will not be
638 * aware of that.
639 *
640 * Return: '0' on Success; Error code otherwise.
641 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530642int dprc_reset_container(struct fsl_mc_io *mc_io,
643 uint32_t cmd_flags,
644 uint16_t token,
645 int child_container_id);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700646
647/**
648 * struct dprc_attributes - Container attributes
649 * @container_id: Container's ID
650 * @icid: Container's ICID
651 * @portal_id: Container's portal ID
652 * @options: Container's options as set at container's creation
653 * @version: DPRC version
654 */
655struct dprc_attributes {
656 int container_id;
657 uint16_t icid;
658 int portal_id;
659 uint64_t options;
660 /**
661 * struct version - DPRC version
662 * @major: DPRC major version
663 * @minor: DPRC minor version
664 */
665 struct {
666 uint16_t major;
667 uint16_t minor;
668 } version;
669};
670
671/**
672 * dprc_get_attributes() - Obtains container attributes
673 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530674 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700675 * @token: Token of DPRC object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530676 * @attributes: Returned container attributes
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700677 *
678 * Return: '0' on Success; Error code otherwise.
679 */
680int dprc_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530681 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700682 uint16_t token,
683 struct dprc_attributes *attributes);
684
685/**
686 * dprc_get_obj_count() - Obtains the number of objects in the DPRC
687 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530688 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700689 * @token: Token of DPRC object
690 * @obj_count: Number of objects assigned to the DPRC
691 *
692 * Return: '0' on Success; Error code otherwise.
693 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530694int dprc_get_obj_count(struct fsl_mc_io *mc_io,
695 uint32_t cmd_flags,
696 uint16_t token,
697 int *obj_count);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700698
699/* Objects Attributes Flags */
700
701/* Opened state - Indicates that an object is open by at least one owner */
702#define DPRC_OBJ_STATE_OPEN 0x00000001
703/* Plugged state - Indicates that the object is plugged */
704#define DPRC_OBJ_STATE_PLUGGED 0x00000002
705
706/**
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530707 * Shareability flag - Object flag indicating no memory shareability.
708 * the object generates memory accesses that are non coherent with other
709 * masters;
710 * user is responsible for proper memory handling through IOMMU configuration.
711 */
712#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
713
714/**
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700715 * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
716 * @type: Type of object: NULL terminated string
717 * @id: ID of logical object resource
718 * @vendor: Object vendor identifier
719 * @ver_major: Major version number
720 * @ver_minor: Minor version number
721 * @irq_count: Number of interrupts supported by the object
722 * @region_count: Number of mappable regions supported by the object
723 * @state: Object state: combination of DPRC_OBJ_STATE_ states
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530724 * @label: Object label
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530725 * @flags: Object's flags
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700726 */
727struct dprc_obj_desc {
728 char type[16];
729 int id;
730 uint16_t vendor;
731 uint16_t ver_major;
732 uint16_t ver_minor;
733 uint8_t irq_count;
734 uint8_t region_count;
735 uint32_t state;
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530736 char label[16];
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530737 uint16_t flags;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700738};
739
740/**
741 * dprc_get_obj() - Get general information on an object
742 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530743 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700744 * @token: Token of DPRC object
745 * @obj_index: Index of the object to be queried (< obj_count)
746 * @obj_desc: Returns the requested object descriptor
747 *
748 * The object descriptors are retrieved one by one by incrementing
749 * obj_index up to (not including) the value of obj_count returned
750 * from dprc_get_obj_count(). dprc_get_obj_count() must
751 * be called prior to dprc_get_obj().
752 *
753 * Return: '0' on Success; Error code otherwise.
754 */
755int dprc_get_obj(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530756 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700757 uint16_t token,
758 int obj_index,
759 struct dprc_obj_desc *obj_desc);
760
761/**
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530762 * dprc_get_res_count() - Obtains the number of free resources that are
763 * assigned to this container, by pool type
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700764 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530765 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700766 * @token: Token of DPRC object
767 * @type: pool type
768 * @res_count: Returned number of free resources of the given
769 * resource type that are assigned to this DPRC
770 *
771 * Return: '0' on Success; Error code otherwise.
772 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530773int dprc_get_res_count(struct fsl_mc_io *mc_io,
774 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700775 uint16_t token,
776 char *type,
777 int *res_count);
778
779/**
780 * enum dprc_iter_status - Iteration status
781 * @DPRC_ITER_STATUS_FIRST: Perform first iteration
782 * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
783 * @DPRC_ITER_STATUS_LAST: Indicates last iteration
784 */
785enum dprc_iter_status {
786 DPRC_ITER_STATUS_FIRST = 0,
787 DPRC_ITER_STATUS_MORE = 1,
788 DPRC_ITER_STATUS_LAST = 2
789};
790
791/**
792 * struct dprc_res_ids_range_desc - Resource ID range descriptor
793 * @base_id: Base resource ID of this range
794 * @last_id: Last resource ID of this range
795 * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
796 * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
797 * additional iterations are needed, until the returned marker is
798 * DPRC_ITER_STATUS_LAST
799 */
800struct dprc_res_ids_range_desc {
801 int base_id;
802 int last_id;
803 enum dprc_iter_status iter_status;
804};
805
806/**
807 * dprc_get_res_ids() - Obtains IDs of free resources in the container
808 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530809 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700810 * @token: Token of DPRC object
811 * @type: pool type
812 * @range_desc: range descriptor
813 *
814 * Return: '0' on Success; Error code otherwise.
815 */
816int dprc_get_res_ids(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530817 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700818 uint16_t token,
819 char *type,
820 struct dprc_res_ids_range_desc *range_desc);
821
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530822/* Region flags */
823/* Cacheable - Indicates that region should be mapped as cacheable */
824#define DPRC_REGION_CACHEABLE 0x00000001
825
826/**
827 * enum dprc_region_type - Region type
828 * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
829 * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
830 */
831enum dprc_region_type {
832 DPRC_REGION_TYPE_MC_PORTAL,
833 DPRC_REGION_TYPE_QBMAN_PORTAL
834};
835
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700836/**
837 * struct dprc_region_desc - Mappable region descriptor
Prabhakar Kushwaha1f1c25c2015-07-02 11:28:59 +0530838 * @base_offset: Region offset from region's base address.
839 * For DPMCP and DPRC objects, region base is offset from SoC MC portals
840 * base address; For DPIO, region base is offset from SoC QMan portals
841 * base address
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700842 * @size: Region size (in bytes)
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530843 * @flags: Region attributes
844 * @type: Portal region type
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700845 */
846struct dprc_region_desc {
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530847 uint32_t base_offset;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700848 uint32_t size;
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530849 uint32_t flags;
850 enum dprc_region_type type;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700851};
852
853/**
854 * dprc_get_obj_region() - Get region information for a specified object.
855 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530856 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700857 * @token: Token of DPRC object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530858 * @obj_type: Object type as returned in dprc_get_obj()
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700859 * @obj_id: Unique object instance as returned in dprc_get_obj()
860 * @region_index: The specific region to query
861 * @region_desc: Returns the requested region descriptor
862 *
863 * Return: '0' on Success; Error code otherwise.
864 */
865int dprc_get_obj_region(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530866 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700867 uint16_t token,
868 char *obj_type,
869 int obj_id,
870 uint8_t region_index,
871 struct dprc_region_desc *region_desc);
872/**
873 * struct dprc_endpoint - Endpoint description for link connect/disconnect
874 * operations
875 * @type: Endpoint object type: NULL terminated string
876 * @id: Endpoint object ID
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530877 * @if_id: Interface ID; should be set for endpoints with multiple
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700878 * interfaces ("dpsw", "dpdmux"); for others, always set to 0
879 */
880struct dprc_endpoint {
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530881 char type[16];
882 int id;
883 uint16_t if_id;
884};
885
886/**
887 * struct dprc_connection_cfg - Connection configuration.
888 * Used for virtual connections only
889 * @committed_rate: Committed rate (Mbits/s)
890 * @max_rate: Maximum rate (Mbits/s)
891 */
892struct dprc_connection_cfg {
893 uint32_t committed_rate;
894 uint32_t max_rate;
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700895};
896
897/**
898 * dprc_connect() - Connect two endpoints to create a network link between them
899 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530900 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700901 * @token: Token of DPRC object
902 * @endpoint1: Endpoint 1 configuration parameters
903 * @endpoint2: Endpoint 2 configuration parameters
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530904 * @cfg: Connection configuration. The connection configuration is ignored for
905 * connections made to DPMAC objects, where rate is retrieved from the
906 * MAC configuration.
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700907 *
908 * Return: '0' on Success; Error code otherwise.
909 */
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530910int dprc_connect(struct fsl_mc_io *mc_io,
911 uint32_t cmd_flags,
912 uint16_t token,
913 const struct dprc_endpoint *endpoint1,
914 const struct dprc_endpoint *endpoint2,
915 const struct dprc_connection_cfg *cfg);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700916
917/**
918 * dprc_disconnect() - Disconnect one endpoint to remove its network connection
919 * @mc_io: Pointer to MC portal's I/O object
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530920 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700921 * @token: Token of DPRC object
922 * @endpoint: Endpoint configuration parameters
923 *
924 * Return: '0' on Success; Error code otherwise.
925 */
926int dprc_disconnect(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530927 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700928 uint16_t token,
929 const struct dprc_endpoint *endpoint);
930
931/**
932* dprc_get_connection() - Get connected endpoint and link status if connection
933* exists.
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530934* @mc_io: Pointer to MC portal's I/O object
935* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
936* @token: Token of DPRC object
937* @endpoint1: Endpoint 1 configuration parameters
938* @endpoint2: Returned endpoint 2 configuration parameters
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530939* @state: Returned link state:
940* 1 - link is up;
941* 0 - link is down;
942* -1 - no connection (endpoint2 information is irrelevant)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700943*
944* Return: '0' on Success; -ENAVAIL if connection does not exist.
945*/
946int dprc_get_connection(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530947 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700948 uint16_t token,
949 const struct dprc_endpoint *endpoint1,
950 struct dprc_endpoint *endpoint2,
951 int *state);
952
953#endif /* _FSL_DPRC_H */