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