Prabhakar Kushwaha | cfd9fbf | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 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 */ |
| 13 | #define DPRC_VER_MAJOR 2 |
| 14 | #define DPRC_VER_MINOR 0 |
| 15 | |
| 16 | /* Command IDs */ |
| 17 | #define DPRC_CMDID_CLOSE 0x800 |
| 18 | #define DPRC_CMDID_OPEN 0x805 |
| 19 | |
| 20 | #define DPRC_CMDID_GET_ATTR 0x004 |
| 21 | #define DPRC_CMDID_RESET_CONT 0x005 |
| 22 | |
| 23 | #define DPRC_CMDID_GET_CONT_ID 0x830 |
| 24 | #define DPRC_CMDID_GET_OBJ_COUNT 0x159 |
| 25 | #define DPRC_CMDID_GET_OBJ 0x15A |
| 26 | #define DPRC_CMDID_GET_RES_COUNT 0x15B |
| 27 | #define DPRC_CMDID_GET_RES_IDS 0x15C |
| 28 | #define DPRC_CMDID_GET_OBJ_REG 0x15E |
| 29 | |
| 30 | #define DPRC_CMDID_CONNECT 0x167 |
| 31 | #define DPRC_CMDID_DISCONNECT 0x168 |
| 32 | #define DPRC_CMDID_GET_CONNECTION 0x16C |
| 33 | |
| 34 | /* cmd, param, offset, width, type, arg_name */ |
| 35 | #define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \ |
| 36 | MC_RSP_OP(cmd, 0, 0, 32, int, container_id) |
| 37 | |
| 38 | /* cmd, param, offset, width, type, arg_name */ |
| 39 | #define DPRC_CMD_OPEN(cmd, container_id) \ |
| 40 | MC_CMD_OP(cmd, 0, 0, 32, int, container_id) |
| 41 | |
| 42 | /* cmd, param, offset, width, type, arg_name */ |
| 43 | #define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \ |
| 44 | MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id) |
| 45 | |
| 46 | /* cmd, param, offset, width, type, arg_name */ |
| 47 | #define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \ |
| 48 | do { \ |
| 49 | MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \ |
| 50 | MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \ |
| 51 | MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\ |
| 52 | MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \ |
| 53 | MC_RSP_OP(cmd, 2, 0, 16, uint16_t, attr->version.major);\ |
| 54 | MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\ |
| 55 | } while (0) |
| 56 | |
| 57 | /* cmd, param, offset, width, type, arg_name */ |
| 58 | #define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \ |
| 59 | MC_RSP_OP(cmd, 0, 32, 32, int, obj_count) |
| 60 | |
| 61 | /* cmd, param, offset, width, type, arg_name */ |
| 62 | #define DPRC_CMD_GET_OBJ(cmd, obj_index) \ |
| 63 | MC_CMD_OP(cmd, 0, 0, 32, int, obj_index) |
| 64 | |
| 65 | /* cmd, param, offset, width, type, arg_name */ |
| 66 | #define DPRC_RSP_GET_OBJ(cmd, obj_desc) \ |
| 67 | do { \ |
| 68 | MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \ |
| 69 | MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \ |
| 70 | MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \ |
| 71 | MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \ |
| 72 | MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\ |
| 73 | MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\ |
| 74 | MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\ |
| 75 | MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\ |
| 76 | MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\ |
| 77 | MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\ |
| 78 | MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\ |
| 79 | MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\ |
| 80 | MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\ |
| 81 | MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\ |
| 82 | MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\ |
| 83 | MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\ |
| 84 | MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\ |
| 85 | MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\ |
| 86 | MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\ |
| 87 | MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\ |
| 88 | MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\ |
| 89 | MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\ |
| 90 | MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\ |
| 91 | } while (0) |
| 92 | |
| 93 | /* cmd, param, offset, width, type, arg_name */ |
| 94 | #define DPRC_CMD_GET_RES_COUNT(cmd, type) \ |
| 95 | do { \ |
| 96 | MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\ |
| 97 | MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\ |
| 98 | MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\ |
| 99 | MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\ |
| 100 | MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\ |
| 101 | MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\ |
| 102 | MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\ |
| 103 | MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\ |
| 104 | MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\ |
| 105 | MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\ |
| 106 | MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\ |
| 107 | MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\ |
| 108 | MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\ |
| 109 | MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\ |
| 110 | MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\ |
| 111 | MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\ |
| 112 | } while (0) |
| 113 | |
| 114 | /* cmd, param, offset, width, type, arg_name */ |
| 115 | #define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \ |
| 116 | MC_RSP_OP(cmd, 0, 0, 32, int, res_count) |
| 117 | |
| 118 | /* cmd, param, offset, width, type, arg_name */ |
| 119 | #define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \ |
| 120 | do { \ |
| 121 | MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ |
| 122 | range_desc->iter_status); \ |
| 123 | MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ |
| 124 | MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ |
| 125 | MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\ |
| 126 | MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\ |
| 127 | MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\ |
| 128 | MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\ |
| 129 | MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\ |
| 130 | MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\ |
| 131 | MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\ |
| 132 | MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\ |
| 133 | MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\ |
| 134 | MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\ |
| 135 | MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\ |
| 136 | MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\ |
| 137 | MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\ |
| 138 | MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\ |
| 139 | MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\ |
| 140 | MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\ |
| 141 | } while (0) |
| 142 | |
| 143 | /* cmd, param, offset, width, type, arg_name */ |
| 144 | #define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \ |
| 145 | do { \ |
| 146 | MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \ |
| 147 | range_desc->iter_status);\ |
| 148 | MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \ |
| 149 | MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\ |
| 150 | } while (0) |
| 151 | |
| 152 | /* cmd, param, offset, width, type, arg_name */ |
| 153 | #define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \ |
| 154 | do { \ |
| 155 | MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \ |
| 156 | MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\ |
| 157 | MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\ |
| 158 | MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\ |
| 159 | MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\ |
| 160 | MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\ |
| 161 | MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\ |
| 162 | MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\ |
| 163 | MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\ |
| 164 | MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\ |
| 165 | MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\ |
| 166 | MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\ |
| 167 | MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\ |
| 168 | MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\ |
| 169 | MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\ |
| 170 | MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\ |
| 171 | MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\ |
| 172 | MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\ |
| 173 | } while (0) |
| 174 | |
| 175 | /* param, offset, width, type, arg_name */ |
| 176 | #define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \ |
| 177 | do { \ |
| 178 | MC_RSP_OP(cmd, 1, 0, 64, uint64_t, region_desc->base_paddr);\ |
| 179 | MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \ |
| 180 | } while (0) |
| 181 | |
| 182 | /* cmd, param, offset, width, type, arg_name */ |
| 183 | #define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2) \ |
| 184 | do { \ |
| 185 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ |
| 186 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->interface_id); \ |
| 187 | MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \ |
| 188 | MC_CMD_OP(cmd, 1, 32, 32, int, endpoint2->interface_id); \ |
| 189 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \ |
| 190 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \ |
| 191 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \ |
| 192 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \ |
| 193 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \ |
| 194 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \ |
| 195 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \ |
| 196 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \ |
| 197 | MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \ |
| 198 | MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \ |
| 199 | MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \ |
| 200 | MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \ |
| 201 | MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \ |
| 202 | MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \ |
| 203 | MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \ |
| 204 | MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \ |
| 205 | MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \ |
| 206 | MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \ |
| 207 | MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \ |
| 208 | MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \ |
| 209 | MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \ |
| 210 | MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \ |
| 211 | MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \ |
| 212 | MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \ |
| 213 | MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \ |
| 214 | MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \ |
| 215 | MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \ |
| 216 | MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \ |
| 217 | MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \ |
| 218 | MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \ |
| 219 | MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \ |
| 220 | MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \ |
| 221 | } while (0) |
| 222 | |
| 223 | /* cmd, param, offset, width, type, arg_name */ |
| 224 | #define DPRC_CMD_DISCONNECT(cmd, endpoint) \ |
| 225 | do { \ |
| 226 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \ |
| 227 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint->interface_id); \ |
| 228 | MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \ |
| 229 | MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \ |
| 230 | MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \ |
| 231 | MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \ |
| 232 | MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \ |
| 233 | MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \ |
| 234 | MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \ |
| 235 | MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \ |
| 236 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \ |
| 237 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \ |
| 238 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \ |
| 239 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \ |
| 240 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \ |
| 241 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \ |
| 242 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \ |
| 243 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \ |
| 244 | } while (0) |
| 245 | |
| 246 | /* cmd, param, offset, width, type, arg_name */ |
| 247 | #define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \ |
| 248 | do { \ |
| 249 | MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \ |
| 250 | MC_CMD_OP(cmd, 0, 32, 32, int, endpoint1->interface_id); \ |
| 251 | MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \ |
| 252 | MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \ |
| 253 | MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \ |
| 254 | MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \ |
| 255 | MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \ |
| 256 | MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \ |
| 257 | MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \ |
| 258 | MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \ |
| 259 | MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \ |
| 260 | MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \ |
| 261 | MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \ |
| 262 | MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \ |
| 263 | MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \ |
| 264 | MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \ |
| 265 | MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \ |
| 266 | MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \ |
| 267 | } while (0) |
| 268 | |
| 269 | |
| 270 | /* cmd, param, offset, width, type, arg_name */ |
| 271 | #define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \ |
| 272 | do { \ |
| 273 | MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \ |
| 274 | MC_RSP_OP(cmd, 3, 32, 32, int, endpoint2->interface_id); \ |
| 275 | MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \ |
| 276 | MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \ |
| 277 | MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \ |
| 278 | MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \ |
| 279 | MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \ |
| 280 | MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \ |
| 281 | MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \ |
| 282 | MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \ |
| 283 | MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \ |
| 284 | MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \ |
| 285 | MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \ |
| 286 | MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \ |
| 287 | MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \ |
| 288 | MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \ |
| 289 | MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \ |
| 290 | MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \ |
| 291 | MC_RSP_OP(cmd, 6, 0, 32, int, state); \ |
| 292 | } while (0) |
| 293 | |
| 294 | /* Data Path Resource Container API |
| 295 | * Contains DPRC API for managing and querying DPAA resources |
| 296 | */ |
| 297 | struct fsl_mc_io; |
| 298 | |
| 299 | /** |
| 300 | * Set this value as the icid value in dprc_cfg structure when creating a |
| 301 | * container, in case the ICID is not selected by the user and should be |
| 302 | * allocated by the DPRC from the pool of ICIDs. |
| 303 | */ |
| 304 | #define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0)) |
| 305 | |
| 306 | /** |
| 307 | * Set this value as the portal_id value in dprc_cfg structure when creating a |
| 308 | * container, in case the portal ID is not specifically selected by the |
| 309 | * user and should be allocated by the DPRC from the pool of portal ids. |
| 310 | */ |
| 311 | #define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0)) |
| 312 | |
| 313 | /** |
| 314 | * dprc_get_container_id() - Get container ID associated with a given portal. |
| 315 | * @mc_io: Pointer to MC portal's I/O object |
| 316 | * @container_id: Requested container ID |
| 317 | * |
| 318 | * Return: '0' on Success; Error code otherwise. |
| 319 | */ |
| 320 | int dprc_get_container_id(struct fsl_mc_io *mc_io, int *container_id); |
| 321 | |
| 322 | /** |
| 323 | * dprc_open() - Open DPRC object for use |
| 324 | * @mc_io: Pointer to MC portal's I/O object |
| 325 | * @container_id: Container ID to open |
| 326 | * @token: Returned token of DPRC object |
| 327 | * |
| 328 | * Return: '0' on Success; Error code otherwise. |
| 329 | * |
| 330 | * @warning Required before any operation on the object. |
| 331 | */ |
| 332 | int dprc_open(struct fsl_mc_io *mc_io, int container_id, uint16_t *token); |
| 333 | |
| 334 | /** |
| 335 | * dprc_close() - Close the control session of the object |
| 336 | * @mc_io: Pointer to MC portal's I/O object |
| 337 | * @token: Token of DPRC object |
| 338 | * |
| 339 | * After this function is called, no further operations are |
| 340 | * allowed on the object without opening a new control session. |
| 341 | * |
| 342 | * Return: '0' on Success; Error code otherwise. |
| 343 | */ |
| 344 | int dprc_close(struct fsl_mc_io *mc_io, uint16_t token); |
| 345 | |
| 346 | /** |
| 347 | * Container general options |
| 348 | * |
| 349 | * These options may be selected at container creation by the container creator |
| 350 | * and can be retrieved using dprc_get_attributes() |
| 351 | */ |
| 352 | |
| 353 | /* Spawn Policy Option allowed - Indicates that the new container is allowed |
| 354 | * to spawn and have its own child containers. |
| 355 | */ |
| 356 | #define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001 |
| 357 | |
| 358 | /* General Container allocation policy - Indicates that the new container is |
| 359 | * allowed to allocate requested resources from its parent container; if not |
| 360 | * set, the container is only allowed to use resources in its own pools; Note |
| 361 | * that this is a container's global policy, but the parent container may |
| 362 | * override it and set specific quota per resource type. |
| 363 | */ |
| 364 | #define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002 |
| 365 | |
| 366 | /* Object initialization allowed - software context associated with this |
| 367 | * container is allowed to invoke object initialization operations. |
| 368 | */ |
| 369 | #define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004 |
| 370 | |
| 371 | /* Topology change allowed - software context associated with this |
| 372 | * container is allowed to invoke topology operations, such as attach/detach |
| 373 | * of network objects. |
| 374 | */ |
| 375 | #define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008 |
| 376 | |
| 377 | /* IOMMU bypass - indicates whether objects of this container are permitted |
| 378 | * to bypass the IOMMU. |
| 379 | */ |
| 380 | #define DPRC_CFG_OPT_IOMMU_BYPASS 0x00000010 |
| 381 | |
| 382 | /* AIOP - Indicates that container belongs to AIOP. */ |
| 383 | #define DPRC_CFG_OPT_AIOP 0x00000020 |
| 384 | |
| 385 | /** |
| 386 | * struct dprc_cfg - Container configuration options |
| 387 | * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free |
| 388 | * ICID value is allocated by the DPRC |
| 389 | * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free |
| 390 | * portal ID is allocated by the DPRC |
| 391 | * @options: Combination of 'DPRC_CFG_OPT_<X>' options |
| 392 | */ |
| 393 | struct dprc_cfg { |
| 394 | uint16_t icid; |
| 395 | int portal_id; |
| 396 | uint64_t options; |
| 397 | }; |
| 398 | |
| 399 | /** |
| 400 | * dprc_reset_container - Reset child container. |
| 401 | * @mc_io: Pointer to MC portal's I/O object |
| 402 | * @token: Token of DPRC object |
| 403 | * @child_container_id: ID of the container to reset |
| 404 | * |
| 405 | * In case a software context crashes or becomes non-responsive, the parent |
| 406 | * may wish to reset its resources container before the software context is |
| 407 | * restarted. |
| 408 | * |
| 409 | * This routine informs all objects assigned to the child container that the |
| 410 | * container is being reset, so they may perform any cleanup operations that are |
| 411 | * needed. All objects handles that were owned by the child container shall be |
| 412 | * closed. |
| 413 | * |
| 414 | * Note that such request may be submitted even if the child software context |
| 415 | * has not crashed, but the resulting object cleanup operations will not be |
| 416 | * aware of that. |
| 417 | * |
| 418 | * Return: '0' on Success; Error code otherwise. |
| 419 | */ |
| 420 | int dprc_reset_container(struct fsl_mc_io *mc_io, |
| 421 | uint16_t token, |
| 422 | int child_container_id); |
| 423 | |
| 424 | /** |
| 425 | * struct dprc_attributes - Container attributes |
| 426 | * @container_id: Container's ID |
| 427 | * @icid: Container's ICID |
| 428 | * @portal_id: Container's portal ID |
| 429 | * @options: Container's options as set at container's creation |
| 430 | * @version: DPRC version |
| 431 | */ |
| 432 | struct dprc_attributes { |
| 433 | int container_id; |
| 434 | uint16_t icid; |
| 435 | int portal_id; |
| 436 | uint64_t options; |
| 437 | /** |
| 438 | * struct version - DPRC version |
| 439 | * @major: DPRC major version |
| 440 | * @minor: DPRC minor version |
| 441 | */ |
| 442 | struct { |
| 443 | uint16_t major; |
| 444 | uint16_t minor; |
| 445 | } version; |
| 446 | }; |
| 447 | |
| 448 | /** |
| 449 | * dprc_get_attributes() - Obtains container attributes |
| 450 | * @mc_io: Pointer to MC portal's I/O object |
| 451 | * @token: Token of DPRC object |
| 452 | * @attributes Returned container attributes |
| 453 | * |
| 454 | * Return: '0' on Success; Error code otherwise. |
| 455 | */ |
| 456 | int dprc_get_attributes(struct fsl_mc_io *mc_io, |
| 457 | uint16_t token, |
| 458 | struct dprc_attributes *attributes); |
| 459 | |
| 460 | /** |
| 461 | * dprc_get_obj_count() - Obtains the number of objects in the DPRC |
| 462 | * @mc_io: Pointer to MC portal's I/O object |
| 463 | * @token: Token of DPRC object |
| 464 | * @obj_count: Number of objects assigned to the DPRC |
| 465 | * |
| 466 | * Return: '0' on Success; Error code otherwise. |
| 467 | */ |
| 468 | int dprc_get_obj_count(struct fsl_mc_io *mc_io, uint16_t token, int *obj_count); |
| 469 | |
| 470 | /* Objects Attributes Flags */ |
| 471 | |
| 472 | /* Opened state - Indicates that an object is open by at least one owner */ |
| 473 | #define DPRC_OBJ_STATE_OPEN 0x00000001 |
| 474 | /* Plugged state - Indicates that the object is plugged */ |
| 475 | #define DPRC_OBJ_STATE_PLUGGED 0x00000002 |
| 476 | |
| 477 | /** |
| 478 | * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj() |
| 479 | * @type: Type of object: NULL terminated string |
| 480 | * @id: ID of logical object resource |
| 481 | * @vendor: Object vendor identifier |
| 482 | * @ver_major: Major version number |
| 483 | * @ver_minor: Minor version number |
| 484 | * @irq_count: Number of interrupts supported by the object |
| 485 | * @region_count: Number of mappable regions supported by the object |
| 486 | * @state: Object state: combination of DPRC_OBJ_STATE_ states |
| 487 | */ |
| 488 | struct dprc_obj_desc { |
| 489 | char type[16]; |
| 490 | int id; |
| 491 | uint16_t vendor; |
| 492 | uint16_t ver_major; |
| 493 | uint16_t ver_minor; |
| 494 | uint8_t irq_count; |
| 495 | uint8_t region_count; |
| 496 | uint32_t state; |
| 497 | }; |
| 498 | |
| 499 | /** |
| 500 | * dprc_get_obj() - Get general information on an object |
| 501 | * @mc_io: Pointer to MC portal's I/O object |
| 502 | * @token: Token of DPRC object |
| 503 | * @obj_index: Index of the object to be queried (< obj_count) |
| 504 | * @obj_desc: Returns the requested object descriptor |
| 505 | * |
| 506 | * The object descriptors are retrieved one by one by incrementing |
| 507 | * obj_index up to (not including) the value of obj_count returned |
| 508 | * from dprc_get_obj_count(). dprc_get_obj_count() must |
| 509 | * be called prior to dprc_get_obj(). |
| 510 | * |
| 511 | * Return: '0' on Success; Error code otherwise. |
| 512 | */ |
| 513 | int dprc_get_obj(struct fsl_mc_io *mc_io, |
| 514 | uint16_t token, |
| 515 | int obj_index, |
| 516 | struct dprc_obj_desc *obj_desc); |
| 517 | |
| 518 | /** |
| 519 | * dprc_get_res_count() - Obtains the number of free resources that are assigned |
| 520 | * to this container, by pool type |
| 521 | * @mc_io: Pointer to MC portal's I/O object |
| 522 | * @token: Token of DPRC object |
| 523 | * @type: pool type |
| 524 | * @res_count: Returned number of free resources of the given |
| 525 | * resource type that are assigned to this DPRC |
| 526 | * |
| 527 | * Return: '0' on Success; Error code otherwise. |
| 528 | */ |
| 529 | int dprc_get_res_count(struct fsl_mc_io *mc_io, |
| 530 | uint16_t token, |
| 531 | char *type, |
| 532 | int *res_count); |
| 533 | |
| 534 | /** |
| 535 | * enum dprc_iter_status - Iteration status |
| 536 | * @DPRC_ITER_STATUS_FIRST: Perform first iteration |
| 537 | * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed |
| 538 | * @DPRC_ITER_STATUS_LAST: Indicates last iteration |
| 539 | */ |
| 540 | enum dprc_iter_status { |
| 541 | DPRC_ITER_STATUS_FIRST = 0, |
| 542 | DPRC_ITER_STATUS_MORE = 1, |
| 543 | DPRC_ITER_STATUS_LAST = 2 |
| 544 | }; |
| 545 | |
| 546 | /** |
| 547 | * struct dprc_res_ids_range_desc - Resource ID range descriptor |
| 548 | * @base_id: Base resource ID of this range |
| 549 | * @last_id: Last resource ID of this range |
| 550 | * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at |
| 551 | * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE, |
| 552 | * additional iterations are needed, until the returned marker is |
| 553 | * DPRC_ITER_STATUS_LAST |
| 554 | */ |
| 555 | struct dprc_res_ids_range_desc { |
| 556 | int base_id; |
| 557 | int last_id; |
| 558 | enum dprc_iter_status iter_status; |
| 559 | }; |
| 560 | |
| 561 | /** |
| 562 | * dprc_get_res_ids() - Obtains IDs of free resources in the container |
| 563 | * @mc_io: Pointer to MC portal's I/O object |
| 564 | * @token: Token of DPRC object |
| 565 | * @type: pool type |
| 566 | * @range_desc: range descriptor |
| 567 | * |
| 568 | * Return: '0' on Success; Error code otherwise. |
| 569 | */ |
| 570 | int dprc_get_res_ids(struct fsl_mc_io *mc_io, |
| 571 | uint16_t token, |
| 572 | char *type, |
| 573 | struct dprc_res_ids_range_desc *range_desc); |
| 574 | |
| 575 | /** |
| 576 | * struct dprc_region_desc - Mappable region descriptor |
| 577 | * @base_paddr: Region base physical address |
| 578 | * @size: Region size (in bytes) |
| 579 | */ |
| 580 | struct dprc_region_desc { |
| 581 | uint64_t base_paddr; |
| 582 | uint32_t size; |
| 583 | }; |
| 584 | |
| 585 | /** |
| 586 | * dprc_get_obj_region() - Get region information for a specified object. |
| 587 | * @mc_io: Pointer to MC portal's I/O object |
| 588 | * @token: Token of DPRC object |
| 589 | * @obj_type; Object type as returned in dprc_get_obj() |
| 590 | * @obj_id: Unique object instance as returned in dprc_get_obj() |
| 591 | * @region_index: The specific region to query |
| 592 | * @region_desc: Returns the requested region descriptor |
| 593 | * |
| 594 | * Return: '0' on Success; Error code otherwise. |
| 595 | */ |
| 596 | int dprc_get_obj_region(struct fsl_mc_io *mc_io, |
| 597 | uint16_t token, |
| 598 | char *obj_type, |
| 599 | int obj_id, |
| 600 | uint8_t region_index, |
| 601 | struct dprc_region_desc *region_desc); |
| 602 | /** |
| 603 | * struct dprc_endpoint - Endpoint description for link connect/disconnect |
| 604 | * operations |
| 605 | * @type: Endpoint object type: NULL terminated string |
| 606 | * @id: Endpoint object ID |
| 607 | * @interface_id: Interface ID; should be set for endpoints with multiple |
| 608 | * interfaces ("dpsw", "dpdmux"); for others, always set to 0 |
| 609 | */ |
| 610 | struct dprc_endpoint { |
| 611 | char type[16]; |
| 612 | int id; |
| 613 | int interface_id; |
| 614 | }; |
| 615 | |
| 616 | /** |
| 617 | * dprc_connect() - Connect two endpoints to create a network link between them |
| 618 | * @mc_io: Pointer to MC portal's I/O object |
| 619 | * @token: Token of DPRC object |
| 620 | * @endpoint1: Endpoint 1 configuration parameters |
| 621 | * @endpoint2: Endpoint 2 configuration parameters |
| 622 | * |
| 623 | * Return: '0' on Success; Error code otherwise. |
| 624 | */ |
| 625 | int dprc_connect(struct fsl_mc_io *mc_io, |
| 626 | uint16_t token, |
| 627 | const struct dprc_endpoint *endpoint1, |
| 628 | const struct dprc_endpoint *endpoint2); |
| 629 | |
| 630 | /** |
| 631 | * dprc_disconnect() - Disconnect one endpoint to remove its network connection |
| 632 | * @mc_io: Pointer to MC portal's I/O object |
| 633 | * @token: Token of DPRC object |
| 634 | * @endpoint: Endpoint configuration parameters |
| 635 | * |
| 636 | * Return: '0' on Success; Error code otherwise. |
| 637 | */ |
| 638 | int dprc_disconnect(struct fsl_mc_io *mc_io, |
| 639 | uint16_t token, |
| 640 | const struct dprc_endpoint *endpoint); |
| 641 | |
| 642 | /** |
| 643 | * dprc_get_connection() - Get connected endpoint and link status if connection |
| 644 | * exists. |
| 645 | * @mc_io Pointer to MC portal's I/O object |
| 646 | * @token Token of DPRC object |
| 647 | * @endpoint1 Endpoint 1 configuration parameters |
| 648 | * @endpoint2 Returned endpoint 2 configuration parameters |
| 649 | * @state: Returned link state: 1 - link is up, 0 - link is down |
| 650 | * |
| 651 | * Return: '0' on Success; -ENAVAIL if connection does not exist. |
| 652 | */ |
| 653 | int dprc_get_connection(struct fsl_mc_io *mc_io, |
| 654 | uint16_t token, |
| 655 | const struct dprc_endpoint *endpoint1, |
| 656 | struct dprc_endpoint *endpoint2, |
| 657 | int *state); |
| 658 | |
| 659 | #endif /* _FSL_DPRC_H */ |