Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 1 | /* |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 2 | * Copyright (C) 2013-2016 Freescale Semiconductor |
| 3 | * Copyright 2017 NXP |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <fsl-mc/fsl_mc_sys.h> |
| 9 | #include <fsl-mc/fsl_mc_cmd.h> |
| 10 | #include <fsl-mc/fsl_dpni.h> |
| 11 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 12 | int dpni_prepare_cfg(const struct dpni_cfg *cfg, |
| 13 | uint8_t *cfg_buf) |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 14 | { |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 15 | uint64_t *params = (uint64_t *)cfg_buf; |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 16 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 17 | DPNI_PREP_CFG(params, cfg); |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 18 | |
| 19 | return 0; |
| 20 | } |
| 21 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 22 | int dpni_extract_cfg(struct dpni_cfg *cfg, |
| 23 | const uint8_t *cfg_buf) |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 24 | { |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 25 | uint64_t *params = (uint64_t *)cfg_buf; |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 26 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 27 | DPNI_EXT_CFG(params, cfg); |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 28 | |
| 29 | return 0; |
| 30 | } |
| 31 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 32 | int dpni_open(struct fsl_mc_io *mc_io, |
| 33 | uint32_t cmd_flags, |
| 34 | int dpni_id, |
| 35 | uint16_t *token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 36 | { |
| 37 | struct mc_command cmd = { 0 }; |
| 38 | int err; |
| 39 | |
| 40 | /* prepare command */ |
| 41 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 42 | cmd_flags, |
| 43 | 0); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 44 | DPNI_CMD_OPEN(cmd, dpni_id); |
| 45 | |
| 46 | /* send command to mc*/ |
| 47 | err = mc_send_command(mc_io, &cmd); |
| 48 | if (err) |
| 49 | return err; |
| 50 | |
| 51 | /* retrieve response parameters */ |
| 52 | *token = MC_CMD_HDR_READ_TOKEN(cmd.header); |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 57 | int dpni_close(struct fsl_mc_io *mc_io, |
| 58 | uint32_t cmd_flags, |
| 59 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 60 | { |
| 61 | struct mc_command cmd = { 0 }; |
| 62 | |
| 63 | /* prepare command */ |
| 64 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 65 | cmd_flags, |
| 66 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 67 | |
| 68 | /* send command to mc*/ |
| 69 | return mc_send_command(mc_io, &cmd); |
| 70 | } |
| 71 | |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 72 | int dpni_create(struct fsl_mc_io *mc_io, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 73 | uint16_t dprc_token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 74 | uint32_t cmd_flags, |
| 75 | const struct dpni_cfg *cfg, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 76 | uint32_t *obj_id) |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 77 | { |
| 78 | struct mc_command cmd = { 0 }; |
| 79 | int err; |
| 80 | |
| 81 | /* prepare command */ |
| 82 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE, |
| 83 | cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 84 | dprc_token); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 85 | DPNI_CMD_CREATE(cmd, cfg); |
| 86 | |
| 87 | /* send command to mc*/ |
| 88 | err = mc_send_command(mc_io, &cmd); |
| 89 | if (err) |
| 90 | return err; |
| 91 | |
| 92 | /* retrieve response parameters */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 93 | MC_CMD_READ_OBJ_ID(cmd, *obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 94 | |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | int dpni_destroy(struct fsl_mc_io *mc_io, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 99 | uint16_t dprc_token, |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 100 | uint32_t cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 101 | uint32_t obj_id) |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 102 | { |
| 103 | struct mc_command cmd = { 0 }; |
| 104 | |
| 105 | /* prepare command */ |
| 106 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY, |
| 107 | cmd_flags, |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 108 | dprc_token); |
| 109 | |
| 110 | /* set object id to destroy */ |
| 111 | CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id); |
Prabhakar Kushwaha | 1ebbe4f | 2015-11-04 12:25:53 +0530 | [diff] [blame] | 112 | |
| 113 | /* send command to mc*/ |
| 114 | return mc_send_command(mc_io, &cmd); |
| 115 | } |
| 116 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 117 | int dpni_set_pools(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 118 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 119 | uint16_t token, |
| 120 | const struct dpni_pools_cfg *cfg) |
| 121 | { |
| 122 | struct mc_command cmd = { 0 }; |
| 123 | |
| 124 | /* prepare command */ |
| 125 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 126 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 127 | token); |
| 128 | DPNI_CMD_SET_POOLS(cmd, cfg); |
| 129 | |
| 130 | /* send command to mc*/ |
| 131 | return mc_send_command(mc_io, &cmd); |
| 132 | } |
| 133 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 134 | int dpni_enable(struct fsl_mc_io *mc_io, |
| 135 | uint32_t cmd_flags, |
| 136 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 137 | { |
| 138 | struct mc_command cmd = { 0 }; |
| 139 | |
| 140 | /* prepare command */ |
| 141 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 142 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 143 | token); |
| 144 | |
| 145 | /* send command to mc*/ |
| 146 | return mc_send_command(mc_io, &cmd); |
| 147 | } |
| 148 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 149 | int dpni_disable(struct fsl_mc_io *mc_io, |
| 150 | uint32_t cmd_flags, |
| 151 | uint16_t token) |
| 152 | { |
| 153 | struct mc_command cmd = { 0 }; |
| 154 | |
| 155 | /* prepare command */ |
| 156 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE, |
| 157 | cmd_flags, |
| 158 | token); |
| 159 | |
| 160 | /* send command to mc*/ |
| 161 | return mc_send_command(mc_io, &cmd); |
| 162 | } |
| 163 | |
| 164 | int dpni_reset(struct fsl_mc_io *mc_io, |
| 165 | uint32_t cmd_flags, |
| 166 | uint16_t token) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 167 | { |
| 168 | struct mc_command cmd = { 0 }; |
| 169 | |
| 170 | /* prepare command */ |
| 171 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 172 | cmd_flags, |
| 173 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 174 | |
| 175 | /* send command to mc*/ |
| 176 | return mc_send_command(mc_io, &cmd); |
| 177 | } |
| 178 | |
| 179 | int dpni_get_attributes(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 180 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 181 | uint16_t token, |
| 182 | struct dpni_attr *attr) |
| 183 | { |
| 184 | struct mc_command cmd = { 0 }; |
| 185 | int err; |
| 186 | |
| 187 | /* prepare command */ |
| 188 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 189 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 190 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 191 | /* send command to mc*/ |
| 192 | err = mc_send_command(mc_io, &cmd); |
| 193 | if (err) |
| 194 | return err; |
| 195 | |
| 196 | /* retrieve response parameters */ |
| 197 | DPNI_RSP_GET_ATTR(cmd, attr); |
| 198 | |
| 199 | return 0; |
| 200 | } |
| 201 | |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 202 | int dpni_set_errors_behavior(struct fsl_mc_io *mc_io, |
| 203 | uint32_t cmd_flags, |
| 204 | uint16_t token, |
| 205 | struct dpni_error_cfg *cfg) |
| 206 | { |
| 207 | struct mc_command cmd = { 0 }; |
| 208 | |
| 209 | /* prepare command */ |
| 210 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR, |
| 211 | cmd_flags, |
| 212 | token); |
| 213 | DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg); |
| 214 | |
| 215 | /* send command to mc*/ |
| 216 | return mc_send_command(mc_io, &cmd); |
| 217 | } |
| 218 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 219 | int dpni_set_buffer_layout(struct fsl_mc_io *mc_io, |
| 220 | uint32_t cmd_flags, |
| 221 | uint16_t token, |
| 222 | const struct dpni_buffer_layout *layout, |
| 223 | enum dpni_queue_type type) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 224 | { |
| 225 | struct mc_command cmd = { 0 }; |
| 226 | |
| 227 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 228 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 229 | cmd_flags, |
| 230 | token); |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 231 | DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, type); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 232 | |
| 233 | /* send command to mc*/ |
| 234 | return mc_send_command(mc_io, &cmd); |
| 235 | } |
| 236 | |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 237 | int dpni_get_qdid(struct fsl_mc_io *mc_io, |
| 238 | uint32_t cmd_flags, |
| 239 | uint16_t token, |
| 240 | uint16_t *qdid) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 241 | { |
| 242 | struct mc_command cmd = { 0 }; |
| 243 | int err; |
| 244 | |
| 245 | /* prepare command */ |
| 246 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 247 | cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 248 | token); |
| 249 | |
| 250 | /* send command to mc*/ |
| 251 | err = mc_send_command(mc_io, &cmd); |
| 252 | if (err) |
| 253 | return err; |
| 254 | |
| 255 | /* retrieve response parameters */ |
| 256 | DPNI_RSP_GET_QDID(cmd, *qdid); |
| 257 | |
| 258 | return 0; |
| 259 | } |
| 260 | |
| 261 | int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 262 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 263 | uint16_t token, |
| 264 | uint16_t *data_offset) |
| 265 | { |
| 266 | struct mc_command cmd = { 0 }; |
| 267 | int err; |
| 268 | |
| 269 | /* prepare command */ |
| 270 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 271 | cmd_flags, |
| 272 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 273 | |
| 274 | /* send command to mc*/ |
| 275 | err = mc_send_command(mc_io, &cmd); |
| 276 | if (err) |
| 277 | return err; |
| 278 | |
| 279 | /* retrieve response parameters */ |
| 280 | DPNI_RSP_GET_TX_DATA_OFFSET(cmd, *data_offset); |
| 281 | |
| 282 | return 0; |
| 283 | } |
| 284 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 285 | int dpni_set_link_cfg(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 286 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 287 | uint16_t token, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 288 | const struct dpni_link_cfg *cfg) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 289 | { |
| 290 | struct mc_command cmd = { 0 }; |
| 291 | |
| 292 | /* prepare command */ |
| 293 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 294 | cmd_flags, |
| 295 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 296 | DPNI_CMD_SET_LINK_CFG(cmd, cfg); |
| 297 | |
| 298 | /* send command to mc*/ |
| 299 | return mc_send_command(mc_io, &cmd); |
| 300 | } |
| 301 | |
| 302 | int dpni_get_link_state(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 303 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 304 | uint16_t token, |
| 305 | struct dpni_link_state *state) |
| 306 | { |
| 307 | struct mc_command cmd = { 0 }; |
| 308 | int err; |
| 309 | |
| 310 | /* prepare command */ |
| 311 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 312 | cmd_flags, |
| 313 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 314 | |
| 315 | /* send command to mc*/ |
| 316 | err = mc_send_command(mc_io, &cmd); |
| 317 | if (err) |
| 318 | return err; |
| 319 | |
| 320 | /* retrieve response parameters */ |
| 321 | DPNI_RSP_GET_LINK_STATE(cmd, state); |
| 322 | |
| 323 | return 0; |
| 324 | } |
| 325 | |
| 326 | |
| 327 | int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 328 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 329 | uint16_t token, |
| 330 | const uint8_t mac_addr[6]) |
| 331 | { |
| 332 | struct mc_command cmd = { 0 }; |
| 333 | |
| 334 | /* prepare command */ |
| 335 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 336 | cmd_flags, |
| 337 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 338 | DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr); |
| 339 | |
| 340 | /* send command to mc*/ |
| 341 | return mc_send_command(mc_io, &cmd); |
| 342 | } |
| 343 | |
| 344 | int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 345 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 346 | uint16_t token, |
| 347 | uint8_t mac_addr[6]) |
| 348 | { |
| 349 | struct mc_command cmd = { 0 }; |
| 350 | int err; |
| 351 | |
| 352 | /* prepare command */ |
| 353 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 354 | cmd_flags, |
| 355 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 356 | |
| 357 | /* send command to mc*/ |
| 358 | err = mc_send_command(mc_io, &cmd); |
| 359 | if (err) |
| 360 | return err; |
| 361 | |
| 362 | /* retrieve response parameters */ |
| 363 | DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr); |
| 364 | |
| 365 | return 0; |
| 366 | } |
| 367 | |
| 368 | int dpni_add_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 369 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 370 | uint16_t token, |
| 371 | const uint8_t mac_addr[6]) |
| 372 | { |
| 373 | struct mc_command cmd = { 0 }; |
| 374 | |
| 375 | /* prepare command */ |
| 376 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 377 | cmd_flags, |
| 378 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 379 | DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr); |
| 380 | |
| 381 | /* send command to mc*/ |
| 382 | return mc_send_command(mc_io, &cmd); |
| 383 | } |
| 384 | |
| 385 | int dpni_remove_mac_addr(struct fsl_mc_io *mc_io, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 386 | uint32_t cmd_flags, |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 387 | uint16_t token, |
| 388 | const uint8_t mac_addr[6]) |
| 389 | { |
| 390 | struct mc_command cmd = { 0 }; |
| 391 | |
| 392 | /* prepare command */ |
| 393 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 394 | cmd_flags, |
| 395 | token); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 396 | DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr); |
| 397 | |
| 398 | /* send command to mc*/ |
| 399 | return mc_send_command(mc_io, &cmd); |
| 400 | } |
| 401 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 402 | int dpni_get_api_version(struct fsl_mc_io *mc_io, |
| 403 | u32 cmd_flags, |
| 404 | u16 *major_ver, |
| 405 | u16 *minor_ver) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 406 | { |
| 407 | struct mc_command cmd = { 0 }; |
| 408 | int err; |
| 409 | |
| 410 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 411 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION, |
| 412 | cmd_flags, 0); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 413 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 414 | /* send command to mc */ |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 415 | err = mc_send_command(mc_io, &cmd); |
| 416 | if (err) |
| 417 | return err; |
| 418 | |
| 419 | /* retrieve response parameters */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 420 | mc_cmd_read_api_version(&cmd, major_ver, minor_ver); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 421 | |
| 422 | return 0; |
| 423 | } |
| 424 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 425 | int dpni_set_queue(struct fsl_mc_io *mc_io, |
| 426 | uint32_t cmd_flags, |
| 427 | uint16_t token, |
| 428 | enum dpni_queue_type type, |
| 429 | uint8_t tc, |
| 430 | uint8_t index, |
| 431 | const struct dpni_queue *queue) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 432 | { |
| 433 | struct mc_command cmd = { 0 }; |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 434 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 435 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 436 | cmd_flags, |
| 437 | token); |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 438 | DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 439 | |
| 440 | /* send command to mc*/ |
| 441 | return mc_send_command(mc_io, &cmd); |
| 442 | } |
| 443 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 444 | int dpni_get_queue(struct fsl_mc_io *mc_io, |
| 445 | uint32_t cmd_flags, |
| 446 | uint16_t token, |
| 447 | enum dpni_queue_type type, |
| 448 | uint8_t tc, |
| 449 | uint8_t index, |
| 450 | struct dpni_queue *queue) |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 451 | { |
| 452 | struct mc_command cmd = { 0 }; |
| 453 | int err; |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 454 | |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 455 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 456 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE, |
Prabhakar Kushwaha | 87457d1 | 2015-07-07 15:40:06 +0530 | [diff] [blame] | 457 | cmd_flags, |
| 458 | token); |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 459 | DPNI_CMD_GET_QUEUE(cmd, type, tc, index); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 460 | |
| 461 | /* send command to mc*/ |
| 462 | err = mc_send_command(mc_io, &cmd); |
| 463 | if (err) |
| 464 | return err; |
| 465 | |
| 466 | /* retrieve response parameters */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 467 | DPNI_RSP_GET_QUEUE(cmd, queue); |
Prabhakar Kushwaha | a2a55e5 | 2015-03-19 09:20:45 -0700 | [diff] [blame] | 468 | return 0; |
| 469 | } |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 470 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 471 | int dpni_set_tx_confirmation_mode(struct fsl_mc_io *mc_io, |
| 472 | uint32_t cmd_flags, |
| 473 | uint16_t token, |
| 474 | enum dpni_confirmation_mode mode) |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 475 | { |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 476 | struct dpni_tx_confirmation_mode *cmd_params; |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 477 | struct mc_command cmd = { 0 }; |
| 478 | |
| 479 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 480 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE, |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 481 | cmd_flags, |
| 482 | token); |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 483 | |
| 484 | cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params; |
| 485 | cmd_params->confirmation_mode = mode; |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 486 | |
| 487 | /* send command to mc*/ |
| 488 | return mc_send_command(mc_io, &cmd); |
| 489 | } |
| 490 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 491 | int dpni_get_statistics(struct fsl_mc_io *mc_io, |
| 492 | uint32_t cmd_flags, |
| 493 | uint16_t token, |
| 494 | uint8_t page, |
| 495 | struct dpni_statistics *stat) |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 496 | { |
| 497 | struct mc_command cmd = { 0 }; |
| 498 | int err; |
| 499 | |
| 500 | /* prepare command */ |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 501 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS, |
| 502 | cmd_flags, token); |
| 503 | DPNI_CMD_GET_STATISTICS(cmd, page); |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 504 | |
| 505 | /* send command to mc*/ |
| 506 | err = mc_send_command(mc_io, &cmd); |
| 507 | if (err) |
| 508 | return err; |
| 509 | |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 510 | /* retrieve response parameters */ |
| 511 | DPNI_RSP_GET_STATISTICS(cmd, stat); |
Prabhakar Kushwaha | 53e353f | 2015-12-24 15:32:49 +0530 | [diff] [blame] | 512 | |
| 513 | return 0; |
| 514 | } |
Yogesh Gaur | 2557c5a | 2017-11-15 11:59:31 +0530 | [diff] [blame] | 515 | |
| 516 | int dpni_reset_statistics(struct fsl_mc_io *mc_io, |
| 517 | uint32_t cmd_flags, |
| 518 | uint16_t token) |
| 519 | { |
| 520 | struct mc_command cmd = { 0 }; |
| 521 | |
| 522 | /* prepare command */ |
| 523 | cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET_STATISTICS, |
| 524 | cmd_flags, token); |
| 525 | |
| 526 | /* send command to mc*/ |
| 527 | return mc_send_command(mc_io, &cmd); |
| 528 | } |
| 529 | |