blob: 41bf56abf5b19c0a773c344d5094f07ed43ff796 [file] [log] [blame]
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -07001/*
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 Kushwahac3d06e32015-12-24 15:32:49 +053011int 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
21int 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 Kushwaha9564df62015-07-07 15:40:06 +053031int dpni_open(struct fsl_mc_io *mc_io,
32 uint32_t cmd_flags,
33 int dpni_id,
34 uint16_t *token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070035{
36 struct mc_command cmd = { 0 };
37 int err;
38
39 /* prepare command */
40 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053041 cmd_flags,
42 0);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070043 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 Kushwaha9564df62015-07-07 15:40:06 +053056int dpni_close(struct fsl_mc_io *mc_io,
57 uint32_t cmd_flags,
58 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070059{
60 struct mc_command cmd = { 0 };
61
62 /* prepare command */
63 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +053064 cmd_flags,
65 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -070066
67 /* send command to mc*/
68 return mc_send_command(mc_io, &cmd);
69}
70
Prabhakar Kushwahacf0c8cf2015-11-04 12:25:53 +053071int 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
96int 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 Kushwahacfd9fbf2015-03-19 09:20:45 -0700111int dpni_set_pools(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530112 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700113 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 Kushwaha9564df62015-07-07 15:40:06 +0530120 cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700121 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 Kushwaha9564df62015-07-07 15:40:06 +0530128int dpni_enable(struct fsl_mc_io *mc_io,
129 uint32_t cmd_flags,
130 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700131{
132 struct mc_command cmd = { 0 };
133
134 /* prepare command */
135 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530136 cmd_flags,
137 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700138
139 /* send command to mc*/
140 return mc_send_command(mc_io, &cmd);
141}
142
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530143int dpni_disable(struct fsl_mc_io *mc_io,
144 uint32_t cmd_flags,
145 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700146{
147 struct mc_command cmd = { 0 };
148
149 /* prepare command */
150 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530151 cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700152 token);
153
154 /* send command to mc*/
155 return mc_send_command(mc_io, &cmd);
156}
157
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530158int dpni_reset(struct fsl_mc_io *mc_io,
159 uint32_t cmd_flags,
160 uint16_t token)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700161{
162 struct mc_command cmd = { 0 };
163
164 /* prepare command */
165 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530166 cmd_flags,
167 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700168
169 /* send command to mc*/
170 return mc_send_command(mc_io, &cmd);
171}
172
173int dpni_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530174 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700175 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 Kushwaha9564df62015-07-07 15:40:06 +0530183 cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700184 token);
Prabhakar Kushwahac3d06e32015-12-24 15:32:49 +0530185 DPNI_CMD_GET_ATTR(cmd, attr);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700186
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 Kushwahac3d06e32015-12-24 15:32:49 +0530198int 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 Kushwahacfd9fbf2015-03-19 09:20:45 -0700215int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530216 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700217 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 Kushwaha9564df62015-07-07 15:40:06 +0530225 cmd_flags,
226 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700227
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
239int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530240 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700241 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 Kushwaha9564df62015-07-07 15:40:06 +0530248 cmd_flags,
249 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700250 DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout);
251
252 /* send command to mc*/
253 return mc_send_command(mc_io, &cmd);
254}
255
256int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530257 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700258 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 Kushwaha9564df62015-07-07 15:40:06 +0530266 cmd_flags,
267 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700268
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
280int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530281 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700282 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 Kushwaha9564df62015-07-07 15:40:06 +0530289 cmd_flags,
290 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700291 DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout);
292
293 /* send command to mc*/
294 return mc_send_command(mc_io, &cmd);
295}
296
297int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530298 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700299 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 Kushwaha9564df62015-07-07 15:40:06 +0530307 cmd_flags,
308 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700309
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
321int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530322 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700323 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 Kushwaha9564df62015-07-07 15:40:06 +0530330 cmd_flags,
331 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700332 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 Kushwaha9564df62015-07-07 15:40:06 +0530338int dpni_get_qdid(struct fsl_mc_io *mc_io,
339 uint32_t cmd_flags,
340 uint16_t token,
341 uint16_t *qdid)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700342{
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 Kushwaha9564df62015-07-07 15:40:06 +0530348 cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700349 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
362int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530363 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700364 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 Kushwaha9564df62015-07-07 15:40:06 +0530372 cmd_flags,
373 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700374
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
386int dpni_get_counter(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530387 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700388 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 Kushwaha9564df62015-07-07 15:40:06 +0530397 cmd_flags,
398 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700399 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
412int dpni_set_counter(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530413 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700414 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 Kushwaha9564df62015-07-07 15:40:06 +0530422 cmd_flags,
423 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700424 DPNI_CMD_SET_COUNTER(cmd, counter, value);
425
426 /* send command to mc*/
427 return mc_send_command(mc_io, &cmd);
428}
429
430int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530431 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700432 uint16_t token,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530433 const struct dpni_link_cfg *cfg)
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700434{
435 struct mc_command cmd = { 0 };
436
437 /* prepare command */
438 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530439 cmd_flags,
440 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700441 DPNI_CMD_SET_LINK_CFG(cmd, cfg);
442
443 /* send command to mc*/
444 return mc_send_command(mc_io, &cmd);
445}
446
447int dpni_get_link_state(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530448 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700449 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 Kushwaha9564df62015-07-07 15:40:06 +0530457 cmd_flags,
458 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700459
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
472int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530473 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700474 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 Kushwaha9564df62015-07-07 15:40:06 +0530481 cmd_flags,
482 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700483 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
489int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530490 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700491 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 Kushwaha9564df62015-07-07 15:40:06 +0530499 cmd_flags,
500 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700501
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
513int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530514 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700515 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 Kushwaha9564df62015-07-07 15:40:06 +0530522 cmd_flags,
523 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700524 DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
525
526 /* send command to mc*/
527 return mc_send_command(mc_io, &cmd);
528}
529
530int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530531 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700532 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 Kushwaha9564df62015-07-07 15:40:06 +0530539 cmd_flags,
540 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700541 DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr);
542
543 /* send command to mc*/
544 return mc_send_command(mc_io, &cmd);
545}
546
547int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530548 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700549 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 Kushwaha9564df62015-07-07 15:40:06 +0530558 cmd_flags,
559 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700560 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
573int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530574 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700575 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 Kushwaha9564df62015-07-07 15:40:06 +0530584 cmd_flags,
585 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700586 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
599int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530600 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700601 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 Kushwaha9564df62015-07-07 15:40:06 +0530610 cmd_flags,
611 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700612 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
618int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha9564df62015-07-07 15:40:06 +0530619 uint32_t cmd_flags,
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700620 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 Kushwaha9564df62015-07-07 15:40:06 +0530629 cmd_flags,
630 token);
Prabhakar Kushwahacfd9fbf2015-03-19 09:20:45 -0700631 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 Kushwahac3d06e32015-12-24 15:32:49 +0530643
644int 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
662int 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}