Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013-2015 Freescale Semiconductor |
| 3 | * |
| 4 | * SPDX-License-Identifier: GPL-2.0+ |
| 5 | */ |
| 6 | |
| 7 | #include <fsl-mc/fsl_mc_sys.h> |
| 8 | #include <fsl-mc/fsl_mc_cmd.h> |
| 9 | #include <fsl-mc/fsl_dpni.h> |
| 10 | |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 11 | int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg, |
| 12 | uint8_t *ext_cfg_buf) |
| 13 | { |
| 14 | uint64_t *ext_params = (uint64_t *)ext_cfg_buf; |
| 15 | |
| 16 | DPNI_PREP_EXTENDED_CFG(ext_params, cfg); |
| 17 | |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg, |
| 22 | const uint8_t *ext_cfg_buf) |
| 23 | { |
| 24 | uint64_t *ext_params = (uint64_t *)ext_cfg_buf; |
| 25 | |
| 26 | DPNI_EXT_EXTENDED_CFG(ext_params, cfg); |
| 27 | |
| 28 | return 0; |
| 29 | } |
| 30 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 31 | int dpni_open(struct fsl_mc_io *mc_io, |
| 32 | uint32_t cmd_flags, |
| 33 | int dpni_id, |
| 34 | uint16_t *token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 35 | { |
| 36 | struct mc_command cmd = { 0 }; |
| 37 | int err; |
| 38 | |
| 39 | /* prepare command */ |
| 40 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 41 | cmd_flags, |
| 42 | 0); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 43 | DPNI_CMD_OPEN(cmd, dpni_id); |
| 44 | |
| 45 | /* send command to mc*/ |
| 46 | err = mc_send_command(mc_io, &cmd); |
| 47 | if (err) |
| 48 | return err; |
| 49 | |
| 50 | /* retrieve response parameters */ |
| 51 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 52 | |
| 53 | return 0; |
| 54 | } |
| 55 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 56 | int dpni_close(struct fsl_mc_io *mc_io, |
| 57 | uint32_t cmd_flags, |
| 58 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 59 | { |
| 60 | struct mc_command cmd = { 0 }; |
| 61 | |
| 62 | /* prepare command */ |
| 63 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 64 | cmd_flags, |
| 65 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 66 | |
| 67 | /* send command to mc*/ |
| 68 | return mc_send_command(mc_io, &cmd); |
| 69 | } |
| 70 | |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 71 | int dpni_create(struct fsl_mc_io *mc_io, |
| 72 | uint32_t cmd_flags, |
| 73 | const struct dpni_cfg *cfg, |
| 74 | uint16_t *token) |
| 75 | { |
| 76 | struct mc_command cmd = { 0 }; |
| 77 | int err; |
| 78 | |
| 79 | /* prepare command */ |
| 80 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE, |
| 81 | cmd_flags, |
| 82 | 0); |
| 83 | DPNI_CMD_CREATE(cmd, cfg); |
| 84 | |
| 85 | /* send command to mc*/ |
| 86 | err = mc_send_command(mc_io, &cmd); |
| 87 | if (err) |
| 88 | return err; |
| 89 | |
| 90 | /* retrieve response parameters */ |
| 91 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 92 | |
| 93 | return 0; |
| 94 | } |
| 95 | |
| 96 | int dpni_destroy(struct fsl_mc_io *mc_io, |
| 97 | uint32_t cmd_flags, |
| 98 | uint16_t token) |
| 99 | { |
| 100 | struct mc_command cmd = { 0 }; |
| 101 | |
| 102 | /* prepare command */ |
| 103 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY, |
| 104 | cmd_flags, |
| 105 | token); |
| 106 | |
| 107 | /* send command to mc*/ |
| 108 | return mc_send_command(mc_io, &cmd); |
| 109 | } |
| 110 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 111 | int dpni_set_pools(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 112 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 113 | uint16_t token, |
| 114 | const struct dpni_pools_cfg *cfg) |
| 115 | { |
| 116 | struct mc_command cmd = { 0 }; |
| 117 | |
| 118 | /* prepare command */ |
| 119 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 120 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 121 | token); |
| 122 | DPNI_CMD_SET_POOLS(cmd, cfg); |
| 123 | |
| 124 | /* send command to mc*/ |
| 125 | return mc_send_command(mc_io, &cmd); |
| 126 | } |
| 127 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 128 | int dpni_enable(struct fsl_mc_io *mc_io, |
| 129 | uint32_t cmd_flags, |
| 130 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 131 | { |
| 132 | struct mc_command cmd = { 0 }; |
| 133 | |
| 134 | /* prepare command */ |
| 135 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 136 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 137 | token); |
| 138 | |
| 139 | /* send command to mc*/ |
| 140 | return mc_send_command(mc_io, &cmd); |
| 141 | } |
| 142 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 143 | int dpni_disable(struct fsl_mc_io *mc_io, |
| 144 | uint32_t cmd_flags, |
| 145 | uint16_t token) |
| 146 | { |
| 147 | struct mc_command cmd = { 0 }; |
| 148 | |
| 149 | /* prepare command */ |
| 150 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE, |
| 151 | cmd_flags, |
| 152 | token); |
| 153 | |
| 154 | /* send command to mc*/ |
| 155 | return mc_send_command(mc_io, &cmd); |
| 156 | } |
| 157 | |
| 158 | int dpni_reset(struct fsl_mc_io *mc_io, |
| 159 | uint32_t cmd_flags, |
| 160 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 161 | { |
| 162 | struct mc_command cmd = { 0 }; |
| 163 | |
| 164 | /* prepare command */ |
| 165 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 166 | cmd_flags, |
| 167 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 168 | |
| 169 | /* send command to mc*/ |
| 170 | return mc_send_command(mc_io, &cmd); |
| 171 | } |
| 172 | |
| 173 | int dpni_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 174 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 175 | uint16_t token, |
| 176 | struct dpni_attr *attr) |
| 177 | { |
| 178 | struct mc_command cmd = { 0 }; |
| 179 | int err; |
| 180 | |
| 181 | /* prepare command */ |
| 182 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 183 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 184 | token); |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 185 | DPNI_CMD_GET_ATTR(cmd, attr); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 186 | |
| 187 | /* send command to mc*/ |
| 188 | err = mc_send_command(mc_io, &cmd); |
| 189 | if (err) |
| 190 | return err; |
| 191 | |
| 192 | /* retrieve response parameters */ |
| 193 | DPNI_RSP_GET_ATTR(cmd, attr); |
| 194 | |
| 195 | return 0; |
| 196 | } |
| 197 | |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 198 | int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, |
| 199 | uint32_t cmd_flags, |
| 200 | uint16_t token, |
| 201 | struct dpni_error_cfg *cfg) |
| 202 | { |
| 203 | struct mc_command cmd = { 0 }; |
| 204 | |
| 205 | /* prepare command */ |
| 206 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR, |
| 207 | cmd_flags, |
| 208 | token); |
| 209 | DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg); |
| 210 | |
| 211 | /* send command to mc*/ |
| 212 | return mc_send_command(mc_io, &cmd); |
| 213 | } |
| 214 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 215 | int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 216 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 217 | uint16_t token, |
| 218 | struct dpni_buffer_layout *layout) |
| 219 | { |
| 220 | struct mc_command cmd = { 0 }; |
| 221 | int err; |
| 222 | |
| 223 | /* prepare command */ |
| 224 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 225 | cmd_flags, |
| 226 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 227 | |
| 228 | /* send command to mc*/ |
| 229 | err = mc_send_command(mc_io, &cmd); |
| 230 | if (err) |
| 231 | return err; |
| 232 | |
| 233 | /* retrieve response parameters */ |
| 234 | DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout); |
| 235 | |
| 236 | return 0; |
| 237 | } |
| 238 | |
| 239 | int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 240 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 241 | uint16_t token, |
| 242 | const struct dpni_buffer_layout *layout) |
| 243 | { |
| 244 | struct mc_command cmd = { 0 }; |
| 245 | |
| 246 | /* prepare command */ |
| 247 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 248 | cmd_flags, |
| 249 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 250 | DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout); |
| 251 | |
| 252 | /* send command to mc*/ |
| 253 | return mc_send_command(mc_io, &cmd); |
| 254 | } |
| 255 | |
| 256 | int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 257 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 258 | uint16_t token, |
| 259 | struct dpni_buffer_layout *layout) |
| 260 | { |
| 261 | struct mc_command cmd = { 0 }; |
| 262 | int err; |
| 263 | |
| 264 | /* prepare command */ |
| 265 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 266 | cmd_flags, |
| 267 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 268 | |
| 269 | /* send command to mc*/ |
| 270 | err = mc_send_command(mc_io, &cmd); |
| 271 | if (err) |
| 272 | return err; |
| 273 | |
| 274 | /* retrieve response parameters */ |
| 275 | DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout); |
| 276 | |
| 277 | return 0; |
| 278 | } |
| 279 | |
| 280 | int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 281 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 282 | uint16_t token, |
| 283 | const struct dpni_buffer_layout *layout) |
| 284 | { |
| 285 | struct mc_command cmd = { 0 }; |
| 286 | |
| 287 | /* prepare command */ |
| 288 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 289 | cmd_flags, |
| 290 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 291 | DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout); |
| 292 | |
| 293 | /* send command to mc*/ |
| 294 | return mc_send_command(mc_io, &cmd); |
| 295 | } |
| 296 | |
| 297 | int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 298 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 299 | uint16_t token, |
| 300 | struct dpni_buffer_layout *layout) |
| 301 | { |
| 302 | struct mc_command cmd = { 0 }; |
| 303 | int err; |
| 304 | |
| 305 | /* prepare command */ |
| 306 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 307 | cmd_flags, |
| 308 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 309 | |
| 310 | /* send command to mc*/ |
| 311 | err = mc_send_command(mc_io, &cmd); |
| 312 | if (err) |
| 313 | return err; |
| 314 | |
| 315 | /* retrieve response parameters */ |
| 316 | DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 322 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 323 | uint16_t token, |
| 324 | const struct dpni_buffer_layout *layout) |
| 325 | { |
| 326 | struct mc_command cmd = { 0 }; |
| 327 | |
| 328 | /* prepare command */ |
| 329 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 330 | cmd_flags, |
| 331 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 332 | DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout); |
| 333 | |
| 334 | /* send command to mc*/ |
| 335 | return mc_send_command(mc_io, &cmd); |
| 336 | } |
| 337 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 338 | int dpni_get_qdid(struct fsl_mc_io *mc_io, |
| 339 | uint32_t cmd_flags, |
| 340 | uint16_t token, |
| 341 | uint16_t *qdid) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 342 | { |
| 343 | struct mc_command cmd = { 0 }; |
| 344 | int err; |
| 345 | |
| 346 | /* prepare command */ |
| 347 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 348 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 349 | token); |
| 350 | |
| 351 | /* send command to mc*/ |
| 352 | err = mc_send_command(mc_io, &cmd); |
| 353 | if (err) |
| 354 | return err; |
| 355 | |
| 356 | /* retrieve response parameters */ |
| 357 | DPNI_RSP_GET_QDID(cmd, *qdid); |
| 358 | |
| 359 | return 0; |
| 360 | } |
| 361 | |
| 362 | int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 363 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 364 | uint16_t token, |
| 365 | uint16_t *data_offset) |
| 366 | { |
| 367 | struct mc_command cmd = { 0 }; |
| 368 | int err; |
| 369 | |
| 370 | /* prepare command */ |
| 371 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 372 | cmd_flags, |
| 373 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 374 | |
| 375 | /* send command to mc*/ |
| 376 | err = mc_send_command(mc_io, &cmd); |
| 377 | if (err) |
| 378 | return err; |
| 379 | |
| 380 | /* retrieve response parameters */ |
| 381 | DPNI_RSP_GET_TX_DATA_OFFSET(cmd, *data_offset); |
| 382 | |
| 383 | return 0; |
| 384 | } |
| 385 | |
| 386 | int dpni_get_counter(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 387 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 388 | uint16_t token, |
| 389 | enum dpni_counter counter, |
| 390 | uint64_t *value) |
| 391 | { |
| 392 | struct mc_command cmd = { 0 }; |
| 393 | int err; |
| 394 | |
| 395 | /* prepare command */ |
| 396 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_COUNTER, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 397 | cmd_flags, |
| 398 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 399 | DPNI_CMD_GET_COUNTER(cmd, counter); |
| 400 | |
| 401 | /* send command to mc*/ |
| 402 | err = mc_send_command(mc_io, &cmd); |
| 403 | if (err) |
| 404 | return err; |
| 405 | |
| 406 | /* retrieve response parameters */ |
| 407 | DPNI_RSP_GET_COUNTER(cmd, *value); |
| 408 | |
| 409 | return 0; |
| 410 | } |
| 411 | |
| 412 | int dpni_set_counter(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 413 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 414 | uint16_t token, |
| 415 | enum dpni_counter counter, |
| 416 | uint64_t value) |
| 417 | { |
| 418 | struct mc_command cmd = { 0 }; |
| 419 | |
| 420 | /* prepare command */ |
| 421 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_COUNTER, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 422 | cmd_flags, |
| 423 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 424 | DPNI_CMD_SET_COUNTER(cmd, counter, value); |
| 425 | |
| 426 | /* send command to mc*/ |
| 427 | return mc_send_command(mc_io, &cmd); |
| 428 | } |
| 429 | |
| 430 | int dpni_set_link_cfg(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 431 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 432 | uint16_t token, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 433 | const struct dpni_link_cfg *cfg) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 434 | { |
| 435 | struct mc_command cmd = { 0 }; |
| 436 | |
| 437 | /* prepare command */ |
| 438 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 439 | cmd_flags, |
| 440 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 441 | DPNI_CMD_SET_LINK_CFG(cmd, cfg); |
| 442 | |
| 443 | /* send command to mc*/ |
| 444 | return mc_send_command(mc_io, &cmd); |
| 445 | } |
| 446 | |
| 447 | int dpni_get_link_state(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 448 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 449 | uint16_t token, |
| 450 | struct dpni_link_state *state) |
| 451 | { |
| 452 | struct mc_command cmd = { 0 }; |
| 453 | int err; |
| 454 | |
| 455 | /* prepare command */ |
| 456 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 457 | cmd_flags, |
| 458 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 459 | |
| 460 | /* send command to mc*/ |
| 461 | err = mc_send_command(mc_io, &cmd); |
| 462 | if (err) |
| 463 | return err; |
| 464 | |
| 465 | /* retrieve response parameters */ |
| 466 | DPNI_RSP_GET_LINK_STATE(cmd, state); |
| 467 | |
| 468 | return 0; |
| 469 | } |
| 470 | |
| 471 | |
| 472 | int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 473 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 474 | uint16_t token, |
| 475 | const uint8_t mac_addr[6]) |
| 476 | { |
| 477 | struct mc_command cmd = { 0 }; |
| 478 | |
| 479 | /* prepare command */ |
| 480 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 481 | cmd_flags, |
| 482 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 483 | DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr); |
| 484 | |
| 485 | /* send command to mc*/ |
| 486 | return mc_send_command(mc_io, &cmd); |
| 487 | } |
| 488 | |
| 489 | int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 490 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 491 | uint16_t token, |
| 492 | uint8_t mac_addr[6]) |
| 493 | { |
| 494 | struct mc_command cmd = { 0 }; |
| 495 | int err; |
| 496 | |
| 497 | /* prepare command */ |
| 498 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 499 | cmd_flags, |
| 500 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 501 | |
| 502 | /* send command to mc*/ |
| 503 | err = mc_send_command(mc_io, &cmd); |
| 504 | if (err) |
| 505 | return err; |
| 506 | |
| 507 | /* retrieve response parameters */ |
| 508 | DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr); |
| 509 | |
| 510 | return 0; |
| 511 | } |
| 512 | |
| 513 | int dpni_add_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 514 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 515 | uint16_t token, |
| 516 | const uint8_t mac_addr[6]) |
| 517 | { |
| 518 | struct mc_command cmd = { 0 }; |
| 519 | |
| 520 | /* prepare command */ |
| 521 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 522 | cmd_flags, |
| 523 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 524 | DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr); |
| 525 | |
| 526 | /* send command to mc*/ |
| 527 | return mc_send_command(mc_io, &cmd); |
| 528 | } |
| 529 | |
| 530 | int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 531 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 532 | uint16_t token, |
| 533 | const uint8_t mac_addr[6]) |
| 534 | { |
| 535 | struct mc_command cmd = { 0 }; |
| 536 | |
| 537 | /* prepare command */ |
| 538 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 539 | cmd_flags, |
| 540 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 541 | DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr); |
| 542 | |
| 543 | /* send command to mc*/ |
| 544 | return mc_send_command(mc_io, &cmd); |
| 545 | } |
| 546 | |
| 547 | int dpni_set_tx_flow(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 548 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 549 | uint16_t token, |
| 550 | uint16_t *flow_id, |
| 551 | const struct dpni_tx_flow_cfg *cfg) |
| 552 | { |
| 553 | struct mc_command cmd = { 0 }; |
| 554 | int err; |
| 555 | |
| 556 | /* prepare command */ |
| 557 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_FLOW, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 558 | cmd_flags, |
| 559 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 560 | DPNI_CMD_SET_TX_FLOW(cmd, *flow_id, cfg); |
| 561 | |
| 562 | /* send command to mc*/ |
| 563 | err = mc_send_command(mc_io, &cmd); |
| 564 | if (err) |
| 565 | return err; |
| 566 | |
| 567 | /* retrieve response parameters */ |
| 568 | DPNI_RSP_SET_TX_FLOW(cmd, *flow_id); |
| 569 | |
| 570 | return 0; |
| 571 | } |
| 572 | |
| 573 | int dpni_get_tx_flow(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 574 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 575 | uint16_t token, |
| 576 | uint16_t flow_id, |
| 577 | struct dpni_tx_flow_attr *attr) |
| 578 | { |
| 579 | struct mc_command cmd = { 0 }; |
| 580 | int err; |
| 581 | |
| 582 | /* prepare command */ |
| 583 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_FLOW, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 584 | cmd_flags, |
| 585 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 586 | DPNI_CMD_GET_TX_FLOW(cmd, flow_id); |
| 587 | |
| 588 | /* send command to mc*/ |
| 589 | err = mc_send_command(mc_io, &cmd); |
| 590 | if (err) |
| 591 | return err; |
| 592 | |
| 593 | /* retrieve response parameters */ |
| 594 | DPNI_RSP_GET_TX_FLOW(cmd, attr); |
| 595 | |
| 596 | return 0; |
| 597 | } |
| 598 | |
| 599 | int dpni_set_rx_flow(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 600 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 601 | uint16_t token, |
| 602 | uint8_t tc_id, |
| 603 | uint16_t flow_id, |
| 604 | const struct dpni_queue_cfg *cfg) |
| 605 | { |
| 606 | struct mc_command cmd = { 0 }; |
| 607 | |
| 608 | /* prepare command */ |
| 609 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_FLOW, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 610 | cmd_flags, |
| 611 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 612 | DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg); |
| 613 | |
| 614 | /* send command to mc*/ |
| 615 | return mc_send_command(mc_io, &cmd); |
| 616 | } |
| 617 | |
| 618 | int dpni_get_rx_flow(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 619 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 620 | uint16_t token, |
| 621 | uint8_t tc_id, |
| 622 | uint16_t flow_id, |
| 623 | struct dpni_queue_attr *attr) |
| 624 | { |
| 625 | struct mc_command cmd = { 0 }; |
| 626 | int err; |
| 627 | /* prepare command */ |
| 628 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_FLOW, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 629 | cmd_flags, |
| 630 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 631 | DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id); |
| 632 | |
| 633 | /* send command to mc*/ |
| 634 | err = mc_send_command(mc_io, &cmd); |
| 635 | if (err) |
| 636 | return err; |
| 637 | |
| 638 | /* retrieve response parameters */ |
| 639 | DPNI_RSP_GET_RX_FLOW(cmd, attr); |
| 640 | |
| 641 | return 0; |
| 642 | } |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 643 | |
| 644 | int dpni_set_tx_conf(struct fsl_mc_io *mc_io, |
| 645 | uint32_t cmd_flags, |
| 646 | uint16_t token, |
| 647 | uint16_t flow_id, |
| 648 | const struct dpni_tx_conf_cfg *cfg) |
| 649 | { |
| 650 | struct mc_command cmd = { 0 }; |
| 651 | |
| 652 | /* prepare command */ |
| 653 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF, |
| 654 | cmd_flags, |
| 655 | token); |
| 656 | DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg); |
| 657 | |
| 658 | /* send command to mc*/ |
| 659 | return mc_send_command(mc_io, &cmd); |
| 660 | } |
| 661 | |
| 662 | int dpni_get_tx_conf(struct fsl_mc_io *mc_io, |
| 663 | uint32_t cmd_flags, |
| 664 | uint16_t token, |
| 665 | uint16_t flow_id, |
| 666 | struct dpni_tx_conf_attr *attr) |
| 667 | { |
| 668 | struct mc_command cmd = { 0 }; |
| 669 | int err; |
| 670 | |
| 671 | /* prepare command */ |
| 672 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF, |
| 673 | cmd_flags, |
| 674 | token); |
| 675 | DPNI_CMD_GET_TX_CONF(cmd, flow_id); |
| 676 | |
| 677 | /* send command to mc*/ |
| 678 | err = mc_send_command(mc_io, &cmd); |
| 679 | if (err) |
| 680 | return err; |
| 681 | |
| 682 | DPNI_RSP_GET_TX_CONF(cmd, attr); |
| 683 | |
| 684 | return 0; |
| 685 | } |