J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1 | /* Copyright 2013-2014 Freescale Semiconductor Inc. |
| 2 | * |
| 3 | * Redistribution and use in source and binary forms, with or without |
| 4 | * modification, are permitted provided that the following conditions are met: |
| 5 | * * Redistributions of source code must retain the above copyright |
| 6 | * notice, this list of conditions and the following disclaimer. |
| 7 | * * Redistributions in binary form must reproduce the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer in the |
| 9 | * documentation and/or other materials provided with the distribution. |
| 10 | * * Neither the name of the above-listed copyright holders nor the |
| 11 | * names of any contributors may be used to endorse or promote products |
| 12 | * derived from this software without specific prior written permission. |
| 13 | * |
| 14 | * |
| 15 | * ALTERNATIVELY, this software may be distributed under the terms of the |
| 16 | * GNU General Public License ("GPL") as published by the Free Software |
| 17 | * Foundation, either version 2 of that License or (at your option) any |
| 18 | * later version. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 | * POSSIBILITY OF SUCH DAMAGE. |
| 31 | */ |
| 32 | #include "../include/mc-sys.h" |
| 33 | #include "../include/mc-cmd.h" |
| 34 | #include "../include/dprc.h" |
| 35 | #include "dprc-cmd.h" |
| 36 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 37 | /** |
| 38 | * dprc_open() - Open DPRC object for use |
| 39 | * @mc_io: Pointer to MC portal's I/O object |
| 40 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 41 | * @container_id: Container ID to open |
| 42 | * @token: Returned token of DPRC object |
| 43 | * |
| 44 | * Return: '0' on Success; Error code otherwise. |
| 45 | * |
| 46 | * @warning Required before any operation on the object. |
| 47 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 48 | int dprc_open(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 49 | u32 cmd_flags, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 50 | int container_id, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 51 | u16 *token) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 52 | { |
| 53 | struct mc_command cmd = { 0 }; |
| 54 | int err; |
| 55 | |
| 56 | /* prepare command */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 57 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 58 | 0); |
| 59 | cmd.params[0] |= mc_enc(0, 32, container_id); |
| 60 | |
| 61 | /* send command to mc*/ |
| 62 | err = mc_send_command(mc_io, &cmd); |
| 63 | if (err) |
| 64 | return err; |
| 65 | |
| 66 | /* retrieve response parameters */ |
| 67 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | EXPORT_SYMBOL(dprc_open); |
| 72 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 73 | /** |
| 74 | * dprc_close() - Close the control session of the object |
| 75 | * @mc_io: Pointer to MC portal's I/O object |
| 76 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 77 | * @token: Token of DPRC object |
| 78 | * |
| 79 | * After this function is called, no further operations are |
| 80 | * allowed on the object without opening a new control session. |
| 81 | * |
| 82 | * Return: '0' on Success; Error code otherwise. |
| 83 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 84 | int dprc_close(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 85 | u32 cmd_flags, |
| 86 | u16 token) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 87 | { |
| 88 | struct mc_command cmd = { 0 }; |
| 89 | |
| 90 | /* prepare command */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 91 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLOSE, cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 92 | token); |
| 93 | |
| 94 | /* send command to mc*/ |
| 95 | return mc_send_command(mc_io, &cmd); |
| 96 | } |
| 97 | EXPORT_SYMBOL(dprc_close); |
| 98 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 99 | /** |
| 100 | * dprc_create_container() - Create child container |
| 101 | * @mc_io: Pointer to MC portal's I/O object |
| 102 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 103 | * @token: Token of DPRC object |
| 104 | * @cfg: Child container configuration |
| 105 | * @child_container_id: Returned child container ID |
| 106 | * @child_portal_offset: Returned child portal offset from MC portal base |
| 107 | * |
| 108 | * Return: '0' on Success; Error code otherwise. |
| 109 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 110 | int dprc_create_container(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 111 | u32 cmd_flags, |
| 112 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 113 | struct dprc_cfg *cfg, |
| 114 | int *child_container_id, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 115 | u64 *child_portal_offset) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 116 | { |
| 117 | struct mc_command cmd = { 0 }; |
| 118 | int err; |
| 119 | |
| 120 | /* prepare command */ |
| 121 | cmd.params[0] |= mc_enc(32, 16, cfg->icid); |
| 122 | cmd.params[0] |= mc_enc(0, 32, cfg->options); |
| 123 | cmd.params[1] |= mc_enc(32, 32, cfg->portal_id); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 124 | cmd.params[2] |= mc_enc(0, 8, cfg->label[0]); |
| 125 | cmd.params[2] |= mc_enc(8, 8, cfg->label[1]); |
| 126 | cmd.params[2] |= mc_enc(16, 8, cfg->label[2]); |
| 127 | cmd.params[2] |= mc_enc(24, 8, cfg->label[3]); |
| 128 | cmd.params[2] |= mc_enc(32, 8, cfg->label[4]); |
| 129 | cmd.params[2] |= mc_enc(40, 8, cfg->label[5]); |
| 130 | cmd.params[2] |= mc_enc(48, 8, cfg->label[6]); |
| 131 | cmd.params[2] |= mc_enc(56, 8, cfg->label[7]); |
| 132 | cmd.params[3] |= mc_enc(0, 8, cfg->label[8]); |
| 133 | cmd.params[3] |= mc_enc(8, 8, cfg->label[9]); |
| 134 | cmd.params[3] |= mc_enc(16, 8, cfg->label[10]); |
| 135 | cmd.params[3] |= mc_enc(24, 8, cfg->label[11]); |
| 136 | cmd.params[3] |= mc_enc(32, 8, cfg->label[12]); |
| 137 | cmd.params[3] |= mc_enc(40, 8, cfg->label[13]); |
| 138 | cmd.params[3] |= mc_enc(48, 8, cfg->label[14]); |
| 139 | cmd.params[3] |= mc_enc(56, 8, cfg->label[15]); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 140 | |
| 141 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 142 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 143 | |
| 144 | /* send command to mc*/ |
| 145 | err = mc_send_command(mc_io, &cmd); |
| 146 | if (err) |
| 147 | return err; |
| 148 | |
| 149 | /* retrieve response parameters */ |
| 150 | *child_container_id = mc_dec(cmd.params[1], 0, 32); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 151 | *child_portal_offset = mc_dec(cmd.params[2], 0, 64); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 152 | |
| 153 | return 0; |
| 154 | } |
| 155 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 156 | /** |
| 157 | * dprc_destroy_container() - Destroy child container. |
| 158 | * @mc_io: Pointer to MC portal's I/O object |
| 159 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 160 | * @token: Token of DPRC object |
| 161 | * @child_container_id: ID of the container to destroy |
| 162 | * |
| 163 | * This function terminates the child container, so following this call the |
| 164 | * child container ID becomes invalid. |
| 165 | * |
| 166 | * Notes: |
| 167 | * - All resources and objects of the destroyed container are returned to the |
| 168 | * parent container or destroyed if were created be the destroyed container. |
| 169 | * - This function destroy all the child containers of the specified |
| 170 | * container prior to destroying the container itself. |
| 171 | * |
| 172 | * warning: Only the parent container is allowed to destroy a child policy |
| 173 | * Container 0 can't be destroyed |
| 174 | * |
| 175 | * Return: '0' on Success; Error code otherwise. |
| 176 | * |
| 177 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 178 | int dprc_destroy_container(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 179 | u32 cmd_flags, |
| 180 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 181 | int child_container_id) |
| 182 | { |
| 183 | struct mc_command cmd = { 0 }; |
| 184 | |
| 185 | /* prepare command */ |
| 186 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 187 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 188 | cmd.params[0] |= mc_enc(0, 32, child_container_id); |
| 189 | |
| 190 | /* send command to mc*/ |
| 191 | return mc_send_command(mc_io, &cmd); |
| 192 | } |
| 193 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 194 | /** |
| 195 | * dprc_reset_container - Reset child container. |
| 196 | * @mc_io: Pointer to MC portal's I/O object |
| 197 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 198 | * @token: Token of DPRC object |
| 199 | * @child_container_id: ID of the container to reset |
| 200 | * |
| 201 | * In case a software context crashes or becomes non-responsive, the parent |
| 202 | * may wish to reset its resources container before the software context is |
| 203 | * restarted. |
| 204 | * |
| 205 | * This routine informs all objects assigned to the child container that the |
| 206 | * container is being reset, so they may perform any cleanup operations that are |
| 207 | * needed. All objects handles that were owned by the child container shall be |
| 208 | * closed. |
| 209 | * |
| 210 | * Note that such request may be submitted even if the child software context |
| 211 | * has not crashed, but the resulting object cleanup operations will not be |
| 212 | * aware of that. |
| 213 | * |
| 214 | * Return: '0' on Success; Error code otherwise. |
| 215 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 216 | int dprc_reset_container(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 217 | u32 cmd_flags, |
| 218 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 219 | int child_container_id) |
| 220 | { |
| 221 | struct mc_command cmd = { 0 }; |
| 222 | |
| 223 | /* prepare command */ |
| 224 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 225 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 226 | cmd.params[0] |= mc_enc(0, 32, child_container_id); |
| 227 | |
| 228 | /* send command to mc*/ |
| 229 | return mc_send_command(mc_io, &cmd); |
| 230 | } |
| 231 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 232 | /** |
| 233 | * dprc_get_irq() - Get IRQ information from the DPRC. |
| 234 | * @mc_io: Pointer to MC portal's I/O object |
| 235 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 236 | * @token: Token of DPRC object |
| 237 | * @irq_index: The interrupt index to configure |
| 238 | * @type: Interrupt type: 0 represents message interrupt |
| 239 | * type (both irq_addr and irq_val are valid) |
| 240 | * @irq_cfg: IRQ attributes |
| 241 | * |
| 242 | * Return: '0' on Success; Error code otherwise. |
| 243 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 244 | int dprc_get_irq(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 245 | u32 cmd_flags, |
| 246 | u16 token, |
| 247 | u8 irq_index, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 248 | int *type, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 249 | struct dprc_irq_cfg *irq_cfg) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 250 | { |
| 251 | struct mc_command cmd = { 0 }; |
| 252 | int err; |
| 253 | |
| 254 | /* prepare command */ |
| 255 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 256 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 257 | token); |
| 258 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 259 | |
| 260 | /* send command to mc*/ |
| 261 | err = mc_send_command(mc_io, &cmd); |
| 262 | if (err) |
| 263 | return err; |
| 264 | |
| 265 | /* retrieve response parameters */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 266 | irq_cfg->val = mc_dec(cmd.params[0], 0, 32); |
| 267 | irq_cfg->paddr = mc_dec(cmd.params[1], 0, 64); |
| 268 | irq_cfg->user_irq_id = mc_dec(cmd.params[2], 0, 32); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 269 | *type = mc_dec(cmd.params[2], 32, 32); |
| 270 | |
| 271 | return 0; |
| 272 | } |
| 273 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 274 | /** |
| 275 | * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt. |
| 276 | * @mc_io: Pointer to MC portal's I/O object |
| 277 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 278 | * @token: Token of DPRC object |
| 279 | * @irq_index: Identifies the interrupt index to configure |
| 280 | * @irq_cfg: IRQ configuration |
| 281 | * |
| 282 | * Return: '0' on Success; Error code otherwise. |
| 283 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 284 | int dprc_set_irq(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 285 | u32 cmd_flags, |
| 286 | u16 token, |
| 287 | u8 irq_index, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 288 | struct dprc_irq_cfg *irq_cfg) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 289 | { |
| 290 | struct mc_command cmd = { 0 }; |
| 291 | |
| 292 | /* prepare command */ |
| 293 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 294 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 295 | token); |
| 296 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 297 | cmd.params[0] |= mc_enc(0, 32, irq_cfg->val); |
| 298 | cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr); |
| 299 | cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 300 | |
| 301 | /* send command to mc*/ |
| 302 | return mc_send_command(mc_io, &cmd); |
| 303 | } |
| 304 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 305 | /** |
| 306 | * dprc_get_irq_enable() - Get overall interrupt state. |
| 307 | * @mc_io: Pointer to MC portal's I/O object |
| 308 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 309 | * @token: Token of DPRC object |
| 310 | * @irq_index: The interrupt index to configure |
| 311 | * @en: Returned interrupt state - enable = 1, disable = 0 |
| 312 | * |
| 313 | * Return: '0' on Success; Error code otherwise. |
| 314 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 315 | int dprc_get_irq_enable(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 316 | u32 cmd_flags, |
| 317 | u16 token, |
| 318 | u8 irq_index, |
| 319 | u8 *en) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 320 | { |
| 321 | struct mc_command cmd = { 0 }; |
| 322 | int err; |
| 323 | |
| 324 | /* prepare command */ |
| 325 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_ENABLE, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 326 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 327 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 328 | |
| 329 | /* send command to mc*/ |
| 330 | err = mc_send_command(mc_io, &cmd); |
| 331 | if (err) |
| 332 | return err; |
| 333 | |
| 334 | /* retrieve response parameters */ |
| 335 | *en = mc_dec(cmd.params[0], 0, 8); |
| 336 | |
| 337 | return 0; |
| 338 | } |
| 339 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 340 | /** |
| 341 | * dprc_set_irq_enable() - Set overall interrupt state. |
| 342 | * @mc_io: Pointer to MC portal's I/O object |
| 343 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 344 | * @token: Token of DPRC object |
| 345 | * @irq_index: The interrupt index to configure |
| 346 | * @en: Interrupt state - enable = 1, disable = 0 |
| 347 | * |
| 348 | * Allows GPP software to control when interrupts are generated. |
| 349 | * Each interrupt can have up to 32 causes. The enable/disable control's the |
| 350 | * overall interrupt state. if the interrupt is disabled no causes will cause |
| 351 | * an interrupt. |
| 352 | * |
| 353 | * Return: '0' on Success; Error code otherwise. |
| 354 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 355 | int dprc_set_irq_enable(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 356 | u32 cmd_flags, |
| 357 | u16 token, |
| 358 | u8 irq_index, |
| 359 | u8 en) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 360 | { |
| 361 | struct mc_command cmd = { 0 }; |
| 362 | |
| 363 | /* prepare command */ |
| 364 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_ENABLE, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 365 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 366 | cmd.params[0] |= mc_enc(0, 8, en); |
| 367 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 368 | |
| 369 | /* send command to mc*/ |
| 370 | return mc_send_command(mc_io, &cmd); |
| 371 | } |
| 372 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 373 | /** |
| 374 | * dprc_get_irq_mask() - Get interrupt mask. |
| 375 | * @mc_io: Pointer to MC portal's I/O object |
| 376 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 377 | * @token: Token of DPRC object |
| 378 | * @irq_index: The interrupt index to configure |
| 379 | * @mask: Returned event mask to trigger interrupt |
| 380 | * |
| 381 | * Every interrupt can have up to 32 causes and the interrupt model supports |
| 382 | * masking/unmasking each cause independently |
| 383 | * |
| 384 | * Return: '0' on Success; Error code otherwise. |
| 385 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 386 | int dprc_get_irq_mask(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 387 | u32 cmd_flags, |
| 388 | u16 token, |
| 389 | u8 irq_index, |
| 390 | u32 *mask) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 391 | { |
| 392 | struct mc_command cmd = { 0 }; |
| 393 | int err; |
| 394 | |
| 395 | /* prepare command */ |
| 396 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_MASK, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 397 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 398 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 399 | |
| 400 | /* send command to mc*/ |
| 401 | err = mc_send_command(mc_io, &cmd); |
| 402 | if (err) |
| 403 | return err; |
| 404 | |
| 405 | /* retrieve response parameters */ |
| 406 | *mask = mc_dec(cmd.params[0], 0, 32); |
| 407 | |
| 408 | return 0; |
| 409 | } |
| 410 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 411 | /** |
| 412 | * dprc_set_irq_mask() - Set interrupt mask. |
| 413 | * @mc_io: Pointer to MC portal's I/O object |
| 414 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 415 | * @token: Token of DPRC object |
| 416 | * @irq_index: The interrupt index to configure |
| 417 | * @mask: event mask to trigger interrupt; |
| 418 | * each bit: |
| 419 | * 0 = ignore event |
| 420 | * 1 = consider event for asserting irq |
| 421 | * |
| 422 | * Every interrupt can have up to 32 causes and the interrupt model supports |
| 423 | * masking/unmasking each cause independently |
| 424 | * |
| 425 | * Return: '0' on Success; Error code otherwise. |
| 426 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 427 | int dprc_set_irq_mask(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 428 | u32 cmd_flags, |
| 429 | u16 token, |
| 430 | u8 irq_index, |
| 431 | u32 mask) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 432 | { |
| 433 | struct mc_command cmd = { 0 }; |
| 434 | |
| 435 | /* prepare command */ |
| 436 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_MASK, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 437 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 438 | cmd.params[0] |= mc_enc(0, 32, mask); |
| 439 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 440 | |
| 441 | /* send command to mc*/ |
| 442 | return mc_send_command(mc_io, &cmd); |
| 443 | } |
| 444 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 445 | /** |
| 446 | * dprc_get_irq_status() - Get the current status of any pending interrupts. |
| 447 | * @mc_io: Pointer to MC portal's I/O object |
| 448 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 449 | * @token: Token of DPRC object |
| 450 | * @irq_index: The interrupt index to configure |
| 451 | * @status: Returned interrupts status - one bit per cause: |
| 452 | * 0 = no interrupt pending |
| 453 | * 1 = interrupt pending |
| 454 | * |
| 455 | * Return: '0' on Success; Error code otherwise. |
| 456 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 457 | int dprc_get_irq_status(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 458 | u32 cmd_flags, |
| 459 | u16 token, |
| 460 | u8 irq_index, |
| 461 | u32 *status) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 462 | { |
| 463 | struct mc_command cmd = { 0 }; |
| 464 | int err; |
| 465 | |
| 466 | /* prepare command */ |
| 467 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 468 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 469 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 470 | |
| 471 | /* send command to mc*/ |
| 472 | err = mc_send_command(mc_io, &cmd); |
| 473 | if (err) |
| 474 | return err; |
| 475 | |
| 476 | /* retrieve response parameters */ |
| 477 | *status = mc_dec(cmd.params[0], 0, 32); |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 482 | /** |
| 483 | * dprc_clear_irq_status() - Clear a pending interrupt's status |
| 484 | * @mc_io: Pointer to MC portal's I/O object |
| 485 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 486 | * @token: Token of DPRC object |
| 487 | * @irq_index: The interrupt index to configure |
| 488 | * @status: bits to clear (W1C) - one bit per cause: |
| 489 | * 0 = don't change |
| 490 | * 1 = clear status bit |
| 491 | * |
| 492 | * Return: '0' on Success; Error code otherwise. |
| 493 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 494 | int dprc_clear_irq_status(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 495 | u32 cmd_flags, |
| 496 | u16 token, |
| 497 | u8 irq_index, |
| 498 | u32 status) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 499 | { |
| 500 | struct mc_command cmd = { 0 }; |
| 501 | |
| 502 | /* prepare command */ |
| 503 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLEAR_IRQ_STATUS, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 504 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 505 | cmd.params[0] |= mc_enc(0, 32, status); |
| 506 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 507 | |
| 508 | /* send command to mc*/ |
| 509 | return mc_send_command(mc_io, &cmd); |
| 510 | } |
| 511 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 512 | /** |
| 513 | * dprc_get_attributes() - Obtains container attributes |
| 514 | * @mc_io: Pointer to MC portal's I/O object |
| 515 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 516 | * @token: Token of DPRC object |
| 517 | * @attributes Returned container attributes |
| 518 | * |
| 519 | * Return: '0' on Success; Error code otherwise. |
| 520 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 521 | int dprc_get_attributes(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 522 | u32 cmd_flags, |
| 523 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 524 | struct dprc_attributes *attr) |
| 525 | { |
| 526 | struct mc_command cmd = { 0 }; |
| 527 | int err; |
| 528 | |
| 529 | /* prepare command */ |
| 530 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_ATTR, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 531 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 532 | token); |
| 533 | |
| 534 | /* send command to mc*/ |
| 535 | err = mc_send_command(mc_io, &cmd); |
| 536 | if (err) |
| 537 | return err; |
| 538 | |
| 539 | /* retrieve response parameters */ |
| 540 | attr->container_id = mc_dec(cmd.params[0], 0, 32); |
| 541 | attr->icid = mc_dec(cmd.params[0], 32, 16); |
| 542 | attr->options = mc_dec(cmd.params[1], 0, 32); |
| 543 | attr->portal_id = mc_dec(cmd.params[1], 32, 32); |
| 544 | attr->version.major = mc_dec(cmd.params[2], 0, 16); |
| 545 | attr->version.minor = mc_dec(cmd.params[2], 16, 16); |
| 546 | |
| 547 | return 0; |
| 548 | } |
| 549 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 550 | /** |
| 551 | * dprc_set_res_quota() - Set allocation policy for a specific resource/object |
| 552 | * type in a child container |
| 553 | * @mc_io: Pointer to MC portal's I/O object |
| 554 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 555 | * @token: Token of DPRC object |
| 556 | * @child_container_id: ID of the child container |
| 557 | * @type: Resource/object type |
| 558 | * @quota: Sets the maximum number of resources of the selected type |
| 559 | * that the child container is allowed to allocate from its parent; |
| 560 | * when quota is set to -1, the policy is the same as container's |
| 561 | * general policy. |
| 562 | * |
| 563 | * Allocation policy determines whether or not a container may allocate |
| 564 | * resources from its parent. Each container has a 'global' allocation policy |
| 565 | * that is set when the container is created. |
| 566 | * |
| 567 | * This function sets allocation policy for a specific resource type. |
| 568 | * The default policy for all resource types matches the container's 'global' |
| 569 | * allocation policy. |
| 570 | * |
| 571 | * Return: '0' on Success; Error code otherwise. |
| 572 | * |
| 573 | * @warning Only the parent container is allowed to change a child policy. |
| 574 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 575 | int dprc_set_res_quota(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 576 | u32 cmd_flags, |
| 577 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 578 | int child_container_id, |
| 579 | char *type, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 580 | u16 quota) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 581 | { |
| 582 | struct mc_command cmd = { 0 }; |
| 583 | |
| 584 | /* prepare command */ |
| 585 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_RES_QUOTA, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 586 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 587 | cmd.params[0] |= mc_enc(0, 32, child_container_id); |
| 588 | cmd.params[0] |= mc_enc(32, 16, quota); |
| 589 | cmd.params[1] |= mc_enc(0, 8, type[0]); |
| 590 | cmd.params[1] |= mc_enc(8, 8, type[1]); |
| 591 | cmd.params[1] |= mc_enc(16, 8, type[2]); |
| 592 | cmd.params[1] |= mc_enc(24, 8, type[3]); |
| 593 | cmd.params[1] |= mc_enc(32, 8, type[4]); |
| 594 | cmd.params[1] |= mc_enc(40, 8, type[5]); |
| 595 | cmd.params[1] |= mc_enc(48, 8, type[6]); |
| 596 | cmd.params[1] |= mc_enc(56, 8, type[7]); |
| 597 | cmd.params[2] |= mc_enc(0, 8, type[8]); |
| 598 | cmd.params[2] |= mc_enc(8, 8, type[9]); |
| 599 | cmd.params[2] |= mc_enc(16, 8, type[10]); |
| 600 | cmd.params[2] |= mc_enc(24, 8, type[11]); |
| 601 | cmd.params[2] |= mc_enc(32, 8, type[12]); |
| 602 | cmd.params[2] |= mc_enc(40, 8, type[13]); |
| 603 | cmd.params[2] |= mc_enc(48, 8, type[14]); |
| 604 | cmd.params[2] |= mc_enc(56, 8, '\0'); |
| 605 | |
| 606 | /* send command to mc*/ |
| 607 | return mc_send_command(mc_io, &cmd); |
| 608 | } |
| 609 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 610 | /** |
| 611 | * dprc_get_res_quota() - Gets the allocation policy of a specific |
| 612 | * resource/object type in a child container |
| 613 | * @mc_io: Pointer to MC portal's I/O object |
| 614 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 615 | * @token: Token of DPRC object |
| 616 | * @child_container_id; ID of the child container |
| 617 | * @type: resource/object type |
| 618 | * @quota: Returnes the maximum number of resources of the selected type |
| 619 | * that the child container is allowed to allocate from the parent; |
| 620 | * when quota is set to -1, the policy is the same as container's |
| 621 | * general policy. |
| 622 | * |
| 623 | * Return: '0' on Success; Error code otherwise. |
| 624 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 625 | int dprc_get_res_quota(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 626 | u32 cmd_flags, |
| 627 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 628 | int child_container_id, |
| 629 | char *type, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 630 | u16 *quota) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 631 | { |
| 632 | struct mc_command cmd = { 0 }; |
| 633 | int err; |
| 634 | |
| 635 | /* prepare command */ |
| 636 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_QUOTA, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 637 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 638 | cmd.params[0] |= mc_enc(0, 32, child_container_id); |
| 639 | cmd.params[1] |= mc_enc(0, 8, type[0]); |
| 640 | cmd.params[1] |= mc_enc(8, 8, type[1]); |
| 641 | cmd.params[1] |= mc_enc(16, 8, type[2]); |
| 642 | cmd.params[1] |= mc_enc(24, 8, type[3]); |
| 643 | cmd.params[1] |= mc_enc(32, 8, type[4]); |
| 644 | cmd.params[1] |= mc_enc(40, 8, type[5]); |
| 645 | cmd.params[1] |= mc_enc(48, 8, type[6]); |
| 646 | cmd.params[1] |= mc_enc(56, 8, type[7]); |
| 647 | cmd.params[2] |= mc_enc(0, 8, type[8]); |
| 648 | cmd.params[2] |= mc_enc(8, 8, type[9]); |
| 649 | cmd.params[2] |= mc_enc(16, 8, type[10]); |
| 650 | cmd.params[2] |= mc_enc(24, 8, type[11]); |
| 651 | cmd.params[2] |= mc_enc(32, 8, type[12]); |
| 652 | cmd.params[2] |= mc_enc(40, 8, type[13]); |
| 653 | cmd.params[2] |= mc_enc(48, 8, type[14]); |
| 654 | cmd.params[2] |= mc_enc(56, 8, '\0'); |
| 655 | |
| 656 | /* send command to mc*/ |
| 657 | err = mc_send_command(mc_io, &cmd); |
| 658 | if (err) |
| 659 | return err; |
| 660 | |
| 661 | /* retrieve response parameters */ |
| 662 | *quota = mc_dec(cmd.params[0], 32, 16); |
| 663 | |
| 664 | return 0; |
| 665 | } |
| 666 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 667 | /** |
| 668 | * dprc_assign() - Assigns objects or resource to a child container. |
| 669 | * @mc_io: Pointer to MC portal's I/O object |
| 670 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 671 | * @token: Token of DPRC object |
| 672 | * @container_id: ID of the child container |
| 673 | * @res_req: Describes the type and amount of resources to |
| 674 | * assign to the given container |
| 675 | * |
| 676 | * Assignment is usually done by a parent (this DPRC) to one of its child |
| 677 | * containers. |
| 678 | * |
| 679 | * According to the DPRC allocation policy, the assigned resources may be taken |
| 680 | * (allocated) from the container's ancestors, if not enough resources are |
| 681 | * available in the container itself. |
| 682 | * |
| 683 | * The type of assignment depends on the dprc_res_req options, as follows: |
| 684 | * - DPRC_RES_REQ_OPT_EXPLICIT: indicates that assigned resources should have |
| 685 | * the explicit base ID specified at the id_base_align field of res_req. |
| 686 | * - DPRC_RES_REQ_OPT_ALIGNED: indicates that the assigned resources should be |
| 687 | * aligned to the value given at id_base_align field of res_req. |
| 688 | * - DPRC_RES_REQ_OPT_PLUGGED: Relevant only for object assignment, |
| 689 | * and indicates that the object must be set to the plugged state. |
| 690 | * |
| 691 | * A container may use this function with its own ID in order to change a |
| 692 | * object state to plugged or unplugged. |
| 693 | * |
| 694 | * If IRQ information has been set in the child DPRC, it will signal an |
| 695 | * interrupt following every change in its object assignment. |
| 696 | * |
| 697 | * Return: '0' on Success; Error code otherwise. |
| 698 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 699 | int dprc_assign(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 700 | u32 cmd_flags, |
| 701 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 702 | int container_id, |
| 703 | struct dprc_res_req *res_req) |
| 704 | { |
| 705 | struct mc_command cmd = { 0 }; |
| 706 | |
| 707 | /* prepare command */ |
| 708 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_ASSIGN, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 709 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 710 | cmd.params[0] |= mc_enc(0, 32, container_id); |
| 711 | cmd.params[0] |= mc_enc(32, 32, res_req->options); |
| 712 | cmd.params[1] |= mc_enc(0, 32, res_req->num); |
| 713 | cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align); |
| 714 | cmd.params[2] |= mc_enc(0, 8, res_req->type[0]); |
| 715 | cmd.params[2] |= mc_enc(8, 8, res_req->type[1]); |
| 716 | cmd.params[2] |= mc_enc(16, 8, res_req->type[2]); |
| 717 | cmd.params[2] |= mc_enc(24, 8, res_req->type[3]); |
| 718 | cmd.params[2] |= mc_enc(32, 8, res_req->type[4]); |
| 719 | cmd.params[2] |= mc_enc(40, 8, res_req->type[5]); |
| 720 | cmd.params[2] |= mc_enc(48, 8, res_req->type[6]); |
| 721 | cmd.params[2] |= mc_enc(56, 8, res_req->type[7]); |
| 722 | cmd.params[3] |= mc_enc(0, 8, res_req->type[8]); |
| 723 | cmd.params[3] |= mc_enc(8, 8, res_req->type[9]); |
| 724 | cmd.params[3] |= mc_enc(16, 8, res_req->type[10]); |
| 725 | cmd.params[3] |= mc_enc(24, 8, res_req->type[11]); |
| 726 | cmd.params[3] |= mc_enc(32, 8, res_req->type[12]); |
| 727 | cmd.params[3] |= mc_enc(40, 8, res_req->type[13]); |
| 728 | cmd.params[3] |= mc_enc(48, 8, res_req->type[14]); |
| 729 | cmd.params[3] |= mc_enc(56, 8, res_req->type[15]); |
| 730 | |
| 731 | /* send command to mc*/ |
| 732 | return mc_send_command(mc_io, &cmd); |
| 733 | } |
| 734 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 735 | /** |
| 736 | * dprc_unassign() - Un-assigns objects or resources from a child container |
| 737 | * and moves them into this (parent) DPRC. |
| 738 | * @mc_io: Pointer to MC portal's I/O object |
| 739 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 740 | * @token: Token of DPRC object |
| 741 | * @child_container_id: ID of the child container |
| 742 | * @res_req: Describes the type and amount of resources to un-assign from |
| 743 | * the child container |
| 744 | * |
| 745 | * Un-assignment of objects can succeed only if the object is not in the |
| 746 | * plugged or opened state. |
| 747 | * |
| 748 | * Return: '0' on Success; Error code otherwise. |
| 749 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 750 | int dprc_unassign(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 751 | u32 cmd_flags, |
| 752 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 753 | int child_container_id, |
| 754 | struct dprc_res_req *res_req) |
| 755 | { |
| 756 | struct mc_command cmd = { 0 }; |
| 757 | |
| 758 | /* prepare command */ |
| 759 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_UNASSIGN, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 760 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 761 | token); |
| 762 | cmd.params[0] |= mc_enc(0, 32, child_container_id); |
| 763 | cmd.params[0] |= mc_enc(32, 32, res_req->options); |
| 764 | cmd.params[1] |= mc_enc(0, 32, res_req->num); |
| 765 | cmd.params[1] |= mc_enc(32, 32, res_req->id_base_align); |
| 766 | cmd.params[2] |= mc_enc(0, 8, res_req->type[0]); |
| 767 | cmd.params[2] |= mc_enc(8, 8, res_req->type[1]); |
| 768 | cmd.params[2] |= mc_enc(16, 8, res_req->type[2]); |
| 769 | cmd.params[2] |= mc_enc(24, 8, res_req->type[3]); |
| 770 | cmd.params[2] |= mc_enc(32, 8, res_req->type[4]); |
| 771 | cmd.params[2] |= mc_enc(40, 8, res_req->type[5]); |
| 772 | cmd.params[2] |= mc_enc(48, 8, res_req->type[6]); |
| 773 | cmd.params[2] |= mc_enc(56, 8, res_req->type[7]); |
| 774 | cmd.params[3] |= mc_enc(0, 8, res_req->type[8]); |
| 775 | cmd.params[3] |= mc_enc(8, 8, res_req->type[9]); |
| 776 | cmd.params[3] |= mc_enc(16, 8, res_req->type[10]); |
| 777 | cmd.params[3] |= mc_enc(24, 8, res_req->type[11]); |
| 778 | cmd.params[3] |= mc_enc(32, 8, res_req->type[12]); |
| 779 | cmd.params[3] |= mc_enc(40, 8, res_req->type[13]); |
| 780 | cmd.params[3] |= mc_enc(48, 8, res_req->type[14]); |
| 781 | cmd.params[3] |= mc_enc(56, 8, res_req->type[15]); |
| 782 | |
| 783 | /* send command to mc*/ |
| 784 | return mc_send_command(mc_io, &cmd); |
| 785 | } |
| 786 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 787 | /** |
| 788 | * dprc_get_pool_count() - Get the number of dprc's pools |
| 789 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 790 | * @mc_io: Pointer to MC portal's I/O object |
| 791 | * @token: Token of DPRC object |
| 792 | * @pool_count: Returned number of resource pools in the dprc |
| 793 | * |
| 794 | * Return: '0' on Success; Error code otherwise. |
| 795 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 796 | int dprc_get_pool_count(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 797 | u32 cmd_flags, |
| 798 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 799 | int *pool_count) |
| 800 | { |
| 801 | struct mc_command cmd = { 0 }; |
| 802 | int err; |
| 803 | |
| 804 | /* prepare command */ |
| 805 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL_COUNT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 806 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 807 | |
| 808 | /* send command to mc*/ |
| 809 | err = mc_send_command(mc_io, &cmd); |
| 810 | if (err) |
| 811 | return err; |
| 812 | |
| 813 | /* retrieve response parameters */ |
| 814 | *pool_count = mc_dec(cmd.params[0], 0, 32); |
| 815 | |
| 816 | return 0; |
| 817 | } |
| 818 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 819 | /** |
| 820 | * dprc_get_pool() - Get the type (string) of a certain dprc's pool |
| 821 | * @mc_io: Pointer to MC portal's I/O object |
| 822 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 823 | * @token: Token of DPRC object |
| 824 | * @pool_index; Index of the pool to be queried (< pool_count) |
| 825 | * @type: The type of the pool |
| 826 | * |
| 827 | * The pool types retrieved one by one by incrementing |
| 828 | * pool_index up to (not including) the value of pool_count returned |
| 829 | * from dprc_get_pool_count(). dprc_get_pool_count() must |
| 830 | * be called prior to dprc_get_pool(). |
| 831 | * |
| 832 | * Return: '0' on Success; Error code otherwise. |
| 833 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 834 | int dprc_get_pool(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 835 | u32 cmd_flags, |
| 836 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 837 | int pool_index, |
| 838 | char *type) |
| 839 | { |
| 840 | struct mc_command cmd = { 0 }; |
| 841 | int err; |
| 842 | |
| 843 | /* prepare command */ |
| 844 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 845 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 846 | token); |
| 847 | cmd.params[0] |= mc_enc(0, 32, pool_index); |
| 848 | |
| 849 | /* send command to mc*/ |
| 850 | err = mc_send_command(mc_io, &cmd); |
| 851 | if (err) |
| 852 | return err; |
| 853 | |
| 854 | /* retrieve response parameters */ |
| 855 | type[0] = mc_dec(cmd.params[1], 0, 8); |
| 856 | type[1] = mc_dec(cmd.params[1], 8, 8); |
| 857 | type[2] = mc_dec(cmd.params[1], 16, 8); |
| 858 | type[3] = mc_dec(cmd.params[1], 24, 8); |
| 859 | type[4] = mc_dec(cmd.params[1], 32, 8); |
| 860 | type[5] = mc_dec(cmd.params[1], 40, 8); |
| 861 | type[6] = mc_dec(cmd.params[1], 48, 8); |
| 862 | type[7] = mc_dec(cmd.params[1], 56, 8); |
| 863 | type[8] = mc_dec(cmd.params[2], 0, 8); |
| 864 | type[9] = mc_dec(cmd.params[2], 8, 8); |
| 865 | type[10] = mc_dec(cmd.params[2], 16, 8); |
| 866 | type[11] = mc_dec(cmd.params[2], 24, 8); |
| 867 | type[12] = mc_dec(cmd.params[2], 32, 8); |
| 868 | type[13] = mc_dec(cmd.params[2], 40, 8); |
| 869 | type[14] = mc_dec(cmd.params[2], 48, 8); |
| 870 | type[15] = '\0'; |
| 871 | |
| 872 | return 0; |
| 873 | } |
| 874 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 875 | /** |
| 876 | * dprc_get_obj_count() - Obtains the number of objects in the DPRC |
| 877 | * @mc_io: Pointer to MC portal's I/O object |
| 878 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 879 | * @token: Token of DPRC object |
| 880 | * @obj_count: Number of objects assigned to the DPRC |
| 881 | * |
| 882 | * Return: '0' on Success; Error code otherwise. |
| 883 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 884 | int dprc_get_obj_count(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 885 | u32 cmd_flags, |
| 886 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 887 | int *obj_count) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 888 | { |
| 889 | struct mc_command cmd = { 0 }; |
| 890 | int err; |
| 891 | |
| 892 | /* prepare command */ |
| 893 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 894 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 895 | |
| 896 | /* send command to mc*/ |
| 897 | err = mc_send_command(mc_io, &cmd); |
| 898 | if (err) |
| 899 | return err; |
| 900 | |
| 901 | /* retrieve response parameters */ |
| 902 | *obj_count = mc_dec(cmd.params[0], 32, 32); |
| 903 | |
| 904 | return 0; |
| 905 | } |
| 906 | EXPORT_SYMBOL(dprc_get_obj_count); |
| 907 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 908 | /** |
| 909 | * dprc_get_obj() - Get general information on an object |
| 910 | * @mc_io: Pointer to MC portal's I/O object |
| 911 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 912 | * @token: Token of DPRC object |
| 913 | * @obj_index: Index of the object to be queried (< obj_count) |
| 914 | * @obj_desc: Returns the requested object descriptor |
| 915 | * |
| 916 | * The object descriptors are retrieved one by one by incrementing |
| 917 | * obj_index up to (not including) the value of obj_count returned |
| 918 | * from dprc_get_obj_count(). dprc_get_obj_count() must |
| 919 | * be called prior to dprc_get_obj(). |
| 920 | * |
| 921 | * Return: '0' on Success; Error code otherwise. |
| 922 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 923 | int dprc_get_obj(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 924 | u32 cmd_flags, |
| 925 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 926 | int obj_index, |
| 927 | struct dprc_obj_desc *obj_desc) |
| 928 | { |
| 929 | struct mc_command cmd = { 0 }; |
| 930 | int err; |
| 931 | |
| 932 | /* prepare command */ |
| 933 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 934 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 935 | token); |
| 936 | cmd.params[0] |= mc_enc(0, 32, obj_index); |
| 937 | |
| 938 | /* send command to mc*/ |
| 939 | err = mc_send_command(mc_io, &cmd); |
| 940 | if (err) |
| 941 | return err; |
| 942 | |
| 943 | /* retrieve response parameters */ |
| 944 | obj_desc->id = mc_dec(cmd.params[0], 32, 32); |
| 945 | obj_desc->vendor = mc_dec(cmd.params[1], 0, 16); |
| 946 | obj_desc->irq_count = mc_dec(cmd.params[1], 16, 8); |
| 947 | obj_desc->region_count = mc_dec(cmd.params[1], 24, 8); |
| 948 | obj_desc->state = mc_dec(cmd.params[1], 32, 32); |
| 949 | obj_desc->ver_major = mc_dec(cmd.params[2], 0, 16); |
| 950 | obj_desc->ver_minor = mc_dec(cmd.params[2], 16, 16); |
| 951 | obj_desc->type[0] = mc_dec(cmd.params[3], 0, 8); |
| 952 | obj_desc->type[1] = mc_dec(cmd.params[3], 8, 8); |
| 953 | obj_desc->type[2] = mc_dec(cmd.params[3], 16, 8); |
| 954 | obj_desc->type[3] = mc_dec(cmd.params[3], 24, 8); |
| 955 | obj_desc->type[4] = mc_dec(cmd.params[3], 32, 8); |
| 956 | obj_desc->type[5] = mc_dec(cmd.params[3], 40, 8); |
| 957 | obj_desc->type[6] = mc_dec(cmd.params[3], 48, 8); |
| 958 | obj_desc->type[7] = mc_dec(cmd.params[3], 56, 8); |
| 959 | obj_desc->type[8] = mc_dec(cmd.params[4], 0, 8); |
| 960 | obj_desc->type[9] = mc_dec(cmd.params[4], 8, 8); |
| 961 | obj_desc->type[10] = mc_dec(cmd.params[4], 16, 8); |
| 962 | obj_desc->type[11] = mc_dec(cmd.params[4], 24, 8); |
| 963 | obj_desc->type[12] = mc_dec(cmd.params[4], 32, 8); |
| 964 | obj_desc->type[13] = mc_dec(cmd.params[4], 40, 8); |
| 965 | obj_desc->type[14] = mc_dec(cmd.params[4], 48, 8); |
| 966 | obj_desc->type[15] = '\0'; |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 967 | obj_desc->label[0] = mc_dec(cmd.params[5], 0, 8); |
| 968 | obj_desc->label[1] = mc_dec(cmd.params[5], 8, 8); |
| 969 | obj_desc->label[2] = mc_dec(cmd.params[5], 16, 8); |
| 970 | obj_desc->label[3] = mc_dec(cmd.params[5], 24, 8); |
| 971 | obj_desc->label[4] = mc_dec(cmd.params[5], 32, 8); |
| 972 | obj_desc->label[5] = mc_dec(cmd.params[5], 40, 8); |
| 973 | obj_desc->label[6] = mc_dec(cmd.params[5], 48, 8); |
| 974 | obj_desc->label[7] = mc_dec(cmd.params[5], 56, 8); |
| 975 | obj_desc->label[8] = mc_dec(cmd.params[6], 0, 8); |
| 976 | obj_desc->label[9] = mc_dec(cmd.params[6], 8, 8); |
| 977 | obj_desc->label[10] = mc_dec(cmd.params[6], 16, 8); |
| 978 | obj_desc->label[11] = mc_dec(cmd.params[6], 24, 8); |
| 979 | obj_desc->label[12] = mc_dec(cmd.params[6], 32, 8); |
| 980 | obj_desc->label[13] = mc_dec(cmd.params[6], 40, 8); |
| 981 | obj_desc->label[14] = mc_dec(cmd.params[6], 48, 8); |
| 982 | obj_desc->label[15] = '\0'; |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 983 | return 0; |
| 984 | } |
| 985 | EXPORT_SYMBOL(dprc_get_obj); |
| 986 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 987 | /** |
| 988 | * dprc_get_obj_desc() - Get object descriptor. |
| 989 | * |
| 990 | * @mc_io: Pointer to MC portal's I/O object |
| 991 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 992 | * @token: Token of DPRC object |
| 993 | * @obj_type: The type of the object to get its descriptor. |
| 994 | * @obj_id: The id of the object to get its descriptor |
| 995 | * @obj_desc: The returned descriptor to fill and return to the user |
| 996 | * |
| 997 | * Return: '0' on Success; Error code otherwise. |
| 998 | * |
| 999 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1000 | int dprc_get_obj_desc(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1001 | u32 cmd_flags, |
| 1002 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1003 | char *obj_type, |
| 1004 | int obj_id, |
| 1005 | struct dprc_obj_desc *obj_desc) |
| 1006 | { |
| 1007 | struct mc_command cmd = { 0 }; |
| 1008 | int err; |
| 1009 | |
| 1010 | /* prepare command */ |
| 1011 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_DESC, |
| 1012 | cmd_flags, |
| 1013 | token); |
| 1014 | cmd.params[0] |= mc_enc(0, 32, obj_id); |
| 1015 | cmd.params[1] |= mc_enc(0, 8, obj_type[0]); |
| 1016 | cmd.params[1] |= mc_enc(8, 8, obj_type[1]); |
| 1017 | cmd.params[1] |= mc_enc(16, 8, obj_type[2]); |
| 1018 | cmd.params[1] |= mc_enc(24, 8, obj_type[3]); |
| 1019 | cmd.params[1] |= mc_enc(32, 8, obj_type[4]); |
| 1020 | cmd.params[1] |= mc_enc(40, 8, obj_type[5]); |
| 1021 | cmd.params[1] |= mc_enc(48, 8, obj_type[6]); |
| 1022 | cmd.params[1] |= mc_enc(56, 8, obj_type[7]); |
| 1023 | cmd.params[2] |= mc_enc(0, 8, obj_type[8]); |
| 1024 | cmd.params[2] |= mc_enc(8, 8, obj_type[9]); |
| 1025 | cmd.params[2] |= mc_enc(16, 8, obj_type[10]); |
| 1026 | cmd.params[2] |= mc_enc(24, 8, obj_type[11]); |
| 1027 | cmd.params[2] |= mc_enc(32, 8, obj_type[12]); |
| 1028 | cmd.params[2] |= mc_enc(40, 8, obj_type[13]); |
| 1029 | cmd.params[2] |= mc_enc(48, 8, obj_type[14]); |
| 1030 | cmd.params[2] |= mc_enc(56, 8, obj_type[15]); |
| 1031 | |
| 1032 | /* send command to mc*/ |
| 1033 | err = mc_send_command(mc_io, &cmd); |
| 1034 | if (err) |
| 1035 | return err; |
| 1036 | |
| 1037 | /* retrieve response parameters */ |
| 1038 | obj_desc->id = (int)mc_dec(cmd.params[0], 32, 32); |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1039 | obj_desc->vendor = (u16)mc_dec(cmd.params[1], 0, 16); |
| 1040 | obj_desc->vendor = (u8)mc_dec(cmd.params[1], 16, 8); |
| 1041 | obj_desc->region_count = (u8)mc_dec(cmd.params[1], 24, 8); |
| 1042 | obj_desc->state = (u32)mc_dec(cmd.params[1], 32, 32); |
| 1043 | obj_desc->ver_major = (u16)mc_dec(cmd.params[2], 0, 16); |
| 1044 | obj_desc->ver_minor = (u16)mc_dec(cmd.params[2], 16, 16); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1045 | obj_desc->type[0] = (char)mc_dec(cmd.params[3], 0, 8); |
| 1046 | obj_desc->type[1] = (char)mc_dec(cmd.params[3], 8, 8); |
| 1047 | obj_desc->type[2] = (char)mc_dec(cmd.params[3], 16, 8); |
| 1048 | obj_desc->type[3] = (char)mc_dec(cmd.params[3], 24, 8); |
| 1049 | obj_desc->type[4] = (char)mc_dec(cmd.params[3], 32, 8); |
| 1050 | obj_desc->type[5] = (char)mc_dec(cmd.params[3], 40, 8); |
| 1051 | obj_desc->type[6] = (char)mc_dec(cmd.params[3], 48, 8); |
| 1052 | obj_desc->type[7] = (char)mc_dec(cmd.params[3], 56, 8); |
| 1053 | obj_desc->type[8] = (char)mc_dec(cmd.params[4], 0, 8); |
| 1054 | obj_desc->type[9] = (char)mc_dec(cmd.params[4], 8, 8); |
| 1055 | obj_desc->type[10] = (char)mc_dec(cmd.params[4], 16, 8); |
| 1056 | obj_desc->type[11] = (char)mc_dec(cmd.params[4], 24, 8); |
| 1057 | obj_desc->type[12] = (char)mc_dec(cmd.params[4], 32, 8); |
| 1058 | obj_desc->type[13] = (char)mc_dec(cmd.params[4], 40, 8); |
| 1059 | obj_desc->type[14] = (char)mc_dec(cmd.params[4], 48, 8); |
| 1060 | obj_desc->type[15] = (char)mc_dec(cmd.params[4], 56, 8); |
| 1061 | obj_desc->label[0] = (char)mc_dec(cmd.params[5], 0, 8); |
| 1062 | obj_desc->label[1] = (char)mc_dec(cmd.params[5], 8, 8); |
| 1063 | obj_desc->label[2] = (char)mc_dec(cmd.params[5], 16, 8); |
| 1064 | obj_desc->label[3] = (char)mc_dec(cmd.params[5], 24, 8); |
| 1065 | obj_desc->label[4] = (char)mc_dec(cmd.params[5], 32, 8); |
| 1066 | obj_desc->label[5] = (char)mc_dec(cmd.params[5], 40, 8); |
| 1067 | obj_desc->label[6] = (char)mc_dec(cmd.params[5], 48, 8); |
| 1068 | obj_desc->label[7] = (char)mc_dec(cmd.params[5], 56, 8); |
| 1069 | obj_desc->label[8] = (char)mc_dec(cmd.params[6], 0, 8); |
| 1070 | obj_desc->label[9] = (char)mc_dec(cmd.params[6], 8, 8); |
| 1071 | obj_desc->label[10] = (char)mc_dec(cmd.params[6], 16, 8); |
| 1072 | obj_desc->label[11] = (char)mc_dec(cmd.params[6], 24, 8); |
| 1073 | obj_desc->label[12] = (char)mc_dec(cmd.params[6], 32, 8); |
| 1074 | obj_desc->label[13] = (char)mc_dec(cmd.params[6], 40, 8); |
| 1075 | obj_desc->label[14] = (char)mc_dec(cmd.params[6], 48, 8); |
| 1076 | obj_desc->label[15] = (char)mc_dec(cmd.params[6], 56, 8); |
| 1077 | |
| 1078 | return 0; |
| 1079 | } |
| 1080 | EXPORT_SYMBOL(dprc_get_obj_desc); |
| 1081 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1082 | /** |
| 1083 | * dprc_set_obj_irq() - Set IRQ information for object to trigger an interrupt. |
| 1084 | * @mc_io: Pointer to MC portal's I/O object |
| 1085 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1086 | * @token: Token of DPRC object |
| 1087 | * @obj_type: Type of the object to set its IRQ |
| 1088 | * @obj_id: ID of the object to set its IRQ |
| 1089 | * @irq_index: The interrupt index to configure |
| 1090 | * @irq_cfg: IRQ configuration |
| 1091 | * |
| 1092 | * Return: '0' on Success; Error code otherwise. |
| 1093 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1094 | int dprc_set_obj_irq(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1095 | u32 cmd_flags, |
| 1096 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1097 | char *obj_type, |
| 1098 | int obj_id, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1099 | u8 irq_index, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1100 | struct dprc_irq_cfg *irq_cfg) |
| 1101 | { |
| 1102 | struct mc_command cmd = { 0 }; |
| 1103 | |
| 1104 | /* prepare command */ |
| 1105 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_IRQ, |
| 1106 | cmd_flags, |
| 1107 | token); |
| 1108 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 1109 | cmd.params[0] |= mc_enc(0, 32, irq_cfg->val); |
| 1110 | cmd.params[1] |= mc_enc(0, 64, irq_cfg->paddr); |
| 1111 | cmd.params[2] |= mc_enc(0, 32, irq_cfg->user_irq_id); |
| 1112 | cmd.params[2] |= mc_enc(32, 32, obj_id); |
| 1113 | cmd.params[3] |= mc_enc(0, 8, obj_type[0]); |
| 1114 | cmd.params[3] |= mc_enc(8, 8, obj_type[1]); |
| 1115 | cmd.params[3] |= mc_enc(16, 8, obj_type[2]); |
| 1116 | cmd.params[3] |= mc_enc(24, 8, obj_type[3]); |
| 1117 | cmd.params[3] |= mc_enc(32, 8, obj_type[4]); |
| 1118 | cmd.params[3] |= mc_enc(40, 8, obj_type[5]); |
| 1119 | cmd.params[3] |= mc_enc(48, 8, obj_type[6]); |
| 1120 | cmd.params[3] |= mc_enc(56, 8, obj_type[7]); |
| 1121 | cmd.params[4] |= mc_enc(0, 8, obj_type[8]); |
| 1122 | cmd.params[4] |= mc_enc(8, 8, obj_type[9]); |
| 1123 | cmd.params[4] |= mc_enc(16, 8, obj_type[10]); |
| 1124 | cmd.params[4] |= mc_enc(24, 8, obj_type[11]); |
| 1125 | cmd.params[4] |= mc_enc(32, 8, obj_type[12]); |
| 1126 | cmd.params[4] |= mc_enc(40, 8, obj_type[13]); |
| 1127 | cmd.params[4] |= mc_enc(48, 8, obj_type[14]); |
| 1128 | cmd.params[4] |= mc_enc(56, 8, obj_type[15]); |
| 1129 | |
| 1130 | /* send command to mc*/ |
| 1131 | return mc_send_command(mc_io, &cmd); |
| 1132 | } |
| 1133 | EXPORT_SYMBOL(dprc_set_obj_irq); |
| 1134 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1135 | /** |
| 1136 | * dprc_get_obj_irq() - Get IRQ information from object. |
| 1137 | * @mc_io: Pointer to MC portal's I/O object |
| 1138 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1139 | * @token: Token of DPRC object |
| 1140 | * @obj_type: Type od the object to get its IRQ |
| 1141 | * @obj_id: ID of the object to get its IRQ |
| 1142 | * @irq_index: The interrupt index to configure |
| 1143 | * @type: Interrupt type: 0 represents message interrupt |
| 1144 | * type (both irq_addr and irq_val are valid) |
| 1145 | * @irq_cfg: The returned IRQ attributes |
| 1146 | * |
| 1147 | * Return: '0' on Success; Error code otherwise. |
| 1148 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1149 | int dprc_get_obj_irq(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1150 | u32 cmd_flags, |
| 1151 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1152 | char *obj_type, |
| 1153 | int obj_id, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1154 | u8 irq_index, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1155 | int *type, |
| 1156 | struct dprc_irq_cfg *irq_cfg) |
| 1157 | { |
| 1158 | struct mc_command cmd = { 0 }; |
| 1159 | int err; |
| 1160 | |
| 1161 | /* prepare command */ |
| 1162 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_IRQ, |
| 1163 | cmd_flags, |
| 1164 | token); |
| 1165 | cmd.params[0] |= mc_enc(0, 32, obj_id); |
| 1166 | cmd.params[0] |= mc_enc(32, 8, irq_index); |
| 1167 | cmd.params[1] |= mc_enc(0, 8, obj_type[0]); |
| 1168 | cmd.params[1] |= mc_enc(8, 8, obj_type[1]); |
| 1169 | cmd.params[1] |= mc_enc(16, 8, obj_type[2]); |
| 1170 | cmd.params[1] |= mc_enc(24, 8, obj_type[3]); |
| 1171 | cmd.params[1] |= mc_enc(32, 8, obj_type[4]); |
| 1172 | cmd.params[1] |= mc_enc(40, 8, obj_type[5]); |
| 1173 | cmd.params[1] |= mc_enc(48, 8, obj_type[6]); |
| 1174 | cmd.params[1] |= mc_enc(56, 8, obj_type[7]); |
| 1175 | cmd.params[2] |= mc_enc(0, 8, obj_type[8]); |
| 1176 | cmd.params[2] |= mc_enc(8, 8, obj_type[9]); |
| 1177 | cmd.params[2] |= mc_enc(16, 8, obj_type[10]); |
| 1178 | cmd.params[2] |= mc_enc(24, 8, obj_type[11]); |
| 1179 | cmd.params[2] |= mc_enc(32, 8, obj_type[12]); |
| 1180 | cmd.params[2] |= mc_enc(40, 8, obj_type[13]); |
| 1181 | cmd.params[2] |= mc_enc(48, 8, obj_type[14]); |
| 1182 | cmd.params[2] |= mc_enc(56, 8, obj_type[15]); |
| 1183 | |
| 1184 | /* send command to mc*/ |
| 1185 | err = mc_send_command(mc_io, &cmd); |
| 1186 | if (err) |
| 1187 | return err; |
| 1188 | |
| 1189 | /* retrieve response parameters */ |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1190 | irq_cfg->val = (u32)mc_dec(cmd.params[0], 0, 32); |
| 1191 | irq_cfg->paddr = (u64)mc_dec(cmd.params[1], 0, 64); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1192 | irq_cfg->user_irq_id = (int)mc_dec(cmd.params[2], 0, 32); |
| 1193 | *type = (int)mc_dec(cmd.params[2], 32, 32); |
| 1194 | |
| 1195 | return 0; |
| 1196 | } |
| 1197 | EXPORT_SYMBOL(dprc_get_obj_irq); |
| 1198 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1199 | /** |
| 1200 | * dprc_get_res_count() - Obtains the number of free resources that are assigned |
| 1201 | * to this container, by pool type |
| 1202 | * @mc_io: Pointer to MC portal's I/O object |
| 1203 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1204 | * @token: Token of DPRC object |
| 1205 | * @type: pool type |
| 1206 | * @res_count: Returned number of free resources of the given |
| 1207 | * resource type that are assigned to this DPRC |
| 1208 | * |
| 1209 | * Return: '0' on Success; Error code otherwise. |
| 1210 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1211 | int dprc_get_res_count(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1212 | u32 cmd_flags, |
| 1213 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1214 | char *type, |
| 1215 | int *res_count) |
| 1216 | { |
| 1217 | struct mc_command cmd = { 0 }; |
| 1218 | int err; |
| 1219 | |
| 1220 | *res_count = 0; |
| 1221 | |
| 1222 | /* prepare command */ |
| 1223 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1224 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1225 | cmd.params[1] |= mc_enc(0, 8, type[0]); |
| 1226 | cmd.params[1] |= mc_enc(8, 8, type[1]); |
| 1227 | cmd.params[1] |= mc_enc(16, 8, type[2]); |
| 1228 | cmd.params[1] |= mc_enc(24, 8, type[3]); |
| 1229 | cmd.params[1] |= mc_enc(32, 8, type[4]); |
| 1230 | cmd.params[1] |= mc_enc(40, 8, type[5]); |
| 1231 | cmd.params[1] |= mc_enc(48, 8, type[6]); |
| 1232 | cmd.params[1] |= mc_enc(56, 8, type[7]); |
| 1233 | cmd.params[2] |= mc_enc(0, 8, type[8]); |
| 1234 | cmd.params[2] |= mc_enc(8, 8, type[9]); |
| 1235 | cmd.params[2] |= mc_enc(16, 8, type[10]); |
| 1236 | cmd.params[2] |= mc_enc(24, 8, type[11]); |
| 1237 | cmd.params[2] |= mc_enc(32, 8, type[12]); |
| 1238 | cmd.params[2] |= mc_enc(40, 8, type[13]); |
| 1239 | cmd.params[2] |= mc_enc(48, 8, type[14]); |
| 1240 | cmd.params[2] |= mc_enc(56, 8, '\0'); |
| 1241 | |
| 1242 | /* send command to mc*/ |
| 1243 | err = mc_send_command(mc_io, &cmd); |
| 1244 | if (err) |
| 1245 | return err; |
| 1246 | |
| 1247 | /* retrieve response parameters */ |
| 1248 | *res_count = mc_dec(cmd.params[0], 0, 32); |
| 1249 | |
| 1250 | return 0; |
| 1251 | } |
| 1252 | EXPORT_SYMBOL(dprc_get_res_count); |
| 1253 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1254 | /** |
| 1255 | * dprc_get_res_ids() - Obtains IDs of free resources in the container |
| 1256 | * @mc_io: Pointer to MC portal's I/O object |
| 1257 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1258 | * @token: Token of DPRC object |
| 1259 | * @type: pool type |
| 1260 | * @range_desc: range descriptor |
| 1261 | * |
| 1262 | * Return: '0' on Success; Error code otherwise. |
| 1263 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1264 | int dprc_get_res_ids(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1265 | u32 cmd_flags, |
| 1266 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1267 | char *type, |
| 1268 | struct dprc_res_ids_range_desc *range_desc) |
| 1269 | { |
| 1270 | struct mc_command cmd = { 0 }; |
| 1271 | int err; |
| 1272 | |
| 1273 | /* prepare command */ |
| 1274 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1275 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1276 | cmd.params[0] |= mc_enc(42, 7, range_desc->iter_status); |
| 1277 | cmd.params[1] |= mc_enc(0, 32, range_desc->base_id); |
| 1278 | cmd.params[1] |= mc_enc(32, 32, range_desc->last_id); |
| 1279 | cmd.params[2] |= mc_enc(0, 8, type[0]); |
| 1280 | cmd.params[2] |= mc_enc(8, 8, type[1]); |
| 1281 | cmd.params[2] |= mc_enc(16, 8, type[2]); |
| 1282 | cmd.params[2] |= mc_enc(24, 8, type[3]); |
| 1283 | cmd.params[2] |= mc_enc(32, 8, type[4]); |
| 1284 | cmd.params[2] |= mc_enc(40, 8, type[5]); |
| 1285 | cmd.params[2] |= mc_enc(48, 8, type[6]); |
| 1286 | cmd.params[2] |= mc_enc(56, 8, type[7]); |
| 1287 | cmd.params[3] |= mc_enc(0, 8, type[8]); |
| 1288 | cmd.params[3] |= mc_enc(8, 8, type[9]); |
| 1289 | cmd.params[3] |= mc_enc(16, 8, type[10]); |
| 1290 | cmd.params[3] |= mc_enc(24, 8, type[11]); |
| 1291 | cmd.params[3] |= mc_enc(32, 8, type[12]); |
| 1292 | cmd.params[3] |= mc_enc(40, 8, type[13]); |
| 1293 | cmd.params[3] |= mc_enc(48, 8, type[14]); |
| 1294 | cmd.params[3] |= mc_enc(56, 8, '\0'); |
| 1295 | |
| 1296 | /* send command to mc*/ |
| 1297 | err = mc_send_command(mc_io, &cmd); |
| 1298 | if (err) |
| 1299 | return err; |
| 1300 | |
| 1301 | /* retrieve response parameters */ |
| 1302 | range_desc->iter_status = mc_dec(cmd.params[0], 42, 7); |
| 1303 | range_desc->base_id = mc_dec(cmd.params[1], 0, 32); |
| 1304 | range_desc->last_id = mc_dec(cmd.params[1], 32, 32); |
| 1305 | |
| 1306 | return 0; |
| 1307 | } |
| 1308 | EXPORT_SYMBOL(dprc_get_res_ids); |
| 1309 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1310 | /** |
| 1311 | * dprc_get_obj_region() - Get region information for a specified object. |
| 1312 | * @mc_io: Pointer to MC portal's I/O object |
| 1313 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1314 | * @token: Token of DPRC object |
| 1315 | * @obj_type; Object type as returned in dprc_get_obj() |
| 1316 | * @obj_id: Unique object instance as returned in dprc_get_obj() |
| 1317 | * @region_index: The specific region to query |
| 1318 | * @region_desc: Returns the requested region descriptor |
| 1319 | * |
| 1320 | * Return: '0' on Success; Error code otherwise. |
| 1321 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1322 | int dprc_get_obj_region(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1323 | u32 cmd_flags, |
| 1324 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1325 | char *obj_type, |
| 1326 | int obj_id, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1327 | u8 region_index, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1328 | struct dprc_region_desc *region_desc) |
| 1329 | { |
| 1330 | struct mc_command cmd = { 0 }; |
| 1331 | int err; |
| 1332 | |
| 1333 | /* prepare command */ |
| 1334 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1335 | cmd_flags, token); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1336 | cmd.params[0] |= mc_enc(0, 32, obj_id); |
| 1337 | cmd.params[0] |= mc_enc(48, 8, region_index); |
| 1338 | cmd.params[3] |= mc_enc(0, 8, obj_type[0]); |
| 1339 | cmd.params[3] |= mc_enc(8, 8, obj_type[1]); |
| 1340 | cmd.params[3] |= mc_enc(16, 8, obj_type[2]); |
| 1341 | cmd.params[3] |= mc_enc(24, 8, obj_type[3]); |
| 1342 | cmd.params[3] |= mc_enc(32, 8, obj_type[4]); |
| 1343 | cmd.params[3] |= mc_enc(40, 8, obj_type[5]); |
| 1344 | cmd.params[3] |= mc_enc(48, 8, obj_type[6]); |
| 1345 | cmd.params[3] |= mc_enc(56, 8, obj_type[7]); |
| 1346 | cmd.params[4] |= mc_enc(0, 8, obj_type[8]); |
| 1347 | cmd.params[4] |= mc_enc(8, 8, obj_type[9]); |
| 1348 | cmd.params[4] |= mc_enc(16, 8, obj_type[10]); |
| 1349 | cmd.params[4] |= mc_enc(24, 8, obj_type[11]); |
| 1350 | cmd.params[4] |= mc_enc(32, 8, obj_type[12]); |
| 1351 | cmd.params[4] |= mc_enc(40, 8, obj_type[13]); |
| 1352 | cmd.params[4] |= mc_enc(48, 8, obj_type[14]); |
| 1353 | cmd.params[4] |= mc_enc(56, 8, '\0'); |
| 1354 | |
| 1355 | /* send command to mc*/ |
| 1356 | err = mc_send_command(mc_io, &cmd); |
| 1357 | if (err) |
| 1358 | return err; |
| 1359 | |
| 1360 | /* retrieve response parameters */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1361 | region_desc->base_offset = mc_dec(cmd.params[1], 0, 64); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1362 | region_desc->size = mc_dec(cmd.params[2], 0, 32); |
| 1363 | |
| 1364 | return 0; |
| 1365 | } |
| 1366 | EXPORT_SYMBOL(dprc_get_obj_region); |
| 1367 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1368 | /** |
| 1369 | * dprc_set_obj_label() - Set object label. |
| 1370 | * @mc_io: Pointer to MC portal's I/O object |
| 1371 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1372 | * @token: Token of DPRC object |
| 1373 | * @obj_type: Object's type |
| 1374 | * @obj_id: Object's ID |
| 1375 | * @label: The required label. The maximum length is 16 chars. |
| 1376 | * |
| 1377 | * Return: '0' on Success; Error code otherwise. |
| 1378 | */ |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1379 | int dprc_set_obj_label(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1380 | u32 cmd_flags, |
| 1381 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1382 | char *obj_type, |
| 1383 | int obj_id, |
| 1384 | char *label) |
| 1385 | { |
| 1386 | struct mc_command cmd = { 0 }; |
| 1387 | |
| 1388 | /* prepare command */ |
| 1389 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_LABEL, |
| 1390 | cmd_flags, |
| 1391 | token); |
| 1392 | |
| 1393 | cmd.params[0] |= mc_enc(0, 32, obj_id); |
| 1394 | cmd.params[1] |= mc_enc(0, 8, label[0]); |
| 1395 | cmd.params[1] |= mc_enc(8, 8, label[1]); |
| 1396 | cmd.params[1] |= mc_enc(16, 8, label[2]); |
| 1397 | cmd.params[1] |= mc_enc(24, 8, label[3]); |
| 1398 | cmd.params[1] |= mc_enc(32, 8, label[4]); |
| 1399 | cmd.params[1] |= mc_enc(40, 8, label[5]); |
| 1400 | cmd.params[1] |= mc_enc(48, 8, label[6]); |
| 1401 | cmd.params[1] |= mc_enc(56, 8, label[7]); |
| 1402 | cmd.params[2] |= mc_enc(0, 8, label[8]); |
| 1403 | cmd.params[2] |= mc_enc(8, 8, label[9]); |
| 1404 | cmd.params[2] |= mc_enc(16, 8, label[10]); |
| 1405 | cmd.params[2] |= mc_enc(24, 8, label[11]); |
| 1406 | cmd.params[2] |= mc_enc(32, 8, label[12]); |
| 1407 | cmd.params[2] |= mc_enc(40, 8, label[13]); |
| 1408 | cmd.params[2] |= mc_enc(48, 8, label[14]); |
| 1409 | cmd.params[2] |= mc_enc(56, 8, label[15]); |
| 1410 | cmd.params[3] |= mc_enc(0, 8, obj_type[0]); |
| 1411 | cmd.params[3] |= mc_enc(8, 8, obj_type[1]); |
| 1412 | cmd.params[3] |= mc_enc(16, 8, obj_type[2]); |
| 1413 | cmd.params[3] |= mc_enc(24, 8, obj_type[3]); |
| 1414 | cmd.params[3] |= mc_enc(32, 8, obj_type[4]); |
| 1415 | cmd.params[3] |= mc_enc(40, 8, obj_type[5]); |
| 1416 | cmd.params[3] |= mc_enc(48, 8, obj_type[6]); |
| 1417 | cmd.params[3] |= mc_enc(56, 8, obj_type[7]); |
| 1418 | cmd.params[4] |= mc_enc(0, 8, obj_type[8]); |
| 1419 | cmd.params[4] |= mc_enc(8, 8, obj_type[9]); |
| 1420 | cmd.params[4] |= mc_enc(16, 8, obj_type[10]); |
| 1421 | cmd.params[4] |= mc_enc(24, 8, obj_type[11]); |
| 1422 | cmd.params[4] |= mc_enc(32, 8, obj_type[12]); |
| 1423 | cmd.params[4] |= mc_enc(40, 8, obj_type[13]); |
| 1424 | cmd.params[4] |= mc_enc(48, 8, obj_type[14]); |
| 1425 | cmd.params[4] |= mc_enc(56, 8, obj_type[15]); |
| 1426 | |
| 1427 | /* send command to mc*/ |
| 1428 | return mc_send_command(mc_io, &cmd); |
| 1429 | } |
| 1430 | EXPORT_SYMBOL(dprc_set_obj_label); |
| 1431 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1432 | /** |
| 1433 | * dprc_connect() - Connect two endpoints to create a network link between them |
| 1434 | * @mc_io: Pointer to MC portal's I/O object |
| 1435 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1436 | * @token: Token of DPRC object |
| 1437 | * @endpoint1: Endpoint 1 configuration parameters |
| 1438 | * @endpoint2: Endpoint 2 configuration parameters |
| 1439 | * @cfg: Connection configuration. The connection configuration is ignored for |
| 1440 | * connections made to DPMAC objects, where rate is set according to |
| 1441 | * MAC configuration. |
| 1442 | * The committed rate is the guaranteed rate for the connection. |
| 1443 | * The maximum rate is an upper limit allowed for the connection; it is |
| 1444 | * expected to be equal or higher than the committed rate. |
| 1445 | * When committed and maximum rates are both zero, the connection is set |
| 1446 | * to "best effort" mode, having lower priority compared to connections |
| 1447 | * with committed or maximum rates. |
| 1448 | * |
| 1449 | * Return: '0' on Success; Error code otherwise. |
| 1450 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1451 | int dprc_connect(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1452 | u32 cmd_flags, |
| 1453 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1454 | const struct dprc_endpoint *endpoint1, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1455 | const struct dprc_endpoint *endpoint2, |
| 1456 | const struct dprc_connection_cfg *cfg) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1457 | { |
| 1458 | struct mc_command cmd = { 0 }; |
| 1459 | |
| 1460 | /* prepare command */ |
| 1461 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1462 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1463 | token); |
| 1464 | cmd.params[0] |= mc_enc(0, 32, endpoint1->id); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1465 | cmd.params[0] |= mc_enc(32, 32, endpoint1->if_id); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1466 | cmd.params[1] |= mc_enc(0, 32, endpoint2->id); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1467 | cmd.params[1] |= mc_enc(32, 32, endpoint2->if_id); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1468 | cmd.params[2] |= mc_enc(0, 8, endpoint1->type[0]); |
| 1469 | cmd.params[2] |= mc_enc(8, 8, endpoint1->type[1]); |
| 1470 | cmd.params[2] |= mc_enc(16, 8, endpoint1->type[2]); |
| 1471 | cmd.params[2] |= mc_enc(24, 8, endpoint1->type[3]); |
| 1472 | cmd.params[2] |= mc_enc(32, 8, endpoint1->type[4]); |
| 1473 | cmd.params[2] |= mc_enc(40, 8, endpoint1->type[5]); |
| 1474 | cmd.params[2] |= mc_enc(48, 8, endpoint1->type[6]); |
| 1475 | cmd.params[2] |= mc_enc(56, 8, endpoint1->type[7]); |
| 1476 | cmd.params[3] |= mc_enc(0, 8, endpoint1->type[8]); |
| 1477 | cmd.params[3] |= mc_enc(8, 8, endpoint1->type[9]); |
| 1478 | cmd.params[3] |= mc_enc(16, 8, endpoint1->type[10]); |
| 1479 | cmd.params[3] |= mc_enc(24, 8, endpoint1->type[11]); |
| 1480 | cmd.params[3] |= mc_enc(32, 8, endpoint1->type[12]); |
| 1481 | cmd.params[3] |= mc_enc(40, 8, endpoint1->type[13]); |
| 1482 | cmd.params[3] |= mc_enc(48, 8, endpoint1->type[14]); |
| 1483 | cmd.params[3] |= mc_enc(56, 8, endpoint1->type[15]); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1484 | cmd.params[4] |= mc_enc(0, 32, cfg->max_rate); |
| 1485 | cmd.params[4] |= mc_enc(32, 32, cfg->committed_rate); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1486 | cmd.params[5] |= mc_enc(0, 8, endpoint2->type[0]); |
| 1487 | cmd.params[5] |= mc_enc(8, 8, endpoint2->type[1]); |
| 1488 | cmd.params[5] |= mc_enc(16, 8, endpoint2->type[2]); |
| 1489 | cmd.params[5] |= mc_enc(24, 8, endpoint2->type[3]); |
| 1490 | cmd.params[5] |= mc_enc(32, 8, endpoint2->type[4]); |
| 1491 | cmd.params[5] |= mc_enc(40, 8, endpoint2->type[5]); |
| 1492 | cmd.params[5] |= mc_enc(48, 8, endpoint2->type[6]); |
| 1493 | cmd.params[5] |= mc_enc(56, 8, endpoint2->type[7]); |
| 1494 | cmd.params[6] |= mc_enc(0, 8, endpoint2->type[8]); |
| 1495 | cmd.params[6] |= mc_enc(8, 8, endpoint2->type[9]); |
| 1496 | cmd.params[6] |= mc_enc(16, 8, endpoint2->type[10]); |
| 1497 | cmd.params[6] |= mc_enc(24, 8, endpoint2->type[11]); |
| 1498 | cmd.params[6] |= mc_enc(32, 8, endpoint2->type[12]); |
| 1499 | cmd.params[6] |= mc_enc(40, 8, endpoint2->type[13]); |
| 1500 | cmd.params[6] |= mc_enc(48, 8, endpoint2->type[14]); |
| 1501 | cmd.params[6] |= mc_enc(56, 8, endpoint2->type[15]); |
| 1502 | |
| 1503 | /* send command to mc*/ |
| 1504 | return mc_send_command(mc_io, &cmd); |
| 1505 | } |
| 1506 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1507 | /** |
| 1508 | * dprc_disconnect() - Disconnect one endpoint to remove its network connection |
| 1509 | * @mc_io: Pointer to MC portal's I/O object |
| 1510 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1511 | * @token: Token of DPRC object |
| 1512 | * @endpoint: Endpoint configuration parameters |
| 1513 | * |
| 1514 | * Return: '0' on Success; Error code otherwise. |
| 1515 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1516 | int dprc_disconnect(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1517 | u32 cmd_flags, |
| 1518 | u16 token, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1519 | const struct dprc_endpoint *endpoint) |
| 1520 | { |
| 1521 | struct mc_command cmd = { 0 }; |
| 1522 | |
| 1523 | /* prepare command */ |
| 1524 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1525 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1526 | token); |
| 1527 | cmd.params[0] |= mc_enc(0, 32, endpoint->id); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1528 | cmd.params[0] |= mc_enc(32, 32, endpoint->if_id); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1529 | cmd.params[1] |= mc_enc(0, 8, endpoint->type[0]); |
| 1530 | cmd.params[1] |= mc_enc(8, 8, endpoint->type[1]); |
| 1531 | cmd.params[1] |= mc_enc(16, 8, endpoint->type[2]); |
| 1532 | cmd.params[1] |= mc_enc(24, 8, endpoint->type[3]); |
| 1533 | cmd.params[1] |= mc_enc(32, 8, endpoint->type[4]); |
| 1534 | cmd.params[1] |= mc_enc(40, 8, endpoint->type[5]); |
| 1535 | cmd.params[1] |= mc_enc(48, 8, endpoint->type[6]); |
| 1536 | cmd.params[1] |= mc_enc(56, 8, endpoint->type[7]); |
| 1537 | cmd.params[2] |= mc_enc(0, 8, endpoint->type[8]); |
| 1538 | cmd.params[2] |= mc_enc(8, 8, endpoint->type[9]); |
| 1539 | cmd.params[2] |= mc_enc(16, 8, endpoint->type[10]); |
| 1540 | cmd.params[2] |= mc_enc(24, 8, endpoint->type[11]); |
| 1541 | cmd.params[2] |= mc_enc(32, 8, endpoint->type[12]); |
| 1542 | cmd.params[2] |= mc_enc(40, 8, endpoint->type[13]); |
| 1543 | cmd.params[2] |= mc_enc(48, 8, endpoint->type[14]); |
| 1544 | cmd.params[2] |= mc_enc(56, 8, endpoint->type[15]); |
| 1545 | |
| 1546 | /* send command to mc*/ |
| 1547 | return mc_send_command(mc_io, &cmd); |
| 1548 | } |
| 1549 | |
J. German Rivera | e9bf3f2 | 2015-09-24 14:26:54 -0500 | [diff] [blame] | 1550 | /** |
| 1551 | * dprc_get_connection() - Get connected endpoint and link status if connection |
| 1552 | * exists. |
| 1553 | * @mc_io: Pointer to MC portal's I/O object |
| 1554 | * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_' |
| 1555 | * @token: Token of DPRC object |
| 1556 | * @endpoint1: Endpoint 1 configuration parameters |
| 1557 | * @endpoint2: Returned endpoint 2 configuration parameters |
| 1558 | * @state: Returned link state: 1 - link is up, 0 - link is down |
| 1559 | * |
| 1560 | * Return: '0' on Success; -ENAVAIL if connection does not exist. |
| 1561 | */ |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1562 | int dprc_get_connection(struct fsl_mc_io *mc_io, |
J. German Rivera | ba72f25 | 2015-09-25 11:21:01 -0500 | [diff] [blame] | 1563 | u32 cmd_flags, |
| 1564 | u16 token, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1565 | const struct dprc_endpoint *endpoint1, |
| 1566 | struct dprc_endpoint *endpoint2, |
| 1567 | int *state) |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1568 | { |
| 1569 | struct mc_command cmd = { 0 }; |
| 1570 | int err; |
| 1571 | |
| 1572 | /* prepare command */ |
| 1573 | cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION, |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1574 | cmd_flags, |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1575 | token); |
| 1576 | cmd.params[0] |= mc_enc(0, 32, endpoint1->id); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1577 | cmd.params[0] |= mc_enc(32, 32, endpoint1->if_id); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1578 | cmd.params[1] |= mc_enc(0, 8, endpoint1->type[0]); |
| 1579 | cmd.params[1] |= mc_enc(8, 8, endpoint1->type[1]); |
| 1580 | cmd.params[1] |= mc_enc(16, 8, endpoint1->type[2]); |
| 1581 | cmd.params[1] |= mc_enc(24, 8, endpoint1->type[3]); |
| 1582 | cmd.params[1] |= mc_enc(32, 8, endpoint1->type[4]); |
| 1583 | cmd.params[1] |= mc_enc(40, 8, endpoint1->type[5]); |
| 1584 | cmd.params[1] |= mc_enc(48, 8, endpoint1->type[6]); |
| 1585 | cmd.params[1] |= mc_enc(56, 8, endpoint1->type[7]); |
| 1586 | cmd.params[2] |= mc_enc(0, 8, endpoint1->type[8]); |
| 1587 | cmd.params[2] |= mc_enc(8, 8, endpoint1->type[9]); |
| 1588 | cmd.params[2] |= mc_enc(16, 8, endpoint1->type[10]); |
| 1589 | cmd.params[2] |= mc_enc(24, 8, endpoint1->type[11]); |
| 1590 | cmd.params[2] |= mc_enc(32, 8, endpoint1->type[12]); |
| 1591 | cmd.params[2] |= mc_enc(40, 8, endpoint1->type[13]); |
| 1592 | cmd.params[2] |= mc_enc(48, 8, endpoint1->type[14]); |
| 1593 | cmd.params[2] |= mc_enc(56, 8, endpoint1->type[15]); |
| 1594 | |
| 1595 | /* send command to mc*/ |
| 1596 | err = mc_send_command(mc_io, &cmd); |
| 1597 | if (err) |
| 1598 | return err; |
| 1599 | |
| 1600 | /* retrieve response parameters */ |
| 1601 | endpoint2->id = mc_dec(cmd.params[3], 0, 32); |
J. German Rivera | 1ee695f | 2015-09-23 16:11:03 -0500 | [diff] [blame] | 1602 | endpoint2->if_id = mc_dec(cmd.params[3], 32, 32); |
J. German Rivera | 31c8896 | 2015-03-05 19:29:09 -0600 | [diff] [blame] | 1603 | endpoint2->type[0] = mc_dec(cmd.params[4], 0, 8); |
| 1604 | endpoint2->type[1] = mc_dec(cmd.params[4], 8, 8); |
| 1605 | endpoint2->type[2] = mc_dec(cmd.params[4], 16, 8); |
| 1606 | endpoint2->type[3] = mc_dec(cmd.params[4], 24, 8); |
| 1607 | endpoint2->type[4] = mc_dec(cmd.params[4], 32, 8); |
| 1608 | endpoint2->type[5] = mc_dec(cmd.params[4], 40, 8); |
| 1609 | endpoint2->type[6] = mc_dec(cmd.params[4], 48, 8); |
| 1610 | endpoint2->type[7] = mc_dec(cmd.params[4], 56, 8); |
| 1611 | endpoint2->type[8] = mc_dec(cmd.params[5], 0, 8); |
| 1612 | endpoint2->type[9] = mc_dec(cmd.params[5], 8, 8); |
| 1613 | endpoint2->type[10] = mc_dec(cmd.params[5], 16, 8); |
| 1614 | endpoint2->type[11] = mc_dec(cmd.params[5], 24, 8); |
| 1615 | endpoint2->type[12] = mc_dec(cmd.params[5], 32, 8); |
| 1616 | endpoint2->type[13] = mc_dec(cmd.params[5], 40, 8); |
| 1617 | endpoint2->type[14] = mc_dec(cmd.params[5], 48, 8); |
| 1618 | endpoint2->type[15] = mc_dec(cmd.params[5], 56, 8); |
| 1619 | *state = mc_dec(cmd.params[6], 0, 32); |
| 1620 | |
| 1621 | return 0; |
| 1622 | } |