mediatek: Add support for Xiaomi Redmi Router AX6S
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0156-staging-fsl-dpaa2-mac-Add-APIs-for-DPMAC-objects.patch
1 From 344af44442388ea7f34cb4c4d88fa1162f8d4ddf Mon Sep 17 00:00:00 2001
2 From: Bogdan Purcareata <bogdan.purcareata@nxp.com>
3 Date: Wed, 12 Apr 2017 12:38:57 +0000
4 Subject: [PATCH] staging: fsl-dpaa2/mac: Add APIs for DPMAC objects
5
6 Add the command build/parse APIs for operating on DPMAC
7 objects through the DPAA2 Management Complex.
8
9 Signed-off-by: Bogdan Hamciuc <bogdan.hamciuc@nxp.com>
10 Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
11 ---
12 drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h | 172 +++++++++
13 drivers/staging/fsl-dpaa2/mac/dpmac.c | 620 ++++++++++++++++++++++++++++++
14 drivers/staging/fsl-dpaa2/mac/dpmac.h | 342 ++++++++++++++++
15 3 files changed, 1134 insertions(+)
16 create mode 100644 drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h
17 create mode 100644 drivers/staging/fsl-dpaa2/mac/dpmac.c
18 create mode 100644 drivers/staging/fsl-dpaa2/mac/dpmac.h
19
20 --- /dev/null
21 +++ b/drivers/staging/fsl-dpaa2/mac/dpmac-cmd.h
22 @@ -0,0 +1,172 @@
23 +/* Copyright 2013-2016 Freescale Semiconductor Inc.
24 + *
25 + * Redistribution and use in source and binary forms, with or without
26 + * modification, are permitted provided that the following conditions are met:
27 + * * Redistributions of source code must retain the above copyright
28 + * notice, this list of conditions and the following disclaimer.
29 + * * Redistributions in binary form must reproduce the above copyright
30 + * notice, this list of conditions and the following disclaimer in the
31 + * documentation and/or other materials provided with the distribution.
32 + * * Neither the name of the above-listed copyright holders nor the
33 + * names of any contributors may be used to endorse or promote products
34 + * derived from this software without specific prior written permission.
35 + *
36 + *
37 + * ALTERNATIVELY, this software may be distributed under the terms of the
38 + * GNU General Public License ("GPL") as published by the Free Software
39 + * Foundation, either version 2 of that License or (at your option) any
40 + * later version.
41 + *
42 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
43 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
46 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
47 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
48 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
49 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
50 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
51 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
52 + * POSSIBILITY OF SUCH DAMAGE.
53 + */
54 +#ifndef _FSL_DPMAC_CMD_H
55 +#define _FSL_DPMAC_CMD_H
56 +
57 +/* DPMAC Version */
58 +#define DPMAC_VER_MAJOR 4
59 +#define DPMAC_VER_MINOR 2
60 +#define DPMAC_CMD_BASE_VERSION 1
61 +#define DPMAC_CMD_ID_OFFSET 4
62 +
63 +#define DPMAC_CMD(id) (((id) << DPMAC_CMD_ID_OFFSET) | DPMAC_CMD_BASE_VERSION)
64 +
65 +/* Command IDs */
66 +#define DPMAC_CMDID_CLOSE DPMAC_CMD(0x800)
67 +#define DPMAC_CMDID_OPEN DPMAC_CMD(0x80c)
68 +#define DPMAC_CMDID_CREATE DPMAC_CMD(0x90c)
69 +#define DPMAC_CMDID_DESTROY DPMAC_CMD(0x98c)
70 +#define DPMAC_CMDID_GET_API_VERSION DPMAC_CMD(0xa0c)
71 +
72 +#define DPMAC_CMDID_GET_ATTR DPMAC_CMD(0x004)
73 +#define DPMAC_CMDID_RESET DPMAC_CMD(0x005)
74 +
75 +#define DPMAC_CMDID_SET_IRQ_ENABLE DPMAC_CMD(0x012)
76 +#define DPMAC_CMDID_GET_IRQ_ENABLE DPMAC_CMD(0x013)
77 +#define DPMAC_CMDID_SET_IRQ_MASK DPMAC_CMD(0x014)
78 +#define DPMAC_CMDID_GET_IRQ_MASK DPMAC_CMD(0x015)
79 +#define DPMAC_CMDID_GET_IRQ_STATUS DPMAC_CMD(0x016)
80 +#define DPMAC_CMDID_CLEAR_IRQ_STATUS DPMAC_CMD(0x017)
81 +
82 +#define DPMAC_CMDID_GET_LINK_CFG DPMAC_CMD(0x0c2)
83 +#define DPMAC_CMDID_SET_LINK_STATE DPMAC_CMD(0x0c3)
84 +#define DPMAC_CMDID_GET_COUNTER DPMAC_CMD(0x0c4)
85 +
86 +#define DPMAC_CMDID_SET_PORT_MAC_ADDR DPMAC_CMD(0x0c5)
87 +
88 +/* Macros for accessing command fields smaller than 1byte */
89 +#define DPMAC_MASK(field) \
90 + GENMASK(DPMAC_##field##_SHIFT + DPMAC_##field##_SIZE - 1, \
91 + DPMAC_##field##_SHIFT)
92 +#define dpmac_set_field(var, field, val) \
93 + ((var) |= (((val) << DPMAC_##field##_SHIFT) & DPMAC_MASK(field)))
94 +#define dpmac_get_field(var, field) \
95 + (((var) & DPMAC_MASK(field)) >> DPMAC_##field##_SHIFT)
96 +
97 +struct dpmac_cmd_open {
98 + u32 dpmac_id;
99 +};
100 +
101 +struct dpmac_cmd_create {
102 + u32 mac_id;
103 +};
104 +
105 +struct dpmac_cmd_destroy {
106 + u32 dpmac_id;
107 +};
108 +
109 +struct dpmac_cmd_set_irq_enable {
110 + u8 enable;
111 + u8 pad[3];
112 + u8 irq_index;
113 +};
114 +
115 +struct dpmac_cmd_get_irq_enable {
116 + u32 pad;
117 + u8 irq_index;
118 +};
119 +
120 +struct dpmac_rsp_get_irq_enable {
121 + u8 enabled;
122 +};
123 +
124 +struct dpmac_cmd_set_irq_mask {
125 + u32 mask;
126 + u8 irq_index;
127 +};
128 +
129 +struct dpmac_cmd_get_irq_mask {
130 + u32 pad;
131 + u8 irq_index;
132 +};
133 +
134 +struct dpmac_rsp_get_irq_mask {
135 + u32 mask;
136 +};
137 +
138 +struct dpmac_cmd_get_irq_status {
139 + u32 status;
140 + u8 irq_index;
141 +};
142 +
143 +struct dpmac_rsp_get_irq_status {
144 + u32 status;
145 +};
146 +
147 +struct dpmac_cmd_clear_irq_status {
148 + u32 status;
149 + u8 irq_index;
150 +};
151 +
152 +struct dpmac_rsp_get_attributes {
153 + u8 eth_if;
154 + u8 link_type;
155 + u16 id;
156 + u32 max_rate;
157 +};
158 +
159 +struct dpmac_rsp_get_link_cfg {
160 + u64 options;
161 + u32 rate;
162 +};
163 +
164 +#define DPMAC_STATE_SIZE 1
165 +#define DPMAC_STATE_SHIFT 0
166 +
167 +struct dpmac_cmd_set_link_state {
168 + u64 options;
169 + u32 rate;
170 + u32 pad;
171 + /* only least significant bit is valid */
172 + u8 up;
173 +};
174 +
175 +struct dpmac_cmd_get_counter {
176 + u8 type;
177 +};
178 +
179 +struct dpmac_rsp_get_counter {
180 + u64 pad;
181 + u64 counter;
182 +};
183 +
184 +struct dpmac_rsp_get_api_version {
185 + u16 major;
186 + u16 minor;
187 +};
188 +
189 +struct dpmac_cmd_set_port_mac_addr {
190 + u8 pad[2];
191 + u8 addr[6];
192 +};
193 +
194 +#endif /* _FSL_DPMAC_CMD_H */
195 --- /dev/null
196 +++ b/drivers/staging/fsl-dpaa2/mac/dpmac.c
197 @@ -0,0 +1,620 @@
198 +/* Copyright 2013-2016 Freescale Semiconductor Inc.
199 + *
200 + * Redistribution and use in source and binary forms, with or without
201 + * modification, are permitted provided that the following conditions are met:
202 + * * Redistributions of source code must retain the above copyright
203 + * notice, this list of conditions and the following disclaimer.
204 + * * Redistributions in binary form must reproduce the above copyright
205 + * notice, this list of conditions and the following disclaimer in the
206 + * documentation and/or other materials provided with the distribution.
207 + * * Neither the name of the above-listed copyright holders nor the
208 + * names of any contributors may be used to endorse or promote products
209 + * derived from this software without specific prior written permission.
210 + *
211 + *
212 + * ALTERNATIVELY, this software may be distributed under the terms of the
213 + * GNU General Public License ("GPL") as published by the Free Software
214 + * Foundation, either version 2 of that License or (at your option) any
215 + * later version.
216 + *
217 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
218 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
219 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
220 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
221 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
222 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
223 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
224 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
225 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
226 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
227 + * POSSIBILITY OF SUCH DAMAGE.
228 + */
229 +#include "../../fsl-mc/include/mc-sys.h"
230 +#include "../../fsl-mc/include/mc-cmd.h"
231 +#include "dpmac.h"
232 +#include "dpmac-cmd.h"
233 +
234 +/**
235 + * dpmac_open() - Open a control session for the specified object.
236 + * @mc_io: Pointer to MC portal's I/O object
237 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
238 + * @dpmac_id: DPMAC unique ID
239 + * @token: Returned token; use in subsequent API calls
240 + *
241 + * This function can be used to open a control session for an
242 + * already created object; an object may have been declared in
243 + * the DPL or by calling the dpmac_create function.
244 + * This function returns a unique authentication token,
245 + * associated with the specific object ID and the specific MC
246 + * portal; this token must be used in all subsequent commands for
247 + * this specific object
248 + *
249 + * Return: '0' on Success; Error code otherwise.
250 + */
251 +int dpmac_open(struct fsl_mc_io *mc_io,
252 + u32 cmd_flags,
253 + int dpmac_id,
254 + u16 *token)
255 +{
256 + struct dpmac_cmd_open *cmd_params;
257 + struct mc_command cmd = { 0 };
258 + int err;
259 +
260 + /* prepare command */
261 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_OPEN,
262 + cmd_flags,
263 + 0);
264 + cmd_params = (struct dpmac_cmd_open *)cmd.params;
265 + cmd_params->dpmac_id = cpu_to_le32(dpmac_id);
266 +
267 + /* send command to mc*/
268 + err = mc_send_command(mc_io, &cmd);
269 + if (err)
270 + return err;
271 +
272 + /* retrieve response parameters */
273 + *token = mc_cmd_hdr_read_token(&cmd);
274 +
275 + return err;
276 +}
277 +
278 +/**
279 + * dpmac_close() - Close the control session of the object
280 + * @mc_io: Pointer to MC portal's I/O object
281 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
282 + * @token: Token of DPMAC object
283 + *
284 + * After this function is called, no further operations are
285 + * allowed on the object without opening a new control session.
286 + *
287 + * Return: '0' on Success; Error code otherwise.
288 + */
289 +int dpmac_close(struct fsl_mc_io *mc_io,
290 + u32 cmd_flags,
291 + u16 token)
292 +{
293 + struct mc_command cmd = { 0 };
294 +
295 + /* prepare command */
296 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLOSE, cmd_flags,
297 + token);
298 +
299 + /* send command to mc*/
300 + return mc_send_command(mc_io, &cmd);
301 +}
302 +
303 +/**
304 + * dpmac_create() - Create the DPMAC object.
305 + * @mc_io: Pointer to MC portal's I/O object
306 + * @dprc_token: Parent container token; '0' for default container
307 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
308 + * @cfg: Configuration structure
309 + * @obj_id: Returned object id
310 + *
311 + * Create the DPMAC object, allocate required resources and
312 + * perform required initialization.
313 + *
314 + * The function accepts an authentication token of a parent
315 + * container that this object should be assigned to. The token
316 + * can be '0' so the object will be assigned to the default container.
317 + * The newly created object can be opened with the returned
318 + * object id and using the container's associated tokens and MC portals.
319 + *
320 + * Return: '0' on Success; Error code otherwise.
321 + */
322 +int dpmac_create(struct fsl_mc_io *mc_io,
323 + u16 dprc_token,
324 + u32 cmd_flags,
325 + const struct dpmac_cfg *cfg,
326 + u32 *obj_id)
327 +{
328 + struct dpmac_cmd_create *cmd_params;
329 + struct mc_command cmd = { 0 };
330 + int err;
331 +
332 + /* prepare command */
333 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CREATE,
334 + cmd_flags,
335 + dprc_token);
336 + cmd_params = (struct dpmac_cmd_create *)cmd.params;
337 + cmd_params->mac_id = cpu_to_le32(cfg->mac_id);
338 +
339 + /* send command to mc*/
340 + err = mc_send_command(mc_io, &cmd);
341 + if (err)
342 + return err;
343 +
344 + /* retrieve response parameters */
345 + *obj_id = mc_cmd_read_object_id(&cmd);
346 +
347 + return 0;
348 +}
349 +
350 +/**
351 + * dpmac_destroy() - Destroy the DPMAC object and release all its resources.
352 + * @mc_io: Pointer to MC portal's I/O object
353 + * @dprc_token: Parent container token; '0' for default container
354 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
355 + * @object_id: The object id; it must be a valid id within the container that
356 + * created this object;
357 + *
358 + * The function accepts the authentication token of the parent container that
359 + * created the object (not the one that currently owns the object). The object
360 + * is searched within parent using the provided 'object_id'.
361 + * All tokens to the object must be closed before calling destroy.
362 + *
363 + * Return: '0' on Success; error code otherwise.
364 + */
365 +int dpmac_destroy(struct fsl_mc_io *mc_io,
366 + u16 dprc_token,
367 + u32 cmd_flags,
368 + u32 object_id)
369 +{
370 + struct dpmac_cmd_destroy *cmd_params;
371 + struct mc_command cmd = { 0 };
372 +
373 + /* prepare command */
374 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_DESTROY,
375 + cmd_flags,
376 + dprc_token);
377 + cmd_params = (struct dpmac_cmd_destroy *)cmd.params;
378 + cmd_params->dpmac_id = cpu_to_le32(object_id);
379 +
380 + /* send command to mc*/
381 + return mc_send_command(mc_io, &cmd);
382 +}
383 +
384 +/**
385 + * dpmac_set_irq_enable() - Set overall interrupt state.
386 + * @mc_io: Pointer to MC portal's I/O object
387 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
388 + * @token: Token of DPMAC object
389 + * @irq_index: The interrupt index to configure
390 + * @en: Interrupt state - enable = 1, disable = 0
391 + *
392 + * Allows GPP software to control when interrupts are generated.
393 + * Each interrupt can have up to 32 causes. The enable/disable control's the
394 + * overall interrupt state. if the interrupt is disabled no causes will cause
395 + * an interrupt.
396 + *
397 + * Return: '0' on Success; Error code otherwise.
398 + */
399 +int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
400 + u32 cmd_flags,
401 + u16 token,
402 + u8 irq_index,
403 + u8 en)
404 +{
405 + struct dpmac_cmd_set_irq_enable *cmd_params;
406 + struct mc_command cmd = { 0 };
407 +
408 + /* prepare command */
409 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_IRQ_ENABLE,
410 + cmd_flags,
411 + token);
412 + cmd_params = (struct dpmac_cmd_set_irq_enable *)cmd.params;
413 + cmd_params->irq_index = irq_index;
414 + cmd_params->enable = en;
415 +
416 + /* send command to mc*/
417 + return mc_send_command(mc_io, &cmd);
418 +}
419 +
420 +/**
421 + * dpmac_get_irq_enable() - Get overall interrupt state
422 + * @mc_io: Pointer to MC portal's I/O object
423 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
424 + * @token: Token of DPMAC object
425 + * @irq_index: The interrupt index to configure
426 + * @en: Returned interrupt state - enable = 1, disable = 0
427 + *
428 + * Return: '0' on Success; Error code otherwise.
429 + */
430 +int dpmac_get_irq_enable(struct fsl_mc_io *mc_io,
431 + u32 cmd_flags,
432 + u16 token,
433 + u8 irq_index,
434 + u8 *en)
435 +{
436 + struct dpmac_cmd_get_irq_enable *cmd_params;
437 + struct dpmac_rsp_get_irq_enable *rsp_params;
438 + struct mc_command cmd = { 0 };
439 + int err;
440 +
441 + /* prepare command */
442 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_ENABLE,
443 + cmd_flags,
444 + token);
445 + cmd_params = (struct dpmac_cmd_get_irq_enable *)cmd.params;
446 + cmd_params->irq_index = irq_index;
447 +
448 + /* send command to mc*/
449 + err = mc_send_command(mc_io, &cmd);
450 + if (err)
451 + return err;
452 +
453 + /* retrieve response parameters */
454 + rsp_params = (struct dpmac_rsp_get_irq_enable *)cmd.params;
455 + *en = rsp_params->enabled;
456 +
457 + return 0;
458 +}
459 +
460 +/**
461 + * dpmac_set_irq_mask() - Set interrupt mask.
462 + * @mc_io: Pointer to MC portal's I/O object
463 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
464 + * @token: Token of DPMAC object
465 + * @irq_index: The interrupt index to configure
466 + * @mask: Event mask to trigger interrupt;
467 + * each bit:
468 + * 0 = ignore event
469 + * 1 = consider event for asserting IRQ
470 + *
471 + * Every interrupt can have up to 32 causes and the interrupt model supports
472 + * masking/unmasking each cause independently
473 + *
474 + * Return: '0' on Success; Error code otherwise.
475 + */
476 +int dpmac_set_irq_mask(struct fsl_mc_io *mc_io,
477 + u32 cmd_flags,
478 + u16 token,
479 + u8 irq_index,
480 + u32 mask)
481 +{
482 + struct dpmac_cmd_set_irq_mask *cmd_params;
483 + struct mc_command cmd = { 0 };
484 +
485 + /* prepare command */
486 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_IRQ_MASK,
487 + cmd_flags,
488 + token);
489 + cmd_params = (struct dpmac_cmd_set_irq_mask *)cmd.params;
490 + cmd_params->mask = cpu_to_le32(mask);
491 + cmd_params->irq_index = irq_index;
492 +
493 + /* send command to mc*/
494 + return mc_send_command(mc_io, &cmd);
495 +}
496 +
497 +/**
498 + * dpmac_get_irq_mask() - Get interrupt mask.
499 + * @mc_io: Pointer to MC portal's I/O object
500 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
501 + * @token: Token of DPMAC object
502 + * @irq_index: The interrupt index to configure
503 + * @mask: Returned event mask to trigger interrupt
504 + *
505 + * Every interrupt can have up to 32 causes and the interrupt model supports
506 + * masking/unmasking each cause independently
507 + *
508 + * Return: '0' on Success; Error code otherwise.
509 + */
510 +int dpmac_get_irq_mask(struct fsl_mc_io *mc_io,
511 + u32 cmd_flags,
512 + u16 token,
513 + u8 irq_index,
514 + u32 *mask)
515 +{
516 + struct dpmac_cmd_get_irq_mask *cmd_params;
517 + struct dpmac_rsp_get_irq_mask *rsp_params;
518 + struct mc_command cmd = { 0 };
519 + int err;
520 +
521 + /* prepare command */
522 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_MASK,
523 + cmd_flags,
524 + token);
525 + cmd_params = (struct dpmac_cmd_get_irq_mask *)cmd.params;
526 + cmd_params->irq_index = irq_index;
527 +
528 + /* send command to mc*/
529 + err = mc_send_command(mc_io, &cmd);
530 + if (err)
531 + return err;
532 +
533 + /* retrieve response parameters */
534 + rsp_params = (struct dpmac_rsp_get_irq_mask *)cmd.params;
535 + *mask = le32_to_cpu(rsp_params->mask);
536 +
537 + return 0;
538 +}
539 +
540 +/**
541 + * dpmac_get_irq_status() - Get the current status of any pending interrupts.
542 + *
543 + * @mc_io: Pointer to MC portal's I/O object
544 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
545 + * @token: Token of DPMAC object
546 + * @irq_index: The interrupt index to configure
547 + * @status: Returned interrupts status - one bit per cause:
548 + * 0 = no interrupt pending
549 + * 1 = interrupt pending
550 + *
551 + * Return: '0' on Success; Error code otherwise.
552 + */
553 +int dpmac_get_irq_status(struct fsl_mc_io *mc_io,
554 + u32 cmd_flags,
555 + u16 token,
556 + u8 irq_index,
557 + u32 *status)
558 +{
559 + struct dpmac_cmd_get_irq_status *cmd_params;
560 + struct dpmac_rsp_get_irq_status *rsp_params;
561 + struct mc_command cmd = { 0 };
562 + int err;
563 +
564 + /* prepare command */
565 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_STATUS,
566 + cmd_flags,
567 + token);
568 + cmd_params = (struct dpmac_cmd_get_irq_status *)cmd.params;
569 + cmd_params->status = cpu_to_le32(*status);
570 + cmd_params->irq_index = irq_index;
571 +
572 + /* send command to mc*/
573 + err = mc_send_command(mc_io, &cmd);
574 + if (err)
575 + return err;
576 +
577 + /* retrieve response parameters */
578 + rsp_params = (struct dpmac_rsp_get_irq_status *)cmd.params;
579 + *status = le32_to_cpu(rsp_params->status);
580 +
581 + return 0;
582 +}
583 +
584 +/**
585 + * dpmac_clear_irq_status() - Clear a pending interrupt's status
586 + *
587 + * @mc_io: Pointer to MC portal's I/O object
588 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
589 + * @token: Token of DPMAC object
590 + * @irq_index: The interrupt index to configure
591 + * @status: Bits to clear (W1C) - one bit per cause:
592 + * 0 = don't change
593 + * 1 = clear status bit
594 + *
595 + * Return: '0' on Success; Error code otherwise.
596 + */
597 +int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
598 + u32 cmd_flags,
599 + u16 token,
600 + u8 irq_index,
601 + u32 status)
602 +{
603 + struct dpmac_cmd_clear_irq_status *cmd_params;
604 + struct mc_command cmd = { 0 };
605 +
606 + /* prepare command */
607 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLEAR_IRQ_STATUS,
608 + cmd_flags,
609 + token);
610 + cmd_params = (struct dpmac_cmd_clear_irq_status *)cmd.params;
611 + cmd_params->status = cpu_to_le32(status);
612 + cmd_params->irq_index = irq_index;
613 +
614 + /* send command to mc*/
615 + return mc_send_command(mc_io, &cmd);
616 +}
617 +
618 +/**
619 + * dpmac_get_attributes - Retrieve DPMAC attributes.
620 + *
621 + * @mc_io: Pointer to MC portal's I/O object
622 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
623 + * @token: Token of DPMAC object
624 + * @attr: Returned object's attributes
625 + *
626 + * Return: '0' on Success; Error code otherwise.
627 + */
628 +int dpmac_get_attributes(struct fsl_mc_io *mc_io,
629 + u32 cmd_flags,
630 + u16 token,
631 + struct dpmac_attr *attr)
632 +{
633 + struct dpmac_rsp_get_attributes *rsp_params;
634 + struct mc_command cmd = { 0 };
635 + int err;
636 +
637 + /* prepare command */
638 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_ATTR,
639 + cmd_flags,
640 + token);
641 +
642 + /* send command to mc*/
643 + err = mc_send_command(mc_io, &cmd);
644 + if (err)
645 + return err;
646 +
647 + /* retrieve response parameters */
648 + rsp_params = (struct dpmac_rsp_get_attributes *)cmd.params;
649 + attr->eth_if = rsp_params->eth_if;
650 + attr->link_type = rsp_params->link_type;
651 + attr->id = le16_to_cpu(rsp_params->id);
652 + attr->max_rate = le32_to_cpu(rsp_params->max_rate);
653 +
654 + return 0;
655 +}
656 +
657 +/**
658 + * dpmac_get_link_cfg() - Get Ethernet link configuration
659 + * @mc_io: Pointer to opaque I/O object
660 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
661 + * @token: Token of DPMAC object
662 + * @cfg: Returned structure with the link configuration
663 + *
664 + * Return: '0' on Success; Error code otherwise.
665 + */
666 +int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
667 + u32 cmd_flags,
668 + u16 token,
669 + struct dpmac_link_cfg *cfg)
670 +{
671 + struct dpmac_rsp_get_link_cfg *rsp_params;
672 + struct mc_command cmd = { 0 };
673 + int err = 0;
674 +
675 + /* prepare command */
676 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_LINK_CFG,
677 + cmd_flags,
678 + token);
679 +
680 + /* send command to mc*/
681 + err = mc_send_command(mc_io, &cmd);
682 + if (err)
683 + return err;
684 +
685 + rsp_params = (struct dpmac_rsp_get_link_cfg *)cmd.params;
686 + cfg->options = le64_to_cpu(rsp_params->options);
687 + cfg->rate = le32_to_cpu(rsp_params->rate);
688 +
689 + return 0;
690 +}
691 +
692 +/**
693 + * dpmac_set_link_state() - Set the Ethernet link status
694 + * @mc_io: Pointer to opaque I/O object
695 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
696 + * @token: Token of DPMAC object
697 + * @link_state: Link state configuration
698 + *
699 + * Return: '0' on Success; Error code otherwise.
700 + */
701 +int dpmac_set_link_state(struct fsl_mc_io *mc_io,
702 + u32 cmd_flags,
703 + u16 token,
704 + struct dpmac_link_state *link_state)
705 +{
706 + struct dpmac_cmd_set_link_state *cmd_params;
707 + struct mc_command cmd = { 0 };
708 +
709 + /* prepare command */
710 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_LINK_STATE,
711 + cmd_flags,
712 + token);
713 + cmd_params = (struct dpmac_cmd_set_link_state *)cmd.params;
714 + cmd_params->options = cpu_to_le64(link_state->options);
715 + cmd_params->rate = cpu_to_le32(link_state->rate);
716 + cmd_params->up = dpmac_get_field(link_state->up, STATE);
717 +
718 + /* send command to mc*/
719 + return mc_send_command(mc_io, &cmd);
720 +}
721 +
722 +/**
723 + * dpmac_get_counter() - Read a specific DPMAC counter
724 + * @mc_io: Pointer to opaque I/O object
725 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
726 + * @token: Token of DPMAC object
727 + * @type: The requested counter
728 + * @counter: Returned counter value
729 + *
730 + * Return: The requested counter; '0' otherwise.
731 + */
732 +int dpmac_get_counter(struct fsl_mc_io *mc_io,
733 + u32 cmd_flags,
734 + u16 token,
735 + enum dpmac_counter type,
736 + u64 *counter)
737 +{
738 + struct dpmac_cmd_get_counter *dpmac_cmd;
739 + struct dpmac_rsp_get_counter *dpmac_rsp;
740 + struct mc_command cmd = { 0 };
741 + int err = 0;
742 +
743 + /* prepare command */
744 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_COUNTER,
745 + cmd_flags,
746 + token);
747 + dpmac_cmd = (struct dpmac_cmd_get_counter *)cmd.params;
748 + dpmac_cmd->type = type;
749 +
750 + /* send command to mc*/
751 + err = mc_send_command(mc_io, &cmd);
752 + if (err)
753 + return err;
754 +
755 + dpmac_rsp = (struct dpmac_rsp_get_counter *)cmd.params;
756 + *counter = le64_to_cpu(dpmac_rsp->counter);
757 +
758 + return 0;
759 +}
760 +
761 +/* untested */
762 +int dpmac_set_port_mac_addr(struct fsl_mc_io *mc_io,
763 + u32 cmd_flags,
764 + u16 token,
765 + const u8 addr[6])
766 +{
767 + struct dpmac_cmd_set_port_mac_addr *dpmac_cmd;
768 + struct mc_command cmd = { 0 };
769 +
770 + /* prepare command */
771 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_PORT_MAC_ADDR,
772 + cmd_flags,
773 + token);
774 + dpmac_cmd = (struct dpmac_cmd_set_port_mac_addr *)cmd.params;
775 + dpmac_cmd->addr[0] = addr[5];
776 + dpmac_cmd->addr[1] = addr[4];
777 + dpmac_cmd->addr[2] = addr[3];
778 + dpmac_cmd->addr[3] = addr[2];
779 + dpmac_cmd->addr[4] = addr[1];
780 + dpmac_cmd->addr[5] = addr[0];
781 +
782 + /* send command to mc*/
783 + return mc_send_command(mc_io, &cmd);
784 +}
785 +
786 +/**
787 + * dpmac_get_api_version() - Get Data Path MAC version
788 + * @mc_io: Pointer to MC portal's I/O object
789 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
790 + * @major_ver: Major version of data path mac API
791 + * @minor_ver: Minor version of data path mac API
792 + *
793 + * Return: '0' on Success; Error code otherwise.
794 + */
795 +int dpmac_get_api_version(struct fsl_mc_io *mc_io,
796 + u32 cmd_flags,
797 + u16 *major_ver,
798 + u16 *minor_ver)
799 +{
800 + struct dpmac_rsp_get_api_version *rsp_params;
801 + struct mc_command cmd = { 0 };
802 + int err;
803 +
804 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_API_VERSION,
805 + cmd_flags,
806 + 0);
807 +
808 + err = mc_send_command(mc_io, &cmd);
809 + if (err)
810 + return err;
811 +
812 + rsp_params = (struct dpmac_rsp_get_api_version *)cmd.params;
813 + *major_ver = le16_to_cpu(rsp_params->major);
814 + *minor_ver = le16_to_cpu(rsp_params->minor);
815 +
816 + return 0;
817 +}
818 --- /dev/null
819 +++ b/drivers/staging/fsl-dpaa2/mac/dpmac.h
820 @@ -0,0 +1,342 @@
821 +/* Copyright 2013-2016 Freescale Semiconductor Inc.
822 + *
823 + * Redistribution and use in source and binary forms, with or without
824 + * modification, are permitted provided that the following conditions are met:
825 + * * Redistributions of source code must retain the above copyright
826 + * notice, this list of conditions and the following disclaimer.
827 + * * Redistributions in binary form must reproduce the above copyright
828 + * notice, this list of conditions and the following disclaimer in the
829 + * documentation and/or other materials provided with the distribution.
830 + * * Neither the name of the above-listed copyright holders nor the
831 + * names of any contributors may be used to endorse or promote products
832 + * derived from this software without specific prior written permission.
833 + *
834 + *
835 + * ALTERNATIVELY, this software may be distributed under the terms of the
836 + * GNU General Public License ("GPL") as published by the Free Software
837 + * Foundation, either version 2 of that License or (at your option) any
838 + * later version.
839 + *
840 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
841 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
842 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
843 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
844 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
845 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
846 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
847 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
848 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
849 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
850 + * POSSIBILITY OF SUCH DAMAGE.
851 + */
852 +#ifndef __FSL_DPMAC_H
853 +#define __FSL_DPMAC_H
854 +
855 +/* Data Path MAC API
856 + * Contains initialization APIs and runtime control APIs for DPMAC
857 + */
858 +
859 +struct fsl_mc_io;
860 +
861 +int dpmac_open(struct fsl_mc_io *mc_io,
862 + u32 cmd_flags,
863 + int dpmac_id,
864 + u16 *token);
865 +
866 +int dpmac_close(struct fsl_mc_io *mc_io,
867 + u32 cmd_flags,
868 + u16 token);
869 +
870 +/**
871 + * enum dpmac_link_type - DPMAC link type
872 + * @DPMAC_LINK_TYPE_NONE: No link
873 + * @DPMAC_LINK_TYPE_FIXED: Link is fixed type
874 + * @DPMAC_LINK_TYPE_PHY: Link by PHY ID
875 + * @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
876 + */
877 +enum dpmac_link_type {
878 + DPMAC_LINK_TYPE_NONE,
879 + DPMAC_LINK_TYPE_FIXED,
880 + DPMAC_LINK_TYPE_PHY,
881 + DPMAC_LINK_TYPE_BACKPLANE
882 +};
883 +
884 +/**
885 + * enum dpmac_eth_if - DPMAC Ethrnet interface
886 + * @DPMAC_ETH_IF_MII: MII interface
887 + * @DPMAC_ETH_IF_RMII: RMII interface
888 + * @DPMAC_ETH_IF_SMII: SMII interface
889 + * @DPMAC_ETH_IF_GMII: GMII interface
890 + * @DPMAC_ETH_IF_RGMII: RGMII interface
891 + * @DPMAC_ETH_IF_SGMII: SGMII interface
892 + * @DPMAC_ETH_IF_QSGMII: QSGMII interface
893 + * @DPMAC_ETH_IF_XAUI: XAUI interface
894 + * @DPMAC_ETH_IF_XFI: XFI interface
895 + */
896 +enum dpmac_eth_if {
897 + DPMAC_ETH_IF_MII,
898 + DPMAC_ETH_IF_RMII,
899 + DPMAC_ETH_IF_SMII,
900 + DPMAC_ETH_IF_GMII,
901 + DPMAC_ETH_IF_RGMII,
902 + DPMAC_ETH_IF_SGMII,
903 + DPMAC_ETH_IF_QSGMII,
904 + DPMAC_ETH_IF_XAUI,
905 + DPMAC_ETH_IF_XFI
906 +};
907 +
908 +/**
909 + * struct dpmac_cfg - Structure representing DPMAC configuration
910 + * @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP,
911 + * the MAC IDs are continuous.
912 + * For example: 2 WRIOPs, 16 MACs in each:
913 + * MAC IDs for the 1st WRIOP: 1-16,
914 + * MAC IDs for the 2nd WRIOP: 17-32.
915 + */
916 +struct dpmac_cfg {
917 + u16 mac_id;
918 +};
919 +
920 +int dpmac_create(struct fsl_mc_io *mc_io,
921 + u16 dprc_token,
922 + u32 cmd_flags,
923 + const struct dpmac_cfg *cfg,
924 + u32 *obj_id);
925 +
926 +int dpmac_destroy(struct fsl_mc_io *mc_io,
927 + u16 dprc_token,
928 + u32 cmd_flags,
929 + u32 object_id);
930 +
931 +/**
932 + * DPMAC IRQ Index and Events
933 + */
934 +
935 +/**
936 + * IRQ index
937 + */
938 +#define DPMAC_IRQ_INDEX 0
939 +/**
940 + * IRQ event - indicates a change in link state
941 + */
942 +#define DPMAC_IRQ_EVENT_LINK_CFG_REQ 0x00000001
943 +/**
944 + * IRQ event - Indicates that the link state changed
945 + */
946 +#define DPMAC_IRQ_EVENT_LINK_CHANGED 0x00000002
947 +
948 +int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
949 + u32 cmd_flags,
950 + u16 token,
951 + u8 irq_index,
952 + u8 en);
953 +
954 +int dpmac_get_irq_enable(struct fsl_mc_io *mc_io,
955 + u32 cmd_flags,
956 + u16 token,
957 + u8 irq_index,
958 + u8 *en);
959 +
960 +int dpmac_set_irq_mask(struct fsl_mc_io *mc_io,
961 + u32 cmd_flags,
962 + u16 token,
963 + u8 irq_index,
964 + u32 mask);
965 +
966 +int dpmac_get_irq_mask(struct fsl_mc_io *mc_io,
967 + u32 cmd_flags,
968 + u16 token,
969 + u8 irq_index,
970 + u32 *mask);
971 +
972 +int dpmac_get_irq_status(struct fsl_mc_io *mc_io,
973 + u32 cmd_flags,
974 + u16 token,
975 + u8 irq_index,
976 + u32 *status);
977 +
978 +int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
979 + u32 cmd_flags,
980 + u16 token,
981 + u8 irq_index,
982 + u32 status);
983 +
984 +/**
985 + * struct dpmac_attr - Structure representing DPMAC attributes
986 + * @id: DPMAC object ID
987 + * @max_rate: Maximum supported rate - in Mbps
988 + * @eth_if: Ethernet interface
989 + * @link_type: link type
990 + */
991 +struct dpmac_attr {
992 + u16 id;
993 + u32 max_rate;
994 + enum dpmac_eth_if eth_if;
995 + enum dpmac_link_type link_type;
996 +};
997 +
998 +int dpmac_get_attributes(struct fsl_mc_io *mc_io,
999 + u32 cmd_flags,
1000 + u16 token,
1001 + struct dpmac_attr *attr);
1002 +
1003 +/**
1004 + * DPMAC link configuration/state options
1005 + */
1006 +
1007 +/**
1008 + * Enable auto-negotiation
1009 + */
1010 +#define DPMAC_LINK_OPT_AUTONEG 0x0000000000000001ULL
1011 +/**
1012 + * Enable half-duplex mode
1013 + */
1014 +#define DPMAC_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
1015 +/**
1016 + * Enable pause frames
1017 + */
1018 +#define DPMAC_LINK_OPT_PAUSE 0x0000000000000004ULL
1019 +/**
1020 + * Enable a-symmetric pause frames
1021 + */
1022 +#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
1023 +
1024 +/**
1025 + * struct dpmac_link_cfg - Structure representing DPMAC link configuration
1026 + * @rate: Link's rate - in Mbps
1027 + * @options: Enable/Disable DPMAC link cfg features (bitmap)
1028 + */
1029 +struct dpmac_link_cfg {
1030 + u32 rate;
1031 + u64 options;
1032 +};
1033 +
1034 +int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
1035 + u32 cmd_flags,
1036 + u16 token,
1037 + struct dpmac_link_cfg *cfg);
1038 +
1039 +/**
1040 + * struct dpmac_link_state - DPMAC link configuration request
1041 + * @rate: Rate in Mbps
1042 + * @options: Enable/Disable DPMAC link cfg features (bitmap)
1043 + * @up: Link state
1044 + */
1045 +struct dpmac_link_state {
1046 + u32 rate;
1047 + u64 options;
1048 + int up;
1049 +};
1050 +
1051 +int dpmac_set_link_state(struct fsl_mc_io *mc_io,
1052 + u32 cmd_flags,
1053 + u16 token,
1054 + struct dpmac_link_state *link_state);
1055 +
1056 +/**
1057 + * enum dpmac_counter - DPMAC counter types
1058 + * @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
1059 + * @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
1060 + * @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
1061 + * @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
1062 + * @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
1063 + * @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
1064 + * @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
1065 + * (up to max frame length specified),
1066 + * good or bad.
1067 + * @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
1068 + * with a wrong CRC
1069 + * @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
1070 + * specified, with a bad frame check sequence.
1071 + * @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
1072 + * Occurs when a receive FIFO overflows.
1073 + * Includes also frames truncated as a result of
1074 + * the receive FIFO overflow.
1075 + * @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
1076 + * (optional used for wrong SFD).
1077 + * @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
1078 + * bytes long with a good CRC.
1079 + * @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
1080 + * specified, with a good frame check sequence.
1081 + * @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
1082 + * @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
1083 + * (regular and PFC).
1084 + * @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
1085 + * frames and valid pause frames.
1086 + * @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
1087 + * @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
1088 + * @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
1089 + * @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
1090 + * @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
1091 + * (except for undersized/fragment frame).
1092 + * @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
1093 + * frames and valid pause frames transmitted.
1094 + * @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
1095 + * @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
1096 + * @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
1097 + * @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
1098 + * @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
1099 + * pause frames.
1100 + * @DPMAC_CNT_ENG_GOOD_FRAME: counts frames transmitted without error, including
1101 + * pause frames.
1102 + */
1103 +enum dpmac_counter {
1104 + DPMAC_CNT_ING_FRAME_64,
1105 + DPMAC_CNT_ING_FRAME_127,
1106 + DPMAC_CNT_ING_FRAME_255,
1107 + DPMAC_CNT_ING_FRAME_511,
1108 + DPMAC_CNT_ING_FRAME_1023,
1109 + DPMAC_CNT_ING_FRAME_1518,
1110 + DPMAC_CNT_ING_FRAME_1519_MAX,
1111 + DPMAC_CNT_ING_FRAG,
1112 + DPMAC_CNT_ING_JABBER,
1113 + DPMAC_CNT_ING_FRAME_DISCARD,
1114 + DPMAC_CNT_ING_ALIGN_ERR,
1115 + DPMAC_CNT_EGR_UNDERSIZED,
1116 + DPMAC_CNT_ING_OVERSIZED,
1117 + DPMAC_CNT_ING_VALID_PAUSE_FRAME,
1118 + DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
1119 + DPMAC_CNT_ING_BYTE,
1120 + DPMAC_CNT_ING_MCAST_FRAME,
1121 + DPMAC_CNT_ING_BCAST_FRAME,
1122 + DPMAC_CNT_ING_ALL_FRAME,
1123 + DPMAC_CNT_ING_UCAST_FRAME,
1124 + DPMAC_CNT_ING_ERR_FRAME,
1125 + DPMAC_CNT_EGR_BYTE,
1126 + DPMAC_CNT_EGR_MCAST_FRAME,
1127 + DPMAC_CNT_EGR_BCAST_FRAME,
1128 + DPMAC_CNT_EGR_UCAST_FRAME,
1129 + DPMAC_CNT_EGR_ERR_FRAME,
1130 + DPMAC_CNT_ING_GOOD_FRAME,
1131 + DPMAC_CNT_ENG_GOOD_FRAME
1132 +};
1133 +
1134 +int dpmac_get_counter(struct fsl_mc_io *mc_io,
1135 + u32 cmd_flags,
1136 + u16 token,
1137 + enum dpmac_counter type,
1138 + u64 *counter);
1139 +
1140 +/**
1141 + * dpmac_set_port_mac_addr() - Set a MAC address associated with the physical
1142 + * port. This is not used for filtering, MAC is always in
1143 + * promiscuous mode, it is passed to DPNIs through DPNI API for
1144 + * application used.
1145 + * @mc_io: Pointer to opaque I/O object
1146 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
1147 + * @token: Token of DPMAC object
1148 + * @addr: MAC address to set
1149 + *
1150 + * Return: The requested counter; '0' otherwise.
1151 + */
1152 +int dpmac_set_port_mac_addr(struct fsl_mc_io *mc_io,
1153 + u32 cmd_flags,
1154 + u16 token,
1155 + const u8 addr[6]);
1156 +
1157 +int dpmac_get_api_version(struct fsl_mc_io *mc_io,
1158 + u32 cmd_flags,
1159 + u16 *major_ver,
1160 + u16 *minor_ver);
1161 +
1162 +#endif /* __FSL_DPMAC_H */