blob: 5cf5eebea6e3bbc5b77a138835829dbb373a6abd [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07002/*
Yogesh Gaur2557c5a2017-11-15 11:59:31 +05303 * Copyright (C) 2013-2016 Freescale Semiconductor
4 * Copyright 2017 NXP
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07005 */
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 Gaur2557c5a2017-11-15 11:59:31 +053011int dpni_prepare_cfg(const struct dpni_cfg *cfg,
12 uint8_t *cfg_buf)
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053013{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053014 uint64_t *params = (uint64_t *)cfg_buf;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053015
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053016 DPNI_PREP_CFG(params, cfg);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053017
18 return 0;
19}
20
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053021int dpni_extract_cfg(struct dpni_cfg *cfg,
22 const uint8_t *cfg_buf)
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053023{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053024 uint64_t *params = (uint64_t *)cfg_buf;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053025
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053026 DPNI_EXT_CFG(params, cfg);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053027
28 return 0;
29}
30
Prabhakar Kushwaha87457d12015-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 Kushwahaa2a55e52015-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 Kushwaha87457d12015-07-07 15:40:06 +053041 cmd_flags,
42 0);
Prabhakar Kushwahaa2a55e52015-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 Kushwaha87457d12015-07-07 15:40:06 +053056int dpni_close(struct fsl_mc_io *mc_io,
57 uint32_t cmd_flags,
58 uint16_t token)
Prabhakar Kushwahaa2a55e52015-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 Kushwaha87457d12015-07-07 15:40:06 +053064 cmd_flags,
65 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070066
67 /* send command to mc*/
68 return mc_send_command(mc_io, &cmd);
69}
70
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053071int dpni_create(struct fsl_mc_io *mc_io,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053072 uint16_t dprc_token,
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053073 uint32_t cmd_flags,
74 const struct dpni_cfg *cfg,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053075 uint32_t *obj_id)
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053076{
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 Gaur2557c5a2017-11-15 11:59:31 +053083 dprc_token);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053084 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 Gaur2557c5a2017-11-15 11:59:31 +053092 MC_CMD_READ_OBJ_ID(cmd, *obj_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053093
94 return 0;
95}
96
97int dpni_destroy(struct fsl_mc_io *mc_io,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053098 uint16_t dprc_token,
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053099 uint32_t cmd_flags,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530100 uint32_t obj_id)
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530101{
102 struct mc_command cmd = { 0 };
103
104 /* prepare command */
105 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY,
106 cmd_flags,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530107 dprc_token);
108
109 /* set object id to destroy */
110 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530111
112 /* send command to mc*/
113 return mc_send_command(mc_io, &cmd);
114}
115
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700116int dpni_set_pools(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530117 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700118 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 Kushwaha87457d12015-07-07 15:40:06 +0530125 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700126 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 Kushwaha87457d12015-07-07 15:40:06 +0530133int dpni_enable(struct fsl_mc_io *mc_io,
134 uint32_t cmd_flags,
135 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700136{
137 struct mc_command cmd = { 0 };
138
139 /* prepare command */
140 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530141 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700142 token);
143
144 /* send command to mc*/
145 return mc_send_command(mc_io, &cmd);
146}
147
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530148int 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
163int dpni_reset(struct fsl_mc_io *mc_io,
164 uint32_t cmd_flags,
165 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700166{
167 struct mc_command cmd = { 0 };
168
169 /* prepare command */
170 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530171 cmd_flags,
172 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700173
174 /* send command to mc*/
175 return mc_send_command(mc_io, &cmd);
176}
177
178int dpni_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530179 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700180 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 Kushwaha87457d12015-07-07 15:40:06 +0530188 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700189 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700190 /* 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 Kushwaha53e353f2015-12-24 15:32:49 +0530201int 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 Gaur2557c5a2017-11-15 11:59:31 +0530218int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700223{
224 struct mc_command cmd = { 0 };
225
226 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530227 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530228 cmd_flags,
229 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530230 DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, type);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700231
232 /* send command to mc*/
233 return mc_send_command(mc_io, &cmd);
234}
235
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530236int dpni_get_qdid(struct fsl_mc_io *mc_io,
237 uint32_t cmd_flags,
238 uint16_t token,
239 uint16_t *qdid)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700240{
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 Kushwaha87457d12015-07-07 15:40:06 +0530246 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700247 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
260int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530261 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700262 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 Kushwaha87457d12015-07-07 15:40:06 +0530270 cmd_flags,
271 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700272
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 Kushwahaa2a55e52015-03-19 09:20:45 -0700284int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530285 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700286 uint16_t token,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530287 const struct dpni_link_cfg *cfg)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700288{
289 struct mc_command cmd = { 0 };
290
291 /* prepare command */
292 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530293 cmd_flags,
294 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700295 DPNI_CMD_SET_LINK_CFG(cmd, cfg);
296
297 /* send command to mc*/
298 return mc_send_command(mc_io, &cmd);
299}
300
301int dpni_get_link_state(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530302 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700303 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 Kushwaha87457d12015-07-07 15:40:06 +0530311 cmd_flags,
312 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700313
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
326int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530327 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700328 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 Kushwaha87457d12015-07-07 15:40:06 +0530335 cmd_flags,
336 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700337 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
343int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530344 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700345 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 Kushwaha87457d12015-07-07 15:40:06 +0530353 cmd_flags,
354 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700355
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
367int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530368 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700369 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 Kushwaha87457d12015-07-07 15:40:06 +0530376 cmd_flags,
377 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700378 DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
379
380 /* send command to mc*/
381 return mc_send_command(mc_io, &cmd);
382}
383
384int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530385 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700386 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 Kushwaha87457d12015-07-07 15:40:06 +0530393 cmd_flags,
394 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700395 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 Gaur2557c5a2017-11-15 11:59:31 +0530401int dpni_get_api_version(struct fsl_mc_io *mc_io,
402 u32 cmd_flags,
403 u16 *major_ver,
404 u16 *minor_ver)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700405{
406 struct mc_command cmd = { 0 };
407 int err;
408
409 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530410 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
411 cmd_flags, 0);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700412
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530413 /* send command to mc */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700414 err = mc_send_command(mc_io, &cmd);
415 if (err)
416 return err;
417
418 /* retrieve response parameters */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530419 mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700420
421 return 0;
422}
423
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530424int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700431{
432 struct mc_command cmd = { 0 };
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700433 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530434 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530435 cmd_flags,
436 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530437 DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700438
439 /* send command to mc*/
440 return mc_send_command(mc_io, &cmd);
441}
442
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530443int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700450{
451 struct mc_command cmd = { 0 };
452 int err;
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530453
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700454 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530455 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530456 cmd_flags,
457 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530458 DPNI_CMD_GET_QUEUE(cmd, type, tc, index);
Prabhakar Kushwahaa2a55e52015-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 */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530466 DPNI_RSP_GET_QUEUE(cmd, queue);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700467 return 0;
468}
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530469
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530470int 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 Kushwaha53e353f2015-12-24 15:32:49 +0530474{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530475 struct dpni_tx_confirmation_mode *cmd_params;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530476 struct mc_command cmd = { 0 };
477
478 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530479 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE,
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530480 cmd_flags,
481 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530482
483 cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params;
484 cmd_params->confirmation_mode = mode;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530485
486 /* send command to mc*/
487 return mc_send_command(mc_io, &cmd);
488}
489
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530490int 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 Kushwaha53e353f2015-12-24 15:32:49 +0530495{
496 struct mc_command cmd = { 0 };
497 int err;
498
499 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530500 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
501 cmd_flags, token);
502 DPNI_CMD_GET_STATISTICS(cmd, page);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530503
504 /* send command to mc*/
505 err = mc_send_command(mc_io, &cmd);
506 if (err)
507 return err;
508
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530509 /* retrieve response parameters */
510 DPNI_RSP_GET_STATISTICS(cmd, stat);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530511
512 return 0;
513}
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530514
515int 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