blob: 481f9d882b0f647539d60da0cf8641496c12f7b1 [file] [log] [blame]
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07001/*
Yogesh Gaur2557c5a2017-11-15 11:59:31 +05302 * Copyright (C) 2013-2016 Freescale Semiconductor
3 * Copyright 2017 NXP
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -07004 *
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 Gaur2557c5a2017-11-15 11:59:31 +053012int dpni_prepare_cfg(const struct dpni_cfg *cfg,
13 uint8_t *cfg_buf)
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053014{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053015 uint64_t *params = (uint64_t *)cfg_buf;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053016
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053017 DPNI_PREP_CFG(params, cfg);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053018
19 return 0;
20}
21
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053022int dpni_extract_cfg(struct dpni_cfg *cfg,
23 const uint8_t *cfg_buf)
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053024{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053025 uint64_t *params = (uint64_t *)cfg_buf;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053026
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053027 DPNI_EXT_CFG(params, cfg);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +053028
29 return 0;
30}
31
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053032int dpni_open(struct fsl_mc_io *mc_io,
33 uint32_t cmd_flags,
34 int dpni_id,
35 uint16_t *token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070036{
37 struct mc_command cmd = { 0 };
38 int err;
39
40 /* prepare command */
41 cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053042 cmd_flags,
43 0);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070044 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 Kushwaha87457d12015-07-07 15:40:06 +053057int dpni_close(struct fsl_mc_io *mc_io,
58 uint32_t cmd_flags,
59 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070060{
61 struct mc_command cmd = { 0 };
62
63 /* prepare command */
64 cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +053065 cmd_flags,
66 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -070067
68 /* send command to mc*/
69 return mc_send_command(mc_io, &cmd);
70}
71
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053072int dpni_create(struct fsl_mc_io *mc_io,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053073 uint16_t dprc_token,
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053074 uint32_t cmd_flags,
75 const struct dpni_cfg *cfg,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053076 uint32_t *obj_id)
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053077{
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 Gaur2557c5a2017-11-15 11:59:31 +053084 dprc_token);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053085 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 Gaur2557c5a2017-11-15 11:59:31 +053093 MC_CMD_READ_OBJ_ID(cmd, *obj_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +053094
95 return 0;
96}
97
98int dpni_destroy(struct fsl_mc_io *mc_io,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +053099 uint16_t dprc_token,
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530100 uint32_t cmd_flags,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530101 uint32_t obj_id)
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530102{
103 struct mc_command cmd = { 0 };
104
105 /* prepare command */
106 cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY,
107 cmd_flags,
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530108 dprc_token);
109
110 /* set object id to destroy */
111 CMD_DESTROY_SET_OBJ_ID_PARAM0(cmd, obj_id);
Prabhakar Kushwaha1ebbe4f2015-11-04 12:25:53 +0530112
113 /* send command to mc*/
114 return mc_send_command(mc_io, &cmd);
115}
116
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700117int dpni_set_pools(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530118 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700119 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 Kushwaha87457d12015-07-07 15:40:06 +0530126 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700127 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 Kushwaha87457d12015-07-07 15:40:06 +0530134int dpni_enable(struct fsl_mc_io *mc_io,
135 uint32_t cmd_flags,
136 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700137{
138 struct mc_command cmd = { 0 };
139
140 /* prepare command */
141 cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530142 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700143 token);
144
145 /* send command to mc*/
146 return mc_send_command(mc_io, &cmd);
147}
148
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530149int 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
164int dpni_reset(struct fsl_mc_io *mc_io,
165 uint32_t cmd_flags,
166 uint16_t token)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700167{
168 struct mc_command cmd = { 0 };
169
170 /* prepare command */
171 cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530172 cmd_flags,
173 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700174
175 /* send command to mc*/
176 return mc_send_command(mc_io, &cmd);
177}
178
179int dpni_get_attributes(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530180 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700181 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 Kushwaha87457d12015-07-07 15:40:06 +0530189 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700190 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700191 /* 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 Kushwaha53e353f2015-12-24 15:32:49 +0530202int 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 Gaur2557c5a2017-11-15 11:59:31 +0530219int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700224{
225 struct mc_command cmd = { 0 };
226
227 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530228 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_BUFFER_LAYOUT,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530229 cmd_flags,
230 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530231 DPNI_CMD_SET_BUFFER_LAYOUT(cmd, layout, type);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700232
233 /* send command to mc*/
234 return mc_send_command(mc_io, &cmd);
235}
236
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530237int dpni_get_qdid(struct fsl_mc_io *mc_io,
238 uint32_t cmd_flags,
239 uint16_t token,
240 uint16_t *qdid)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700241{
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 Kushwaha87457d12015-07-07 15:40:06 +0530247 cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700248 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
261int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530262 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700263 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 Kushwaha87457d12015-07-07 15:40:06 +0530271 cmd_flags,
272 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700273
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 Kushwahaa2a55e52015-03-19 09:20:45 -0700285int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530286 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700287 uint16_t token,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530288 const struct dpni_link_cfg *cfg)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700289{
290 struct mc_command cmd = { 0 };
291
292 /* prepare command */
293 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530294 cmd_flags,
295 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700296 DPNI_CMD_SET_LINK_CFG(cmd, cfg);
297
298 /* send command to mc*/
299 return mc_send_command(mc_io, &cmd);
300}
301
302int dpni_get_link_state(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530303 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700304 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 Kushwaha87457d12015-07-07 15:40:06 +0530312 cmd_flags,
313 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700314
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
327int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530328 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700329 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 Kushwaha87457d12015-07-07 15:40:06 +0530336 cmd_flags,
337 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700338 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
344int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530345 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700346 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 Kushwaha87457d12015-07-07 15:40:06 +0530354 cmd_flags,
355 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700356
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
368int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530369 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700370 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 Kushwaha87457d12015-07-07 15:40:06 +0530377 cmd_flags,
378 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700379 DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
380
381 /* send command to mc*/
382 return mc_send_command(mc_io, &cmd);
383}
384
385int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530386 uint32_t cmd_flags,
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700387 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 Kushwaha87457d12015-07-07 15:40:06 +0530394 cmd_flags,
395 token);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700396 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 Gaur2557c5a2017-11-15 11:59:31 +0530402int dpni_get_api_version(struct fsl_mc_io *mc_io,
403 u32 cmd_flags,
404 u16 *major_ver,
405 u16 *minor_ver)
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700406{
407 struct mc_command cmd = { 0 };
408 int err;
409
410 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530411 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_API_VERSION,
412 cmd_flags, 0);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700413
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530414 /* send command to mc */
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700415 err = mc_send_command(mc_io, &cmd);
416 if (err)
417 return err;
418
419 /* retrieve response parameters */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530420 mc_cmd_read_api_version(&cmd, major_ver, minor_ver);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700421
422 return 0;
423}
424
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530425int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700432{
433 struct mc_command cmd = { 0 };
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700434 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530435 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QUEUE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530436 cmd_flags,
437 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530438 DPNI_CMD_SET_QUEUE(cmd, type, tc, index, queue);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700439
440 /* send command to mc*/
441 return mc_send_command(mc_io, &cmd);
442}
443
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530444int 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 Kushwahaa2a55e52015-03-19 09:20:45 -0700451{
452 struct mc_command cmd = { 0 };
453 int err;
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530454
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700455 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530456 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QUEUE,
Prabhakar Kushwaha87457d12015-07-07 15:40:06 +0530457 cmd_flags,
458 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530459 DPNI_CMD_GET_QUEUE(cmd, type, tc, index);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700460
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 Gaur2557c5a2017-11-15 11:59:31 +0530467 DPNI_RSP_GET_QUEUE(cmd, queue);
Prabhakar Kushwahaa2a55e52015-03-19 09:20:45 -0700468 return 0;
469}
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530470
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530471int 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 Kushwaha53e353f2015-12-24 15:32:49 +0530475{
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530476 struct dpni_tx_confirmation_mode *cmd_params;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530477 struct mc_command cmd = { 0 };
478
479 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530480 cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONFIRMATION_MODE,
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530481 cmd_flags,
482 token);
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530483
484 cmd_params = (struct dpni_tx_confirmation_mode *)cmd.params;
485 cmd_params->confirmation_mode = mode;
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530486
487 /* send command to mc*/
488 return mc_send_command(mc_io, &cmd);
489}
490
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530491int 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 Kushwaha53e353f2015-12-24 15:32:49 +0530496{
497 struct mc_command cmd = { 0 };
498 int err;
499
500 /* prepare command */
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530501 cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_STATISTICS,
502 cmd_flags, token);
503 DPNI_CMD_GET_STATISTICS(cmd, page);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530504
505 /* send command to mc*/
506 err = mc_send_command(mc_io, &cmd);
507 if (err)
508 return err;
509
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530510 /* retrieve response parameters */
511 DPNI_RSP_GET_STATISTICS(cmd, stat);
Prabhakar Kushwaha53e353f2015-12-24 15:32:49 +0530512
513 return 0;
514}
Yogesh Gaur2557c5a2017-11-15 11:59:31 +0530515
516int 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