blob: eacb3c8bb2f804c8908db1c557229d16eab1c5b9 [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-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 Kushwaha87457d12015-07-07 15:40:06 +053011int dpni_open(struct fsl_mc_io *mc_io,
12 uint32_t cmd_flags,
13 int dpni_id,
14 uint16_t *token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070015{
16 struct mc_command cmd = { 0 };
17 int err;
18
19 /* prepare command */
20 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053021 cmd_flags,
22 0);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070023 DPNI_CMD_OPEN(cmd, dpni_id);
24
25 /* send command to mc*/
26 err = mc_send_command(mc_io, &cmd);
27 if (err)
28 return err;
29
30 /* retrieve response parameters */
31 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
32
33 return 0;
34}
35
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053036int dpni_close(struct fsl_mc_io *mc_io,
37 uint32_t cmd_flags,
38 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070039{
40 struct mc_command cmd = { 0 };
41
42 /* prepare command */
43 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053044 cmd_flags,
45 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070046
47 /* send command to mc*/
48 return mc_send_command(mc_io, &cmd);
49}
50
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053051int dpni_create(struct fsl_mc_io *mc_io,
52 uint32_t cmd_flags,
53 const struct dpni_cfg *cfg,
54 uint16_t *token)
55{
56 struct mc_command cmd = { 0 };
57 int err;
58
59 /* prepare command */
60 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE,
61 cmd_flags,
62 0);
63 DPNI_CMD_CREATE(cmd, cfg);
64
65 /* send command to mc*/
66 err = mc_send_command(mc_io, &cmd);
67 if (err)
68 return err;
69
70 /* retrieve response parameters */
71 *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
72
73 return 0;
74}
75
76int dpni_destroy(struct fsl_mc_io *mc_io,
77 uint32_t cmd_flags,
78 uint16_t token)
79{
80 struct mc_command cmd = { 0 };
81
82 /* prepare command */
83 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY,
84 cmd_flags,
85 token);
86
87 /* send command to mc*/
88 return mc_send_command(mc_io, &cmd);
89}
90
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070091int dpni_set_pools(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053092 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070093 uint16_t token,
94 const struct dpni_pools_cfg *cfg)
95{
96 struct mc_command cmd = { 0 };
97
98 /* prepare command */
99 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530100 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700101 token);
102 DPNI_CMD_SET_POOLS(cmd, cfg);
103
104 /* send command to mc*/
105 return mc_send_command(mc_io, &cmd);
106}
107
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530108int dpni_enable(struct fsl_mc_io *mc_io,
109 uint32_t cmd_flags,
110 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700111{
112 struct mc_command cmd = { 0 };
113
114 /* prepare command */
115 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530116 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700117 token);
118
119 /* send command to mc*/
120 return mc_send_command(mc_io, &cmd);
121}
122
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530123int dpni_disable(struct fsl_mc_io *mc_io,
124 uint32_t cmd_flags,
125 uint16_t token)
126{
127 struct mc_command cmd = { 0 };
128
129 /* prepare command */
130 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
131 cmd_flags,
132 token);
133
134 /* send command to mc*/
135 return mc_send_command(mc_io, &cmd);
136}
137
138int dpni_reset(struct fsl_mc_io *mc_io,
139 uint32_t cmd_flags,
140 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700141{
142 struct mc_command cmd = { 0 };
143
144 /* prepare command */
145 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530146 cmd_flags,
147 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700148
149 /* send command to mc*/
150 return mc_send_command(mc_io, &cmd);
151}
152
153int dpni_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530154 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700155 uint16_t token,
156 struct dpni_attr *attr)
157{
158 struct mc_command cmd = { 0 };
159 int err;
160
161 /* prepare command */
162 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530163 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700164 token);
165
166 /* send command to mc*/
167 err = mc_send_command(mc_io, &cmd);
168 if (err)
169 return err;
170
171 /* retrieve response parameters */
172 DPNI_RSP_GET_ATTR(cmd, attr);
173
174 return 0;
175}
176
177int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530178 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700179 uint16_t token,
180 struct dpni_buffer_layout *layout)
181{
182 struct mc_command cmd = { 0 };
183 int err;
184
185 /* prepare command */
186 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530187 cmd_flags,
188 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700189
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_RX_BUFFER_LAYOUT(cmd, layout);
197
198 return 0;
199}
200
201int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530202 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700203 uint16_t token,
204 const struct dpni_buffer_layout *layout)
205{
206 struct mc_command cmd = { 0 };
207
208 /* prepare command */
209 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530210 cmd_flags,
211 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700212 DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout);
213
214 /* send command to mc*/
215 return mc_send_command(mc_io, &cmd);
216}
217
218int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530219 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700220 uint16_t token,
221 struct dpni_buffer_layout *layout)
222{
223 struct mc_command cmd = { 0 };
224 int err;
225
226 /* prepare command */
227 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530228 cmd_flags,
229 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700230
231 /* send command to mc*/
232 err = mc_send_command(mc_io, &cmd);
233 if (err)
234 return err;
235
236 /* retrieve response parameters */
237 DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout);
238
239 return 0;
240}
241
242int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530243 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700244 uint16_t token,
245 const struct dpni_buffer_layout *layout)
246{
247 struct mc_command cmd = { 0 };
248
249 /* prepare command */
250 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530251 cmd_flags,
252 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700253 DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout);
254
255 /* send command to mc*/
256 return mc_send_command(mc_io, &cmd);
257}
258
259int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530260 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700261 uint16_t token,
262 struct dpni_buffer_layout *layout)
263{
264 struct mc_command cmd = { 0 };
265 int err;
266
267 /* prepare command */
268 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530269 cmd_flags,
270 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700271
272 /* send command to mc*/
273 err = mc_send_command(mc_io, &cmd);
274 if (err)
275 return err;
276
277 /* retrieve response parameters */
278 DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
279
280 return 0;
281}
282
283int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530284 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700285 uint16_t token,
286 const struct dpni_buffer_layout *layout)
287{
288 struct mc_command cmd = { 0 };
289
290 /* prepare command */
291 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530292 cmd_flags,
293 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700294 DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
295
296 /* send command to mc*/
297 return mc_send_command(mc_io, &cmd);
298}
299
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530300int dpni_get_qdid(struct fsl_mc_io *mc_io,
301 uint32_t cmd_flags,
302 uint16_t token,
303 uint16_t *qdid)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700304{
305 struct mc_command cmd = { 0 };
306 int err;
307
308 /* prepare command */
309 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530310 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700311 token);
312
313 /* send command to mc*/
314 err = mc_send_command(mc_io, &cmd);
315 if (err)
316 return err;
317
318 /* retrieve response parameters */
319 DPNI_RSP_GET_QDID(cmd, *qdid);
320
321 return 0;
322}
323
324int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530325 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700326 uint16_t token,
327 uint16_t *data_offset)
328{
329 struct mc_command cmd = { 0 };
330 int err;
331
332 /* prepare command */
333 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530334 cmd_flags,
335 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700336
337 /* send command to mc*/
338 err = mc_send_command(mc_io, &cmd);
339 if (err)
340 return err;
341
342 /* retrieve response parameters */
343 DPNI_RSP_GET_TX_DATA_OFFSET(cmd, *data_offset);
344
345 return 0;
346}
347
348int dpni_get_counter(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530349 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700350 uint16_t token,
351 enum dpni_counter counter,
352 uint64_t *value)
353{
354 struct mc_command cmd = { 0 };
355 int err;
356
357 /* prepare command */
358 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_COUNTER,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530359 cmd_flags,
360 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700361 DPNI_CMD_GET_COUNTER(cmd, counter);
362
363 /* send command to mc*/
364 err = mc_send_command(mc_io, &cmd);
365 if (err)
366 return err;
367
368 /* retrieve response parameters */
369 DPNI_RSP_GET_COUNTER(cmd, *value);
370
371 return 0;
372}
373
374int dpni_set_counter(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530375 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700376 uint16_t token,
377 enum dpni_counter counter,
378 uint64_t value)
379{
380 struct mc_command cmd = { 0 };
381
382 /* prepare command */
383 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_COUNTER,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530384 cmd_flags,
385 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700386 DPNI_CMD_SET_COUNTER(cmd, counter, value);
387
388 /* send command to mc*/
389 return mc_send_command(mc_io, &cmd);
390}
391
392int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530393 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700394 uint16_t token,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530395 const struct dpni_link_cfg *cfg)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700396{
397 struct mc_command cmd = { 0 };
398
399 /* prepare command */
400 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530401 cmd_flags,
402 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700403 DPNI_CMD_SET_LINK_CFG(cmd, cfg);
404
405 /* send command to mc*/
406 return mc_send_command(mc_io, &cmd);
407}
408
409int dpni_get_link_state(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530410 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700411 uint16_t token,
412 struct dpni_link_state *state)
413{
414 struct mc_command cmd = { 0 };
415 int err;
416
417 /* prepare command */
418 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530419 cmd_flags,
420 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700421
422 /* send command to mc*/
423 err = mc_send_command(mc_io, &cmd);
424 if (err)
425 return err;
426
427 /* retrieve response parameters */
428 DPNI_RSP_GET_LINK_STATE(cmd, state);
429
430 return 0;
431}
432
433
434int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530435 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700436 uint16_t token,
437 const uint8_t mac_addr[6])
438{
439 struct mc_command cmd = { 0 };
440
441 /* prepare command */
442 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530443 cmd_flags,
444 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700445 DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr);
446
447 /* send command to mc*/
448 return mc_send_command(mc_io, &cmd);
449}
450
451int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530452 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700453 uint16_t token,
454 uint8_t mac_addr[6])
455{
456 struct mc_command cmd = { 0 };
457 int err;
458
459 /* prepare command */
460 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530461 cmd_flags,
462 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700463
464 /* send command to mc*/
465 err = mc_send_command(mc_io, &cmd);
466 if (err)
467 return err;
468
469 /* retrieve response parameters */
470 DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr);
471
472 return 0;
473}
474
475int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530476 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700477 uint16_t token,
478 const uint8_t mac_addr[6])
479{
480 struct mc_command cmd = { 0 };
481
482 /* prepare command */
483 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530484 cmd_flags,
485 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700486 DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
487
488 /* send command to mc*/
489 return mc_send_command(mc_io, &cmd);
490}
491
492int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530493 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700494 uint16_t token,
495 const uint8_t mac_addr[6])
496{
497 struct mc_command cmd = { 0 };
498
499 /* prepare command */
500 cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530501 cmd_flags,
502 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700503 DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr);
504
505 /* send command to mc*/
506 return mc_send_command(mc_io, &cmd);
507}
508
509int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530510 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700511 uint16_t token,
512 uint16_t *flow_id,
513 const struct dpni_tx_flow_cfg *cfg)
514{
515 struct mc_command cmd = { 0 };
516 int err;
517
518 /* prepare command */
519 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_FLOW,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530520 cmd_flags,
521 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700522 DPNI_CMD_SET_TX_FLOW(cmd, *flow_id, cfg);
523
524 /* send command to mc*/
525 err = mc_send_command(mc_io, &cmd);
526 if (err)
527 return err;
528
529 /* retrieve response parameters */
530 DPNI_RSP_SET_TX_FLOW(cmd, *flow_id);
531
532 return 0;
533}
534
535int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530536 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700537 uint16_t token,
538 uint16_t flow_id,
539 struct dpni_tx_flow_attr *attr)
540{
541 struct mc_command cmd = { 0 };
542 int err;
543
544 /* prepare command */
545 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_FLOW,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530546 cmd_flags,
547 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700548 DPNI_CMD_GET_TX_FLOW(cmd, flow_id);
549
550 /* send command to mc*/
551 err = mc_send_command(mc_io, &cmd);
552 if (err)
553 return err;
554
555 /* retrieve response parameters */
556 DPNI_RSP_GET_TX_FLOW(cmd, attr);
557
558 return 0;
559}
560
561int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530562 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700563 uint16_t token,
564 uint8_t tc_id,
565 uint16_t flow_id,
566 const struct dpni_queue_cfg *cfg)
567{
568 struct mc_command cmd = { 0 };
569
570 /* prepare command */
571 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_FLOW,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530572 cmd_flags,
573 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700574 DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg);
575
576 /* send command to mc*/
577 return mc_send_command(mc_io, &cmd);
578}
579
580int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530581 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700582 uint16_t token,
583 uint8_t tc_id,
584 uint16_t flow_id,
585 struct dpni_queue_attr *attr)
586{
587 struct mc_command cmd = { 0 };
588 int err;
589 /* prepare command */
590 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_FLOW,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530591 cmd_flags,
592 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700593 DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id);
594
595 /* send command to mc*/
596 err = mc_send_command(mc_io, &cmd);
597 if (err)
598 return err;
599
600 /* retrieve response parameters */
601 DPNI_RSP_GET_RX_FLOW(cmd, attr);
602
603 return 0;
604}