1 From 5a2069b38e85771f3857af390e407360d66cd6ed Mon Sep 17 00:00:00 2001
2 From: Sachin Saxena <sachin.saxena@nxp.com>
3 Date: Fri, 5 Aug 2016 14:06:11 +0530
4 Subject: [PATCH 5/5] NXP DPAA2 Poll Mode Driver Support (dpdk-16.07)
6 Upstreaming of DPAA2 driver changes is in progress.This patch will
7 temporary add the support in VPP in-built DPDK.
10 1. Driver specfic independent files. No impact on any other functionality.
11 2. Changes in common EAL framework. These changes are done in compile time DPAA2
12 specific flag, so no impact is expected on other existing features if not
15 Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
17 config/defconfig_arm64-dpaa2-linuxapp-gcc | 18 +-
18 drivers/net/Makefile | 1 +
19 drivers/net/dpaa2/Makefile | 102 +
20 drivers/net/dpaa2/dpaa2_logs.h | 78 +
21 drivers/net/dpaa2/mc/dpaiop.c | 457 ++++
22 drivers/net/dpaa2/mc/dpbp.c | 432 ++++
23 drivers/net/dpaa2/mc/dpci.c | 501 ++++
24 drivers/net/dpaa2/mc/dpcon.c | 400 +++
25 drivers/net/dpaa2/mc/dpdbg.c | 547 +++++
26 drivers/net/dpaa2/mc/dpdcei.c | 449 ++++
27 drivers/net/dpaa2/mc/dpdmai.c | 452 ++++
28 drivers/net/dpaa2/mc/dpdmux.c | 567 +++++
29 drivers/net/dpaa2/mc/dpio.c | 468 ++++
30 drivers/net/dpaa2/mc/dpmac.c | 422 ++++
31 drivers/net/dpaa2/mc/dpmcp.c | 312 +++
32 drivers/net/dpaa2/mc/dpmng.c | 58 +
33 drivers/net/dpaa2/mc/dpni.c | 1907 +++++++++++++++
34 drivers/net/dpaa2/mc/dprc.c | 786 ++++++
35 drivers/net/dpaa2/mc/dprtc.c | 509 ++++
36 drivers/net/dpaa2/mc/dpseci.c | 502 ++++
37 drivers/net/dpaa2/mc/dpsw.c | 1639 +++++++++++++
38 drivers/net/dpaa2/mc/fsl_dpaiop.h | 494 ++++
39 drivers/net/dpaa2/mc/fsl_dpaiop_cmd.h | 190 ++
40 drivers/net/dpaa2/mc/fsl_dpbp.h | 438 ++++
41 drivers/net/dpaa2/mc/fsl_dpbp_cmd.h | 172 ++
42 drivers/net/dpaa2/mc/fsl_dpci.h | 594 +++++
43 drivers/net/dpaa2/mc/fsl_dpci_cmd.h | 200 ++
44 drivers/net/dpaa2/mc/fsl_dpcon.h | 407 +++
45 drivers/net/dpaa2/mc/fsl_dpcon_cmd.h | 162 ++
46 drivers/net/dpaa2/mc/fsl_dpdbg.h | 635 +++++
47 drivers/net/dpaa2/mc/fsl_dpdbg_cmd.h | 249 ++
48 drivers/net/dpaa2/mc/fsl_dpdcei.h | 515 ++++
49 drivers/net/dpaa2/mc/fsl_dpdcei_cmd.h | 182 ++
50 drivers/net/dpaa2/mc/fsl_dpdmai.h | 521 ++++
51 drivers/net/dpaa2/mc/fsl_dpdmai_cmd.h | 191 ++
52 drivers/net/dpaa2/mc/fsl_dpdmux.h | 724 ++++++
53 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h | 256 ++
54 drivers/net/dpaa2/mc/fsl_dpio.h | 460 ++++
55 drivers/net/dpaa2/mc/fsl_dpio_cmd.h | 184 ++
56 drivers/net/dpaa2/mc/fsl_dpkg.h | 174 ++
57 drivers/net/dpaa2/mc/fsl_dpmac.h | 593 +++++
58 drivers/net/dpaa2/mc/fsl_dpmac_cmd.h | 195 ++
59 drivers/net/dpaa2/mc/fsl_dpmcp.h | 332 +++
60 drivers/net/dpaa2/mc/fsl_dpmcp_cmd.h | 135 +
61 drivers/net/dpaa2/mc/fsl_dpmng.h | 74 +
62 drivers/net/dpaa2/mc/fsl_dpmng_cmd.h | 46 +
63 drivers/net/dpaa2/mc/fsl_dpni.h | 2581 ++++++++++++++++++++
64 drivers/net/dpaa2/mc/fsl_dpni_cmd.h | 1058 ++++++++
65 drivers/net/dpaa2/mc/fsl_dprc.h | 1032 ++++++++
66 drivers/net/dpaa2/mc/fsl_dprc_cmd.h | 755 ++++++
67 drivers/net/dpaa2/mc/fsl_dprtc.h | 434 ++++
68 drivers/net/dpaa2/mc/fsl_dprtc_cmd.h | 181 ++
69 drivers/net/dpaa2/mc/fsl_dpseci.h | 647 +++++
70 drivers/net/dpaa2/mc/fsl_dpseci_cmd.h | 241 ++
71 drivers/net/dpaa2/mc/fsl_dpsw.h | 2164 ++++++++++++++++
72 drivers/net/dpaa2/mc/fsl_dpsw_cmd.h | 916 +++++++
73 drivers/net/dpaa2/mc/fsl_mc_cmd.h | 221 ++
74 drivers/net/dpaa2/mc/fsl_mc_sys.h | 98 +
75 drivers/net/dpaa2/mc/fsl_net.h | 480 ++++
76 drivers/net/dpaa2/mc/mc_sys.c | 127 +
77 drivers/net/dpaa2/qbman/driver/qbman_debug.c | 929 +++++++
78 drivers/net/dpaa2/qbman/driver/qbman_debug.h | 140 ++
79 drivers/net/dpaa2/qbman/driver/qbman_portal.c | 1441 +++++++++++
80 drivers/net/dpaa2/qbman/driver/qbman_portal.h | 270 ++
81 drivers/net/dpaa2/qbman/driver/qbman_private.h | 168 ++
82 drivers/net/dpaa2/qbman/driver/qbman_sys.h | 373 +++
83 drivers/net/dpaa2/qbman/driver/qbman_sys_decl.h | 69 +
84 drivers/net/dpaa2/qbman/include/compat.h | 637 +++++
85 .../dpaa2/qbman/include/drivers/fsl_qbman_base.h | 151 ++
86 .../dpaa2/qbman/include/drivers/fsl_qbman_portal.h | 1087 +++++++++
87 drivers/net/dpaa2/rte_eth_dpaa2_pvt.h | 330 +++
88 drivers/net/dpaa2/rte_eth_dpbp.c | 377 +++
89 drivers/net/dpaa2/rte_eth_dpio.c | 336 +++
90 drivers/net/dpaa2/rte_eth_dpni.c | 2269 +++++++++++++++++
91 drivers/net/dpaa2/rte_eth_dpni_annot.h | 310 +++
92 lib/librte_eal/common/eal_private.h | 7 +
93 lib/librte_eal/linuxapp/eal/Makefile | 4 +
94 lib/librte_eal/linuxapp/eal/eal.c | 5 +
95 lib/librte_eal/linuxapp/eal/eal_soc.c | 67 +
96 lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.c | 650 +++++
97 lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.h | 98 +
98 lib/librte_mempool/rte_mempool.h | 8 +
100 83 files changed, 39391 insertions(+), 1 deletion(-)
101 create mode 100644 drivers/net/dpaa2/Makefile
102 create mode 100644 drivers/net/dpaa2/dpaa2_logs.h
103 create mode 100644 drivers/net/dpaa2/mc/dpaiop.c
104 create mode 100644 drivers/net/dpaa2/mc/dpbp.c
105 create mode 100644 drivers/net/dpaa2/mc/dpci.c
106 create mode 100644 drivers/net/dpaa2/mc/dpcon.c
107 create mode 100644 drivers/net/dpaa2/mc/dpdbg.c
108 create mode 100644 drivers/net/dpaa2/mc/dpdcei.c
109 create mode 100644 drivers/net/dpaa2/mc/dpdmai.c
110 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
111 create mode 100644 drivers/net/dpaa2/mc/dpio.c
112 create mode 100644 drivers/net/dpaa2/mc/dpmac.c
113 create mode 100644 drivers/net/dpaa2/mc/dpmcp.c
114 create mode 100644 drivers/net/dpaa2/mc/dpmng.c
115 create mode 100644 drivers/net/dpaa2/mc/dpni.c
116 create mode 100644 drivers/net/dpaa2/mc/dprc.c
117 create mode 100644 drivers/net/dpaa2/mc/dprtc.c
118 create mode 100644 drivers/net/dpaa2/mc/dpseci.c
119 create mode 100644 drivers/net/dpaa2/mc/dpsw.c
120 create mode 100644 drivers/net/dpaa2/mc/fsl_dpaiop.h
121 create mode 100644 drivers/net/dpaa2/mc/fsl_dpaiop_cmd.h
122 create mode 100644 drivers/net/dpaa2/mc/fsl_dpbp.h
123 create mode 100644 drivers/net/dpaa2/mc/fsl_dpbp_cmd.h
124 create mode 100644 drivers/net/dpaa2/mc/fsl_dpci.h
125 create mode 100644 drivers/net/dpaa2/mc/fsl_dpci_cmd.h
126 create mode 100644 drivers/net/dpaa2/mc/fsl_dpcon.h
127 create mode 100644 drivers/net/dpaa2/mc/fsl_dpcon_cmd.h
128 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdbg.h
129 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdbg_cmd.h
130 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdcei.h
131 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdcei_cmd.h
132 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmai.h
133 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmai_cmd.h
134 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
135 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
136 create mode 100644 drivers/net/dpaa2/mc/fsl_dpio.h
137 create mode 100644 drivers/net/dpaa2/mc/fsl_dpio_cmd.h
138 create mode 100644 drivers/net/dpaa2/mc/fsl_dpkg.h
139 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmac.h
140 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmac_cmd.h
141 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmcp.h
142 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmcp_cmd.h
143 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmng.h
144 create mode 100644 drivers/net/dpaa2/mc/fsl_dpmng_cmd.h
145 create mode 100644 drivers/net/dpaa2/mc/fsl_dpni.h
146 create mode 100644 drivers/net/dpaa2/mc/fsl_dpni_cmd.h
147 create mode 100644 drivers/net/dpaa2/mc/fsl_dprc.h
148 create mode 100644 drivers/net/dpaa2/mc/fsl_dprc_cmd.h
149 create mode 100644 drivers/net/dpaa2/mc/fsl_dprtc.h
150 create mode 100644 drivers/net/dpaa2/mc/fsl_dprtc_cmd.h
151 create mode 100644 drivers/net/dpaa2/mc/fsl_dpseci.h
152 create mode 100644 drivers/net/dpaa2/mc/fsl_dpseci_cmd.h
153 create mode 100644 drivers/net/dpaa2/mc/fsl_dpsw.h
154 create mode 100644 drivers/net/dpaa2/mc/fsl_dpsw_cmd.h
155 create mode 100644 drivers/net/dpaa2/mc/fsl_mc_cmd.h
156 create mode 100644 drivers/net/dpaa2/mc/fsl_mc_sys.h
157 create mode 100644 drivers/net/dpaa2/mc/fsl_net.h
158 create mode 100644 drivers/net/dpaa2/mc/mc_sys.c
159 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_debug.c
160 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_debug.h
161 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_portal.c
162 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_portal.h
163 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_private.h
164 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_sys.h
165 create mode 100644 drivers/net/dpaa2/qbman/driver/qbman_sys_decl.h
166 create mode 100644 drivers/net/dpaa2/qbman/include/compat.h
167 create mode 100644 drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_base.h
168 create mode 100644 drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_portal.h
169 create mode 100644 drivers/net/dpaa2/rte_eth_dpaa2_pvt.h
170 create mode 100644 drivers/net/dpaa2/rte_eth_dpbp.c
171 create mode 100644 drivers/net/dpaa2/rte_eth_dpio.c
172 create mode 100644 drivers/net/dpaa2/rte_eth_dpni.c
173 create mode 100644 drivers/net/dpaa2/rte_eth_dpni_annot.h
174 create mode 100644 lib/librte_eal/linuxapp/eal/eal_soc.c
175 create mode 100644 lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.c
176 create mode 100644 lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.h
178 diff --git a/config/defconfig_arm64-dpaa2-linuxapp-gcc b/config/defconfig_arm64-dpaa2-linuxapp-gcc
179 index 66df54c..e42fa90 100644
180 --- a/config/defconfig_arm64-dpaa2-linuxapp-gcc
181 +++ b/config/defconfig_arm64-dpaa2-linuxapp-gcc
185 -# Copyright(c) 2016 Freescale Semiconductor, Inc. All rights reserved.
186 +# Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
188 # Redistribution and use in source and binary forms, with or without
189 # modification, are permitted provided that the following conditions
190 @@ -40,3 +40,19 @@ CONFIG_RTE_ARCH_ARM_TUNE="cortex-a57+fp+simd"
192 CONFIG_RTE_MAX_LCORE=8
193 CONFIG_RTE_MAX_NUMA_NODES=1
195 +CONFIG_RTE_PKTMBUF_HEADROOM=256
197 +#Kernel KNI component - disable by default to avoid kernel
200 +CONFIG_RTE_KNI_KMOD=n
202 +# Compile software PMD backed by FSL DPAA2 files
204 +CONFIG_RTE_LIBRTE_DPAA2_PMD=y
205 +CONFIG_RTE_LIBRTE_DPAA2_USE_PHYS_IOVA=n
206 +CONFIG_RTE_LIBRTE_DPAA2_DEBUG_INIT=n
207 +CONFIG_RTE_LIBRTE_DPAA2_DEBUG_DRIVER=n
208 +CONFIG_RTE_LIBRTE_ETHDEV_DEBUG=n
209 +CONFIG_RTE_MBUF_DEFAULT_MEMPOOL_OPS="dpaa2"
210 diff --git a/drivers/net/Makefile b/drivers/net/Makefile
211 index bc93230..a71c14a 100644
212 --- a/drivers/net/Makefile
213 +++ b/drivers/net/Makefile
214 @@ -55,6 +55,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_THUNDERX_NICVF_PMD) += thunderx
215 DIRS-$(CONFIG_RTE_LIBRTE_VIRTIO_PMD) += virtio
216 DIRS-$(CONFIG_RTE_LIBRTE_VMXNET3_PMD) += vmxnet3
217 DIRS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += xenvirt
218 +DIRS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2
220 ifeq ($(CONFIG_RTE_LIBRTE_VHOST),y)
221 DIRS-$(CONFIG_RTE_LIBRTE_PMD_VHOST) += vhost
222 diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
224 index 0000000..3cf1782
226 +++ b/drivers/net/dpaa2/Makefile
230 +# Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
232 +# Redistribution and use in source and binary forms, with or without
233 +# modification, are permitted provided that the following conditions
236 +# * Redistributions of source code must retain the above copyright
237 +# notice, this list of conditions and the following disclaimer.
238 +# * Redistributions in binary form must reproduce the above copyright
239 +# notice, this list of conditions and the following disclaimer in
240 +# the documentation and/or other materials provided with the
242 +# * Neither the name of Freescale Semiconductor nor the names of its
243 +# contributors may be used to endorse or promote products derived
244 +# from this software without specific prior written permission.
246 +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
247 +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
248 +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
249 +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
250 +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
251 +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
252 +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
253 +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
254 +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
255 +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
256 +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
258 +include $(RTE_SDK)/mk/rte.vars.mk
263 +LIB = librte_pmd_dpaa2.a
265 +ifeq ($(CONFIG_RTE_LIBRTE_DPAA2_DEBUG_INIT),y)
267 +CFLAGS += "-Wno-error"
270 +CFLAGS += $(WERROR_FLAGS)
272 +CFLAGS +=-Wno-strict-aliasing
273 +CFLAGS +=-Wno-missing-prototypes
274 +CFLAGS +=-Wno-missing-declarations
275 +CFLAGS +=-Wno-unused-function
277 +CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2/mc
278 +CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2/qbman/include
279 +CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2/qbman/include/drivers
280 +CFLAGS += -I$(RTE_SDK)/drivers/net/dpaa2/driver/
281 +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/common/include
282 +CFLAGS += -I$(RTE_SDK)/lib/librte_ether
283 +CFLAGS += -I$(RTE_SDK)/lib/librte_eal/linuxapp/eal
285 +EXPORT_MAP := rte_pmd_dpaa2_version.map
289 +# all source are stored in SRCS-y
291 +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += \
312 +# all source are stored in SRCS-y
314 +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += \
315 + qbman/driver/qbman_portal.c \
316 + qbman/driver/qbman_debug.c
318 +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += rte_eth_dpni.c
319 +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += rte_eth_dpio.c
320 +SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += rte_eth_dpbp.c
323 +# Export include files
325 +SYMLINK-y-include +=
327 +# this lib depends upon:
328 +DEPDIRS-y += lib/librte_eal
329 +include $(RTE_SDK)/mk/rte.lib.mk
330 diff --git a/drivers/net/dpaa2/dpaa2_logs.h b/drivers/net/dpaa2/dpaa2_logs.h
332 index 0000000..534d4b5
334 +++ b/drivers/net/dpaa2/dpaa2_logs.h
339 + * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
341 + * Redistribution and use in source and binary forms, with or without
342 + * modification, are permitted provided that the following conditions
345 + * * Redistributions of source code must retain the above copyright
346 + * notice, this list of conditions and the following disclaimer.
347 + * * Redistributions in binary form must reproduce the above copyright
348 + * notice, this list of conditions and the following disclaimer in
349 + * the documentation and/or other materials provided with the
351 + * * Neither the name of Freescale Semiconductor, Inc nor the names of its
352 + * contributors may be used to endorse or promote products derived
353 + * from this software without specific prior written permission.
355 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
356 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
357 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
358 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
359 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
360 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
361 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
362 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
363 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
364 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
365 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
368 +#ifndef _DPAA2_LOGS_H_
369 +#define _DPAA2_LOGS_H_
371 +#define PMD_INIT_LOG(level, fmt, args...) \
372 + RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ##args)
374 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_INIT
375 +#define PMD_INIT_FUNC_TRACE() PMD_INIT_LOG(DEBUG, " >>")
377 +#define PMD_INIT_FUNC_TRACE() do { } while (0)
380 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_RX
381 +#define PMD_RX_LOG(level, fmt, args...) \
382 + RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
384 +#define PMD_RX_LOG(level, fmt, args...) do { } while (0)
387 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_TX
388 +#define PMD_TX_LOG(level, fmt, args...) \
389 + RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
391 +#define PMD_TX_LOG(level, fmt, args...) do { } while (0)
394 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_TX_FREE
395 +#define PMD_TX_FREE_LOG(level, fmt, args...) \
396 + RTE_LOG(level, PMD, "%s(): " fmt "\n", __func__, ## args)
398 +#define PMD_TX_FREE_LOG(level, fmt, args...) do { } while (0)
401 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_DRIVER
402 +#define PMD_DRV_LOG_RAW(level, fmt, args...) \
403 + RTE_LOG(level, PMD, "%s(): " fmt, __func__, ## args)
405 +#define PMD_DRV_LOG_RAW(level, fmt, args...) do { } while (0)
408 +#define PMD_DRV_LOG2(level, fmt, args...) do { } while (0)
410 +#define PMD_DRV_LOG(level, fmt, args...) \
411 + PMD_DRV_LOG_RAW(level, fmt "\n", ## args)
413 +#endif /* _DPAA2_LOGS_H_ */
414 diff --git a/drivers/net/dpaa2/mc/dpaiop.c b/drivers/net/dpaa2/mc/dpaiop.c
416 index 0000000..7c1ecff
418 +++ b/drivers/net/dpaa2/mc/dpaiop.c
420 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
422 + * Redistribution and use in source and binary forms, with or without
423 + * modification, are permitted provided that the following conditions are met:
424 + * * Redistributions of source code must retain the above copyright
425 + * notice, this list of conditions and the following disclaimer.
426 + * * Redistributions in binary form must reproduce the above copyright
427 + * notice, this list of conditions and the following disclaimer in the
428 + * documentation and/or other materials provided with the distribution.
429 + * * Neither the name of the above-listed copyright holders nor the
430 + * names of any contributors may be used to endorse or promote products
431 + * derived from this software without specific prior written permission.
434 + * ALTERNATIVELY, this software may be distributed under the terms of the
435 + * GNU General Public License ("GPL") as published by the Free Software
436 + * Foundation, either version 2 of that License or (at your option) any
439 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
440 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
441 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
442 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
443 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
444 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
445 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
446 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
447 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
448 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
449 + * POSSIBILITY OF SUCH DAMAGE.
451 +#include <fsl_mc_sys.h>
452 +#include <fsl_mc_cmd.h>
453 +#include <fsl_dpaiop.h>
454 +#include <fsl_dpaiop_cmd.h>
456 +int dpaiop_open(struct fsl_mc_io *mc_io,
457 + uint32_t cmd_flags,
461 + struct mc_command cmd = { 0 };
464 + /* prepare command */
465 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_OPEN,
468 + DPAIOP_CMD_OPEN(cmd, dpaiop_id);
470 + /* send command to mc*/
471 + err = mc_send_command(mc_io, &cmd);
475 + /* retrieve response parameters */
476 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
481 +int dpaiop_close(struct fsl_mc_io *mc_io,
482 + uint32_t cmd_flags,
485 + struct mc_command cmd = { 0 };
487 + /* prepare command */
488 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_CLOSE, cmd_flags,
491 + /* send command to mc*/
492 + return mc_send_command(mc_io, &cmd);
495 +int dpaiop_create(struct fsl_mc_io *mc_io,
496 + uint32_t cmd_flags,
497 + const struct dpaiop_cfg *cfg,
500 + struct mc_command cmd = { 0 };
503 + (void)(cfg); /* unused */
505 + /* prepare command */
506 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_CREATE,
509 + DPAIOP_CMD_CREATE(cmd, cfg);
511 + /* send command to mc*/
512 + err = mc_send_command(mc_io, &cmd);
516 + /* retrieve response parameters */
517 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
522 +int dpaiop_destroy(struct fsl_mc_io *mc_io,
523 + uint32_t cmd_flags,
526 + struct mc_command cmd = { 0 };
528 + /* prepare command */
529 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_DESTROY,
533 + /* send command to mc*/
534 + return mc_send_command(mc_io, &cmd);
537 +int dpaiop_reset(struct fsl_mc_io *mc_io,
538 + uint32_t cmd_flags,
541 + struct mc_command cmd = { 0 };
543 + /* prepare command */
544 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_RESET,
548 + /* send command to mc*/
549 + return mc_send_command(mc_io, &cmd);
552 +int dpaiop_set_irq(struct fsl_mc_io *mc_io,
553 + uint32_t cmd_flags,
556 + struct dpaiop_irq_cfg *irq_cfg)
558 + struct mc_command cmd = { 0 };
560 + /* prepare command */
561 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_SET_IRQ,
565 + DPAIOP_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
567 + /* send command to mc*/
568 + return mc_send_command(mc_io, &cmd);
571 +int dpaiop_get_irq(struct fsl_mc_io *mc_io,
572 + uint32_t cmd_flags,
576 + struct dpaiop_irq_cfg *irq_cfg)
578 + struct mc_command cmd = { 0 };
581 + /* prepare command */
582 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_IRQ,
586 + DPAIOP_CMD_GET_IRQ(cmd, irq_index);
588 + /* send command to mc*/
589 + err = mc_send_command(mc_io, &cmd);
593 + /* retrieve response parameters */
594 + DPAIOP_RSP_GET_IRQ(cmd, *type, irq_cfg);
599 +int dpaiop_set_irq_enable(struct fsl_mc_io *mc_io,
600 + uint32_t cmd_flags,
605 + struct mc_command cmd = { 0 };
607 + /* prepare command */
608 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_SET_IRQ_ENABLE,
612 + DPAIOP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
614 + /* send command to mc*/
615 + return mc_send_command(mc_io, &cmd);
618 +int dpaiop_get_irq_enable(struct fsl_mc_io *mc_io,
619 + uint32_t cmd_flags,
624 + struct mc_command cmd = { 0 };
627 + /* prepare command */
628 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_IRQ_ENABLE,
632 + DPAIOP_CMD_GET_IRQ_ENABLE(cmd, irq_index);
634 + /* send command to mc*/
635 + err = mc_send_command(mc_io, &cmd);
639 + /* retrieve response parameters */
640 + DPAIOP_RSP_GET_IRQ_ENABLE(cmd, *en);
645 +int dpaiop_set_irq_mask(struct fsl_mc_io *mc_io,
646 + uint32_t cmd_flags,
651 + struct mc_command cmd = { 0 };
653 + /* prepare command */
654 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_SET_IRQ_MASK,
658 + DPAIOP_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
660 + /* send command to mc*/
661 + return mc_send_command(mc_io, &cmd);
664 +int dpaiop_get_irq_mask(struct fsl_mc_io *mc_io,
665 + uint32_t cmd_flags,
670 + struct mc_command cmd = { 0 };
673 + /* prepare command */
674 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_IRQ_MASK,
678 + DPAIOP_CMD_GET_IRQ_MASK(cmd, irq_index);
680 + /* send command to mc*/
681 + err = mc_send_command(mc_io, &cmd);
685 + /* retrieve response parameters */
686 + DPAIOP_RSP_GET_IRQ_MASK(cmd, *mask);
691 +int dpaiop_get_irq_status(struct fsl_mc_io *mc_io,
692 + uint32_t cmd_flags,
697 + struct mc_command cmd = { 0 };
700 + /* prepare command */
701 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_IRQ_STATUS,
704 + DPAIOP_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
706 + /* send command to mc*/
707 + err = mc_send_command(mc_io, &cmd);
711 + /* retrieve response parameters */
712 + DPAIOP_RSP_GET_IRQ_STATUS(cmd, *status);
717 +int dpaiop_clear_irq_status(struct fsl_mc_io *mc_io,
718 + uint32_t cmd_flags,
723 + struct mc_command cmd = { 0 };
725 + /* prepare command */
726 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_CLEAR_IRQ_STATUS,
729 + DPAIOP_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
731 + /* send command to mc*/
732 + return mc_send_command(mc_io, &cmd);
735 +int dpaiop_get_attributes(struct fsl_mc_io *mc_io,
736 + uint32_t cmd_flags,
738 + struct dpaiop_attr *attr)
740 + struct mc_command cmd = { 0 };
743 + /* prepare command */
744 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_ATTR,
748 + /* send command to mc*/
749 + err = mc_send_command(mc_io, &cmd);
753 + /* retrieve response parameters */
754 + DPAIOP_RSP_GET_ATTRIBUTES(cmd, attr);
759 +int dpaiop_load(struct fsl_mc_io *mc_io,
760 + uint32_t cmd_flags,
762 + struct dpaiop_load_cfg *cfg)
764 + struct mc_command cmd = { 0 };
766 + /* prepare command */
767 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_LOAD,
770 + DPAIOP_CMD_LOAD(cmd, cfg);
772 + /* send command to mc*/
773 + return mc_send_command(mc_io, &cmd);
776 +int dpaiop_run(struct fsl_mc_io *mc_io,
777 + uint32_t cmd_flags,
779 + const struct dpaiop_run_cfg *cfg)
781 + struct mc_command cmd = { 0 };
783 + /* prepare command */
784 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_RUN,
787 + DPAIOP_CMD_RUN(cmd, cfg);
789 + /* send command to mc*/
790 + return mc_send_command(mc_io, &cmd);
793 +int dpaiop_get_sl_version(struct fsl_mc_io *mc_io,
794 + uint32_t cmd_flags,
796 + struct dpaiop_sl_version *version)
798 + struct mc_command cmd = { 0 };
801 + /* prepare command */
802 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_SL_VERSION,
806 + /* send command to mc*/
807 + err = mc_send_command(mc_io, &cmd);
811 + /* retrieve response parameters */
812 + DPAIOP_RSP_GET_SL_VERSION(cmd, version);
817 +int dpaiop_get_state(struct fsl_mc_io *mc_io,
818 + uint32_t cmd_flags,
822 + struct mc_command cmd = { 0 };
825 + /* prepare command */
826 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_STATE,
830 + /* send command to mc*/
831 + err = mc_send_command(mc_io, &cmd);
835 + /* retrieve response parameters */
836 + DPAIOP_RSP_GET_STATE(cmd, *state);
841 +int dpaiop_set_time_of_day(struct fsl_mc_io *mc_io,
842 + uint32_t cmd_flags,
844 + uint64_t time_of_day)
846 + struct mc_command cmd = { 0 };
848 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_SET_TIME_OF_DAY,
852 + DPAIOP_CMD_SET_TIME_OF_DAY(cmd, time_of_day);
854 + return mc_send_command(mc_io, &cmd);
857 +int dpaiop_get_time_of_day(struct fsl_mc_io *mc_io,
858 + uint32_t cmd_flags,
860 + uint64_t *time_of_day)
862 + struct mc_command cmd = { 0 };
865 + cmd.header = mc_encode_cmd_header(DPAIOP_CMDID_GET_TIME_OF_DAY,
869 + err = mc_send_command(mc_io, &cmd);
873 + DPAIOP_RSP_GET_TIME_OF_DAY(cmd, *time_of_day);
877 diff --git a/drivers/net/dpaa2/mc/dpbp.c b/drivers/net/dpaa2/mc/dpbp.c
879 index 0000000..87899b8
881 +++ b/drivers/net/dpaa2/mc/dpbp.c
883 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
885 + * Redistribution and use in source and binary forms, with or without
886 + * modification, are permitted provided that the following conditions are met:
887 + * * Redistributions of source code must retain the above copyright
888 + * notice, this list of conditions and the following disclaimer.
889 + * * Redistributions in binary form must reproduce the above copyright
890 + * notice, this list of conditions and the following disclaimer in the
891 + * documentation and/or other materials provided with the distribution.
892 + * * Neither the name of the above-listed copyright holders nor the
893 + * names of any contributors may be used to endorse or promote products
894 + * derived from this software without specific prior written permission.
897 + * ALTERNATIVELY, this software may be distributed under the terms of the
898 + * GNU General Public License ("GPL") as published by the Free Software
899 + * Foundation, either version 2 of that License or (at your option) any
902 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
903 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
904 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
905 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
906 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
907 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
908 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
909 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
910 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
911 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
912 + * POSSIBILITY OF SUCH DAMAGE.
914 +#include <fsl_mc_sys.h>
915 +#include <fsl_mc_cmd.h>
916 +#include <fsl_dpbp.h>
917 +#include <fsl_dpbp_cmd.h>
919 +int dpbp_open(struct fsl_mc_io *mc_io,
920 + uint32_t cmd_flags,
924 + struct mc_command cmd = { 0 };
927 + /* prepare command */
928 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_OPEN,
931 + DPBP_CMD_OPEN(cmd, dpbp_id);
933 + /* send command to mc*/
934 + err = mc_send_command(mc_io, &cmd);
938 + /* retrieve response parameters */
939 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
944 +int dpbp_close(struct fsl_mc_io *mc_io,
945 + uint32_t cmd_flags,
948 + struct mc_command cmd = { 0 };
950 + /* prepare command */
951 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLOSE, cmd_flags,
954 + /* send command to mc*/
955 + return mc_send_command(mc_io, &cmd);
958 +int dpbp_create(struct fsl_mc_io *mc_io,
959 + uint32_t cmd_flags,
960 + const struct dpbp_cfg *cfg,
963 + struct mc_command cmd = { 0 };
966 + (void)(cfg); /* unused */
968 + /* prepare command */
969 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_CREATE,
973 + /* send command to mc*/
974 + err = mc_send_command(mc_io, &cmd);
978 + /* retrieve response parameters */
979 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
984 +int dpbp_destroy(struct fsl_mc_io *mc_io,
985 + uint32_t cmd_flags,
988 + struct mc_command cmd = { 0 };
990 + /* prepare command */
991 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_DESTROY,
995 + /* send command to mc*/
996 + return mc_send_command(mc_io, &cmd);
999 +int dpbp_enable(struct fsl_mc_io *mc_io,
1000 + uint32_t cmd_flags,
1003 + struct mc_command cmd = { 0 };
1005 + /* prepare command */
1006 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_ENABLE, cmd_flags,
1009 + /* send command to mc*/
1010 + return mc_send_command(mc_io, &cmd);
1013 +int dpbp_disable(struct fsl_mc_io *mc_io,
1014 + uint32_t cmd_flags,
1017 + struct mc_command cmd = { 0 };
1019 + /* prepare command */
1020 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_DISABLE,
1024 + /* send command to mc*/
1025 + return mc_send_command(mc_io, &cmd);
1028 +int dpbp_is_enabled(struct fsl_mc_io *mc_io,
1029 + uint32_t cmd_flags,
1033 + struct mc_command cmd = { 0 };
1035 + /* prepare command */
1036 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_IS_ENABLED, cmd_flags,
1039 + /* send command to mc*/
1040 + err = mc_send_command(mc_io, &cmd);
1044 + /* retrieve response parameters */
1045 + DPBP_RSP_IS_ENABLED(cmd, *en);
1050 +int dpbp_reset(struct fsl_mc_io *mc_io,
1051 + uint32_t cmd_flags,
1054 + struct mc_command cmd = { 0 };
1056 + /* prepare command */
1057 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_RESET,
1061 + /* send command to mc*/
1062 + return mc_send_command(mc_io, &cmd);
1065 +int dpbp_set_irq(struct fsl_mc_io *mc_io,
1066 + uint32_t cmd_flags,
1068 + uint8_t irq_index,
1069 + struct dpbp_irq_cfg *irq_cfg)
1071 + struct mc_command cmd = { 0 };
1073 + /* prepare command */
1074 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ,
1078 + DPBP_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
1080 + /* send command to mc*/
1081 + return mc_send_command(mc_io, &cmd);
1084 +int dpbp_get_irq(struct fsl_mc_io *mc_io,
1085 + uint32_t cmd_flags,
1087 + uint8_t irq_index,
1089 + struct dpbp_irq_cfg *irq_cfg)
1091 + struct mc_command cmd = { 0 };
1094 + /* prepare command */
1095 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ,
1099 + DPBP_CMD_GET_IRQ(cmd, irq_index);
1101 + /* send command to mc*/
1102 + err = mc_send_command(mc_io, &cmd);
1106 + /* retrieve response parameters */
1107 + DPBP_RSP_GET_IRQ(cmd, *type, irq_cfg);
1112 +int dpbp_set_irq_enable(struct fsl_mc_io *mc_io,
1113 + uint32_t cmd_flags,
1115 + uint8_t irq_index,
1118 + struct mc_command cmd = { 0 };
1120 + /* prepare command */
1121 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_ENABLE,
1125 + DPBP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
1127 + /* send command to mc*/
1128 + return mc_send_command(mc_io, &cmd);
1131 +int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
1132 + uint32_t cmd_flags,
1134 + uint8_t irq_index,
1137 + struct mc_command cmd = { 0 };
1140 + /* prepare command */
1141 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_ENABLE,
1145 + DPBP_CMD_GET_IRQ_ENABLE(cmd, irq_index);
1147 + /* send command to mc*/
1148 + err = mc_send_command(mc_io, &cmd);
1152 + /* retrieve response parameters */
1153 + DPBP_RSP_GET_IRQ_ENABLE(cmd, *en);
1158 +int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
1159 + uint32_t cmd_flags,
1161 + uint8_t irq_index,
1164 + struct mc_command cmd = { 0 };
1166 + /* prepare command */
1167 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_IRQ_MASK,
1171 + DPBP_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
1173 + /* send command to mc*/
1174 + return mc_send_command(mc_io, &cmd);
1177 +int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
1178 + uint32_t cmd_flags,
1180 + uint8_t irq_index,
1183 + struct mc_command cmd = { 0 };
1186 + /* prepare command */
1187 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_MASK,
1191 + DPBP_CMD_GET_IRQ_MASK(cmd, irq_index);
1193 + /* send command to mc*/
1194 + err = mc_send_command(mc_io, &cmd);
1198 + /* retrieve response parameters */
1199 + DPBP_RSP_GET_IRQ_MASK(cmd, *mask);
1204 +int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
1205 + uint32_t cmd_flags,
1207 + uint8_t irq_index,
1210 + struct mc_command cmd = { 0 };
1213 + /* prepare command */
1214 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_IRQ_STATUS,
1218 + DPBP_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
1220 + /* send command to mc*/
1221 + err = mc_send_command(mc_io, &cmd);
1225 + /* retrieve response parameters */
1226 + DPBP_RSP_GET_IRQ_STATUS(cmd, *status);
1231 +int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
1232 + uint32_t cmd_flags,
1234 + uint8_t irq_index,
1237 + struct mc_command cmd = { 0 };
1239 + /* prepare command */
1240 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_CLEAR_IRQ_STATUS,
1244 + DPBP_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
1246 + /* send command to mc*/
1247 + return mc_send_command(mc_io, &cmd);
1250 +int dpbp_get_attributes(struct fsl_mc_io *mc_io,
1251 + uint32_t cmd_flags,
1253 + struct dpbp_attr *attr)
1255 + struct mc_command cmd = { 0 };
1258 + /* prepare command */
1259 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_ATTR,
1263 + /* send command to mc*/
1264 + err = mc_send_command(mc_io, &cmd);
1268 + /* retrieve response parameters */
1269 + DPBP_RSP_GET_ATTRIBUTES(cmd, attr);
1274 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
1275 + uint32_t cmd_flags,
1277 + struct dpbp_notification_cfg *cfg)
1279 + struct mc_command cmd = { 0 };
1281 + /* prepare command */
1282 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_SET_NOTIFICATIONS,
1286 + DPBP_CMD_SET_NOTIFICATIONS(cmd, cfg);
1288 + /* send command to mc*/
1289 + return mc_send_command(mc_io, &cmd);
1292 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
1293 + uint32_t cmd_flags,
1295 + struct dpbp_notification_cfg *cfg)
1297 + struct mc_command cmd = { 0 };
1300 + /* prepare command */
1301 + cmd.header = mc_encode_cmd_header(DPBP_CMDID_GET_NOTIFICATIONS,
1305 + /* send command to mc*/
1306 + err = mc_send_command(mc_io, &cmd);
1310 + /* retrieve response parameters */
1311 + DPBP_CMD_GET_NOTIFICATIONS(cmd, cfg);
1315 diff --git a/drivers/net/dpaa2/mc/dpci.c b/drivers/net/dpaa2/mc/dpci.c
1316 new file mode 100644
1317 index 0000000..2ec02a1
1319 +++ b/drivers/net/dpaa2/mc/dpci.c
1321 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
1323 + * Redistribution and use in source and binary forms, with or without
1324 + * modification, are permitted provided that the following conditions are met:
1325 + * * Redistributions of source code must retain the above copyright
1326 + * notice, this list of conditions and the following disclaimer.
1327 + * * Redistributions in binary form must reproduce the above copyright
1328 + * notice, this list of conditions and the following disclaimer in the
1329 + * documentation and/or other materials provided with the distribution.
1330 + * * Neither the name of the above-listed copyright holders nor the
1331 + * names of any contributors may be used to endorse or promote products
1332 + * derived from this software without specific prior written permission.
1335 + * ALTERNATIVELY, this software may be distributed under the terms of the
1336 + * GNU General Public License ("GPL") as published by the Free Software
1337 + * Foundation, either version 2 of that License or (at your option) any
1340 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1341 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1342 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1343 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1344 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1345 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1346 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1347 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1348 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1349 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1350 + * POSSIBILITY OF SUCH DAMAGE.
1352 +#include <fsl_mc_sys.h>
1353 +#include <fsl_mc_cmd.h>
1354 +#include <fsl_dpci.h>
1355 +#include <fsl_dpci_cmd.h>
1357 +int dpci_open(struct fsl_mc_io *mc_io,
1358 + uint32_t cmd_flags,
1362 + struct mc_command cmd = { 0 };
1365 + /* prepare command */
1366 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_OPEN,
1369 + DPCI_CMD_OPEN(cmd, dpci_id);
1371 + /* send command to mc*/
1372 + err = mc_send_command(mc_io, &cmd);
1376 + /* retrieve response parameters */
1377 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
1382 +int dpci_close(struct fsl_mc_io *mc_io,
1383 + uint32_t cmd_flags,
1386 + struct mc_command cmd = { 0 };
1388 + /* prepare command */
1389 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_CLOSE,
1393 + /* send command to mc*/
1394 + return mc_send_command(mc_io, &cmd);
1397 +int dpci_create(struct fsl_mc_io *mc_io,
1398 + uint32_t cmd_flags,
1399 + const struct dpci_cfg *cfg,
1402 + struct mc_command cmd = { 0 };
1405 + /* prepare command */
1406 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_CREATE,
1409 + DPCI_CMD_CREATE(cmd, cfg);
1411 + /* send command to mc*/
1412 + err = mc_send_command(mc_io, &cmd);
1416 + /* retrieve response parameters */
1417 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
1422 +int dpci_destroy(struct fsl_mc_io *mc_io,
1423 + uint32_t cmd_flags,
1426 + struct mc_command cmd = { 0 };
1428 + /* prepare command */
1429 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_DESTROY,
1433 + /* send command to mc*/
1434 + return mc_send_command(mc_io, &cmd);
1437 +int dpci_enable(struct fsl_mc_io *mc_io,
1438 + uint32_t cmd_flags,
1441 + struct mc_command cmd = { 0 };
1443 + /* prepare command */
1444 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_ENABLE,
1448 + /* send command to mc*/
1449 + return mc_send_command(mc_io, &cmd);
1452 +int dpci_disable(struct fsl_mc_io *mc_io,
1453 + uint32_t cmd_flags,
1456 + struct mc_command cmd = { 0 };
1458 + /* prepare command */
1459 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_DISABLE,
1463 + /* send command to mc*/
1464 + return mc_send_command(mc_io, &cmd);
1467 +int dpci_is_enabled(struct fsl_mc_io *mc_io,
1468 + uint32_t cmd_flags,
1472 + struct mc_command cmd = { 0 };
1474 + /* prepare command */
1475 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_IS_ENABLED, cmd_flags,
1478 + /* send command to mc*/
1479 + err = mc_send_command(mc_io, &cmd);
1483 + /* retrieve response parameters */
1484 + DPCI_RSP_IS_ENABLED(cmd, *en);
1489 +int dpci_reset(struct fsl_mc_io *mc_io,
1490 + uint32_t cmd_flags,
1493 + struct mc_command cmd = { 0 };
1495 + /* prepare command */
1496 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_RESET,
1500 + /* send command to mc*/
1501 + return mc_send_command(mc_io, &cmd);
1504 +int dpci_set_irq(struct fsl_mc_io *mc_io,
1505 + uint32_t cmd_flags,
1507 + uint8_t irq_index,
1508 + struct dpci_irq_cfg *irq_cfg)
1510 + struct mc_command cmd = { 0 };
1512 + /* prepare command */
1513 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_IRQ,
1516 + DPCI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
1518 + /* send command to mc*/
1519 + return mc_send_command(mc_io, &cmd);
1522 +int dpci_get_irq(struct fsl_mc_io *mc_io,
1523 + uint32_t cmd_flags,
1525 + uint8_t irq_index,
1527 + struct dpci_irq_cfg *irq_cfg)
1529 + struct mc_command cmd = { 0 };
1532 + /* prepare command */
1533 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_IRQ,
1536 + DPCI_CMD_GET_IRQ(cmd, irq_index);
1538 + /* send command to mc*/
1539 + err = mc_send_command(mc_io, &cmd);
1543 + /* retrieve response parameters */
1544 + DPCI_RSP_GET_IRQ(cmd, *type, irq_cfg);
1549 +int dpci_set_irq_enable(struct fsl_mc_io *mc_io,
1550 + uint32_t cmd_flags,
1552 + uint8_t irq_index,
1555 + struct mc_command cmd = { 0 };
1557 + /* prepare command */
1558 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_IRQ_ENABLE,
1561 + DPCI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
1563 + /* send command to mc*/
1564 + return mc_send_command(mc_io, &cmd);
1567 +int dpci_get_irq_enable(struct fsl_mc_io *mc_io,
1568 + uint32_t cmd_flags,
1570 + uint8_t irq_index,
1573 + struct mc_command cmd = { 0 };
1576 + /* prepare command */
1577 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_IRQ_ENABLE,
1580 + DPCI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
1582 + /* send command to mc*/
1583 + err = mc_send_command(mc_io, &cmd);
1587 + /* retrieve response parameters */
1588 + DPCI_RSP_GET_IRQ_ENABLE(cmd, *en);
1593 +int dpci_set_irq_mask(struct fsl_mc_io *mc_io,
1594 + uint32_t cmd_flags,
1596 + uint8_t irq_index,
1599 + struct mc_command cmd = { 0 };
1601 + /* prepare command */
1602 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_IRQ_MASK,
1605 + DPCI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
1607 + /* send command to mc*/
1608 + return mc_send_command(mc_io, &cmd);
1611 +int dpci_get_irq_mask(struct fsl_mc_io *mc_io,
1612 + uint32_t cmd_flags,
1614 + uint8_t irq_index,
1617 + struct mc_command cmd = { 0 };
1620 + /* prepare command */
1621 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_IRQ_MASK,
1624 + DPCI_CMD_GET_IRQ_MASK(cmd, irq_index);
1626 + /* send command to mc*/
1627 + err = mc_send_command(mc_io, &cmd);
1631 + /* retrieve response parameters */
1632 + DPCI_RSP_GET_IRQ_MASK(cmd, *mask);
1637 +int dpci_get_irq_status(struct fsl_mc_io *mc_io,
1638 + uint32_t cmd_flags,
1640 + uint8_t irq_index,
1643 + struct mc_command cmd = { 0 };
1646 + /* prepare command */
1647 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_IRQ_STATUS,
1650 + DPCI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
1652 + /* send command to mc*/
1653 + err = mc_send_command(mc_io, &cmd);
1657 + /* retrieve response parameters */
1658 + DPCI_RSP_GET_IRQ_STATUS(cmd, *status);
1663 +int dpci_clear_irq_status(struct fsl_mc_io *mc_io,
1664 + uint32_t cmd_flags,
1666 + uint8_t irq_index,
1669 + struct mc_command cmd = { 0 };
1671 + /* prepare command */
1672 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_CLEAR_IRQ_STATUS,
1675 + DPCI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
1677 + /* send command to mc*/
1678 + return mc_send_command(mc_io, &cmd);
1681 +int dpci_get_attributes(struct fsl_mc_io *mc_io,
1682 + uint32_t cmd_flags,
1684 + struct dpci_attr *attr)
1686 + struct mc_command cmd = { 0 };
1689 + /* prepare command */
1690 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_ATTR,
1694 + /* send command to mc*/
1695 + err = mc_send_command(mc_io, &cmd);
1699 + /* retrieve response parameters */
1700 + DPCI_RSP_GET_ATTR(cmd, attr);
1705 +int dpci_get_peer_attributes(struct fsl_mc_io *mc_io,
1706 + uint32_t cmd_flags,
1708 + struct dpci_peer_attr *attr)
1710 + struct mc_command cmd = { 0 };
1713 + /* prepare command */
1714 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_PEER_ATTR,
1718 + /* send command to mc*/
1719 + err = mc_send_command(mc_io, &cmd);
1723 + /* retrieve response parameters */
1724 + DPCI_RSP_GET_PEER_ATTR(cmd, attr);
1729 +int dpci_get_link_state(struct fsl_mc_io *mc_io,
1730 + uint32_t cmd_flags,
1734 + struct mc_command cmd = { 0 };
1737 + /* prepare command */
1738 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_LINK_STATE,
1742 + /* send command to mc*/
1743 + err = mc_send_command(mc_io, &cmd);
1747 + /* retrieve response parameters */
1748 + DPCI_RSP_GET_LINK_STATE(cmd, *up);
1753 +int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
1754 + uint32_t cmd_flags,
1757 + const struct dpci_rx_queue_cfg *cfg)
1759 + struct mc_command cmd = { 0 };
1761 + /* prepare command */
1762 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_SET_RX_QUEUE,
1765 + DPCI_CMD_SET_RX_QUEUE(cmd, priority, cfg);
1767 + /* send command to mc*/
1768 + return mc_send_command(mc_io, &cmd);
1771 +int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
1772 + uint32_t cmd_flags,
1775 + struct dpci_rx_queue_attr *attr)
1777 + struct mc_command cmd = { 0 };
1780 + /* prepare command */
1781 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_RX_QUEUE,
1784 + DPCI_CMD_GET_RX_QUEUE(cmd, priority);
1786 + /* send command to mc*/
1787 + err = mc_send_command(mc_io, &cmd);
1791 + /* retrieve response parameters */
1792 + DPCI_RSP_GET_RX_QUEUE(cmd, attr);
1797 +int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
1798 + uint32_t cmd_flags,
1801 + struct dpci_tx_queue_attr *attr)
1803 + struct mc_command cmd = { 0 };
1806 + /* prepare command */
1807 + cmd.header = mc_encode_cmd_header(DPCI_CMDID_GET_TX_QUEUE,
1810 + DPCI_CMD_GET_TX_QUEUE(cmd, priority);
1812 + /* send command to mc*/
1813 + err = mc_send_command(mc_io, &cmd);
1817 + /* retrieve response parameters */
1818 + DPCI_RSP_GET_TX_QUEUE(cmd, attr);
1822 diff --git a/drivers/net/dpaa2/mc/dpcon.c b/drivers/net/dpaa2/mc/dpcon.c
1823 new file mode 100644
1824 index 0000000..56dbcf7
1826 +++ b/drivers/net/dpaa2/mc/dpcon.c
1828 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
1830 + * Redistribution and use in source and binary forms, with or without
1831 + * modification, are permitted provided that the following conditions are met:
1832 + * * Redistributions of source code must retain the above copyright
1833 + * notice, this list of conditions and the following disclaimer.
1834 + * * Redistributions in binary form must reproduce the above copyright
1835 + * notice, this list of conditions and the following disclaimer in the
1836 + * documentation and/or other materials provided with the distribution.
1837 + * * Neither the name of the above-listed copyright holders nor the
1838 + * names of any contributors may be used to endorse or promote products
1839 + * derived from this software without specific prior written permission.
1842 + * ALTERNATIVELY, this software may be distributed under the terms of the
1843 + * GNU General Public License ("GPL") as published by the Free Software
1844 + * Foundation, either version 2 of that License or (at your option) any
1847 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1848 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1849 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1850 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
1851 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
1852 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
1853 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
1854 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
1855 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
1856 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
1857 + * POSSIBILITY OF SUCH DAMAGE.
1859 +#include <fsl_mc_sys.h>
1860 +#include <fsl_mc_cmd.h>
1861 +#include <fsl_dpcon.h>
1862 +#include <fsl_dpcon_cmd.h>
1864 +int dpcon_open(struct fsl_mc_io *mc_io,
1865 + uint32_t cmd_flags,
1869 + struct mc_command cmd = { 0 };
1872 + /* prepare command */
1873 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_OPEN,
1876 + DPCON_CMD_OPEN(cmd, dpcon_id);
1878 + /* send command to mc*/
1879 + err = mc_send_command(mc_io, &cmd);
1883 + /* retrieve response parameters */
1884 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
1889 +int dpcon_close(struct fsl_mc_io *mc_io,
1890 + uint32_t cmd_flags,
1893 + struct mc_command cmd = { 0 };
1895 + /* prepare command */
1896 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLOSE,
1900 + /* send command to mc*/
1901 + return mc_send_command(mc_io, &cmd);
1904 +int dpcon_create(struct fsl_mc_io *mc_io,
1905 + uint32_t cmd_flags,
1906 + const struct dpcon_cfg *cfg,
1909 + struct mc_command cmd = { 0 };
1912 + /* prepare command */
1913 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CREATE,
1916 + DPCON_CMD_CREATE(cmd, cfg);
1918 + /* send command to mc*/
1919 + err = mc_send_command(mc_io, &cmd);
1923 + /* retrieve response parameters */
1924 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
1929 +int dpcon_destroy(struct fsl_mc_io *mc_io,
1930 + uint32_t cmd_flags,
1933 + struct mc_command cmd = { 0 };
1935 + /* prepare command */
1936 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_DESTROY,
1940 + /* send command to mc*/
1941 + return mc_send_command(mc_io, &cmd);
1944 +int dpcon_enable(struct fsl_mc_io *mc_io,
1945 + uint32_t cmd_flags,
1948 + struct mc_command cmd = { 0 };
1950 + /* prepare command */
1951 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_ENABLE,
1955 + /* send command to mc*/
1956 + return mc_send_command(mc_io, &cmd);
1959 +int dpcon_disable(struct fsl_mc_io *mc_io,
1960 + uint32_t cmd_flags,
1963 + struct mc_command cmd = { 0 };
1965 + /* prepare command */
1966 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_DISABLE,
1970 + /* send command to mc*/
1971 + return mc_send_command(mc_io, &cmd);
1974 +int dpcon_is_enabled(struct fsl_mc_io *mc_io,
1975 + uint32_t cmd_flags,
1979 + struct mc_command cmd = { 0 };
1981 + /* prepare command */
1982 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_IS_ENABLED,
1986 + /* send command to mc*/
1987 + err = mc_send_command(mc_io, &cmd);
1991 + /* retrieve response parameters */
1992 + DPCON_RSP_IS_ENABLED(cmd, *en);
1997 +int dpcon_reset(struct fsl_mc_io *mc_io,
1998 + uint32_t cmd_flags,
2001 + struct mc_command cmd = { 0 };
2003 + /* prepare command */
2004 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_RESET,
2005 + cmd_flags, token);
2007 + /* send command to mc*/
2008 + return mc_send_command(mc_io, &cmd);
2011 +int dpcon_set_irq(struct fsl_mc_io *mc_io,
2012 + uint32_t cmd_flags,
2014 + uint8_t irq_index,
2015 + struct dpcon_irq_cfg *irq_cfg)
2017 + struct mc_command cmd = { 0 };
2019 + /* prepare command */
2020 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ,
2023 + DPCON_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
2025 + /* send command to mc*/
2026 + return mc_send_command(mc_io, &cmd);
2029 +int dpcon_get_irq(struct fsl_mc_io *mc_io,
2030 + uint32_t cmd_flags,
2032 + uint8_t irq_index,
2034 + struct dpcon_irq_cfg *irq_cfg)
2036 + struct mc_command cmd = { 0 };
2039 + /* prepare command */
2040 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ,
2043 + DPCON_CMD_GET_IRQ(cmd, irq_index);
2045 + /* send command to mc*/
2046 + err = mc_send_command(mc_io, &cmd);
2050 + /* retrieve response parameters */
2051 + DPCON_RSP_GET_IRQ(cmd, *type, irq_cfg);
2056 +int dpcon_set_irq_enable(struct fsl_mc_io *mc_io,
2057 + uint32_t cmd_flags,
2059 + uint8_t irq_index,
2062 + struct mc_command cmd = { 0 };
2064 + /* prepare command */
2065 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ_ENABLE,
2068 + DPCON_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
2070 + /* send command to mc*/
2071 + return mc_send_command(mc_io, &cmd);
2074 +int dpcon_get_irq_enable(struct fsl_mc_io *mc_io,
2075 + uint32_t cmd_flags,
2077 + uint8_t irq_index,
2080 + struct mc_command cmd = { 0 };
2083 + /* prepare command */
2084 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_ENABLE,
2087 + DPCON_CMD_GET_IRQ_ENABLE(cmd, irq_index);
2089 + /* send command to mc*/
2090 + err = mc_send_command(mc_io, &cmd);
2094 + /* retrieve response parameters */
2095 + DPCON_RSP_GET_IRQ_ENABLE(cmd, *en);
2100 +int dpcon_set_irq_mask(struct fsl_mc_io *mc_io,
2101 + uint32_t cmd_flags,
2103 + uint8_t irq_index,
2106 + struct mc_command cmd = { 0 };
2108 + /* prepare command */
2109 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_IRQ_MASK,
2112 + DPCON_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
2114 + /* send command to mc*/
2115 + return mc_send_command(mc_io, &cmd);
2118 +int dpcon_get_irq_mask(struct fsl_mc_io *mc_io,
2119 + uint32_t cmd_flags,
2121 + uint8_t irq_index,
2124 + struct mc_command cmd = { 0 };
2127 + /* prepare command */
2128 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_MASK,
2131 + DPCON_CMD_GET_IRQ_MASK(cmd, irq_index);
2133 + /* send command to mc*/
2134 + err = mc_send_command(mc_io, &cmd);
2138 + /* retrieve response parameters */
2139 + DPCON_RSP_GET_IRQ_MASK(cmd, *mask);
2144 +int dpcon_get_irq_status(struct fsl_mc_io *mc_io,
2145 + uint32_t cmd_flags,
2147 + uint8_t irq_index,
2150 + struct mc_command cmd = { 0 };
2153 + /* prepare command */
2154 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_IRQ_STATUS,
2157 + DPCON_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
2159 + /* send command to mc*/
2160 + err = mc_send_command(mc_io, &cmd);
2164 + /* retrieve response parameters */
2165 + DPCON_RSP_GET_IRQ_STATUS(cmd, *status);
2170 +int dpcon_clear_irq_status(struct fsl_mc_io *mc_io,
2171 + uint32_t cmd_flags,
2173 + uint8_t irq_index,
2176 + struct mc_command cmd = { 0 };
2178 + /* prepare command */
2179 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_CLEAR_IRQ_STATUS,
2182 + DPCON_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
2184 + /* send command to mc*/
2185 + return mc_send_command(mc_io, &cmd);
2188 +int dpcon_get_attributes(struct fsl_mc_io *mc_io,
2189 + uint32_t cmd_flags,
2191 + struct dpcon_attr *attr)
2193 + struct mc_command cmd = { 0 };
2196 + /* prepare command */
2197 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_GET_ATTR,
2201 + /* send command to mc*/
2202 + err = mc_send_command(mc_io, &cmd);
2206 + /* retrieve response parameters */
2207 + DPCON_RSP_GET_ATTR(cmd, attr);
2212 +int dpcon_set_notification(struct fsl_mc_io *mc_io,
2213 + uint32_t cmd_flags,
2215 + struct dpcon_notification_cfg *cfg)
2217 + struct mc_command cmd = { 0 };
2219 + /* prepare command */
2220 + cmd.header = mc_encode_cmd_header(DPCON_CMDID_SET_NOTIFICATION,
2223 + DPCON_CMD_SET_NOTIFICATION(cmd, cfg);
2225 + /* send command to mc*/
2226 + return mc_send_command(mc_io, &cmd);
2228 diff --git a/drivers/net/dpaa2/mc/dpdbg.c b/drivers/net/dpaa2/mc/dpdbg.c
2229 new file mode 100644
2230 index 0000000..6f2a08d
2232 +++ b/drivers/net/dpaa2/mc/dpdbg.c
2234 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
2236 + * Redistribution and use in source and binary forms, with or without
2237 + * modification, are permitted provided that the following conditions are met:
2238 + * * Redistributions of source code must retain the above copyright
2239 + * notice, this list of conditions and the following disclaimer.
2240 + * * Redistributions in binary form must reproduce the above copyright
2241 + * notice, this list of conditions and the following disclaimer in the
2242 + * documentation and/or other materials provided with the distribution.
2243 + * * Neither the name of the above-listed copyright holders nor the
2244 + * names of any contributors may be used to endorse or promote products
2245 + * derived from this software without specific prior written permission.
2248 + * ALTERNATIVELY, this software may be distributed under the terms of the
2249 + * GNU General Public License ("GPL") as published by the Free Software
2250 + * Foundation, either version 2 of that License or (at your option) any
2253 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2254 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2255 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2256 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2257 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2258 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2259 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2260 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2261 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2262 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2263 + * POSSIBILITY OF SUCH DAMAGE.
2265 +#include <fsl_mc_sys.h>
2266 +#include <fsl_mc_cmd.h>
2267 +#include <fsl_dpdbg.h>
2268 +#include <fsl_dpdbg_cmd.h>
2270 +int dpdbg_open(struct fsl_mc_io *mc_io,
2271 + uint32_t cmd_flags,
2275 + struct mc_command cmd = { 0 };
2278 + /* prepare command */
2279 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_OPEN,
2282 + DPDBG_CMD_OPEN(cmd, dpdbg_id);
2284 + /* send command to mc*/
2285 + err = mc_send_command(mc_io, &cmd);
2289 + /* retrieve response parameters */
2290 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
2295 +int dpdbg_close(struct fsl_mc_io *mc_io,
2296 + uint32_t cmd_flags,
2299 + struct mc_command cmd = { 0 };
2301 + /* prepare command */
2302 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_CLOSE, cmd_flags,
2305 + /* send command to mc*/
2306 + return mc_send_command(mc_io, &cmd);
2309 +int dpdbg_get_attributes(struct fsl_mc_io *mc_io,
2310 + uint32_t cmd_flags,
2312 + struct dpdbg_attr *attr)
2314 + struct mc_command cmd = { 0 };
2317 + /* prepare command */
2318 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_ATTR,
2322 + /* send command to mc*/
2323 + err = mc_send_command(mc_io, &cmd);
2327 + /* retrieve response parameters */
2328 + DPDBG_RSP_GET_ATTRIBUTES(cmd, attr);
2333 +int dpdbg_get_dpni_info(struct fsl_mc_io *mc_io,
2334 + uint32_t cmd_flags,
2337 + struct dpdbg_dpni_info *info)
2339 + struct mc_command cmd = { 0 };
2342 + /* prepare command */
2343 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPNI_INFO,
2346 + DPDBG_CMD_GET_DPNI_INFO(cmd, dpni_id);
2348 + /* send command to mc*/
2349 + err = mc_send_command(mc_io, &cmd);
2353 + /* retrieve response parameters */
2354 + DPDBG_RSP_GET_DPNI_INFO(cmd, info);
2359 +int dpdbg_get_dpni_priv_tx_conf_fqid(struct fsl_mc_io *mc_io,
2360 + uint32_t cmd_flags,
2363 + uint8_t sender_id,
2366 + struct mc_command cmd = { 0 };
2369 + /* prepare command */
2370 + cmd.header = mc_encode_cmd_header(
2371 + DPDBG_CMDID_GET_DPNI_PRIV_TX_CONF_FQID,
2374 + DPDBG_CMD_GET_DPNI_PRIV_TX_CONF_FQID(cmd, dpni_id, sender_id);
2376 + /* send command to mc*/
2377 + err = mc_send_command(mc_io, &cmd);
2381 + /* retrieve response parameters */
2382 + DPDBG_RSP_GET_DPNI_PRIV_TX_CONF_FQID(cmd, *fqid);
2387 +int dpdbg_get_dpcon_info(struct fsl_mc_io *mc_io,
2388 + uint32_t cmd_flags,
2391 + struct dpdbg_dpcon_info *info)
2393 + struct mc_command cmd = { 0 };
2396 + /* prepare command */
2397 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPCON_INFO,
2400 + DPDBG_CMD_GET_DPCON_INFO(cmd, dpcon_id);
2402 + /* send command to mc*/
2403 + err = mc_send_command(mc_io, &cmd);
2407 + /* retrieve response parameters */
2408 + DPDBG_RSP_GET_DPCON_INFO(cmd, info);
2413 +int dpdbg_get_dpbp_info(struct fsl_mc_io *mc_io,
2414 + uint32_t cmd_flags,
2417 + struct dpdbg_dpbp_info *info)
2419 + struct mc_command cmd = { 0 };
2422 + /* prepare command */
2423 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPBP_INFO,
2426 + DPDBG_CMD_GET_DPBP_INFO(cmd, dpbp_id);
2428 + /* send command to mc*/
2429 + err = mc_send_command(mc_io, &cmd);
2433 + /* retrieve response parameters */
2434 + DPDBG_RSP_GET_DPBP_INFO(cmd, info);
2439 +int dpdbg_get_dpci_fqid(struct fsl_mc_io *mc_io,
2440 + uint32_t cmd_flags,
2446 + struct mc_command cmd = { 0 };
2449 + /* prepare command */
2450 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPBP_INFO,
2453 + DPDBG_CMD_GET_DPCI_FQID(cmd, dpci_id, priority);
2455 + /* send command to mc*/
2456 + err = mc_send_command(mc_io, &cmd);
2460 + /* retrieve response parameters */
2461 + DPDBG_RSP_GET_DPCI_FQID(cmd, *fqid);
2466 +int dpdbg_prepare_ctlu_global_rule(struct dpkg_profile_cfg *dpkg_rule,
2467 + uint8_t *rule_buf)
2472 + uint64_t *params = (uint64_t *)rule_buf;
2474 + if (!rule_buf || !dpkg_rule)
2477 + params[0] |= mc_enc(0, 8, dpkg_rule->num_extracts);
2478 + params[0] = cpu_to_le64(params[0]);
2480 + if (dpkg_rule->num_extracts >= DPKG_MAX_NUM_OF_EXTRACTS)
2483 + for (i = 0; i < dpkg_rule->num_extracts; i++) {
2484 + switch (dpkg_rule->extracts[i].type) {
2485 + case DPKG_EXTRACT_FROM_HDR:
2486 + params[param] |= mc_enc(0, 8,
2487 + dpkg_rule->extracts[i].extract.from_hdr.prot);
2488 + params[param] |= mc_enc(8, 4,
2489 + dpkg_rule->extracts[i].extract.from_hdr.type);
2490 + params[param] |= mc_enc(16, 8,
2491 + dpkg_rule->extracts[i].extract.from_hdr.size);
2492 + params[param] |= mc_enc(24, 8,
2493 + dpkg_rule->extracts[i].extract.from_hdr.offset);
2494 + params[param] |= mc_enc(32, 32,
2495 + dpkg_rule->extracts[i].extract.from_hdr.field);
2496 + params[param] = cpu_to_le64(params[param]);
2498 + params[param] |= mc_enc(0, 8,
2499 + dpkg_rule->extracts[i].extract.
2500 + from_hdr.hdr_index);
2502 + case DPKG_EXTRACT_FROM_DATA:
2503 + params[param] |= mc_enc(16, 8,
2504 + dpkg_rule->extracts[i].extract.from_data.size);
2505 + params[param] |= mc_enc(24, 8,
2506 + dpkg_rule->extracts[i].extract.
2507 + from_data.offset);
2508 + params[param] = cpu_to_le64(params[param]);
2511 + case DPKG_EXTRACT_FROM_PARSE:
2512 + params[param] |= mc_enc(16, 8,
2513 + dpkg_rule->extracts[i].extract.from_parse.size);
2514 + params[param] |= mc_enc(24, 8,
2515 + dpkg_rule->extracts[i].extract.
2516 + from_parse.offset);
2517 + params[param] = cpu_to_le64(params[param]);
2523 + params[param] |= mc_enc(
2524 + 24, 8, dpkg_rule->extracts[i].num_of_byte_masks);
2525 + params[param] |= mc_enc(32, 4, dpkg_rule->extracts[i].type);
2526 + params[param] = cpu_to_le64(params[param]);
2528 + for (offset = 0, j = 0;
2529 + j < DPKG_NUM_OF_MASKS;
2530 + offset += 16, j++) {
2531 + params[param] |= mc_enc(
2533 + dpkg_rule->extracts[i].masks[j].mask);
2534 + params[param] |= mc_enc(
2536 + dpkg_rule->extracts[i].masks[j].offset);
2538 + params[param] = cpu_to_le64(params[param]);
2544 +int dpdbg_set_ctlu_global_marking(struct fsl_mc_io *mc_io,
2545 + uint32_t cmd_flags,
2548 + struct dpdbg_rule_cfg *cfg)
2550 + struct mc_command cmd = { 0 };
2552 + /* prepare command */
2553 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_CTLU_GLOBAL_MARKING,
2556 + DPDBG_CMD_SET_CTLU_GLOBAL_MARKING(cmd, marking, cfg);
2558 + /* send command to mc*/
2559 + return mc_send_command(mc_io, &cmd);
2562 +int dpdbg_set_dpni_rx_marking(struct fsl_mc_io *mc_io,
2563 + uint32_t cmd_flags,
2566 + struct dpdbg_dpni_rx_marking_cfg *cfg)
2568 + struct mc_command cmd = { 0 };
2570 + /* prepare command */
2571 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPNI_RX_MARKING,
2574 + DPDBG_CMD_SET_DPNI_RX_MARKING(cmd, dpni_id, cfg);
2576 + /* send command to mc*/
2577 + return mc_send_command(mc_io, &cmd);
2580 +int dpdbg_set_dpni_tx_conf_marking(struct fsl_mc_io *mc_io,
2581 + uint32_t cmd_flags,
2584 + uint16_t sender_id,
2587 + struct mc_command cmd = { 0 };
2589 + /* prepare command */
2590 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPNI_TX_CONF_MARKING,
2593 + DPDBG_CMD_SET_DPNI_TX_CONF_MARKING(cmd, dpni_id, sender_id, marking);
2595 + /* send command to mc*/
2596 + return mc_send_command(mc_io, &cmd);
2599 +int dpdbg_set_dpio_marking(struct fsl_mc_io *mc_io,
2600 + uint32_t cmd_flags,
2605 + struct mc_command cmd = { 0 };
2607 + /* prepare command */
2608 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPIO_MARKING,
2611 + DPDBG_CMD_SET_DPIO_MARKING(cmd, dpio_id, marking);
2613 + /* send command to mc*/
2614 + return mc_send_command(mc_io, &cmd);
2617 +int dpdbg_set_ctlu_global_trace(struct fsl_mc_io *mc_io,
2618 + uint32_t cmd_flags,
2620 + struct dpdbg_rule_cfg *cfg)
2622 + struct mc_command cmd = { 0 };
2624 + /* prepare command */
2625 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_CTLU_GLOBAL_TRACE,
2628 + DPDBG_CMD_SET_CTLU_GLOBAL_TRACE(cmd, cfg);
2630 + /* send command to mc*/
2631 + return mc_send_command(mc_io, &cmd);
2634 +int dpdbg_set_dpio_trace(struct fsl_mc_io *mc_io,
2635 + uint32_t cmd_flags,
2638 + struct dpdbg_dpio_trace_cfg
2639 + trace_point[DPDBG_NUM_OF_DPIO_TRACE_POINTS])
2641 + struct mc_command cmd = { 0 };
2643 + /* prepare command */
2644 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPIO_TRACE,
2647 + DPDBG_CMD_SET_DPIO_TRACE(cmd, dpio_id, trace_point);
2649 + /* send command to mc*/
2650 + return mc_send_command(mc_io, &cmd);
2653 +int dpdbg_set_dpni_rx_trace(struct fsl_mc_io *mc_io,
2654 + uint32_t cmd_flags,
2657 + struct dpdbg_dpni_rx_trace_cfg *trace_cfg)
2659 + struct mc_command cmd = { 0 };
2661 + /* prepare command */
2662 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPNI_RX_TRACE,
2665 + DPDBG_CMD_SET_DPNI_RX_TRACE(cmd, dpni_id, trace_cfg);
2667 + /* send command to mc*/
2668 + return mc_send_command(mc_io, &cmd);
2671 +int dpdbg_set_dpni_tx_trace(struct fsl_mc_io *mc_io,
2672 + uint32_t cmd_flags,
2675 + uint16_t sender_id,
2676 + struct dpdbg_dpni_tx_trace_cfg *trace_cfg)
2678 + struct mc_command cmd = { 0 };
2680 + /* prepare command */
2681 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPNI_TX_TRACE,
2684 + DPDBG_CMD_SET_DPNI_TX_TRACE(cmd, dpni_id, sender_id, trace_cfg);
2686 + /* send command to mc*/
2687 + return mc_send_command(mc_io, &cmd);
2690 +int dpdbg_set_dpcon_trace(struct fsl_mc_io *mc_io,
2691 + uint32_t cmd_flags,
2694 + struct dpdbg_dpcon_trace_cfg
2695 + trace_point[DPDBG_NUM_OF_DPCON_TRACE_POINTS])
2697 + struct mc_command cmd = { 0 };
2699 + /* prepare command */
2700 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPCON_TRACE,
2703 + DPDBG_CMD_SET_DPCON_TRACE(cmd, dpcon_id, trace_point);
2705 + /* send command to mc*/
2706 + return mc_send_command(mc_io, &cmd);
2709 +int dpdbg_set_dpseci_trace(struct fsl_mc_io *mc_io,
2710 + uint32_t cmd_flags,
2713 + struct dpdbg_dpseci_trace_cfg
2714 + trace_point[DPDBG_NUM_OF_DPSECI_TRACE_POINTS])
2716 + struct mc_command cmd = { 0 };
2718 + /* prepare command */
2719 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_SET_DPSECI_TRACE,
2722 + DPDBG_CMD_SET_DPSECI_TRACE(cmd, dpseci_id, trace_point);
2724 + /* send command to mc*/
2725 + return mc_send_command(mc_io, &cmd);
2728 +int dpdbg_get_dpmac_counter(struct fsl_mc_io *mc_io,
2729 + uint32_t cmd_flags,
2732 + enum dpmac_counter counter_type,
2733 + uint64_t *counter)
2735 + struct mc_command cmd = { 0 };
2738 + /* prepare command */
2739 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPMAC_COUNTER,
2742 + DPDBG_CMD_GET_DPMAC_COUNTER(cmd, dpmac_id, counter_type);
2744 + /* send command to mc*/
2745 + err = mc_send_command(mc_io, &cmd);
2749 + /* retrieve response parameters */
2750 + DPDBG_RSP_GET_DPMAC_COUNTER(cmd, *counter);
2755 +int dpdbg_get_dpni_counter(struct fsl_mc_io *mc_io,
2756 + uint32_t cmd_flags,
2759 + enum dpni_counter counter_type,
2760 + uint64_t *counter)
2762 + struct mc_command cmd = { 0 };
2765 + /* prepare command */
2766 + cmd.header = mc_encode_cmd_header(DPDBG_CMDID_GET_DPNI_COUNTER,
2769 + DPDBG_CMD_GET_DPMAC_COUNTER(cmd, dpni_id, counter_type);
2771 + /* send command to mc*/
2772 + err = mc_send_command(mc_io, &cmd);
2776 + /* retrieve response parameters */
2777 + DPDBG_RSP_GET_DPNI_COUNTER(cmd, *counter);
2781 diff --git a/drivers/net/dpaa2/mc/dpdcei.c b/drivers/net/dpaa2/mc/dpdcei.c
2782 new file mode 100644
2783 index 0000000..a5c4c47
2785 +++ b/drivers/net/dpaa2/mc/dpdcei.c
2787 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
2789 + * Redistribution and use in source and binary forms, with or without
2790 + * modification, are permitted provided that the following conditions are met:
2791 + * * Redistributions of source code must retain the above copyright
2792 + * notice, this list of conditions and the following disclaimer.
2793 + * * Redistributions in binary form must reproduce the above copyright
2794 + * notice, this list of conditions and the following disclaimer in the
2795 + * documentation and/or other materials provided with the distribution.
2796 + * * Neither the name of the above-listed copyright holders nor the
2797 + * names of any contributors may be used to endorse or promote products
2798 + * derived from this software without specific prior written permission.
2801 + * ALTERNATIVELY, this software may be distributed under the terms of the
2802 + * GNU General Public License ("GPL") as published by the Free Software
2803 + * Foundation, either version 2 of that License or (at your option) any
2806 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
2807 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2808 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2809 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
2810 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2811 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2812 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2813 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2814 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2815 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2816 + * POSSIBILITY OF SUCH DAMAGE.
2818 +#include <fsl_mc_sys.h>
2819 +#include <fsl_mc_cmd.h>
2820 +#include <fsl_dpdcei.h>
2821 +#include <fsl_dpdcei_cmd.h>
2823 +int dpdcei_open(struct fsl_mc_io *mc_io,
2824 + uint32_t cmd_flags,
2828 + struct mc_command cmd = { 0 };
2831 + /* prepare command */
2832 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_OPEN,
2835 + DPDCEI_CMD_OPEN(cmd, dpdcei_id);
2837 + /* send command to mc*/
2838 + err = mc_send_command(mc_io, &cmd);
2842 + /* retrieve response parameters */
2843 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
2848 +int dpdcei_close(struct fsl_mc_io *mc_io,
2849 + uint32_t cmd_flags,
2852 + struct mc_command cmd = { 0 };
2854 + /* prepare command */
2855 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_CLOSE,
2859 + /* send command to mc*/
2860 + return mc_send_command(mc_io, &cmd);
2863 +int dpdcei_create(struct fsl_mc_io *mc_io,
2864 + uint32_t cmd_flags,
2865 + const struct dpdcei_cfg *cfg,
2868 + struct mc_command cmd = { 0 };
2871 + /* prepare command */
2872 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_CREATE,
2875 + DPDCEI_CMD_CREATE(cmd, cfg);
2877 + /* send command to mc*/
2878 + err = mc_send_command(mc_io, &cmd);
2882 + /* retrieve response parameters */
2883 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
2888 +int dpdcei_destroy(struct fsl_mc_io *mc_io,
2889 + uint32_t cmd_flags,
2892 + struct mc_command cmd = { 0 };
2894 + /* prepare command */
2895 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_DESTROY,
2899 + /* send command to mc*/
2900 + return mc_send_command(mc_io, &cmd);
2903 +int dpdcei_enable(struct fsl_mc_io *mc_io,
2904 + uint32_t cmd_flags,
2907 + struct mc_command cmd = { 0 };
2909 + /* prepare command */
2910 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_ENABLE,
2914 + /* send command to mc*/
2915 + return mc_send_command(mc_io, &cmd);
2918 +int dpdcei_disable(struct fsl_mc_io *mc_io,
2919 + uint32_t cmd_flags,
2922 + struct mc_command cmd = { 0 };
2924 + /* prepare command */
2925 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_DISABLE,
2929 + /* send command to mc*/
2930 + return mc_send_command(mc_io, &cmd);
2933 +int dpdcei_is_enabled(struct fsl_mc_io *mc_io,
2934 + uint32_t cmd_flags,
2938 + struct mc_command cmd = { 0 };
2940 + /* prepare command */
2941 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_IS_ENABLED,
2945 + /* send command to mc*/
2946 + err = mc_send_command(mc_io, &cmd);
2950 + /* retrieve response parameters */
2951 + DPDCEI_RSP_IS_ENABLED(cmd, *en);
2956 +int dpdcei_reset(struct fsl_mc_io *mc_io,
2957 + uint32_t cmd_flags,
2960 + struct mc_command cmd = { 0 };
2962 + /* prepare command */
2963 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_RESET,
2967 + /* send command to mc*/
2968 + return mc_send_command(mc_io, &cmd);
2971 +int dpdcei_get_irq(struct fsl_mc_io *mc_io,
2972 + uint32_t cmd_flags,
2974 + uint8_t irq_index,
2976 + struct dpdcei_irq_cfg *irq_cfg)
2978 + struct mc_command cmd = { 0 };
2981 + /* prepare command */
2982 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_IRQ,
2985 + DPDCEI_CMD_GET_IRQ(cmd, irq_index);
2987 + /* send command to mc*/
2988 + err = mc_send_command(mc_io, &cmd);
2992 + /* retrieve response parameters */
2993 + DPDCEI_RSP_GET_IRQ(cmd, *type, irq_cfg);
2998 +int dpdcei_set_irq(struct fsl_mc_io *mc_io,
2999 + uint32_t cmd_flags,
3001 + uint8_t irq_index,
3002 + struct dpdcei_irq_cfg *irq_cfg)
3004 + struct mc_command cmd = { 0 };
3006 + /* prepare command */
3007 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_SET_IRQ,
3010 + DPDCEI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
3012 + /* send command to mc*/
3013 + return mc_send_command(mc_io, &cmd);
3016 +int dpdcei_get_irq_enable(struct fsl_mc_io *mc_io,
3017 + uint32_t cmd_flags,
3019 + uint8_t irq_index,
3022 + struct mc_command cmd = { 0 };
3025 + /* prepare command */
3026 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_IRQ_ENABLE,
3029 + DPDCEI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
3031 + /* send command to mc*/
3032 + err = mc_send_command(mc_io, &cmd);
3036 + /* retrieve response parameters */
3037 + DPDCEI_RSP_GET_IRQ_ENABLE(cmd, *en);
3042 +int dpdcei_set_irq_enable(struct fsl_mc_io *mc_io,
3043 + uint32_t cmd_flags,
3045 + uint8_t irq_index,
3048 + struct mc_command cmd = { 0 };
3050 + /* prepare command */
3051 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_SET_IRQ_ENABLE,
3054 + DPDCEI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
3056 + /* send command to mc*/
3057 + return mc_send_command(mc_io, &cmd);
3060 +int dpdcei_get_irq_mask(struct fsl_mc_io *mc_io,
3061 + uint32_t cmd_flags,
3063 + uint8_t irq_index,
3066 + struct mc_command cmd = { 0 };
3069 + /* prepare command */
3070 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_IRQ_MASK,
3073 + DPDCEI_CMD_GET_IRQ_MASK(cmd, irq_index);
3075 + /* send command to mc*/
3076 + err = mc_send_command(mc_io, &cmd);
3080 + /* retrieve response parameters */
3081 + DPDCEI_RSP_GET_IRQ_MASK(cmd, *mask);
3086 +int dpdcei_set_irq_mask(struct fsl_mc_io *mc_io,
3087 + uint32_t cmd_flags,
3089 + uint8_t irq_index,
3092 + struct mc_command cmd = { 0 };
3094 + /* prepare command */
3095 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_SET_IRQ_MASK,
3098 + DPDCEI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
3100 + /* send command to mc*/
3101 + return mc_send_command(mc_io, &cmd);
3104 +int dpdcei_get_irq_status(struct fsl_mc_io *mc_io,
3105 + uint32_t cmd_flags,
3107 + uint8_t irq_index,
3110 + struct mc_command cmd = { 0 };
3113 + /* prepare command */
3114 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_IRQ_STATUS,
3117 + DPDCEI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
3119 + /* send command to mc*/
3120 + err = mc_send_command(mc_io, &cmd);
3124 + /* retrieve response parameters */
3125 + DPDCEI_RSP_GET_IRQ_STATUS(cmd, *status);
3130 +int dpdcei_clear_irq_status(struct fsl_mc_io *mc_io,
3131 + uint32_t cmd_flags,
3133 + uint8_t irq_index,
3136 + struct mc_command cmd = { 0 };
3138 + /* prepare command */
3139 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_CLEAR_IRQ_STATUS,
3142 + DPDCEI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
3144 + /* send command to mc*/
3145 + return mc_send_command(mc_io, &cmd);
3148 +int dpdcei_get_attributes(struct fsl_mc_io *mc_io,
3149 + uint32_t cmd_flags,
3151 + struct dpdcei_attr *attr)
3153 + struct mc_command cmd = { 0 };
3156 + /* prepare command */
3157 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_ATTR,
3161 + /* send command to mc*/
3162 + err = mc_send_command(mc_io, &cmd);
3166 + /* retrieve response parameters */
3167 + DPDCEI_RSP_GET_ATTR(cmd, attr);
3172 +int dpdcei_set_rx_queue(struct fsl_mc_io *mc_io,
3173 + uint32_t cmd_flags,
3175 + const struct dpdcei_rx_queue_cfg *cfg)
3177 + struct mc_command cmd = { 0 };
3179 + /* prepare command */
3180 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_SET_RX_QUEUE,
3183 + DPDCEI_CMD_SET_RX_QUEUE(cmd, cfg);
3185 + /* send command to mc*/
3186 + return mc_send_command(mc_io, &cmd);
3189 +int dpdcei_get_rx_queue(struct fsl_mc_io *mc_io,
3190 + uint32_t cmd_flags,
3192 + struct dpdcei_rx_queue_attr *attr)
3194 + struct mc_command cmd = { 0 };
3197 + /* prepare command */
3198 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_RX_QUEUE,
3202 + /* send command to mc*/
3203 + err = mc_send_command(mc_io, &cmd);
3207 + /* retrieve response parameters */
3208 + DPDCEI_RSP_GET_RX_QUEUE(cmd, attr);
3213 +int dpdcei_get_tx_queue(struct fsl_mc_io *mc_io,
3214 + uint32_t cmd_flags,
3216 + struct dpdcei_tx_queue_attr *attr)
3218 + struct mc_command cmd = { 0 };
3221 + /* prepare command */
3222 + cmd.header = mc_encode_cmd_header(DPDCEI_CMDID_GET_TX_QUEUE,
3226 + /* send command to mc*/
3227 + err = mc_send_command(mc_io, &cmd);
3231 + /* retrieve response parameters */
3232 + DPDCEI_RSP_GET_TX_QUEUE(cmd, attr);
3236 diff --git a/drivers/net/dpaa2/mc/dpdmai.c b/drivers/net/dpaa2/mc/dpdmai.c
3237 new file mode 100644
3238 index 0000000..154d2c6
3240 +++ b/drivers/net/dpaa2/mc/dpdmai.c
3242 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
3244 + * Redistribution and use in source and binary forms, with or without
3245 + * modification, are permitted provided that the following conditions are met:
3246 + * * Redistributions of source code must retain the above copyright
3247 + * notice, this list of conditions and the following disclaimer.
3248 + * * Redistributions in binary form must reproduce the above copyright
3249 + * notice, this list of conditions and the following disclaimer in the
3250 + * documentation and/or other materials provided with the distribution.
3251 + * * Neither the name of the above-listed copyright holders nor the
3252 + * names of any contributors may be used to endorse or promote products
3253 + * derived from this software without specific prior written permission.
3256 + * ALTERNATIVELY, this software may be distributed under the terms of the
3257 + * GNU General Public License ("GPL") as published by the Free Software
3258 + * Foundation, either version 2 of that License or (at your option) any
3261 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3262 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3263 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3264 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
3265 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3266 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3267 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3268 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3269 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3270 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3271 + * POSSIBILITY OF SUCH DAMAGE.
3273 +#include <fsl_mc_sys.h>
3274 +#include <fsl_mc_cmd.h>
3275 +#include <fsl_dpdmai.h>
3276 +#include <fsl_dpdmai_cmd.h>
3278 +int dpdmai_open(struct fsl_mc_io *mc_io,
3279 + uint32_t cmd_flags,
3283 + struct mc_command cmd = { 0 };
3286 + /* prepare command */
3287 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_OPEN,
3290 + DPDMAI_CMD_OPEN(cmd, dpdmai_id);
3292 + /* send command to mc*/
3293 + err = mc_send_command(mc_io, &cmd);
3297 + /* retrieve response parameters */
3298 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
3303 +int dpdmai_close(struct fsl_mc_io *mc_io,
3304 + uint32_t cmd_flags,
3307 + struct mc_command cmd = { 0 };
3309 + /* prepare command */
3310 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CLOSE,
3311 + cmd_flags, token);
3313 + /* send command to mc*/
3314 + return mc_send_command(mc_io, &cmd);
3317 +int dpdmai_create(struct fsl_mc_io *mc_io,
3318 + uint32_t cmd_flags,
3319 + const struct dpdmai_cfg *cfg,
3322 + struct mc_command cmd = { 0 };
3325 + /* prepare command */
3326 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CREATE,
3329 + DPDMAI_CMD_CREATE(cmd, cfg);
3331 + /* send command to mc*/
3332 + err = mc_send_command(mc_io, &cmd);
3336 + /* retrieve response parameters */
3337 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
3342 +int dpdmai_destroy(struct fsl_mc_io *mc_io,
3343 + uint32_t cmd_flags,
3346 + struct mc_command cmd = { 0 };
3348 + /* prepare command */
3349 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DESTROY,
3353 + /* send command to mc*/
3354 + return mc_send_command(mc_io, &cmd);
3357 +int dpdmai_enable(struct fsl_mc_io *mc_io,
3358 + uint32_t cmd_flags,
3361 + struct mc_command cmd = { 0 };
3363 + /* prepare command */
3364 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_ENABLE,
3368 + /* send command to mc*/
3369 + return mc_send_command(mc_io, &cmd);
3372 +int dpdmai_disable(struct fsl_mc_io *mc_io,
3373 + uint32_t cmd_flags,
3376 + struct mc_command cmd = { 0 };
3378 + /* prepare command */
3379 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_DISABLE,
3383 + /* send command to mc*/
3384 + return mc_send_command(mc_io, &cmd);
3387 +int dpdmai_is_enabled(struct fsl_mc_io *mc_io,
3388 + uint32_t cmd_flags,
3392 + struct mc_command cmd = { 0 };
3394 + /* prepare command */
3395 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_IS_ENABLED,
3399 + /* send command to mc*/
3400 + err = mc_send_command(mc_io, &cmd);
3404 + /* retrieve response parameters */
3405 + DPDMAI_RSP_IS_ENABLED(cmd, *en);
3410 +int dpdmai_reset(struct fsl_mc_io *mc_io,
3411 + uint32_t cmd_flags,
3414 + struct mc_command cmd = { 0 };
3416 + /* prepare command */
3417 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_RESET,
3421 + /* send command to mc*/
3422 + return mc_send_command(mc_io, &cmd);
3425 +int dpdmai_get_irq(struct fsl_mc_io *mc_io,
3426 + uint32_t cmd_flags,
3428 + uint8_t irq_index,
3430 + struct dpdmai_irq_cfg *irq_cfg)
3432 + struct mc_command cmd = { 0 };
3435 + /* prepare command */
3436 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ,
3439 + DPDMAI_CMD_GET_IRQ(cmd, irq_index);
3441 + /* send command to mc*/
3442 + err = mc_send_command(mc_io, &cmd);
3446 + /* retrieve response parameters */
3447 + DPDMAI_RSP_GET_IRQ(cmd, *type, irq_cfg);
3452 +int dpdmai_set_irq(struct fsl_mc_io *mc_io,
3453 + uint32_t cmd_flags,
3455 + uint8_t irq_index,
3456 + struct dpdmai_irq_cfg *irq_cfg)
3458 + struct mc_command cmd = { 0 };
3460 + /* prepare command */
3461 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ,
3464 + DPDMAI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
3466 + /* send command to mc*/
3467 + return mc_send_command(mc_io, &cmd);
3470 +int dpdmai_get_irq_enable(struct fsl_mc_io *mc_io,
3471 + uint32_t cmd_flags,
3473 + uint8_t irq_index,
3476 + struct mc_command cmd = { 0 };
3479 + /* prepare command */
3480 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_ENABLE,
3483 + DPDMAI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
3485 + /* send command to mc*/
3486 + err = mc_send_command(mc_io, &cmd);
3490 + /* retrieve response parameters */
3491 + DPDMAI_RSP_GET_IRQ_ENABLE(cmd, *en);
3496 +int dpdmai_set_irq_enable(struct fsl_mc_io *mc_io,
3497 + uint32_t cmd_flags,
3499 + uint8_t irq_index,
3502 + struct mc_command cmd = { 0 };
3504 + /* prepare command */
3505 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ_ENABLE,
3508 + DPDMAI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
3510 + /* send command to mc*/
3511 + return mc_send_command(mc_io, &cmd);
3514 +int dpdmai_get_irq_mask(struct fsl_mc_io *mc_io,
3515 + uint32_t cmd_flags,
3517 + uint8_t irq_index,
3520 + struct mc_command cmd = { 0 };
3523 + /* prepare command */
3524 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_MASK,
3527 + DPDMAI_CMD_GET_IRQ_MASK(cmd, irq_index);
3529 + /* send command to mc*/
3530 + err = mc_send_command(mc_io, &cmd);
3534 + /* retrieve response parameters */
3535 + DPDMAI_RSP_GET_IRQ_MASK(cmd, *mask);
3540 +int dpdmai_set_irq_mask(struct fsl_mc_io *mc_io,
3541 + uint32_t cmd_flags,
3543 + uint8_t irq_index,
3546 + struct mc_command cmd = { 0 };
3548 + /* prepare command */
3549 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_IRQ_MASK,
3552 + DPDMAI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
3554 + /* send command to mc*/
3555 + return mc_send_command(mc_io, &cmd);
3558 +int dpdmai_get_irq_status(struct fsl_mc_io *mc_io,
3559 + uint32_t cmd_flags,
3561 + uint8_t irq_index,
3564 + struct mc_command cmd = { 0 };
3567 + /* prepare command */
3568 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_IRQ_STATUS,
3571 + DPDMAI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
3573 + /* send command to mc*/
3574 + err = mc_send_command(mc_io, &cmd);
3578 + /* retrieve response parameters */
3579 + DPDMAI_RSP_GET_IRQ_STATUS(cmd, *status);
3584 +int dpdmai_clear_irq_status(struct fsl_mc_io *mc_io,
3585 + uint32_t cmd_flags,
3587 + uint8_t irq_index,
3590 + struct mc_command cmd = { 0 };
3592 + /* prepare command */
3593 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_CLEAR_IRQ_STATUS,
3596 + DPDMAI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
3598 + /* send command to mc*/
3599 + return mc_send_command(mc_io, &cmd);
3602 +int dpdmai_get_attributes(struct fsl_mc_io *mc_io,
3603 + uint32_t cmd_flags,
3605 + struct dpdmai_attr *attr)
3607 + struct mc_command cmd = { 0 };
3610 + /* prepare command */
3611 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_ATTR,
3615 + /* send command to mc*/
3616 + err = mc_send_command(mc_io, &cmd);
3620 + /* retrieve response parameters */
3621 + DPDMAI_RSP_GET_ATTR(cmd, attr);
3626 +int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io,
3627 + uint32_t cmd_flags,
3630 + const struct dpdmai_rx_queue_cfg *cfg)
3632 + struct mc_command cmd = { 0 };
3634 + /* prepare command */
3635 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_SET_RX_QUEUE,
3638 + DPDMAI_CMD_SET_RX_QUEUE(cmd, priority, cfg);
3640 + /* send command to mc*/
3641 + return mc_send_command(mc_io, &cmd);
3644 +int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io,
3645 + uint32_t cmd_flags,
3647 + uint8_t priority, struct dpdmai_rx_queue_attr *attr)
3649 + struct mc_command cmd = { 0 };
3652 + /* prepare command */
3653 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_RX_QUEUE,
3656 + DPDMAI_CMD_GET_RX_QUEUE(cmd, priority);
3658 + /* send command to mc*/
3659 + err = mc_send_command(mc_io, &cmd);
3663 + /* retrieve response parameters */
3664 + DPDMAI_RSP_GET_RX_QUEUE(cmd, attr);
3669 +int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
3670 + uint32_t cmd_flags,
3673 + struct dpdmai_tx_queue_attr *attr)
3675 + struct mc_command cmd = { 0 };
3678 + /* prepare command */
3679 + cmd.header = mc_encode_cmd_header(DPDMAI_CMDID_GET_TX_QUEUE,
3682 + DPDMAI_CMD_GET_TX_QUEUE(cmd, priority);
3684 + /* send command to mc*/
3685 + err = mc_send_command(mc_io, &cmd);
3689 + /* retrieve response parameters */
3690 + DPDMAI_RSP_GET_TX_QUEUE(cmd, attr);
3694 diff --git a/drivers/net/dpaa2/mc/dpdmux.c b/drivers/net/dpaa2/mc/dpdmux.c
3695 new file mode 100644
3696 index 0000000..dc07608
3698 +++ b/drivers/net/dpaa2/mc/dpdmux.c
3700 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
3702 + * Redistribution and use in source and binary forms, with or without
3703 + * modification, are permitted provided that the following conditions are met:
3704 + * * Redistributions of source code must retain the above copyright
3705 + * notice, this list of conditions and the following disclaimer.
3706 + * * Redistributions in binary form must reproduce the above copyright
3707 + * notice, this list of conditions and the following disclaimer in the
3708 + * documentation and/or other materials provided with the distribution.
3709 + * * Neither the name of the above-listed copyright holders nor the
3710 + * names of any contributors may be used to endorse or promote products
3711 + * derived from this software without specific prior written permission.
3714 + * ALTERNATIVELY, this software may be distributed under the terms of the
3715 + * GNU General Public License ("GPL") as published by the Free Software
3716 + * Foundation, either version 2 of that License or (at your option) any
3719 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
3720 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3721 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3722 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
3723 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
3724 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
3725 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
3726 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
3727 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
3728 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
3729 + * POSSIBILITY OF SUCH DAMAGE.
3731 +#include <fsl_mc_sys.h>
3732 +#include <fsl_mc_cmd.h>
3733 +#include <fsl_dpdmux.h>
3734 +#include <fsl_dpdmux_cmd.h>
3736 +int dpdmux_open(struct fsl_mc_io *mc_io,
3737 + uint32_t cmd_flags,
3741 + struct mc_command cmd = { 0 };
3744 + /* prepare command */
3745 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_OPEN,
3748 + DPDMUX_CMD_OPEN(cmd, dpdmux_id);
3750 + /* send command to mc*/
3751 + err = mc_send_command(mc_io, &cmd);
3755 + /* retrieve response parameters */
3756 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
3761 +int dpdmux_close(struct fsl_mc_io *mc_io,
3762 + uint32_t cmd_flags,
3765 + struct mc_command cmd = { 0 };
3767 + /* prepare command */
3768 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CLOSE,
3772 + /* send command to mc*/
3773 + return mc_send_command(mc_io, &cmd);
3776 +int dpdmux_create(struct fsl_mc_io *mc_io,
3777 + uint32_t cmd_flags,
3778 + const struct dpdmux_cfg *cfg,
3781 + struct mc_command cmd = { 0 };
3784 + /* prepare command */
3785 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CREATE,
3788 + DPDMUX_CMD_CREATE(cmd, cfg);
3790 + /* send command to mc*/
3791 + err = mc_send_command(mc_io, &cmd);
3795 + /* retrieve response parameters */
3796 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
3801 +int dpdmux_destroy(struct fsl_mc_io *mc_io,
3802 + uint32_t cmd_flags,
3805 + struct mc_command cmd = { 0 };
3807 + /* prepare command */
3808 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DESTROY,
3812 + /* send command to mc*/
3813 + return mc_send_command(mc_io, &cmd);
3816 +int dpdmux_enable(struct fsl_mc_io *mc_io,
3817 + uint32_t cmd_flags,
3820 + struct mc_command cmd = { 0 };
3822 + /* prepare command */
3823 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ENABLE,
3827 + /* send command to mc*/
3828 + return mc_send_command(mc_io, &cmd);
3831 +int dpdmux_disable(struct fsl_mc_io *mc_io,
3832 + uint32_t cmd_flags,
3835 + struct mc_command cmd = { 0 };
3837 + /* prepare command */
3838 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DISABLE,
3842 + /* send command to mc*/
3843 + return mc_send_command(mc_io, &cmd);
3846 +int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
3847 + uint32_t cmd_flags,
3851 + struct mc_command cmd = { 0 };
3853 + /* prepare command */
3854 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IS_ENABLED,
3858 + /* send command to mc*/
3859 + err = mc_send_command(mc_io, &cmd);
3863 + /* retrieve response parameters */
3864 + DPDMUX_RSP_IS_ENABLED(cmd, *en);
3869 +int dpdmux_reset(struct fsl_mc_io *mc_io,
3870 + uint32_t cmd_flags,
3873 + struct mc_command cmd = { 0 };
3875 + /* prepare command */
3876 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_RESET,
3880 + /* send command to mc*/
3881 + return mc_send_command(mc_io, &cmd);
3884 +int dpdmux_set_irq(struct fsl_mc_io *mc_io,
3885 + uint32_t cmd_flags,
3887 + uint8_t irq_index,
3888 + struct dpdmux_irq_cfg *irq_cfg)
3890 + struct mc_command cmd = { 0 };
3892 + /* prepare command */
3893 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_IRQ,
3896 + DPDMUX_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
3898 + /* send command to mc*/
3899 + return mc_send_command(mc_io, &cmd);
3902 +int dpdmux_get_irq(struct fsl_mc_io *mc_io,
3903 + uint32_t cmd_flags,
3905 + uint8_t irq_index,
3907 + struct dpdmux_irq_cfg *irq_cfg)
3909 + struct mc_command cmd = { 0 };
3912 + /* prepare command */
3913 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_IRQ,
3916 + DPDMUX_CMD_GET_IRQ(cmd, irq_index);
3918 + /* send command to mc*/
3919 + err = mc_send_command(mc_io, &cmd);
3923 + /* retrieve response parameters */
3924 + DPDMUX_RSP_GET_IRQ(cmd, *type, irq_cfg);
3929 +int dpdmux_set_irq_enable(struct fsl_mc_io *mc_io,
3930 + uint32_t cmd_flags,
3932 + uint8_t irq_index,
3935 + struct mc_command cmd = { 0 };
3937 + /* prepare command */
3938 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_IRQ_ENABLE,
3941 + DPDMUX_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
3943 + /* send command to mc*/
3944 + return mc_send_command(mc_io, &cmd);
3947 +int dpdmux_get_irq_enable(struct fsl_mc_io *mc_io,
3948 + uint32_t cmd_flags,
3950 + uint8_t irq_index,
3953 + struct mc_command cmd = { 0 };
3956 + /* prepare command */
3957 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_IRQ_ENABLE,
3960 + DPDMUX_CMD_GET_IRQ_ENABLE(cmd, irq_index);
3962 + /* send command to mc*/
3963 + err = mc_send_command(mc_io, &cmd);
3967 + /* retrieve response parameters */
3968 + DPDMUX_RSP_GET_IRQ_ENABLE(cmd, *en);
3973 +int dpdmux_set_irq_mask(struct fsl_mc_io *mc_io,
3974 + uint32_t cmd_flags,
3976 + uint8_t irq_index,
3979 + struct mc_command cmd = { 0 };
3981 + /* prepare command */
3982 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_IRQ_MASK,
3985 + DPDMUX_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
3987 + /* send command to mc*/
3988 + return mc_send_command(mc_io, &cmd);
3991 +int dpdmux_get_irq_mask(struct fsl_mc_io *mc_io,
3992 + uint32_t cmd_flags,
3994 + uint8_t irq_index,
3997 + struct mc_command cmd = { 0 };
4000 + /* prepare command */
4001 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_IRQ_MASK,
4004 + DPDMUX_CMD_GET_IRQ_MASK(cmd, irq_index);
4006 + /* send command to mc*/
4007 + err = mc_send_command(mc_io, &cmd);
4011 + /* retrieve response parameters */
4012 + DPDMUX_RSP_GET_IRQ_MASK(cmd, *mask);
4017 +int dpdmux_get_irq_status(struct fsl_mc_io *mc_io,
4018 + uint32_t cmd_flags,
4020 + uint8_t irq_index,
4023 + struct mc_command cmd = { 0 };
4026 + /* prepare command */
4027 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_IRQ_STATUS,
4030 + DPDMUX_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
4032 + /* send command to mc*/
4033 + err = mc_send_command(mc_io, &cmd);
4037 + /* retrieve response parameters */
4038 + DPDMUX_RSP_GET_IRQ_STATUS(cmd, *status);
4043 +int dpdmux_clear_irq_status(struct fsl_mc_io *mc_io,
4044 + uint32_t cmd_flags,
4046 + uint8_t irq_index,
4049 + struct mc_command cmd = { 0 };
4051 + /* prepare command */
4052 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CLEAR_IRQ_STATUS,
4055 + DPDMUX_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
4057 + /* send command to mc*/
4058 + return mc_send_command(mc_io, &cmd);
4061 +int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
4062 + uint32_t cmd_flags,
4064 + struct dpdmux_attr *attr)
4066 + struct mc_command cmd = { 0 };
4069 + /* prepare command */
4070 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_ATTR,
4074 + /* send command to mc*/
4075 + err = mc_send_command(mc_io, &cmd);
4079 + /* retrieve response parameters */
4080 + DPDMUX_RSP_GET_ATTR(cmd, attr);
4085 +int dpdmux_ul_set_max_frame_length(struct fsl_mc_io *mc_io,
4086 + uint32_t cmd_flags,
4088 + uint16_t max_frame_length)
4090 + struct mc_command cmd = { 0 };
4092 + /* prepare command */
4093 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_UL_SET_MAX_FRAME_LENGTH,
4096 + DPDMUX_CMD_UL_SET_MAX_FRAME_LENGTH(cmd, max_frame_length);
4098 + /* send command to mc*/
4099 + return mc_send_command(mc_io, &cmd);
4102 +int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
4103 + uint32_t cmd_flags,
4106 + struct mc_command cmd = { 0 };
4108 + /* prepare command */
4109 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_UL_RESET_COUNTERS,
4113 + /* send command to mc*/
4114 + return mc_send_command(mc_io, &cmd);
4117 +int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
4118 + uint32_t cmd_flags,
4121 + const struct dpdmux_accepted_frames *cfg)
4123 + struct mc_command cmd = { 0 };
4125 + /* prepare command */
4126 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES,
4129 + DPDMUX_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg);
4131 + /* send command to mc*/
4132 + return mc_send_command(mc_io, &cmd);
4135 +int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
4136 + uint32_t cmd_flags,
4139 + struct dpdmux_if_attr *attr)
4141 + struct mc_command cmd = { 0 };
4144 + /* prepare command */
4145 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_ATTR,
4148 + DPDMUX_CMD_IF_GET_ATTR(cmd, if_id);
4150 + /* send command to mc*/
4151 + err = mc_send_command(mc_io, &cmd);
4155 + /* retrieve response parameters */
4156 + DPDMUX_RSP_IF_GET_ATTR(cmd, attr);
4161 +int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
4162 + uint32_t cmd_flags,
4165 + const struct dpdmux_l2_rule *rule)
4167 + struct mc_command cmd = { 0 };
4169 + /* prepare command */
4170 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_REMOVE_L2_RULE,
4173 + DPDMUX_CMD_IF_REMOVE_L2_RULE(cmd, if_id, rule);
4175 + /* send command to mc*/
4176 + return mc_send_command(mc_io, &cmd);
4179 +int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
4180 + uint32_t cmd_flags,
4183 + const struct dpdmux_l2_rule *rule)
4185 + struct mc_command cmd = { 0 };
4187 + /* prepare command */
4188 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ADD_L2_RULE,
4191 + DPDMUX_CMD_IF_ADD_L2_RULE(cmd, if_id, rule);
4193 + /* send command to mc*/
4194 + return mc_send_command(mc_io, &cmd);
4197 +int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
4198 + uint32_t cmd_flags,
4201 + enum dpdmux_counter_type counter_type,
4202 + uint64_t *counter)
4204 + struct mc_command cmd = { 0 };
4207 + /* prepare command */
4208 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_COUNTER,
4211 + DPDMUX_CMD_IF_GET_COUNTER(cmd, if_id, counter_type);
4213 + /* send command to mc*/
4214 + err = mc_send_command(mc_io, &cmd);
4218 + /* retrieve response parameters */
4219 + DPDMUX_RSP_IF_GET_COUNTER(cmd, *counter);
4224 +int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
4225 + uint32_t cmd_flags,
4228 + struct dpdmux_link_cfg *cfg)
4230 + struct mc_command cmd = { 0 };
4232 + /* prepare command */
4233 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_LINK_CFG,
4236 + DPDMUX_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg);
4238 + /* send command to mc*/
4239 + return mc_send_command(mc_io, &cmd);
4242 +int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
4243 + uint32_t cmd_flags,
4246 + struct dpdmux_link_state *state)
4248 + struct mc_command cmd = { 0 };
4251 + /* prepare command */
4252 + cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_LINK_STATE,
4255 + DPDMUX_CMD_IF_GET_LINK_STATE(cmd, if_id);
4257 + /* send command to mc*/
4258 + err = mc_send_command(mc_io, &cmd);
4262 + /* retrieve response parameters */
4263 + DPDMUX_RSP_IF_GET_LINK_STATE(cmd, state);
4267 diff --git a/drivers/net/dpaa2/mc/dpio.c b/drivers/net/dpaa2/mc/dpio.c
4268 new file mode 100644
4269 index 0000000..f511e29
4271 +++ b/drivers/net/dpaa2/mc/dpio.c
4273 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
4275 + * Redistribution and use in source and binary forms, with or without
4276 + * modification, are permitted provided that the following conditions are met:
4277 + * * Redistributions of source code must retain the above copyright
4278 + * notice, this list of conditions and the following disclaimer.
4279 + * * Redistributions in binary form must reproduce the above copyright
4280 + * notice, this list of conditions and the following disclaimer in the
4281 + * documentation and/or other materials provided with the distribution.
4282 + * * Neither the name of the above-listed copyright holders nor the
4283 + * names of any contributors may be used to endorse or promote products
4284 + * derived from this software without specific prior written permission.
4287 + * ALTERNATIVELY, this software may be distributed under the terms of the
4288 + * GNU General Public License ("GPL") as published by the Free Software
4289 + * Foundation, either version 2 of that License or (at your option) any
4292 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4293 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4294 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4295 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
4296 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4297 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4298 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4299 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4300 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4301 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4302 + * POSSIBILITY OF SUCH DAMAGE.
4304 +#include <fsl_mc_sys.h>
4305 +#include <fsl_mc_cmd.h>
4306 +#include <fsl_dpio.h>
4307 +#include <fsl_dpio_cmd.h>
4309 +int dpio_open(struct fsl_mc_io *mc_io,
4310 + uint32_t cmd_flags,
4314 + struct mc_command cmd = { 0 };
4317 + /* prepare command */
4318 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_OPEN,
4321 + DPIO_CMD_OPEN(cmd, dpio_id);
4323 + /* send command to mc*/
4324 + err = mc_send_command(mc_io, &cmd);
4328 + /* retrieve response parameters */
4329 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
4334 +int dpio_close(struct fsl_mc_io *mc_io,
4335 + uint32_t cmd_flags,
4338 + struct mc_command cmd = { 0 };
4340 + /* prepare command */
4341 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLOSE,
4345 + /* send command to mc*/
4346 + return mc_send_command(mc_io, &cmd);
4349 +int dpio_create(struct fsl_mc_io *mc_io,
4350 + uint32_t cmd_flags,
4351 + const struct dpio_cfg *cfg,
4354 + struct mc_command cmd = { 0 };
4357 + /* prepare command */
4358 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_CREATE,
4361 + DPIO_CMD_CREATE(cmd, cfg);
4363 + /* send command to mc*/
4364 + err = mc_send_command(mc_io, &cmd);
4368 + /* retrieve response parameters */
4369 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
4374 +int dpio_destroy(struct fsl_mc_io *mc_io,
4375 + uint32_t cmd_flags,
4378 + struct mc_command cmd = { 0 };
4380 + /* prepare command */
4381 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_DESTROY,
4385 + /* send command to mc*/
4386 + return mc_send_command(mc_io, &cmd);
4389 +int dpio_enable(struct fsl_mc_io *mc_io,
4390 + uint32_t cmd_flags,
4393 + struct mc_command cmd = { 0 };
4395 + /* prepare command */
4396 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_ENABLE,
4400 + /* send command to mc*/
4401 + return mc_send_command(mc_io, &cmd);
4404 +int dpio_disable(struct fsl_mc_io *mc_io,
4405 + uint32_t cmd_flags,
4408 + struct mc_command cmd = { 0 };
4410 + /* prepare command */
4411 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_DISABLE,
4415 + /* send command to mc*/
4416 + return mc_send_command(mc_io, &cmd);
4419 +int dpio_is_enabled(struct fsl_mc_io *mc_io,
4420 + uint32_t cmd_flags,
4424 + struct mc_command cmd = { 0 };
4426 + /* prepare command */
4427 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_IS_ENABLED, cmd_flags,
4430 + /* send command to mc*/
4431 + err = mc_send_command(mc_io, &cmd);
4435 + /* retrieve response parameters */
4436 + DPIO_RSP_IS_ENABLED(cmd, *en);
4441 +int dpio_reset(struct fsl_mc_io *mc_io,
4442 + uint32_t cmd_flags,
4445 + struct mc_command cmd = { 0 };
4447 + /* prepare command */
4448 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_RESET,
4452 + /* send command to mc*/
4453 + return mc_send_command(mc_io, &cmd);
4456 +int dpio_set_irq(struct fsl_mc_io *mc_io,
4457 + uint32_t cmd_flags,
4459 + uint8_t irq_index,
4460 + struct dpio_irq_cfg *irq_cfg)
4462 + struct mc_command cmd = { 0 };
4464 + /* prepare command */
4465 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_IRQ,
4468 + DPIO_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
4470 + /* send command to mc*/
4471 + return mc_send_command(mc_io, &cmd);
4474 +int dpio_get_irq(struct fsl_mc_io *mc_io,
4475 + uint32_t cmd_flags,
4477 + uint8_t irq_index,
4479 + struct dpio_irq_cfg *irq_cfg)
4481 + struct mc_command cmd = { 0 };
4484 + /* prepare command */
4485 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_IRQ,
4488 + DPIO_CMD_GET_IRQ(cmd, irq_index);
4490 + /* send command to mc*/
4491 + err = mc_send_command(mc_io, &cmd);
4495 + /* retrieve response parameters */
4496 + DPIO_RSP_GET_IRQ(cmd, *type, irq_cfg);
4501 +int dpio_set_irq_enable(struct fsl_mc_io *mc_io,
4502 + uint32_t cmd_flags,
4504 + uint8_t irq_index,
4507 + struct mc_command cmd = { 0 };
4509 + /* prepare command */
4510 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_IRQ_ENABLE,
4513 + DPIO_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
4515 + /* send command to mc*/
4516 + return mc_send_command(mc_io, &cmd);
4519 +int dpio_get_irq_enable(struct fsl_mc_io *mc_io,
4520 + uint32_t cmd_flags,
4522 + uint8_t irq_index,
4525 + struct mc_command cmd = { 0 };
4528 + /* prepare command */
4529 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_IRQ_ENABLE,
4532 + DPIO_CMD_GET_IRQ_ENABLE(cmd, irq_index);
4534 + /* send command to mc*/
4535 + err = mc_send_command(mc_io, &cmd);
4539 + /* retrieve response parameters */
4540 + DPIO_RSP_GET_IRQ_ENABLE(cmd, *en);
4545 +int dpio_set_irq_mask(struct fsl_mc_io *mc_io,
4546 + uint32_t cmd_flags,
4548 + uint8_t irq_index,
4551 + struct mc_command cmd = { 0 };
4553 + /* prepare command */
4554 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_IRQ_MASK,
4557 + DPIO_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
4559 + /* send command to mc*/
4560 + return mc_send_command(mc_io, &cmd);
4563 +int dpio_get_irq_mask(struct fsl_mc_io *mc_io,
4564 + uint32_t cmd_flags,
4566 + uint8_t irq_index,
4569 + struct mc_command cmd = { 0 };
4572 + /* prepare command */
4573 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_IRQ_MASK,
4576 + DPIO_CMD_GET_IRQ_MASK(cmd, irq_index);
4578 + /* send command to mc*/
4579 + err = mc_send_command(mc_io, &cmd);
4583 + /* retrieve response parameters */
4584 + DPIO_RSP_GET_IRQ_MASK(cmd, *mask);
4589 +int dpio_get_irq_status(struct fsl_mc_io *mc_io,
4590 + uint32_t cmd_flags,
4592 + uint8_t irq_index,
4595 + struct mc_command cmd = { 0 };
4598 + /* prepare command */
4599 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_IRQ_STATUS,
4602 + DPIO_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
4604 + /* send command to mc*/
4605 + err = mc_send_command(mc_io, &cmd);
4609 + /* retrieve response parameters */
4610 + DPIO_RSP_GET_IRQ_STATUS(cmd, *status);
4615 +int dpio_clear_irq_status(struct fsl_mc_io *mc_io,
4616 + uint32_t cmd_flags,
4618 + uint8_t irq_index,
4621 + struct mc_command cmd = { 0 };
4623 + /* prepare command */
4624 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_CLEAR_IRQ_STATUS,
4627 + DPIO_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
4629 + /* send command to mc*/
4630 + return mc_send_command(mc_io, &cmd);
4633 +int dpio_get_attributes(struct fsl_mc_io *mc_io,
4634 + uint32_t cmd_flags,
4636 + struct dpio_attr *attr)
4638 + struct mc_command cmd = { 0 };
4641 + /* prepare command */
4642 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_ATTR,
4646 + /* send command to mc*/
4647 + err = mc_send_command(mc_io, &cmd);
4651 + /* retrieve response parameters */
4652 + DPIO_RSP_GET_ATTR(cmd, attr);
4657 +int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
4658 + uint32_t cmd_flags,
4662 + struct mc_command cmd = { 0 };
4664 + /* prepare command */
4665 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_SET_STASHING_DEST,
4668 + DPIO_CMD_SET_STASHING_DEST(cmd, sdest);
4670 + /* send command to mc*/
4671 + return mc_send_command(mc_io, &cmd);
4674 +int dpio_get_stashing_destination(struct fsl_mc_io *mc_io,
4675 + uint32_t cmd_flags,
4679 + struct mc_command cmd = { 0 };
4682 + /* prepare command */
4683 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_GET_STASHING_DEST,
4687 + /* send command to mc*/
4688 + err = mc_send_command(mc_io, &cmd);
4692 + /* retrieve response parameters */
4693 + DPIO_RSP_GET_STASHING_DEST(cmd, *sdest);
4698 +int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io,
4699 + uint32_t cmd_flags,
4702 + uint8_t *channel_index)
4704 + struct mc_command cmd = { 0 };
4707 + /* prepare command */
4708 + cmd.header = mc_encode_cmd_header(DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL,
4711 + DPIO_CMD_ADD_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id);
4713 + /* send command to mc*/
4714 + err = mc_send_command(mc_io, &cmd);
4718 + /* retrieve response parameters */
4719 + DPIO_RSP_ADD_STATIC_DEQUEUE_CHANNEL(cmd, *channel_index);
4724 +int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io,
4725 + uint32_t cmd_flags,
4729 + struct mc_command cmd = { 0 };
4731 + /* prepare command */
4732 + cmd.header = mc_encode_cmd_header(
4733 + DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL,
4736 + DPIO_CMD_REMOVE_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id);
4738 + /* send command to mc*/
4739 + return mc_send_command(mc_io, &cmd);
4741 diff --git a/drivers/net/dpaa2/mc/dpmac.c b/drivers/net/dpaa2/mc/dpmac.c
4742 new file mode 100644
4743 index 0000000..f31d949
4745 +++ b/drivers/net/dpaa2/mc/dpmac.c
4747 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
4749 + * Redistribution and use in source and binary forms, with or without
4750 + * modification, are permitted provided that the following conditions are met:
4751 + * * Redistributions of source code must retain the above copyright
4752 + * notice, this list of conditions and the following disclaimer.
4753 + * * Redistributions in binary form must reproduce the above copyright
4754 + * notice, this list of conditions and the following disclaimer in the
4755 + * documentation and/or other materials provided with the distribution.
4756 + * * Neither the name of the above-listed copyright holders nor the
4757 + * names of any contributors may be used to endorse or promote products
4758 + * derived from this software without specific prior written permission.
4761 + * ALTERNATIVELY, this software may be distributed under the terms of the
4762 + * GNU General Public License ("GPL") as published by the Free Software
4763 + * Foundation, either version 2 of that License or (at your option) any
4766 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4767 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
4768 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
4769 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
4770 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
4771 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
4772 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
4773 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
4774 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
4775 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4776 + * POSSIBILITY OF SUCH DAMAGE.
4778 +#include <fsl_mc_sys.h>
4779 +#include <fsl_mc_cmd.h>
4780 +#include <fsl_dpmac.h>
4781 +#include <fsl_dpmac_cmd.h>
4783 +int dpmac_open(struct fsl_mc_io *mc_io,
4784 + uint32_t cmd_flags,
4788 + struct mc_command cmd = { 0 };
4791 + /* prepare command */
4792 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_OPEN,
4795 + DPMAC_CMD_OPEN(cmd, dpmac_id);
4797 + /* send command to mc*/
4798 + err = mc_send_command(mc_io, &cmd);
4802 + /* retrieve response parameters */
4803 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
4808 +int dpmac_close(struct fsl_mc_io *mc_io,
4809 + uint32_t cmd_flags,
4812 + struct mc_command cmd = { 0 };
4814 + /* prepare command */
4815 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLOSE, cmd_flags,
4818 + /* send command to mc*/
4819 + return mc_send_command(mc_io, &cmd);
4822 +int dpmac_create(struct fsl_mc_io *mc_io,
4823 + uint32_t cmd_flags,
4824 + const struct dpmac_cfg *cfg,
4827 + struct mc_command cmd = { 0 };
4830 + /* prepare command */
4831 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CREATE,
4834 + DPMAC_CMD_CREATE(cmd, cfg);
4836 + /* send command to mc*/
4837 + err = mc_send_command(mc_io, &cmd);
4841 + /* retrieve response parameters */
4842 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
4847 +int dpmac_destroy(struct fsl_mc_io *mc_io,
4848 + uint32_t cmd_flags,
4851 + struct mc_command cmd = { 0 };
4853 + /* prepare command */
4854 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_DESTROY,
4858 + /* send command to mc*/
4859 + return mc_send_command(mc_io, &cmd);
4862 +int dpmac_set_irq(struct fsl_mc_io *mc_io,
4863 + uint32_t cmd_flags,
4865 + uint8_t irq_index,
4866 + struct dpmac_irq_cfg *irq_cfg)
4868 + struct mc_command cmd = { 0 };
4870 + /* prepare command */
4871 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_IRQ,
4874 + DPMAC_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
4876 + /* send command to mc*/
4877 + return mc_send_command(mc_io, &cmd);
4880 +int dpmac_get_irq(struct fsl_mc_io *mc_io,
4881 + uint32_t cmd_flags,
4883 + uint8_t irq_index,
4885 + struct dpmac_irq_cfg *irq_cfg)
4887 + struct mc_command cmd = { 0 };
4890 + /* prepare command */
4891 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ,
4894 + DPMAC_CMD_GET_IRQ(cmd, irq_index);
4896 + /* send command to mc*/
4897 + err = mc_send_command(mc_io, &cmd);
4901 + /* retrieve response parameters */
4902 + DPMAC_RSP_GET_IRQ(cmd, *type, irq_cfg);
4907 +int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
4908 + uint32_t cmd_flags,
4910 + uint8_t irq_index,
4913 + struct mc_command cmd = { 0 };
4915 + /* prepare command */
4916 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_IRQ_ENABLE,
4919 + DPMAC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
4921 + /* send command to mc*/
4922 + return mc_send_command(mc_io, &cmd);
4925 +int dpmac_get_irq_enable(struct fsl_mc_io *mc_io,
4926 + uint32_t cmd_flags,
4928 + uint8_t irq_index,
4931 + struct mc_command cmd = { 0 };
4934 + /* prepare command */
4935 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_ENABLE,
4938 + DPMAC_CMD_GET_IRQ_ENABLE(cmd, irq_index);
4940 + /* send command to mc*/
4941 + err = mc_send_command(mc_io, &cmd);
4945 + /* retrieve response parameters */
4946 + DPMAC_RSP_GET_IRQ_ENABLE(cmd, *en);
4951 +int dpmac_set_irq_mask(struct fsl_mc_io *mc_io,
4952 + uint32_t cmd_flags,
4954 + uint8_t irq_index,
4957 + struct mc_command cmd = { 0 };
4959 + /* prepare command */
4960 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_IRQ_MASK,
4963 + DPMAC_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
4965 + /* send command to mc*/
4966 + return mc_send_command(mc_io, &cmd);
4969 +int dpmac_get_irq_mask(struct fsl_mc_io *mc_io,
4970 + uint32_t cmd_flags,
4972 + uint8_t irq_index,
4975 + struct mc_command cmd = { 0 };
4978 + /* prepare command */
4979 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_MASK,
4982 + DPMAC_CMD_GET_IRQ_MASK(cmd, irq_index);
4984 + /* send command to mc*/
4985 + err = mc_send_command(mc_io, &cmd);
4989 + /* retrieve response parameters */
4990 + DPMAC_RSP_GET_IRQ_MASK(cmd, *mask);
4995 +int dpmac_get_irq_status(struct fsl_mc_io *mc_io,
4996 + uint32_t cmd_flags,
4998 + uint8_t irq_index,
5001 + struct mc_command cmd = { 0 };
5004 + /* prepare command */
5005 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_IRQ_STATUS,
5008 + DPMAC_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
5010 + /* send command to mc*/
5011 + err = mc_send_command(mc_io, &cmd);
5015 + /* retrieve response parameters */
5016 + DPMAC_RSP_GET_IRQ_STATUS(cmd, *status);
5021 +int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
5022 + uint32_t cmd_flags,
5024 + uint8_t irq_index,
5027 + struct mc_command cmd = { 0 };
5029 + /* prepare command */
5030 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_CLEAR_IRQ_STATUS,
5033 + DPMAC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
5035 + /* send command to mc*/
5036 + return mc_send_command(mc_io, &cmd);
5039 +int dpmac_get_attributes(struct fsl_mc_io *mc_io,
5040 + uint32_t cmd_flags,
5042 + struct dpmac_attr *attr)
5044 + struct mc_command cmd = { 0 };
5047 + /* prepare command */
5048 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_ATTR,
5052 + /* send command to mc*/
5053 + err = mc_send_command(mc_io, &cmd);
5057 + /* retrieve response parameters */
5058 + DPMAC_RSP_GET_ATTRIBUTES(cmd, attr);
5063 +int dpmac_mdio_read(struct fsl_mc_io *mc_io,
5064 + uint32_t cmd_flags,
5066 + struct dpmac_mdio_cfg *cfg)
5068 + struct mc_command cmd = { 0 };
5071 + /* prepare command */
5072 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_READ,
5075 + DPMAC_CMD_MDIO_READ(cmd, cfg);
5077 + /* send command to mc*/
5078 + err = mc_send_command(mc_io, &cmd);
5082 + /* retrieve response parameters */
5083 + DPMAC_RSP_MDIO_READ(cmd, cfg->data);
5088 +int dpmac_mdio_write(struct fsl_mc_io *mc_io,
5089 + uint32_t cmd_flags,
5091 + struct dpmac_mdio_cfg *cfg)
5093 + struct mc_command cmd = { 0 };
5095 + /* prepare command */
5096 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_MDIO_WRITE,
5099 + DPMAC_CMD_MDIO_WRITE(cmd, cfg);
5101 + /* send command to mc*/
5102 + return mc_send_command(mc_io, &cmd);
5105 +int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
5106 + uint32_t cmd_flags,
5108 + struct dpmac_link_cfg *cfg)
5110 + struct mc_command cmd = { 0 };
5113 + /* prepare command */
5114 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_LINK_CFG,
5118 + /* send command to mc*/
5119 + err = mc_send_command(mc_io, &cmd);
5123 + DPMAC_RSP_GET_LINK_CFG(cmd, cfg);
5128 +int dpmac_set_link_state(struct fsl_mc_io *mc_io,
5129 + uint32_t cmd_flags,
5131 + struct dpmac_link_state *link_state)
5133 + struct mc_command cmd = { 0 };
5135 + /* prepare command */
5136 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_SET_LINK_STATE,
5139 + DPMAC_CMD_SET_LINK_STATE(cmd, link_state);
5141 + /* send command to mc*/
5142 + return mc_send_command(mc_io, &cmd);
5145 +int dpmac_get_counter(struct fsl_mc_io *mc_io,
5146 + uint32_t cmd_flags,
5148 + enum dpmac_counter type,
5149 + uint64_t *counter)
5151 + struct mc_command cmd = { 0 };
5154 + /* prepare command */
5155 + cmd.header = mc_encode_cmd_header(DPMAC_CMDID_GET_COUNTER,
5158 + DPMAC_CMD_GET_COUNTER(cmd, type);
5160 + /* send command to mc*/
5161 + err = mc_send_command(mc_io, &cmd);
5165 + DPMAC_RSP_GET_COUNTER(cmd, *counter);
5169 diff --git a/drivers/net/dpaa2/mc/dpmcp.c b/drivers/net/dpaa2/mc/dpmcp.c
5170 new file mode 100644
5171 index 0000000..dfd84b8
5173 +++ b/drivers/net/dpaa2/mc/dpmcp.c
5175 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
5177 + * Redistribution and use in source and binary forms, with or without
5178 + * modification, are permitted provided that the following conditions are met:
5179 + * * Redistributions of source code must retain the above copyright
5180 + * notice, this list of conditions and the following disclaimer.
5181 + * * Redistributions in binary form must reproduce the above copyright
5182 + * notice, this list of conditions and the following disclaimer in the
5183 + * documentation and/or other materials provided with the distribution.
5184 + * * Neither the name of the above-listed copyright holders nor the
5185 + * names of any contributors may be used to endorse or promote products
5186 + * derived from this software without specific prior written permission.
5189 + * ALTERNATIVELY, this software may be distributed under the terms of the
5190 + * GNU General Public License ("GPL") as published by the Free Software
5191 + * Foundation, either version 2 of that License or (at your option) any
5194 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5195 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5196 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5197 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
5198 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5199 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5200 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5201 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5202 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5203 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5204 + * POSSIBILITY OF SUCH DAMAGE.
5206 +#include <fsl_mc_sys.h>
5207 +#include <fsl_mc_cmd.h>
5208 +#include <fsl_dpmcp.h>
5209 +#include <fsl_dpmcp_cmd.h>
5211 +int dpmcp_open(struct fsl_mc_io *mc_io,
5212 + uint32_t cmd_flags,
5216 + struct mc_command cmd = { 0 };
5219 + /* prepare command */
5220 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_OPEN,
5223 + DPMCP_CMD_OPEN(cmd, dpmcp_id);
5225 + /* send command to mc*/
5226 + err = mc_send_command(mc_io, &cmd);
5230 + /* retrieve response parameters */
5231 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
5236 +int dpmcp_close(struct fsl_mc_io *mc_io,
5237 + uint32_t cmd_flags,
5240 + struct mc_command cmd = { 0 };
5242 + /* prepare command */
5243 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CLOSE, cmd_flags,
5246 + /* send command to mc*/
5247 + return mc_send_command(mc_io, &cmd);
5250 +int dpmcp_create(struct fsl_mc_io *mc_io,
5251 + uint32_t cmd_flags,
5252 + const struct dpmcp_cfg *cfg,
5255 + struct mc_command cmd = { 0 };
5258 + /* prepare command */
5259 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_CREATE,
5262 + DPMCP_CMD_CREATE(cmd, cfg);
5264 + /* send command to mc*/
5265 + err = mc_send_command(mc_io, &cmd);
5269 + /* retrieve response parameters */
5270 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
5275 +int dpmcp_destroy(struct fsl_mc_io *mc_io,
5276 + uint32_t cmd_flags,
5279 + struct mc_command cmd = { 0 };
5281 + /* prepare command */
5282 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_DESTROY,
5286 + /* send command to mc*/
5287 + return mc_send_command(mc_io, &cmd);
5290 +int dpmcp_reset(struct fsl_mc_io *mc_io,
5291 + uint32_t cmd_flags,
5294 + struct mc_command cmd = { 0 };
5296 + /* prepare command */
5297 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_RESET,
5301 + /* send command to mc*/
5302 + return mc_send_command(mc_io, &cmd);
5305 +int dpmcp_set_irq(struct fsl_mc_io *mc_io,
5306 + uint32_t cmd_flags,
5308 + uint8_t irq_index,
5309 + struct dpmcp_irq_cfg *irq_cfg)
5311 + struct mc_command cmd = { 0 };
5313 + /* prepare command */
5314 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ,
5317 + DPMCP_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
5319 + /* send command to mc*/
5320 + return mc_send_command(mc_io, &cmd);
5323 +int dpmcp_get_irq(struct fsl_mc_io *mc_io,
5324 + uint32_t cmd_flags,
5326 + uint8_t irq_index,
5328 + struct dpmcp_irq_cfg *irq_cfg)
5330 + struct mc_command cmd = { 0 };
5333 + /* prepare command */
5334 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ,
5337 + DPMCP_CMD_GET_IRQ(cmd, irq_index);
5339 + /* send command to mc*/
5340 + err = mc_send_command(mc_io, &cmd);
5344 + /* retrieve response parameters */
5345 + DPMCP_RSP_GET_IRQ(cmd, *type, irq_cfg);
5350 +int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io,
5351 + uint32_t cmd_flags,
5353 + uint8_t irq_index,
5356 + struct mc_command cmd = { 0 };
5358 + /* prepare command */
5359 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_ENABLE,
5362 + DPMCP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
5364 + /* send command to mc*/
5365 + return mc_send_command(mc_io, &cmd);
5368 +int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
5369 + uint32_t cmd_flags,
5371 + uint8_t irq_index,
5374 + struct mc_command cmd = { 0 };
5377 + /* prepare command */
5378 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_ENABLE,
5381 + DPMCP_CMD_GET_IRQ_ENABLE(cmd, irq_index);
5383 + /* send command to mc*/
5384 + err = mc_send_command(mc_io, &cmd);
5388 + /* retrieve response parameters */
5389 + DPMCP_RSP_GET_IRQ_ENABLE(cmd, *en);
5394 +int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io,
5395 + uint32_t cmd_flags,
5397 + uint8_t irq_index,
5400 + struct mc_command cmd = { 0 };
5402 + /* prepare command */
5403 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_SET_IRQ_MASK,
5406 + DPMCP_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
5408 + /* send command to mc*/
5409 + return mc_send_command(mc_io, &cmd);
5412 +int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
5413 + uint32_t cmd_flags,
5415 + uint8_t irq_index,
5418 + struct mc_command cmd = { 0 };
5421 + /* prepare command */
5422 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_MASK,
5425 + DPMCP_CMD_GET_IRQ_MASK(cmd, irq_index);
5427 + /* send command to mc*/
5428 + err = mc_send_command(mc_io, &cmd);
5432 + /* retrieve response parameters */
5433 + DPMCP_RSP_GET_IRQ_MASK(cmd, *mask);
5438 +int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
5439 + uint32_t cmd_flags,
5441 + uint8_t irq_index,
5444 + struct mc_command cmd = { 0 };
5447 + /* prepare command */
5448 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_IRQ_STATUS,
5451 + DPMCP_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
5453 + /* send command to mc*/
5454 + err = mc_send_command(mc_io, &cmd);
5458 + /* retrieve response parameters */
5459 + DPMCP_RSP_GET_IRQ_STATUS(cmd, *status);
5464 +int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
5465 + uint32_t cmd_flags,
5467 + struct dpmcp_attr *attr)
5469 + struct mc_command cmd = { 0 };
5472 + /* prepare command */
5473 + cmd.header = mc_encode_cmd_header(DPMCP_CMDID_GET_ATTR,
5477 + /* send command to mc*/
5478 + err = mc_send_command(mc_io, &cmd);
5482 + /* retrieve response parameters */
5483 + DPMCP_RSP_GET_ATTRIBUTES(cmd, attr);
5487 diff --git a/drivers/net/dpaa2/mc/dpmng.c b/drivers/net/dpaa2/mc/dpmng.c
5488 new file mode 100644
5489 index 0000000..cac5ba5
5491 +++ b/drivers/net/dpaa2/mc/dpmng.c
5493 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
5495 + * Redistribution and use in source and binary forms, with or without
5496 + * modification, are permitted provided that the following conditions are met:
5497 + * * Redistributions of source code must retain the above copyright
5498 + * notice, this list of conditions and the following disclaimer.
5499 + * * Redistributions in binary form must reproduce the above copyright
5500 + * notice, this list of conditions and the following disclaimer in the
5501 + * documentation and/or other materials provided with the distribution.
5502 + * * Neither the name of the above-listed copyright holders nor the
5503 + * names of any contributors may be used to endorse or promote products
5504 + * derived from this software without specific prior written permission.
5507 + * ALTERNATIVELY, this software may be distributed under the terms of the
5508 + * GNU General Public License ("GPL") as published by the Free Software
5509 + * Foundation, either version 2 of that License or (at your option) any
5512 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5513 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5514 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5515 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
5516 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5517 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5518 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5519 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5520 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5521 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5522 + * POSSIBILITY OF SUCH DAMAGE.
5524 +#include <fsl_mc_sys.h>
5525 +#include <fsl_mc_cmd.h>
5526 +#include <fsl_dpmng.h>
5527 +#include <fsl_dpmng_cmd.h>
5529 +int mc_get_version(struct fsl_mc_io *mc_io,
5530 + uint32_t cmd_flags,
5531 + struct mc_version *mc_ver_info)
5533 + struct mc_command cmd = { 0 };
5536 + /* prepare command */
5537 + cmd.header = mc_encode_cmd_header(DPMNG_CMDID_GET_VERSION,
5541 + /* send command to mc*/
5542 + err = mc_send_command(mc_io, &cmd);
5546 + /* retrieve response parameters */
5547 + DPMNG_RSP_GET_VERSION(cmd, mc_ver_info);
5551 diff --git a/drivers/net/dpaa2/mc/dpni.c b/drivers/net/dpaa2/mc/dpni.c
5552 new file mode 100644
5553 index 0000000..cdd2f37
5555 +++ b/drivers/net/dpaa2/mc/dpni.c
5557 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
5559 + * Redistribution and use in source and binary forms, with or without
5560 + * modification, are permitted provided that the following conditions are met:
5561 + * * Redistributions of source code must retain the above copyright
5562 + * notice, this list of conditions and the following disclaimer.
5563 + * * Redistributions in binary form must reproduce the above copyright
5564 + * notice, this list of conditions and the following disclaimer in the
5565 + * documentation and/or other materials provided with the distribution.
5566 + * * Neither the name of the above-listed copyright holders nor the
5567 + * names of any contributors may be used to endorse or promote products
5568 + * derived from this software without specific prior written permission.
5571 + * ALTERNATIVELY, this software may be distributed under the terms of the
5572 + * GNU General Public License ("GPL") as published by the Free Software
5573 + * Foundation, either version 2 of that License or (at your option) any
5576 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5577 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5578 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
5579 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
5580 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
5581 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
5582 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
5583 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
5584 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
5585 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
5586 + * POSSIBILITY OF SUCH DAMAGE.
5588 +#include <fsl_mc_sys.h>
5589 +#include <fsl_mc_cmd.h>
5590 +#include <fsl_dpni.h>
5591 +#include <fsl_dpni_cmd.h>
5593 +int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
5594 + uint8_t *key_cfg_buf)
5599 + uint64_t *params = (uint64_t *)key_cfg_buf;
5601 + if (!key_cfg_buf || !cfg)
5604 + params[0] |= mc_enc(0, 8, cfg->num_extracts);
5605 + params[0] = cpu_to_le64(params[0]);
5607 + if (cfg->num_extracts >= DPKG_MAX_NUM_OF_EXTRACTS)
5610 + for (i = 0; i < cfg->num_extracts; i++) {
5611 + switch (cfg->extracts[i].type) {
5612 + case DPKG_EXTRACT_FROM_HDR:
5613 + params[param] |= mc_enc(0, 8,
5614 + cfg->extracts[i].extract.from_hdr.prot);
5615 + params[param] |= mc_enc(8, 4,
5616 + cfg->extracts[i].extract.from_hdr.type);
5617 + params[param] |= mc_enc(16, 8,
5618 + cfg->extracts[i].extract.from_hdr.size);
5619 + params[param] |= mc_enc(24, 8,
5620 + cfg->extracts[i].extract.
5622 + params[param] |= mc_enc(32, 32,
5623 + cfg->extracts[i].extract.
5625 + params[param] = cpu_to_le64(params[param]);
5627 + params[param] |= mc_enc(0, 8,
5628 + cfg->extracts[i].extract.
5629 + from_hdr.hdr_index);
5631 + case DPKG_EXTRACT_FROM_DATA:
5632 + params[param] |= mc_enc(16, 8,
5633 + cfg->extracts[i].extract.
5635 + params[param] |= mc_enc(24, 8,
5636 + cfg->extracts[i].extract.
5637 + from_data.offset);
5638 + params[param] = cpu_to_le64(params[param]);
5641 + case DPKG_EXTRACT_FROM_PARSE:
5642 + params[param] |= mc_enc(16, 8,
5643 + cfg->extracts[i].extract.
5645 + params[param] |= mc_enc(24, 8,
5646 + cfg->extracts[i].extract.
5647 + from_parse.offset);
5648 + params[param] = cpu_to_le64(params[param]);
5654 + params[param] |= mc_enc(
5655 + 24, 8, cfg->extracts[i].num_of_byte_masks);
5656 + params[param] |= mc_enc(32, 4, cfg->extracts[i].type);
5657 + params[param] = cpu_to_le64(params[param]);
5659 + for (offset = 0, j = 0;
5660 + j < DPKG_NUM_OF_MASKS;
5661 + offset += 16, j++) {
5662 + params[param] |= mc_enc(
5663 + (offset), 8, cfg->extracts[i].masks[j].mask);
5664 + params[param] |= mc_enc(
5666 + cfg->extracts[i].masks[j].offset);
5668 + params[param] = cpu_to_le64(params[param]);
5674 +int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg,
5675 + uint8_t *ext_cfg_buf)
5677 + uint64_t *ext_params = (uint64_t *)ext_cfg_buf;
5679 + DPNI_PREP_EXTENDED_CFG(ext_params, cfg);
5684 +int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg,
5685 + const uint8_t *ext_cfg_buf)
5687 + const uint64_t *ext_params = (const uint64_t *)ext_cfg_buf;
5689 + DPNI_EXT_EXTENDED_CFG(ext_params, cfg);
5694 +int dpni_open(struct fsl_mc_io *mc_io,
5695 + uint32_t cmd_flags,
5699 + struct mc_command cmd = { 0 };
5702 + /* prepare command */
5703 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_OPEN,
5706 + DPNI_CMD_OPEN(cmd, dpni_id);
5708 + /* send command to mc*/
5709 + err = mc_send_command(mc_io, &cmd);
5713 + /* retrieve response parameters */
5714 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
5719 +int dpni_close(struct fsl_mc_io *mc_io,
5720 + uint32_t cmd_flags,
5723 + struct mc_command cmd = { 0 };
5725 + /* prepare command */
5726 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLOSE,
5730 + /* send command to mc*/
5731 + return mc_send_command(mc_io, &cmd);
5734 +int dpni_create(struct fsl_mc_io *mc_io,
5735 + uint32_t cmd_flags,
5736 + const struct dpni_cfg *cfg,
5739 + struct mc_command cmd = { 0 };
5742 + /* prepare command */
5743 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CREATE,
5746 + DPNI_CMD_CREATE(cmd, cfg);
5748 + /* send command to mc*/
5749 + err = mc_send_command(mc_io, &cmd);
5753 + /* retrieve response parameters */
5754 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
5759 +int dpni_destroy(struct fsl_mc_io *mc_io,
5760 + uint32_t cmd_flags,
5763 + struct mc_command cmd = { 0 };
5765 + /* prepare command */
5766 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_DESTROY,
5770 + /* send command to mc*/
5771 + return mc_send_command(mc_io, &cmd);
5774 +int dpni_set_pools(struct fsl_mc_io *mc_io,
5775 + uint32_t cmd_flags,
5777 + const struct dpni_pools_cfg *cfg)
5779 + struct mc_command cmd = { 0 };
5781 + /* prepare command */
5782 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_POOLS,
5785 + DPNI_CMD_SET_POOLS(cmd, cfg);
5787 + /* send command to mc*/
5788 + return mc_send_command(mc_io, &cmd);
5791 +int dpni_enable(struct fsl_mc_io *mc_io,
5792 + uint32_t cmd_flags,
5795 + struct mc_command cmd = { 0 };
5797 + /* prepare command */
5798 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ENABLE,
5802 + /* send command to mc*/
5803 + return mc_send_command(mc_io, &cmd);
5806 +int dpni_disable(struct fsl_mc_io *mc_io,
5807 + uint32_t cmd_flags,
5810 + struct mc_command cmd = { 0 };
5812 + /* prepare command */
5813 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_DISABLE,
5817 + /* send command to mc*/
5818 + return mc_send_command(mc_io, &cmd);
5821 +int dpni_is_enabled(struct fsl_mc_io *mc_io,
5822 + uint32_t cmd_flags,
5826 + struct mc_command cmd = { 0 };
5828 + /* prepare command */
5829 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_IS_ENABLED, cmd_flags,
5832 + /* send command to mc*/
5833 + err = mc_send_command(mc_io, &cmd);
5837 + /* retrieve response parameters */
5838 + DPNI_RSP_IS_ENABLED(cmd, *en);
5843 +int dpni_reset(struct fsl_mc_io *mc_io,
5844 + uint32_t cmd_flags,
5847 + struct mc_command cmd = { 0 };
5849 + /* prepare command */
5850 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_RESET,
5854 + /* send command to mc*/
5855 + return mc_send_command(mc_io, &cmd);
5858 +int dpni_set_irq(struct fsl_mc_io *mc_io,
5859 + uint32_t cmd_flags,
5861 + uint8_t irq_index,
5862 + struct dpni_irq_cfg *irq_cfg)
5864 + struct mc_command cmd = { 0 };
5866 + /* prepare command */
5867 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ,
5870 + DPNI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
5872 + /* send command to mc*/
5873 + return mc_send_command(mc_io, &cmd);
5876 +int dpni_get_irq(struct fsl_mc_io *mc_io,
5877 + uint32_t cmd_flags,
5879 + uint8_t irq_index,
5881 + struct dpni_irq_cfg *irq_cfg)
5883 + struct mc_command cmd = { 0 };
5886 + /* prepare command */
5887 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ,
5890 + DPNI_CMD_GET_IRQ(cmd, irq_index);
5892 + /* send command to mc*/
5893 + err = mc_send_command(mc_io, &cmd);
5897 + /* retrieve response parameters */
5898 + DPNI_RSP_GET_IRQ(cmd, *type, irq_cfg);
5903 +int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
5904 + uint32_t cmd_flags,
5906 + uint8_t irq_index,
5909 + struct mc_command cmd = { 0 };
5911 + /* prepare command */
5912 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_ENABLE,
5915 + DPNI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
5917 + /* send command to mc*/
5918 + return mc_send_command(mc_io, &cmd);
5921 +int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
5922 + uint32_t cmd_flags,
5924 + uint8_t irq_index,
5927 + struct mc_command cmd = { 0 };
5930 + /* prepare command */
5931 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_ENABLE,
5934 + DPNI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
5936 + /* send command to mc*/
5937 + err = mc_send_command(mc_io, &cmd);
5941 + /* retrieve response parameters */
5942 + DPNI_RSP_GET_IRQ_ENABLE(cmd, *en);
5947 +int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
5948 + uint32_t cmd_flags,
5950 + uint8_t irq_index,
5953 + struct mc_command cmd = { 0 };
5955 + /* prepare command */
5956 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IRQ_MASK,
5959 + DPNI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
5961 + /* send command to mc*/
5962 + return mc_send_command(mc_io, &cmd);
5965 +int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
5966 + uint32_t cmd_flags,
5968 + uint8_t irq_index,
5971 + struct mc_command cmd = { 0 };
5974 + /* prepare command */
5975 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_MASK,
5978 + DPNI_CMD_GET_IRQ_MASK(cmd, irq_index);
5980 + /* send command to mc*/
5981 + err = mc_send_command(mc_io, &cmd);
5985 + /* retrieve response parameters */
5986 + DPNI_RSP_GET_IRQ_MASK(cmd, *mask);
5991 +int dpni_get_irq_status(struct fsl_mc_io *mc_io,
5992 + uint32_t cmd_flags,
5994 + uint8_t irq_index,
5997 + struct mc_command cmd = { 0 };
6000 + /* prepare command */
6001 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_IRQ_STATUS,
6004 + DPNI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
6006 + /* send command to mc*/
6007 + err = mc_send_command(mc_io, &cmd);
6011 + /* retrieve response parameters */
6012 + DPNI_RSP_GET_IRQ_STATUS(cmd, *status);
6017 +int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
6018 + uint32_t cmd_flags,
6020 + uint8_t irq_index,
6023 + struct mc_command cmd = { 0 };
6025 + /* prepare command */
6026 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLEAR_IRQ_STATUS,
6029 + DPNI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
6031 + /* send command to mc*/
6032 + return mc_send_command(mc_io, &cmd);
6035 +int dpni_get_attributes(struct fsl_mc_io *mc_io,
6036 + uint32_t cmd_flags,
6038 + struct dpni_attr *attr)
6040 + struct mc_command cmd = { 0 };
6043 + /* prepare command */
6044 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_ATTR,
6047 + DPNI_CMD_GET_ATTR(cmd, attr);
6049 + /* send command to mc*/
6050 + err = mc_send_command(mc_io, &cmd);
6054 + /* retrieve response parameters */
6055 + DPNI_RSP_GET_ATTR(cmd, attr);
6060 +int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
6061 + uint32_t cmd_flags,
6063 + struct dpni_error_cfg *cfg)
6065 + struct mc_command cmd = { 0 };
6067 + /* prepare command */
6068 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_ERRORS_BEHAVIOR,
6071 + DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg);
6073 + /* send command to mc*/
6074 + return mc_send_command(mc_io, &cmd);
6077 +int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
6078 + uint32_t cmd_flags,
6080 + struct dpni_buffer_layout *layout)
6082 + struct mc_command cmd = { 0 };
6085 + /* prepare command */
6086 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_BUFFER_LAYOUT,
6090 + /* send command to mc*/
6091 + err = mc_send_command(mc_io, &cmd);
6095 + /* retrieve response parameters */
6096 + DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout);
6101 +int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
6102 + uint32_t cmd_flags,
6104 + const struct dpni_buffer_layout *layout)
6106 + struct mc_command cmd = { 0 };
6108 + /* prepare command */
6109 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_BUFFER_LAYOUT,
6112 + DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout);
6114 + /* send command to mc*/
6115 + return mc_send_command(mc_io, &cmd);
6118 +int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
6119 + uint32_t cmd_flags,
6121 + struct dpni_buffer_layout *layout)
6123 + struct mc_command cmd = { 0 };
6126 + /* prepare command */
6127 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_BUFFER_LAYOUT,
6131 + /* send command to mc*/
6132 + err = mc_send_command(mc_io, &cmd);
6136 + /* retrieve response parameters */
6137 + DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout);
6142 +int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
6143 + uint32_t cmd_flags,
6145 + const struct dpni_buffer_layout *layout)
6147 + struct mc_command cmd = { 0 };
6149 + /* prepare command */
6150 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_BUFFER_LAYOUT,
6153 + DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout);
6155 + /* send command to mc*/
6156 + return mc_send_command(mc_io, &cmd);
6159 +int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
6160 + uint32_t cmd_flags,
6162 + struct dpni_buffer_layout *layout)
6164 + struct mc_command cmd = { 0 };
6167 + /* prepare command */
6168 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT,
6172 + /* send command to mc*/
6173 + err = mc_send_command(mc_io, &cmd);
6177 + /* retrieve response parameters */
6178 + DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
6183 +int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
6184 + uint32_t cmd_flags,
6186 + const struct dpni_buffer_layout *layout)
6188 + struct mc_command cmd = { 0 };
6190 + /* prepare command */
6191 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT,
6194 + DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout);
6196 + /* send command to mc*/
6197 + return mc_send_command(mc_io, &cmd);
6200 +int dpni_get_l3_chksum_validation(struct fsl_mc_io *mc_io,
6201 + uint32_t cmd_flags,
6205 + struct mc_command cmd = { 0 };
6208 + /* prepare command */
6209 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_L3_CHKSUM_VALIDATION,
6213 + /* send command to mc*/
6214 + err = mc_send_command(mc_io, &cmd);
6218 + /* retrieve response parameters */
6219 + DPNI_RSP_GET_L3_CHKSUM_VALIDATION(cmd, *en);
6224 +int dpni_set_l3_chksum_validation(struct fsl_mc_io *mc_io,
6225 + uint32_t cmd_flags,
6229 + struct mc_command cmd = { 0 };
6231 + /* prepare command */
6232 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_L3_CHKSUM_VALIDATION,
6235 + DPNI_CMD_SET_L3_CHKSUM_VALIDATION(cmd, en);
6237 + /* send command to mc*/
6238 + return mc_send_command(mc_io, &cmd);
6241 +int dpni_get_l4_chksum_validation(struct fsl_mc_io *mc_io,
6242 + uint32_t cmd_flags,
6246 + struct mc_command cmd = { 0 };
6249 + /* prepare command */
6250 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_L4_CHKSUM_VALIDATION,
6254 + /* send command to mc*/
6255 + err = mc_send_command(mc_io, &cmd);
6259 + /* retrieve response parameters */
6260 + DPNI_RSP_GET_L4_CHKSUM_VALIDATION(cmd, *en);
6265 +int dpni_set_l4_chksum_validation(struct fsl_mc_io *mc_io,
6266 + uint32_t cmd_flags,
6270 + struct mc_command cmd = { 0 };
6272 + /* prepare command */
6273 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_L4_CHKSUM_VALIDATION,
6276 + DPNI_CMD_SET_L4_CHKSUM_VALIDATION(cmd, en);
6278 + /* send command to mc*/
6279 + return mc_send_command(mc_io, &cmd);
6282 +int dpni_get_qdid(struct fsl_mc_io *mc_io,
6283 + uint32_t cmd_flags,
6287 + struct mc_command cmd = { 0 };
6290 + /* prepare command */
6291 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_QDID,
6295 + /* send command to mc*/
6296 + err = mc_send_command(mc_io, &cmd);
6300 + /* retrieve response parameters */
6301 + DPNI_RSP_GET_QDID(cmd, *qdid);
6306 +int dpni_get_sp_info(struct fsl_mc_io *mc_io,
6307 + uint32_t cmd_flags,
6309 + struct dpni_sp_info *sp_info)
6311 + struct mc_command cmd = { 0 };
6314 + /* prepare command */
6315 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_SP_INFO,
6319 + /* send command to mc*/
6320 + err = mc_send_command(mc_io, &cmd);
6324 + /* retrieve response parameters */
6325 + DPNI_RSP_GET_SP_INFO(cmd, sp_info);
6330 +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
6331 + uint32_t cmd_flags,
6333 + uint16_t *data_offset)
6335 + struct mc_command cmd = { 0 };
6338 + /* prepare command */
6339 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_DATA_OFFSET,
6343 + /* send command to mc*/
6344 + err = mc_send_command(mc_io, &cmd);
6348 + /* retrieve response parameters */
6349 + DPNI_RSP_GET_TX_DATA_OFFSET(cmd, *data_offset);
6354 +int dpni_get_counter(struct fsl_mc_io *mc_io,
6355 + uint32_t cmd_flags,
6357 + enum dpni_counter counter,
6360 + struct mc_command cmd = { 0 };
6363 + /* prepare command */
6364 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_COUNTER,
6367 + DPNI_CMD_GET_COUNTER(cmd, counter);
6369 + /* send command to mc*/
6370 + err = mc_send_command(mc_io, &cmd);
6374 + /* retrieve response parameters */
6375 + DPNI_RSP_GET_COUNTER(cmd, *value);
6380 +int dpni_set_counter(struct fsl_mc_io *mc_io,
6381 + uint32_t cmd_flags,
6383 + enum dpni_counter counter,
6386 + struct mc_command cmd = { 0 };
6388 + /* prepare command */
6389 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_COUNTER,
6392 + DPNI_CMD_SET_COUNTER(cmd, counter, value);
6394 + /* send command to mc*/
6395 + return mc_send_command(mc_io, &cmd);
6398 +int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
6399 + uint32_t cmd_flags,
6401 + const struct dpni_link_cfg *cfg)
6403 + struct mc_command cmd = { 0 };
6405 + /* prepare command */
6406 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_LINK_CFG,
6409 + DPNI_CMD_SET_LINK_CFG(cmd, cfg);
6411 + /* send command to mc*/
6412 + return mc_send_command(mc_io, &cmd);
6415 +int dpni_get_link_state(struct fsl_mc_io *mc_io,
6416 + uint32_t cmd_flags,
6418 + struct dpni_link_state *state)
6420 + struct mc_command cmd = { 0 };
6423 + /* prepare command */
6424 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_LINK_STATE,
6428 + /* send command to mc*/
6429 + err = mc_send_command(mc_io, &cmd);
6433 + /* retrieve response parameters */
6434 + DPNI_RSP_GET_LINK_STATE(cmd, state);
6439 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
6440 + uint32_t cmd_flags,
6442 + const struct dpni_tx_shaping_cfg *tx_shaper)
6444 + struct mc_command cmd = { 0 };
6446 + /* prepare command */
6447 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_SHAPING,
6450 + DPNI_CMD_SET_TX_SHAPING(cmd, tx_shaper);
6452 + /* send command to mc*/
6453 + return mc_send_command(mc_io, &cmd);
6456 +int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
6457 + uint32_t cmd_flags,
6459 + uint16_t max_frame_length)
6461 + struct mc_command cmd = { 0 };
6463 + /* prepare command */
6464 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MAX_FRAME_LENGTH,
6467 + DPNI_CMD_SET_MAX_FRAME_LENGTH(cmd, max_frame_length);
6469 + /* send command to mc*/
6470 + return mc_send_command(mc_io, &cmd);
6473 +int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
6474 + uint32_t cmd_flags,
6476 + uint16_t *max_frame_length)
6478 + struct mc_command cmd = { 0 };
6481 + /* prepare command */
6482 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MAX_FRAME_LENGTH,
6486 + /* send command to mc*/
6487 + err = mc_send_command(mc_io, &cmd);
6491 + /* retrieve response parameters */
6492 + DPNI_RSP_GET_MAX_FRAME_LENGTH(cmd, *max_frame_length);
6497 +int dpni_set_mtu(struct fsl_mc_io *mc_io,
6498 + uint32_t cmd_flags,
6502 + struct mc_command cmd = { 0 };
6504 + /* prepare command */
6505 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MTU,
6508 + DPNI_CMD_SET_MTU(cmd, mtu);
6510 + /* send command to mc*/
6511 + return mc_send_command(mc_io, &cmd);
6514 +int dpni_get_mtu(struct fsl_mc_io *mc_io,
6515 + uint32_t cmd_flags,
6519 + struct mc_command cmd = { 0 };
6522 + /* prepare command */
6523 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MTU,
6527 + /* send command to mc*/
6528 + err = mc_send_command(mc_io, &cmd);
6532 + /* retrieve response parameters */
6533 + DPNI_RSP_GET_MTU(cmd, *mtu);
6538 +int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
6539 + uint32_t cmd_flags,
6543 + struct mc_command cmd = { 0 };
6545 + /* prepare command */
6546 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_MCAST_PROMISC,
6549 + DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en);
6551 + /* send command to mc*/
6552 + return mc_send_command(mc_io, &cmd);
6555 +int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
6556 + uint32_t cmd_flags,
6560 + struct mc_command cmd = { 0 };
6563 + /* prepare command */
6564 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_MCAST_PROMISC,
6568 + /* send command to mc*/
6569 + err = mc_send_command(mc_io, &cmd);
6573 + /* retrieve response parameters */
6574 + DPNI_RSP_GET_MULTICAST_PROMISC(cmd, *en);
6579 +int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
6580 + uint32_t cmd_flags,
6584 + struct mc_command cmd = { 0 };
6586 + /* prepare command */
6587 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_UNICAST_PROMISC,
6590 + DPNI_CMD_SET_UNICAST_PROMISC(cmd, en);
6592 + /* send command to mc*/
6593 + return mc_send_command(mc_io, &cmd);
6596 +int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
6597 + uint32_t cmd_flags,
6601 + struct mc_command cmd = { 0 };
6604 + /* prepare command */
6605 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_UNICAST_PROMISC,
6609 + /* send command to mc*/
6610 + err = mc_send_command(mc_io, &cmd);
6614 + /* retrieve response parameters */
6615 + DPNI_RSP_GET_UNICAST_PROMISC(cmd, *en);
6620 +int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
6621 + uint32_t cmd_flags,
6623 + const uint8_t mac_addr[6])
6625 + struct mc_command cmd = { 0 };
6627 + /* prepare command */
6628 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_PRIM_MAC,
6631 + DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr);
6633 + /* send command to mc*/
6634 + return mc_send_command(mc_io, &cmd);
6637 +int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
6638 + uint32_t cmd_flags,
6640 + uint8_t mac_addr[6])
6642 + struct mc_command cmd = { 0 };
6645 + /* prepare command */
6646 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_PRIM_MAC,
6650 + /* send command to mc*/
6651 + err = mc_send_command(mc_io, &cmd);
6655 + /* retrieve response parameters */
6656 + DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr);
6661 +int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
6662 + uint32_t cmd_flags,
6664 + const uint8_t mac_addr[6])
6666 + struct mc_command cmd = { 0 };
6668 + /* prepare command */
6669 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_MAC_ADDR,
6672 + DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr);
6674 + /* send command to mc*/
6675 + return mc_send_command(mc_io, &cmd);
6678 +int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
6679 + uint32_t cmd_flags,
6681 + const uint8_t mac_addr[6])
6683 + struct mc_command cmd = { 0 };
6685 + /* prepare command */
6686 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_MAC_ADDR,
6689 + DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr);
6691 + /* send command to mc*/
6692 + return mc_send_command(mc_io, &cmd);
6695 +int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
6696 + uint32_t cmd_flags,
6701 + struct mc_command cmd = { 0 };
6703 + /* prepare command */
6704 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_MAC_FILTERS,
6707 + DPNI_CMD_CLEAR_MAC_FILTERS(cmd, unicast, multicast);
6709 + /* send command to mc*/
6710 + return mc_send_command(mc_io, &cmd);
6713 +int dpni_set_vlan_filters(struct fsl_mc_io *mc_io,
6714 + uint32_t cmd_flags,
6718 + struct mc_command cmd = { 0 };
6720 + /* prepare command */
6721 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_VLAN_FILTERS,
6724 + DPNI_CMD_SET_VLAN_FILTERS(cmd, en);
6726 + /* send command to mc*/
6727 + return mc_send_command(mc_io, &cmd);
6730 +int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
6731 + uint32_t cmd_flags,
6735 + struct mc_command cmd = { 0 };
6737 + /* prepare command */
6738 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_VLAN_ID,
6741 + DPNI_CMD_ADD_VLAN_ID(cmd, vlan_id);
6743 + /* send command to mc*/
6744 + return mc_send_command(mc_io, &cmd);
6747 +int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
6748 + uint32_t cmd_flags,
6752 + struct mc_command cmd = { 0 };
6754 + /* prepare command */
6755 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_VLAN_ID,
6758 + DPNI_CMD_REMOVE_VLAN_ID(cmd, vlan_id);
6760 + /* send command to mc*/
6761 + return mc_send_command(mc_io, &cmd);
6764 +int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
6765 + uint32_t cmd_flags,
6768 + struct mc_command cmd = { 0 };
6770 + /* prepare command */
6771 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_VLAN_FILTERS,
6775 + /* send command to mc*/
6776 + return mc_send_command(mc_io, &cmd);
6779 +int dpni_set_tx_selection(struct fsl_mc_io *mc_io,
6780 + uint32_t cmd_flags,
6782 + const struct dpni_tx_selection_cfg *cfg)
6784 + struct mc_command cmd = { 0 };
6786 + /* prepare command */
6787 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_SELECTION,
6790 + DPNI_CMD_SET_TX_SELECTION(cmd, cfg);
6792 + /* send command to mc*/
6793 + return mc_send_command(mc_io, &cmd);
6796 +int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
6797 + uint32_t cmd_flags,
6800 + const struct dpni_rx_tc_dist_cfg *cfg)
6802 + struct mc_command cmd = { 0 };
6804 + /* prepare command */
6805 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_DIST,
6808 + DPNI_CMD_SET_RX_TC_DIST(cmd, tc_id, cfg);
6810 + /* send command to mc*/
6811 + return mc_send_command(mc_io, &cmd);
6814 +int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
6815 + uint32_t cmd_flags,
6817 + uint16_t *flow_id,
6818 + const struct dpni_tx_flow_cfg *cfg)
6820 + struct mc_command cmd = { 0 };
6823 + /* prepare command */
6824 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_FLOW,
6827 + DPNI_CMD_SET_TX_FLOW(cmd, *flow_id, cfg);
6829 + /* send command to mc*/
6830 + err = mc_send_command(mc_io, &cmd);
6834 + /* retrieve response parameters */
6835 + DPNI_RSP_SET_TX_FLOW(cmd, *flow_id);
6840 +int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
6841 + uint32_t cmd_flags,
6844 + struct dpni_tx_flow_attr *attr)
6846 + struct mc_command cmd = { 0 };
6849 + /* prepare command */
6850 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_FLOW,
6853 + DPNI_CMD_GET_TX_FLOW(cmd, flow_id);
6855 + /* send command to mc*/
6856 + err = mc_send_command(mc_io, &cmd);
6860 + /* retrieve response parameters */
6861 + DPNI_RSP_GET_TX_FLOW(cmd, attr);
6866 +int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
6867 + uint32_t cmd_flags,
6871 + const struct dpni_queue_cfg *cfg)
6873 + struct mc_command cmd = { 0 };
6875 + /* prepare command */
6876 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_FLOW,
6879 + DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg);
6881 + /* send command to mc*/
6882 + return mc_send_command(mc_io, &cmd);
6885 +int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
6886 + uint32_t cmd_flags,
6890 + struct dpni_queue_attr *attr)
6892 + struct mc_command cmd = { 0 };
6894 + /* prepare command */
6895 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_FLOW,
6898 + DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id);
6900 + /* send command to mc*/
6901 + err = mc_send_command(mc_io, &cmd);
6905 + /* retrieve response parameters */
6906 + DPNI_RSP_GET_RX_FLOW(cmd, attr);
6911 +int dpni_set_rx_err_queue(struct fsl_mc_io *mc_io,
6912 + uint32_t cmd_flags,
6914 + const struct dpni_queue_cfg *cfg)
6916 + struct mc_command cmd = { 0 };
6918 + /* prepare command */
6919 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_ERR_QUEUE,
6922 + DPNI_CMD_SET_RX_ERR_QUEUE(cmd, cfg);
6924 + /* send command to mc*/
6925 + return mc_send_command(mc_io, &cmd);
6928 +int dpni_get_rx_err_queue(struct fsl_mc_io *mc_io,
6929 + uint32_t cmd_flags,
6931 + struct dpni_queue_attr *attr)
6933 + struct mc_command cmd = { 0 };
6936 + /* prepare command */
6937 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_ERR_QUEUE,
6941 + /* send command to mc*/
6942 + err = mc_send_command(mc_io, &cmd);
6946 + /* retrieve response parameters */
6947 + DPNI_RSP_GET_RX_ERR_QUEUE(cmd, attr);
6952 +int dpni_set_tx_conf_revoke(struct fsl_mc_io *mc_io,
6953 + uint32_t cmd_flags,
6957 + struct mc_command cmd = { 0 };
6959 + /* prepare command */
6960 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF_REVOKE,
6963 + DPNI_CMD_SET_TX_CONF_REVOKE(cmd, revoke);
6965 + /* send command to mc*/
6966 + return mc_send_command(mc_io, &cmd);
6969 +int dpni_set_qos_table(struct fsl_mc_io *mc_io,
6970 + uint32_t cmd_flags,
6972 + const struct dpni_qos_tbl_cfg *cfg)
6974 + struct mc_command cmd = { 0 };
6976 + /* prepare command */
6977 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_QOS_TBL,
6980 + DPNI_CMD_SET_QOS_TABLE(cmd, cfg);
6982 + /* send command to mc*/
6983 + return mc_send_command(mc_io, &cmd);
6986 +int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
6987 + uint32_t cmd_flags,
6989 + const struct dpni_rule_cfg *cfg,
6992 + struct mc_command cmd = { 0 };
6994 + /* prepare command */
6995 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_QOS_ENT,
6998 + DPNI_CMD_ADD_QOS_ENTRY(cmd, cfg, tc_id);
7000 + /* send command to mc*/
7001 + return mc_send_command(mc_io, &cmd);
7004 +int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
7005 + uint32_t cmd_flags,
7007 + const struct dpni_rule_cfg *cfg)
7009 + struct mc_command cmd = { 0 };
7011 + /* prepare command */
7012 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_QOS_ENT,
7015 + DPNI_CMD_REMOVE_QOS_ENTRY(cmd, cfg);
7017 + /* send command to mc*/
7018 + return mc_send_command(mc_io, &cmd);
7021 +int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
7022 + uint32_t cmd_flags,
7025 + struct mc_command cmd = { 0 };
7027 + /* prepare command */
7028 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_QOS_TBL,
7032 + /* send command to mc*/
7033 + return mc_send_command(mc_io, &cmd);
7036 +int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
7037 + uint32_t cmd_flags,
7040 + const struct dpni_rule_cfg *cfg,
7043 + struct mc_command cmd = { 0 };
7045 + /* prepare command */
7046 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_ADD_FS_ENT,
7049 + DPNI_CMD_ADD_FS_ENTRY(cmd, tc_id, cfg, flow_id);
7051 + /* send command to mc*/
7052 + return mc_send_command(mc_io, &cmd);
7055 +int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
7056 + uint32_t cmd_flags,
7059 + const struct dpni_rule_cfg *cfg)
7061 + struct mc_command cmd = { 0 };
7063 + /* prepare command */
7064 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_REMOVE_FS_ENT,
7067 + DPNI_CMD_REMOVE_FS_ENTRY(cmd, tc_id, cfg);
7069 + /* send command to mc*/
7070 + return mc_send_command(mc_io, &cmd);
7073 +int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
7074 + uint32_t cmd_flags,
7078 + struct mc_command cmd = { 0 };
7080 + /* prepare command */
7081 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_CLR_FS_ENT,
7084 + DPNI_CMD_CLEAR_FS_ENTRIES(cmd, tc_id);
7086 + /* send command to mc*/
7087 + return mc_send_command(mc_io, &cmd);
7090 +int dpni_set_vlan_insertion(struct fsl_mc_io *mc_io,
7091 + uint32_t cmd_flags,
7095 + struct mc_command cmd = { 0 };
7097 + /* prepare command */
7098 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_VLAN_INSERTION,
7099 + cmd_flags, token);
7100 + DPNI_CMD_SET_VLAN_INSERTION(cmd, en);
7102 + /* send command to mc*/
7103 + return mc_send_command(mc_io, &cmd);
7106 +int dpni_set_vlan_removal(struct fsl_mc_io *mc_io,
7107 + uint32_t cmd_flags,
7111 + struct mc_command cmd = { 0 };
7113 + /* prepare command */
7114 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_VLAN_REMOVAL,
7115 + cmd_flags, token);
7116 + DPNI_CMD_SET_VLAN_REMOVAL(cmd, en);
7118 + /* send command to mc*/
7119 + return mc_send_command(mc_io, &cmd);
7122 +int dpni_set_ipr(struct fsl_mc_io *mc_io,
7123 + uint32_t cmd_flags,
7127 + struct mc_command cmd = { 0 };
7129 + /* prepare command */
7130 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IPR,
7133 + DPNI_CMD_SET_IPR(cmd, en);
7135 + /* send command to mc*/
7136 + return mc_send_command(mc_io, &cmd);
7139 +int dpni_set_ipf(struct fsl_mc_io *mc_io,
7140 + uint32_t cmd_flags,
7144 + struct mc_command cmd = { 0 };
7146 + /* prepare command */
7147 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_IPF,
7150 + DPNI_CMD_SET_IPF(cmd, en);
7152 + /* send command to mc*/
7153 + return mc_send_command(mc_io, &cmd);
7156 +int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
7157 + uint32_t cmd_flags,
7160 + const struct dpni_rx_tc_policing_cfg *cfg)
7162 + struct mc_command cmd = { 0 };
7164 + /* prepare command */
7165 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_POLICING,
7168 + DPNI_CMD_SET_RX_TC_POLICING(cmd, tc_id, cfg);
7170 + /* send command to mc*/
7171 + return mc_send_command(mc_io, &cmd);
7174 +int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
7175 + uint32_t cmd_flags,
7178 + struct dpni_rx_tc_policing_cfg *cfg)
7180 + struct mc_command cmd = { 0 };
7183 + /* prepare command */
7184 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_TC_POLICING,
7187 + DPNI_CMD_GET_RX_TC_POLICING(cmd, tc_id);
7189 + /* send command to mc*/
7190 + err = mc_send_command(mc_io, &cmd);
7194 + DPNI_RSP_GET_RX_TC_POLICING(cmd, cfg);
7199 +void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
7200 + uint8_t *early_drop_buf)
7202 + uint64_t *ext_params = (uint64_t *)early_drop_buf;
7204 + DPNI_PREP_EARLY_DROP(ext_params, cfg);
7207 +void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
7208 + const uint8_t *early_drop_buf)
7210 + const uint64_t *ext_params = (const uint64_t *)early_drop_buf;
7212 + DPNI_EXT_EARLY_DROP(ext_params, cfg);
7215 +int dpni_set_rx_tc_early_drop(struct fsl_mc_io *mc_io,
7216 + uint32_t cmd_flags,
7219 + uint64_t early_drop_iova)
7221 + struct mc_command cmd = { 0 };
7223 + /* prepare command */
7224 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_RX_TC_EARLY_DROP,
7227 + DPNI_CMD_SET_RX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova);
7229 + /* send command to mc*/
7230 + return mc_send_command(mc_io, &cmd);
7233 +int dpni_get_rx_tc_early_drop(struct fsl_mc_io *mc_io,
7234 + uint32_t cmd_flags,
7237 + uint64_t early_drop_iova)
7239 + struct mc_command cmd = { 0 };
7241 + /* prepare command */
7242 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_RX_TC_EARLY_DROP,
7245 + DPNI_CMD_GET_RX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova);
7247 + /* send command to mc*/
7248 + return mc_send_command(mc_io, &cmd);
7251 +int dpni_set_tx_tc_early_drop(struct fsl_mc_io *mc_io,
7252 + uint32_t cmd_flags,
7255 + uint64_t early_drop_iova)
7257 + struct mc_command cmd = { 0 };
7259 + /* prepare command */
7260 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_TC_EARLY_DROP,
7263 + DPNI_CMD_SET_TX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova);
7265 + /* send command to mc*/
7266 + return mc_send_command(mc_io, &cmd);
7269 +int dpni_get_tx_tc_early_drop(struct fsl_mc_io *mc_io,
7270 + uint32_t cmd_flags,
7273 + uint64_t early_drop_iova)
7275 + struct mc_command cmd = { 0 };
7277 + /* prepare command */
7278 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_TC_EARLY_DROP,
7281 + DPNI_CMD_GET_TX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova);
7283 + /* send command to mc*/
7284 + return mc_send_command(mc_io, &cmd);
7287 +int dpni_set_rx_tc_congestion_notification(struct fsl_mc_io *mc_io,
7288 + uint32_t cmd_flags,
7291 + const struct dpni_congestion_notification_cfg *cfg)
7293 + struct mc_command cmd = { 0 };
7295 + /* prepare command */
7296 + cmd.header = mc_encode_cmd_header(
7297 + DPNI_CMDID_SET_RX_TC_CONGESTION_NOTIFICATION,
7300 + DPNI_CMD_SET_RX_TC_CONGESTION_NOTIFICATION(cmd, tc_id, cfg);
7302 + /* send command to mc*/
7303 + return mc_send_command(mc_io, &cmd);
7306 +int dpni_get_rx_tc_congestion_notification(struct fsl_mc_io *mc_io,
7307 + uint32_t cmd_flags,
7310 + struct dpni_congestion_notification_cfg *cfg)
7312 + struct mc_command cmd = { 0 };
7315 + /* prepare command */
7316 + cmd.header = mc_encode_cmd_header(
7317 + DPNI_CMDID_GET_RX_TC_CONGESTION_NOTIFICATION,
7320 + DPNI_CMD_GET_RX_TC_CONGESTION_NOTIFICATION(cmd, tc_id);
7322 + /* send command to mc*/
7323 + err = mc_send_command(mc_io, &cmd);
7327 + DPNI_RSP_GET_RX_TC_CONGESTION_NOTIFICATION(cmd, cfg);
7332 +int dpni_set_tx_tc_congestion_notification(struct fsl_mc_io *mc_io,
7333 + uint32_t cmd_flags,
7336 + const struct dpni_congestion_notification_cfg *cfg)
7338 + struct mc_command cmd = { 0 };
7340 + /* prepare command */
7341 + cmd.header = mc_encode_cmd_header(
7342 + DPNI_CMDID_SET_TX_TC_CONGESTION_NOTIFICATION,
7345 + DPNI_CMD_SET_TX_TC_CONGESTION_NOTIFICATION(cmd, tc_id, cfg);
7347 + /* send command to mc*/
7348 + return mc_send_command(mc_io, &cmd);
7351 +int dpni_get_tx_tc_congestion_notification(struct fsl_mc_io *mc_io,
7352 + uint32_t cmd_flags,
7355 + struct dpni_congestion_notification_cfg *cfg)
7357 + struct mc_command cmd = { 0 };
7360 + /* prepare command */
7361 + cmd.header = mc_encode_cmd_header(
7362 + DPNI_CMDID_GET_TX_TC_CONGESTION_NOTIFICATION,
7365 + DPNI_CMD_GET_TX_TC_CONGESTION_NOTIFICATION(cmd, tc_id);
7367 + /* send command to mc*/
7368 + err = mc_send_command(mc_io, &cmd);
7372 + DPNI_RSP_GET_TX_TC_CONGESTION_NOTIFICATION(cmd, cfg);
7377 +int dpni_set_tx_conf(struct fsl_mc_io *mc_io,
7378 + uint32_t cmd_flags,
7381 + const struct dpni_tx_conf_cfg *cfg)
7383 + struct mc_command cmd = { 0 };
7385 + /* prepare command */
7386 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_CONF,
7389 + DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg);
7391 + /* send command to mc*/
7392 + return mc_send_command(mc_io, &cmd);
7395 +int dpni_get_tx_conf(struct fsl_mc_io *mc_io,
7396 + uint32_t cmd_flags,
7399 + struct dpni_tx_conf_attr *attr)
7401 + struct mc_command cmd = { 0 };
7404 + /* prepare command */
7405 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TX_CONF,
7408 + DPNI_CMD_GET_TX_CONF(cmd, flow_id);
7410 + /* send command to mc*/
7411 + err = mc_send_command(mc_io, &cmd);
7415 + DPNI_RSP_GET_TX_CONF(cmd, attr);
7420 +int dpni_set_tx_conf_congestion_notification(struct fsl_mc_io *mc_io,
7421 + uint32_t cmd_flags,
7424 + const struct dpni_congestion_notification_cfg *cfg)
7426 + struct mc_command cmd = { 0 };
7428 + /* prepare command */
7429 + cmd.header = mc_encode_cmd_header(
7430 + DPNI_CMDID_SET_TX_CONF_CONGESTION_NOTIFICATION,
7433 + DPNI_CMD_SET_TX_CONF_CONGESTION_NOTIFICATION(cmd, flow_id, cfg);
7435 + /* send command to mc*/
7436 + return mc_send_command(mc_io, &cmd);
7439 +int dpni_get_tx_conf_congestion_notification(struct fsl_mc_io *mc_io,
7440 + uint32_t cmd_flags,
7443 + struct dpni_congestion_notification_cfg *cfg)
7445 + struct mc_command cmd = { 0 };
7448 + /* prepare command */
7449 + cmd.header = mc_encode_cmd_header(
7450 + DPNI_CMDID_GET_TX_CONF_CONGESTION_NOTIFICATION,
7453 + DPNI_CMD_GET_TX_CONF_CONGESTION_NOTIFICATION(cmd, flow_id);
7455 + /* send command to mc*/
7456 + err = mc_send_command(mc_io, &cmd);
7460 + DPNI_RSP_GET_TX_CONF_CONGESTION_NOTIFICATION(cmd, cfg);
7464 diff --git a/drivers/net/dpaa2/mc/dprc.c b/drivers/net/dpaa2/mc/dprc.c
7465 new file mode 100644
7466 index 0000000..75c6a68
7468 +++ b/drivers/net/dpaa2/mc/dprc.c
7470 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
7472 + * Redistribution and use in source and binary forms, with or without
7473 + * modification, are permitted provided that the following conditions are met:
7474 + * * Redistributions of source code must retain the above copyright
7475 + * notice, this list of conditions and the following disclaimer.
7476 + * * Redistributions in binary form must reproduce the above copyright
7477 + * notice, this list of conditions and the following disclaimer in the
7478 + * documentation and/or other materials provided with the distribution.
7479 + * * Neither the name of the above-listed copyright holders nor the
7480 + * names of any contributors may be used to endorse or promote products
7481 + * derived from this software without specific prior written permission.
7484 + * ALTERNATIVELY, this software may be distributed under the terms of the
7485 + * GNU General Public License ("GPL") as published by the Free Software
7486 + * Foundation, either version 2 of that License or (at your option) any
7489 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
7490 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
7491 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
7492 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
7493 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
7494 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
7495 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
7496 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
7497 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
7498 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
7499 + * POSSIBILITY OF SUCH DAMAGE.
7501 +#include <fsl_mc_sys.h>
7502 +#include <fsl_mc_cmd.h>
7503 +#include <fsl_dprc.h>
7504 +#include <fsl_dprc_cmd.h>
7506 +int dprc_get_container_id(struct fsl_mc_io *mc_io,
7507 + uint32_t cmd_flags,
7508 + int *container_id)
7510 + struct mc_command cmd = { 0 };
7513 + /* prepare command */
7514 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONT_ID,
7518 + /* send command to mc*/
7519 + err = mc_send_command(mc_io, &cmd);
7523 + /* retrieve response parameters */
7524 + DPRC_RSP_GET_CONTAINER_ID(cmd, *container_id);
7529 +int dprc_open(struct fsl_mc_io *mc_io,
7530 + uint32_t cmd_flags,
7534 + struct mc_command cmd = { 0 };
7537 + /* prepare command */
7538 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_OPEN, cmd_flags,
7540 + DPRC_CMD_OPEN(cmd, container_id);
7542 + /* send command to mc*/
7543 + err = mc_send_command(mc_io, &cmd);
7547 + /* retrieve response parameters */
7548 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
7553 +int dprc_close(struct fsl_mc_io *mc_io,
7554 + uint32_t cmd_flags,
7557 + struct mc_command cmd = { 0 };
7559 + /* prepare command */
7560 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLOSE, cmd_flags,
7563 + /* send command to mc*/
7564 + return mc_send_command(mc_io, &cmd);
7567 +int dprc_create_container(struct fsl_mc_io *mc_io,
7568 + uint32_t cmd_flags,
7570 + struct dprc_cfg *cfg,
7571 + int *child_container_id,
7572 + uint64_t *child_portal_paddr)
7574 + struct mc_command cmd = { 0 };
7577 + /* prepare command */
7578 + DPRC_CMD_CREATE_CONTAINER(cmd, cfg);
7580 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_CREATE_CONT,
7584 + /* send command to mc*/
7585 + err = mc_send_command(mc_io, &cmd);
7589 + /* retrieve response parameters */
7590 + DPRC_RSP_CREATE_CONTAINER(cmd, *child_container_id,
7591 + *child_portal_paddr);
7596 +int dprc_destroy_container(struct fsl_mc_io *mc_io,
7597 + uint32_t cmd_flags,
7599 + int child_container_id)
7601 + struct mc_command cmd = { 0 };
7603 + /* prepare command */
7604 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_DESTROY_CONT,
7607 + DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id);
7609 + /* send command to mc*/
7610 + return mc_send_command(mc_io, &cmd);
7613 +int dprc_reset_container(struct fsl_mc_io *mc_io,
7614 + uint32_t cmd_flags,
7616 + int child_container_id)
7618 + struct mc_command cmd = { 0 };
7620 + /* prepare command */
7621 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_RESET_CONT,
7624 + DPRC_CMD_RESET_CONTAINER(cmd, child_container_id);
7626 + /* send command to mc*/
7627 + return mc_send_command(mc_io, &cmd);
7630 +int dprc_get_irq(struct fsl_mc_io *mc_io,
7631 + uint32_t cmd_flags,
7633 + uint8_t irq_index,
7635 + struct dprc_irq_cfg *irq_cfg)
7637 + struct mc_command cmd = { 0 };
7640 + /* prepare command */
7641 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ,
7644 + DPRC_CMD_GET_IRQ(cmd, irq_index);
7646 + /* send command to mc*/
7647 + err = mc_send_command(mc_io, &cmd);
7651 + /* retrieve response parameters */
7652 + DPRC_RSP_GET_IRQ(cmd, *type, irq_cfg);
7657 +int dprc_set_irq(struct fsl_mc_io *mc_io,
7658 + uint32_t cmd_flags,
7660 + uint8_t irq_index,
7661 + struct dprc_irq_cfg *irq_cfg)
7663 + struct mc_command cmd = { 0 };
7665 + /* prepare command */
7666 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ,
7669 + DPRC_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
7671 + /* send command to mc*/
7672 + return mc_send_command(mc_io, &cmd);
7675 +int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
7676 + uint32_t cmd_flags,
7678 + uint8_t irq_index,
7681 + struct mc_command cmd = { 0 };
7684 + /* prepare command */
7685 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_ENABLE,
7688 + DPRC_CMD_GET_IRQ_ENABLE(cmd, irq_index);
7690 + /* send command to mc*/
7691 + err = mc_send_command(mc_io, &cmd);
7695 + /* retrieve response parameters */
7696 + DPRC_RSP_GET_IRQ_ENABLE(cmd, *en);
7701 +int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
7702 + uint32_t cmd_flags,
7704 + uint8_t irq_index,
7707 + struct mc_command cmd = { 0 };
7709 + /* prepare command */
7710 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_ENABLE,
7713 + DPRC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
7715 + /* send command to mc*/
7716 + return mc_send_command(mc_io, &cmd);
7719 +int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
7720 + uint32_t cmd_flags,
7722 + uint8_t irq_index,
7725 + struct mc_command cmd = { 0 };
7728 + /* prepare command */
7729 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_MASK,
7732 + DPRC_CMD_GET_IRQ_MASK(cmd, irq_index);
7734 + /* send command to mc*/
7735 + err = mc_send_command(mc_io, &cmd);
7739 + /* retrieve response parameters */
7740 + DPRC_RSP_GET_IRQ_MASK(cmd, *mask);
7745 +int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
7746 + uint32_t cmd_flags,
7748 + uint8_t irq_index,
7751 + struct mc_command cmd = { 0 };
7753 + /* prepare command */
7754 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_IRQ_MASK,
7757 + DPRC_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
7759 + /* send command to mc*/
7760 + return mc_send_command(mc_io, &cmd);
7763 +int dprc_get_irq_status(struct fsl_mc_io *mc_io,
7764 + uint32_t cmd_flags,
7766 + uint8_t irq_index,
7769 + struct mc_command cmd = { 0 };
7772 + /* prepare command */
7773 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_IRQ_STATUS,
7776 + DPRC_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
7778 + /* send command to mc*/
7779 + err = mc_send_command(mc_io, &cmd);
7783 + /* retrieve response parameters */
7784 + DPRC_RSP_GET_IRQ_STATUS(cmd, *status);
7789 +int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
7790 + uint32_t cmd_flags,
7792 + uint8_t irq_index,
7795 + struct mc_command cmd = { 0 };
7797 + /* prepare command */
7798 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_CLEAR_IRQ_STATUS,
7801 + DPRC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
7803 + /* send command to mc*/
7804 + return mc_send_command(mc_io, &cmd);
7807 +int dprc_get_attributes(struct fsl_mc_io *mc_io,
7808 + uint32_t cmd_flags,
7810 + struct dprc_attributes *attr)
7812 + struct mc_command cmd = { 0 };
7815 + /* prepare command */
7816 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_ATTR,
7820 + /* send command to mc*/
7821 + err = mc_send_command(mc_io, &cmd);
7825 + /* retrieve response parameters */
7826 + DPRC_RSP_GET_ATTRIBUTES(cmd, attr);
7831 +int dprc_set_res_quota(struct fsl_mc_io *mc_io,
7832 + uint32_t cmd_flags,
7834 + int child_container_id,
7838 + struct mc_command cmd = { 0 };
7840 + /* prepare command */
7841 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_RES_QUOTA,
7844 + DPRC_CMD_SET_RES_QUOTA(cmd, child_container_id, type, quota);
7846 + /* send command to mc*/
7847 + return mc_send_command(mc_io, &cmd);
7850 +int dprc_get_res_quota(struct fsl_mc_io *mc_io,
7851 + uint32_t cmd_flags,
7853 + int child_container_id,
7857 + struct mc_command cmd = { 0 };
7860 + /* prepare command */
7861 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_QUOTA,
7864 + DPRC_CMD_GET_RES_QUOTA(cmd, child_container_id, type);
7866 + /* send command to mc*/
7867 + err = mc_send_command(mc_io, &cmd);
7871 + /* retrieve response parameters */
7872 + DPRC_RSP_GET_RES_QUOTA(cmd, *quota);
7877 +int dprc_assign(struct fsl_mc_io *mc_io,
7878 + uint32_t cmd_flags,
7881 + struct dprc_res_req *res_req)
7883 + struct mc_command cmd = { 0 };
7885 + /* prepare command */
7886 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_ASSIGN,
7889 + DPRC_CMD_ASSIGN(cmd, container_id, res_req);
7891 + /* send command to mc*/
7892 + return mc_send_command(mc_io, &cmd);
7895 +int dprc_unassign(struct fsl_mc_io *mc_io,
7896 + uint32_t cmd_flags,
7898 + int child_container_id,
7899 + struct dprc_res_req *res_req)
7901 + struct mc_command cmd = { 0 };
7903 + /* prepare command */
7904 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_UNASSIGN,
7907 + DPRC_CMD_UNASSIGN(cmd, child_container_id, res_req);
7909 + /* send command to mc*/
7910 + return mc_send_command(mc_io, &cmd);
7913 +int dprc_get_pool_count(struct fsl_mc_io *mc_io,
7914 + uint32_t cmd_flags,
7918 + struct mc_command cmd = { 0 };
7921 + /* prepare command */
7922 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL_COUNT,
7926 + /* send command to mc*/
7927 + err = mc_send_command(mc_io, &cmd);
7931 + /* retrieve response parameters */
7932 + DPRC_RSP_GET_POOL_COUNT(cmd, *pool_count);
7937 +int dprc_get_pool(struct fsl_mc_io *mc_io,
7938 + uint32_t cmd_flags,
7943 + struct mc_command cmd = { 0 };
7946 + /* prepare command */
7947 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_POOL,
7950 + DPRC_CMD_GET_POOL(cmd, pool_index);
7952 + /* send command to mc*/
7953 + err = mc_send_command(mc_io, &cmd);
7957 + /* retrieve response parameters */
7958 + DPRC_RSP_GET_POOL(cmd, type);
7963 +int dprc_get_obj_count(struct fsl_mc_io *mc_io,
7964 + uint32_t cmd_flags,
7968 + struct mc_command cmd = { 0 };
7971 + /* prepare command */
7972 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_COUNT,
7976 + /* send command to mc*/
7977 + err = mc_send_command(mc_io, &cmd);
7981 + /* retrieve response parameters */
7982 + DPRC_RSP_GET_OBJ_COUNT(cmd, *obj_count);
7987 +int dprc_get_obj(struct fsl_mc_io *mc_io,
7988 + uint32_t cmd_flags,
7991 + struct dprc_obj_desc *obj_desc)
7993 + struct mc_command cmd = { 0 };
7996 + /* prepare command */
7997 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ,
8000 + DPRC_CMD_GET_OBJ(cmd, obj_index);
8002 + /* send command to mc*/
8003 + err = mc_send_command(mc_io, &cmd);
8007 + /* retrieve response parameters */
8008 + DPRC_RSP_GET_OBJ(cmd, obj_desc);
8013 +int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
8014 + uint32_t cmd_flags,
8018 + struct dprc_obj_desc *obj_desc)
8020 + struct mc_command cmd = { 0 };
8023 + /* prepare command */
8024 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_DESC,
8027 + DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id);
8029 + /* send command to mc*/
8030 + err = mc_send_command(mc_io, &cmd);
8034 + /* retrieve response parameters */
8035 + DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc);
8040 +int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
8041 + uint32_t cmd_flags,
8045 + uint8_t irq_index,
8046 + struct dprc_irq_cfg *irq_cfg)
8048 + struct mc_command cmd = { 0 };
8050 + /* prepare command */
8051 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_IRQ,
8054 + DPRC_CMD_SET_OBJ_IRQ(cmd,
8060 + /* send command to mc*/
8061 + return mc_send_command(mc_io, &cmd);
8064 +int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
8065 + uint32_t cmd_flags,
8069 + uint8_t irq_index,
8071 + struct dprc_irq_cfg *irq_cfg)
8073 + struct mc_command cmd = { 0 };
8076 + /* prepare command */
8077 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_IRQ,
8080 + DPRC_CMD_GET_OBJ_IRQ(cmd, obj_type, obj_id, irq_index);
8082 + /* send command to mc*/
8083 + err = mc_send_command(mc_io, &cmd);
8087 + /* retrieve response parameters */
8088 + DPRC_RSP_GET_OBJ_IRQ(cmd, *type, irq_cfg);
8093 +int dprc_get_res_count(struct fsl_mc_io *mc_io,
8094 + uint32_t cmd_flags,
8099 + struct mc_command cmd = { 0 };
8104 + /* prepare command */
8105 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_COUNT,
8108 + DPRC_CMD_GET_RES_COUNT(cmd, type);
8110 + /* send command to mc*/
8111 + err = mc_send_command(mc_io, &cmd);
8115 + /* retrieve response parameters */
8116 + DPRC_RSP_GET_RES_COUNT(cmd, *res_count);
8121 +int dprc_get_res_ids(struct fsl_mc_io *mc_io,
8122 + uint32_t cmd_flags,
8125 + struct dprc_res_ids_range_desc *range_desc)
8127 + struct mc_command cmd = { 0 };
8130 + /* prepare command */
8131 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_RES_IDS,
8134 + DPRC_CMD_GET_RES_IDS(cmd, range_desc, type);
8136 + /* send command to mc*/
8137 + err = mc_send_command(mc_io, &cmd);
8141 + /* retrieve response parameters */
8142 + DPRC_RSP_GET_RES_IDS(cmd, range_desc);
8147 +int dprc_get_obj_region(struct fsl_mc_io *mc_io,
8148 + uint32_t cmd_flags,
8152 + uint8_t region_index,
8153 + struct dprc_region_desc *region_desc)
8155 + struct mc_command cmd = { 0 };
8158 + /* prepare command */
8159 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_OBJ_REG,
8162 + DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index);
8164 + /* send command to mc*/
8165 + err = mc_send_command(mc_io, &cmd);
8169 + /* retrieve response parameters */
8170 + DPRC_RSP_GET_OBJ_REGION(cmd, region_desc);
8175 +int dprc_set_obj_label(struct fsl_mc_io *mc_io,
8176 + uint32_t cmd_flags,
8182 + struct mc_command cmd = { 0 };
8184 + /* prepare command */
8185 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_SET_OBJ_LABEL,
8188 + DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label);
8190 + /* send command to mc*/
8191 + return mc_send_command(mc_io, &cmd);
8194 +int dprc_connect(struct fsl_mc_io *mc_io,
8195 + uint32_t cmd_flags,
8197 + const struct dprc_endpoint *endpoint1,
8198 + const struct dprc_endpoint *endpoint2,
8199 + const struct dprc_connection_cfg *cfg)
8201 + struct mc_command cmd = { 0 };
8203 + /* prepare command */
8204 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_CONNECT,
8207 + DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg);
8209 + /* send command to mc*/
8210 + return mc_send_command(mc_io, &cmd);
8213 +int dprc_disconnect(struct fsl_mc_io *mc_io,
8214 + uint32_t cmd_flags,
8216 + const struct dprc_endpoint *endpoint)
8218 + struct mc_command cmd = { 0 };
8220 + /* prepare command */
8221 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_DISCONNECT,
8224 + DPRC_CMD_DISCONNECT(cmd, endpoint);
8226 + /* send command to mc*/
8227 + return mc_send_command(mc_io, &cmd);
8230 +int dprc_get_connection(struct fsl_mc_io *mc_io,
8231 + uint32_t cmd_flags,
8233 + const struct dprc_endpoint *endpoint1,
8234 + struct dprc_endpoint *endpoint2,
8237 + struct mc_command cmd = { 0 };
8240 + /* prepare command */
8241 + cmd.header = mc_encode_cmd_header(DPRC_CMDID_GET_CONNECTION,
8244 + DPRC_CMD_GET_CONNECTION(cmd, endpoint1);
8246 + /* send command to mc*/
8247 + err = mc_send_command(mc_io, &cmd);
8251 + /* retrieve response parameters */
8252 + DPRC_RSP_GET_CONNECTION(cmd, endpoint2, *state);
8256 diff --git a/drivers/net/dpaa2/mc/dprtc.c b/drivers/net/dpaa2/mc/dprtc.c
8257 new file mode 100644
8258 index 0000000..73667af
8260 +++ b/drivers/net/dpaa2/mc/dprtc.c
8262 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
8264 + * Redistribution and use in source and binary forms, with or without
8265 + * modification, are permitted provided that the following conditions are met:
8266 + * * Redistributions of source code must retain the above copyright
8267 + * notice, this list of conditions and the following disclaimer.
8268 + * * Redistributions in binary form must reproduce the above copyright
8269 + * notice, this list of conditions and the following disclaimer in the
8270 + * documentation and/or other materials provided with the distribution.
8271 + * * Neither the name of the above-listed copyright holders nor the
8272 + * names of any contributors may be used to endorse or promote products
8273 + * derived from this software without specific prior written permission.
8276 + * ALTERNATIVELY, this software may be distributed under the terms of the
8277 + * GNU General Public License ("GPL") as published by the Free Software
8278 + * Foundation, either version 2 of that License or (at your option) any
8281 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
8282 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8283 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8284 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
8285 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
8286 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
8287 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
8288 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
8289 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8290 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
8291 + * POSSIBILITY OF SUCH DAMAGE.
8293 +#include <fsl_mc_sys.h>
8294 +#include <fsl_mc_cmd.h>
8295 +#include <fsl_dprtc.h>
8296 +#include <fsl_dprtc_cmd.h>
8298 +int dprtc_open(struct fsl_mc_io *mc_io,
8299 + uint32_t cmd_flags,
8303 + struct mc_command cmd = { 0 };
8306 + /* prepare command */
8307 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_OPEN,
8310 + DPRTC_CMD_OPEN(cmd, dprtc_id);
8312 + /* send command to mc*/
8313 + err = mc_send_command(mc_io, &cmd);
8317 + /* retrieve response parameters */
8318 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
8323 +int dprtc_close(struct fsl_mc_io *mc_io,
8324 + uint32_t cmd_flags,
8327 + struct mc_command cmd = { 0 };
8329 + /* prepare command */
8330 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLOSE, cmd_flags,
8333 + /* send command to mc*/
8334 + return mc_send_command(mc_io, &cmd);
8337 +int dprtc_create(struct fsl_mc_io *mc_io,
8338 + uint32_t cmd_flags,
8339 + const struct dprtc_cfg *cfg,
8342 + struct mc_command cmd = { 0 };
8345 + (void)(cfg); /* unused */
8347 + /* prepare command */
8348 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CREATE,
8352 + /* send command to mc*/
8353 + err = mc_send_command(mc_io, &cmd);
8357 + /* retrieve response parameters */
8358 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
8363 +int dprtc_destroy(struct fsl_mc_io *mc_io,
8364 + uint32_t cmd_flags,
8367 + struct mc_command cmd = { 0 };
8369 + /* prepare command */
8370 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_DESTROY,
8374 + /* send command to mc*/
8375 + return mc_send_command(mc_io, &cmd);
8378 +int dprtc_enable(struct fsl_mc_io *mc_io,
8379 + uint32_t cmd_flags,
8382 + struct mc_command cmd = { 0 };
8384 + /* prepare command */
8385 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_ENABLE, cmd_flags,
8388 + /* send command to mc*/
8389 + return mc_send_command(mc_io, &cmd);
8392 +int dprtc_disable(struct fsl_mc_io *mc_io,
8393 + uint32_t cmd_flags,
8396 + struct mc_command cmd = { 0 };
8398 + /* prepare command */
8399 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_DISABLE,
8403 + /* send command to mc*/
8404 + return mc_send_command(mc_io, &cmd);
8407 +int dprtc_is_enabled(struct fsl_mc_io *mc_io,
8408 + uint32_t cmd_flags,
8412 + struct mc_command cmd = { 0 };
8414 + /* prepare command */
8415 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_IS_ENABLED, cmd_flags,
8418 + /* send command to mc*/
8419 + err = mc_send_command(mc_io, &cmd);
8423 + /* retrieve response parameters */
8424 + DPRTC_RSP_IS_ENABLED(cmd, *en);
8429 +int dprtc_reset(struct fsl_mc_io *mc_io,
8430 + uint32_t cmd_flags,
8433 + struct mc_command cmd = { 0 };
8435 + /* prepare command */
8436 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_RESET,
8440 + /* send command to mc*/
8441 + return mc_send_command(mc_io, &cmd);
8444 +int dprtc_set_irq(struct fsl_mc_io *mc_io,
8445 + uint32_t cmd_flags,
8447 + uint8_t irq_index,
8448 + struct dprtc_irq_cfg *irq_cfg)
8450 + struct mc_command cmd = { 0 };
8452 + /* prepare command */
8453 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ,
8457 + DPRTC_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
8459 + /* send command to mc*/
8460 + return mc_send_command(mc_io, &cmd);
8463 +int dprtc_get_irq(struct fsl_mc_io *mc_io,
8464 + uint32_t cmd_flags,
8466 + uint8_t irq_index,
8468 + struct dprtc_irq_cfg *irq_cfg)
8470 + struct mc_command cmd = { 0 };
8473 + /* prepare command */
8474 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ,
8478 + DPRTC_CMD_GET_IRQ(cmd, irq_index);
8480 + /* send command to mc*/
8481 + err = mc_send_command(mc_io, &cmd);
8485 + /* retrieve response parameters */
8486 + DPRTC_RSP_GET_IRQ(cmd, *type, irq_cfg);
8491 +int dprtc_set_irq_enable(struct fsl_mc_io *mc_io,
8492 + uint32_t cmd_flags,
8494 + uint8_t irq_index,
8497 + struct mc_command cmd = { 0 };
8499 + /* prepare command */
8500 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_ENABLE,
8504 + DPRTC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
8506 + /* send command to mc*/
8507 + return mc_send_command(mc_io, &cmd);
8510 +int dprtc_get_irq_enable(struct fsl_mc_io *mc_io,
8511 + uint32_t cmd_flags,
8513 + uint8_t irq_index,
8516 + struct mc_command cmd = { 0 };
8519 + /* prepare command */
8520 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_ENABLE,
8524 + DPRTC_CMD_GET_IRQ_ENABLE(cmd, irq_index);
8526 + /* send command to mc*/
8527 + err = mc_send_command(mc_io, &cmd);
8531 + /* retrieve response parameters */
8532 + DPRTC_RSP_GET_IRQ_ENABLE(cmd, *en);
8537 +int dprtc_set_irq_mask(struct fsl_mc_io *mc_io,
8538 + uint32_t cmd_flags,
8540 + uint8_t irq_index,
8543 + struct mc_command cmd = { 0 };
8545 + /* prepare command */
8546 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_IRQ_MASK,
8550 + DPRTC_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
8552 + /* send command to mc*/
8553 + return mc_send_command(mc_io, &cmd);
8556 +int dprtc_get_irq_mask(struct fsl_mc_io *mc_io,
8557 + uint32_t cmd_flags,
8559 + uint8_t irq_index,
8562 + struct mc_command cmd = { 0 };
8565 + /* prepare command */
8566 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_MASK,
8570 + DPRTC_CMD_GET_IRQ_MASK(cmd, irq_index);
8572 + /* send command to mc*/
8573 + err = mc_send_command(mc_io, &cmd);
8577 + /* retrieve response parameters */
8578 + DPRTC_RSP_GET_IRQ_MASK(cmd, *mask);
8583 +int dprtc_get_irq_status(struct fsl_mc_io *mc_io,
8584 + uint32_t cmd_flags,
8586 + uint8_t irq_index,
8589 + struct mc_command cmd = { 0 };
8592 + /* prepare command */
8593 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_IRQ_STATUS,
8597 + DPRTC_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
8599 + /* send command to mc*/
8600 + err = mc_send_command(mc_io, &cmd);
8604 + /* retrieve response parameters */
8605 + DPRTC_RSP_GET_IRQ_STATUS(cmd, *status);
8610 +int dprtc_clear_irq_status(struct fsl_mc_io *mc_io,
8611 + uint32_t cmd_flags,
8613 + uint8_t irq_index,
8616 + struct mc_command cmd = { 0 };
8618 + /* prepare command */
8619 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_CLEAR_IRQ_STATUS,
8623 + DPRTC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
8625 + /* send command to mc*/
8626 + return mc_send_command(mc_io, &cmd);
8629 +int dprtc_get_attributes(struct fsl_mc_io *mc_io,
8630 + uint32_t cmd_flags,
8632 + struct dprtc_attr *attr)
8634 + struct mc_command cmd = { 0 };
8637 + /* prepare command */
8638 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_ATTR,
8642 + /* send command to mc*/
8643 + err = mc_send_command(mc_io, &cmd);
8647 + /* retrieve response parameters */
8648 + DPRTC_RSP_GET_ATTRIBUTES(cmd, attr);
8653 +int dprtc_set_clock_offset(struct fsl_mc_io *mc_io,
8654 + uint32_t cmd_flags,
8658 + struct mc_command cmd = { 0 };
8660 + /* prepare command */
8661 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_CLOCK_OFFSET,
8665 + DPRTC_CMD_SET_CLOCK_OFFSET(cmd, offset);
8667 + /* send command to mc*/
8668 + return mc_send_command(mc_io, &cmd);
8671 +int dprtc_set_freq_compensation(struct fsl_mc_io *mc_io,
8672 + uint32_t cmd_flags,
8674 + uint32_t freq_compensation)
8676 + struct mc_command cmd = { 0 };
8678 + /* prepare command */
8679 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_FREQ_COMPENSATION,
8683 + DPRTC_CMD_SET_FREQ_COMPENSATION(cmd, freq_compensation);
8685 + /* send command to mc*/
8686 + return mc_send_command(mc_io, &cmd);
8689 +int dprtc_get_freq_compensation(struct fsl_mc_io *mc_io,
8690 + uint32_t cmd_flags,
8692 + uint32_t *freq_compensation)
8694 + struct mc_command cmd = { 0 };
8697 + /* prepare command */
8698 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_FREQ_COMPENSATION,
8702 + /* send command to mc*/
8703 + err = mc_send_command(mc_io, &cmd);
8707 + /* retrieve response parameters */
8708 + DPRTC_RSP_GET_FREQ_COMPENSATION(cmd, *freq_compensation);
8713 +int dprtc_get_time(struct fsl_mc_io *mc_io,
8714 + uint32_t cmd_flags,
8718 + struct mc_command cmd = { 0 };
8721 + /* prepare command */
8722 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_GET_TIME,
8726 + /* send command to mc*/
8727 + err = mc_send_command(mc_io, &cmd);
8731 + /* retrieve response parameters */
8732 + DPRTC_RSP_GET_TIME(cmd, *time);
8737 +int dprtc_set_time(struct fsl_mc_io *mc_io,
8738 + uint32_t cmd_flags,
8742 + struct mc_command cmd = { 0 };
8744 + /* prepare command */
8745 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_TIME,
8749 + DPRTC_CMD_SET_TIME(cmd, time);
8751 + /* send command to mc*/
8752 + return mc_send_command(mc_io, &cmd);
8755 +int dprtc_set_alarm(struct fsl_mc_io *mc_io,
8756 + uint32_t cmd_flags,
8757 + uint16_t token, uint64_t time)
8759 + struct mc_command cmd = { 0 };
8761 + /* prepare command */
8762 + cmd.header = mc_encode_cmd_header(DPRTC_CMDID_SET_ALARM,
8766 + DPRTC_CMD_SET_ALARM(cmd, time);
8768 + /* send command to mc*/
8769 + return mc_send_command(mc_io, &cmd);
8771 diff --git a/drivers/net/dpaa2/mc/dpseci.c b/drivers/net/dpaa2/mc/dpseci.c
8772 new file mode 100644
8773 index 0000000..a4b932a
8775 +++ b/drivers/net/dpaa2/mc/dpseci.c
8777 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
8779 + * Redistribution and use in source and binary forms, with or without
8780 + * modification, are permitted provided that the following conditions are met:
8781 + * * Redistributions of source code must retain the above copyright
8782 + * notice, this list of conditions and the following disclaimer.
8783 + * * Redistributions in binary form must reproduce the above copyright
8784 + * notice, this list of conditions and the following disclaimer in the
8785 + * documentation and/or other materials provided with the distribution.
8786 + * * Neither the name of the above-listed copyright holders nor the
8787 + * names of any contributors may be used to endorse or promote products
8788 + * derived from this software without specific prior written permission.
8791 + * ALTERNATIVELY, this software may be distributed under the terms of the
8792 + * GNU General Public License ("GPL") as published by the Free Software
8793 + * Foundation, either version 2 of that License or (at your option) any
8796 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
8797 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
8798 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
8799 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
8800 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
8801 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
8802 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
8803 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
8804 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
8805 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
8806 + * POSSIBILITY OF SUCH DAMAGE.
8808 +#include <fsl_mc_sys.h>
8809 +#include <fsl_mc_cmd.h>
8810 +#include <fsl_dpseci.h>
8811 +#include <fsl_dpseci_cmd.h>
8813 +int dpseci_open(struct fsl_mc_io *mc_io,
8814 + uint32_t cmd_flags,
8818 + struct mc_command cmd = { 0 };
8821 + /* prepare command */
8822 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_OPEN,
8825 + DPSECI_CMD_OPEN(cmd, dpseci_id);
8827 + /* send command to mc*/
8828 + err = mc_send_command(mc_io, &cmd);
8832 + /* retrieve response parameters */
8833 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
8838 +int dpseci_close(struct fsl_mc_io *mc_io,
8839 + uint32_t cmd_flags,
8842 + struct mc_command cmd = { 0 };
8844 + /* prepare command */
8845 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLOSE,
8849 + /* send command to mc*/
8850 + return mc_send_command(mc_io, &cmd);
8853 +int dpseci_create(struct fsl_mc_io *mc_io,
8854 + uint32_t cmd_flags,
8855 + const struct dpseci_cfg *cfg,
8858 + struct mc_command cmd = { 0 };
8861 + /* prepare command */
8862 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CREATE,
8865 + DPSECI_CMD_CREATE(cmd, cfg);
8867 + /* send command to mc*/
8868 + err = mc_send_command(mc_io, &cmd);
8872 + /* retrieve response parameters */
8873 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
8878 +int dpseci_destroy(struct fsl_mc_io *mc_io,
8879 + uint32_t cmd_flags,
8882 + struct mc_command cmd = { 0 };
8884 + /* prepare command */
8885 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DESTROY,
8889 + /* send command to mc*/
8890 + return mc_send_command(mc_io, &cmd);
8893 +int dpseci_enable(struct fsl_mc_io *mc_io,
8894 + uint32_t cmd_flags,
8897 + struct mc_command cmd = { 0 };
8899 + /* prepare command */
8900 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_ENABLE,
8904 + /* send command to mc*/
8905 + return mc_send_command(mc_io, &cmd);
8908 +int dpseci_disable(struct fsl_mc_io *mc_io,
8909 + uint32_t cmd_flags,
8912 + struct mc_command cmd = { 0 };
8914 + /* prepare command */
8915 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_DISABLE,
8919 + /* send command to mc*/
8920 + return mc_send_command(mc_io, &cmd);
8923 +int dpseci_is_enabled(struct fsl_mc_io *mc_io,
8924 + uint32_t cmd_flags,
8928 + struct mc_command cmd = { 0 };
8930 + /* prepare command */
8931 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_IS_ENABLED,
8935 + /* send command to mc*/
8936 + err = mc_send_command(mc_io, &cmd);
8940 + /* retrieve response parameters */
8941 + DPSECI_RSP_IS_ENABLED(cmd, *en);
8946 +int dpseci_reset(struct fsl_mc_io *mc_io,
8947 + uint32_t cmd_flags,
8950 + struct mc_command cmd = { 0 };
8952 + /* prepare command */
8953 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_RESET,
8957 + /* send command to mc*/
8958 + return mc_send_command(mc_io, &cmd);
8961 +int dpseci_get_irq(struct fsl_mc_io *mc_io,
8962 + uint32_t cmd_flags,
8964 + uint8_t irq_index,
8966 + struct dpseci_irq_cfg *irq_cfg)
8968 + struct mc_command cmd = { 0 };
8971 + /* prepare command */
8972 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ,
8975 + DPSECI_CMD_GET_IRQ(cmd, irq_index);
8977 + /* send command to mc*/
8978 + err = mc_send_command(mc_io, &cmd);
8982 + /* retrieve response parameters */
8983 + DPSECI_RSP_GET_IRQ(cmd, *type, irq_cfg);
8988 +int dpseci_set_irq(struct fsl_mc_io *mc_io,
8989 + uint32_t cmd_flags,
8991 + uint8_t irq_index,
8992 + struct dpseci_irq_cfg *irq_cfg)
8994 + struct mc_command cmd = { 0 };
8996 + /* prepare command */
8997 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ,
9000 + DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
9002 + /* send command to mc*/
9003 + return mc_send_command(mc_io, &cmd);
9006 +int dpseci_get_irq_enable(struct fsl_mc_io *mc_io,
9007 + uint32_t cmd_flags,
9009 + uint8_t irq_index,
9012 + struct mc_command cmd = { 0 };
9015 + /* prepare command */
9016 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_ENABLE,
9019 + DPSECI_CMD_GET_IRQ_ENABLE(cmd, irq_index);
9021 + /* send command to mc*/
9022 + err = mc_send_command(mc_io, &cmd);
9026 + /* retrieve response parameters */
9027 + DPSECI_RSP_GET_IRQ_ENABLE(cmd, *en);
9032 +int dpseci_set_irq_enable(struct fsl_mc_io *mc_io,
9033 + uint32_t cmd_flags,
9035 + uint8_t irq_index,
9038 + struct mc_command cmd = { 0 };
9040 + /* prepare command */
9041 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_ENABLE,
9044 + DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
9046 + /* send command to mc*/
9047 + return mc_send_command(mc_io, &cmd);
9050 +int dpseci_get_irq_mask(struct fsl_mc_io *mc_io,
9051 + uint32_t cmd_flags,
9053 + uint8_t irq_index,
9056 + struct mc_command cmd = { 0 };
9059 + /* prepare command */
9060 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_MASK,
9063 + DPSECI_CMD_GET_IRQ_MASK(cmd, irq_index);
9065 + /* send command to mc*/
9066 + err = mc_send_command(mc_io, &cmd);
9070 + /* retrieve response parameters */
9071 + DPSECI_RSP_GET_IRQ_MASK(cmd, *mask);
9076 +int dpseci_set_irq_mask(struct fsl_mc_io *mc_io,
9077 + uint32_t cmd_flags,
9079 + uint8_t irq_index,
9082 + struct mc_command cmd = { 0 };
9084 + /* prepare command */
9085 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_IRQ_MASK,
9088 + DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
9090 + /* send command to mc*/
9091 + return mc_send_command(mc_io, &cmd);
9094 +int dpseci_get_irq_status(struct fsl_mc_io *mc_io,
9095 + uint32_t cmd_flags,
9097 + uint8_t irq_index,
9100 + struct mc_command cmd = { 0 };
9103 + /* prepare command */
9104 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_IRQ_STATUS,
9107 + DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
9109 + /* send command to mc*/
9110 + err = mc_send_command(mc_io, &cmd);
9114 + /* retrieve response parameters */
9115 + DPSECI_RSP_GET_IRQ_STATUS(cmd, *status);
9120 +int dpseci_clear_irq_status(struct fsl_mc_io *mc_io,
9121 + uint32_t cmd_flags,
9123 + uint8_t irq_index,
9126 + struct mc_command cmd = { 0 };
9128 + /* prepare command */
9129 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_CLEAR_IRQ_STATUS,
9132 + DPSECI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
9134 + /* send command to mc*/
9135 + return mc_send_command(mc_io, &cmd);
9138 +int dpseci_get_attributes(struct fsl_mc_io *mc_io,
9139 + uint32_t cmd_flags,
9141 + struct dpseci_attr *attr)
9143 + struct mc_command cmd = { 0 };
9146 + /* prepare command */
9147 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_ATTR,
9151 + /* send command to mc*/
9152 + err = mc_send_command(mc_io, &cmd);
9156 + /* retrieve response parameters */
9157 + DPSECI_RSP_GET_ATTR(cmd, attr);
9162 +int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
9163 + uint32_t cmd_flags,
9166 + const struct dpseci_rx_queue_cfg *cfg)
9168 + struct mc_command cmd = { 0 };
9170 + /* prepare command */
9171 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_SET_RX_QUEUE,
9174 + DPSECI_CMD_SET_RX_QUEUE(cmd, queue, cfg);
9176 + /* send command to mc*/
9177 + return mc_send_command(mc_io, &cmd);
9180 +int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
9181 + uint32_t cmd_flags,
9184 + struct dpseci_rx_queue_attr *attr)
9186 + struct mc_command cmd = { 0 };
9189 + /* prepare command */
9190 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_RX_QUEUE,
9193 + DPSECI_CMD_GET_RX_QUEUE(cmd, queue);
9195 + /* send command to mc*/
9196 + err = mc_send_command(mc_io, &cmd);
9200 + /* retrieve response parameters */
9201 + DPSECI_RSP_GET_RX_QUEUE(cmd, attr);
9206 +int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
9207 + uint32_t cmd_flags,
9210 + struct dpseci_tx_queue_attr *attr)
9212 + struct mc_command cmd = { 0 };
9215 + /* prepare command */
9216 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_TX_QUEUE,
9219 + DPSECI_CMD_GET_TX_QUEUE(cmd, queue);
9221 + /* send command to mc*/
9222 + err = mc_send_command(mc_io, &cmd);
9226 + /* retrieve response parameters */
9227 + DPSECI_RSP_GET_TX_QUEUE(cmd, attr);
9232 +int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
9233 + uint32_t cmd_flags,
9235 + struct dpseci_sec_attr *attr)
9237 + struct mc_command cmd = { 0 };
9240 + /* prepare command */
9241 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_ATTR,
9245 + /* send command to mc*/
9246 + err = mc_send_command(mc_io, &cmd);
9250 + /* retrieve response parameters */
9251 + DPSECI_RSP_GET_SEC_ATTR(cmd, attr);
9256 +int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
9257 + uint32_t cmd_flags,
9259 + struct dpseci_sec_counters *counters)
9261 + struct mc_command cmd = { 0 };
9264 + /* prepare command */
9265 + cmd.header = mc_encode_cmd_header(DPSECI_CMDID_GET_SEC_COUNTERS,
9269 + /* send command to mc*/
9270 + err = mc_send_command(mc_io, &cmd);
9274 + /* retrieve response parameters */
9275 + DPSECI_RSP_GET_SEC_COUNTERS(cmd, counters);
9279 diff --git a/drivers/net/dpaa2/mc/dpsw.c b/drivers/net/dpaa2/mc/dpsw.c
9280 new file mode 100644
9281 index 0000000..2034b55
9283 +++ b/drivers/net/dpaa2/mc/dpsw.c
9285 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
9287 + * Redistribution and use in source and binary forms, with or without
9288 + * modification, are permitted provided that the following conditions are met:
9289 + * * Redistributions of source code must retain the above copyright
9290 + * notice, this list of conditions and the following disclaimer.
9291 + * * Redistributions in binary form must reproduce the above copyright
9292 + * notice, this list of conditions and the following disclaimer in the
9293 + * documentation and/or other materials provided with the distribution.
9294 + * * Neither the name of the above-listed copyright holders nor the
9295 + * names of any contributors may be used to endorse or promote products
9296 + * derived from this software without specific prior written permission.
9299 + * ALTERNATIVELY, this software may be distributed under the terms of the
9300 + * GNU General Public License ("GPL") as published by the Free Software
9301 + * Foundation, either version 2 of that License or (at your option) any
9304 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
9305 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
9306 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
9307 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
9308 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
9309 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
9310 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
9311 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
9312 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
9313 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
9314 + * POSSIBILITY OF SUCH DAMAGE.
9316 +#include <fsl_mc_sys.h>
9317 +#include <fsl_mc_cmd.h>
9318 +#include <fsl_dpsw.h>
9319 +#include <fsl_dpsw_cmd.h>
9321 +/* internal functions */
9322 +static void build_if_id_bitmap(const uint16_t *if_id,
9323 + const uint16_t num_ifs,
9324 + struct mc_command *cmd,
9329 + for (i = 0; (i < num_ifs) && (i < DPSW_MAX_IF); i++)
9330 + cmd->params[start_param + (if_id[i] / 64)] |= mc_enc(
9331 + (if_id[i] % 64), 1, 1);
9334 +static int read_if_id_bitmap(uint16_t *if_id,
9335 + uint16_t *num_ifs,
9336 + struct mc_command *cmd,
9339 + int bitmap[DPSW_MAX_IF] = { 0 };
9343 + for (i = 0; i < DPSW_MAX_IF; i++) {
9344 + bitmap[i] = (int)mc_dec(cmd->params[start_param + i / 64],
9346 + count += bitmap[i];
9349 + *num_ifs = (uint16_t)count;
9351 + for (i = 0; (i < DPSW_MAX_IF) && (j < count); i++) {
9353 + if_id[j] = (uint16_t)i;
9362 +int dpsw_open(struct fsl_mc_io *mc_io,
9363 + uint32_t cmd_flags,
9367 + struct mc_command cmd = { 0 };
9370 + /* prepare command */
9371 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_OPEN,
9374 + DPSW_CMD_OPEN(cmd, dpsw_id);
9376 + /* send command to mc*/
9377 + err = mc_send_command(mc_io, &cmd);
9381 + /* retrieve response parameters */
9382 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
9387 +int dpsw_close(struct fsl_mc_io *mc_io,
9388 + uint32_t cmd_flags,
9391 + struct mc_command cmd = { 0 };
9393 + /* prepare command */
9394 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CLOSE,
9398 + /* send command to mc*/
9399 + return mc_send_command(mc_io, &cmd);
9402 +int dpsw_create(struct fsl_mc_io *mc_io,
9403 + uint32_t cmd_flags,
9404 + const struct dpsw_cfg *cfg,
9407 + struct mc_command cmd = { 0 };
9410 + /* prepare command */
9411 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CREATE,
9414 + DPSW_CMD_CREATE(cmd, cfg);
9416 + /* send command to mc*/
9417 + err = mc_send_command(mc_io, &cmd);
9421 + /* retrieve response parameters */
9422 + *token = MC_CMD_HDR_READ_TOKEN(cmd.header);
9427 +int dpsw_destroy(struct fsl_mc_io *mc_io,
9428 + uint32_t cmd_flags,
9431 + struct mc_command cmd = { 0 };
9433 + /* prepare command */
9434 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_DESTROY,
9438 + /* send command to mc*/
9439 + return mc_send_command(mc_io, &cmd);
9442 +int dpsw_enable(struct fsl_mc_io *mc_io,
9443 + uint32_t cmd_flags,
9446 + struct mc_command cmd = { 0 };
9448 + /* prepare command */
9449 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ENABLE,
9453 + /* send command to mc*/
9454 + return mc_send_command(mc_io, &cmd);
9457 +int dpsw_disable(struct fsl_mc_io *mc_io,
9458 + uint32_t cmd_flags,
9461 + struct mc_command cmd = { 0 };
9463 + /* prepare command */
9464 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_DISABLE,
9468 + /* send command to mc*/
9469 + return mc_send_command(mc_io, &cmd);
9472 +int dpsw_is_enabled(struct fsl_mc_io *mc_io,
9473 + uint32_t cmd_flags,
9477 + struct mc_command cmd = { 0 };
9480 + /* prepare command */
9481 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IS_ENABLED, cmd_flags,
9484 + /* send command to mc*/
9485 + err = mc_send_command(mc_io, &cmd);
9489 + /* retrieve response parameters */
9490 + DPSW_RSP_IS_ENABLED(cmd, *en);
9495 +int dpsw_reset(struct fsl_mc_io *mc_io,
9496 + uint32_t cmd_flags,
9499 + struct mc_command cmd = { 0 };
9501 + /* prepare command */
9502 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_RESET,
9506 + /* send command to mc*/
9507 + return mc_send_command(mc_io, &cmd);
9510 +int dpsw_set_irq(struct fsl_mc_io *mc_io,
9511 + uint32_t cmd_flags,
9513 + uint8_t irq_index,
9514 + struct dpsw_irq_cfg *irq_cfg)
9516 + struct mc_command cmd = { 0 };
9518 + /* prepare command */
9519 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ,
9522 + DPSW_CMD_SET_IRQ(cmd, irq_index, irq_cfg);
9524 + /* send command to mc*/
9525 + return mc_send_command(mc_io, &cmd);
9528 +int dpsw_get_irq(struct fsl_mc_io *mc_io,
9529 + uint32_t cmd_flags,
9531 + uint8_t irq_index,
9533 + struct dpsw_irq_cfg *irq_cfg)
9535 + struct mc_command cmd = { 0 };
9538 + /* prepare command */
9539 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ,
9542 + DPSW_CMD_GET_IRQ(cmd, irq_index);
9544 + /* send command to mc*/
9545 + err = mc_send_command(mc_io, &cmd);
9549 + /* retrieve response parameters */
9550 + DPSW_RSP_GET_IRQ(cmd, *type, irq_cfg);
9555 +int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
9556 + uint32_t cmd_flags,
9558 + uint8_t irq_index,
9561 + struct mc_command cmd = { 0 };
9563 + /* prepare command */
9564 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ_ENABLE,
9567 + DPSW_CMD_SET_IRQ_ENABLE(cmd, irq_index, en);
9569 + /* send command to mc*/
9570 + return mc_send_command(mc_io, &cmd);
9573 +int dpsw_get_irq_enable(struct fsl_mc_io *mc_io,
9574 + uint32_t cmd_flags,
9576 + uint8_t irq_index,
9579 + struct mc_command cmd = { 0 };
9582 + /* prepare command */
9583 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_ENABLE,
9586 + DPSW_CMD_GET_IRQ_ENABLE(cmd, irq_index);
9588 + /* send command to mc*/
9589 + err = mc_send_command(mc_io, &cmd);
9593 + /* retrieve response parameters */
9594 + DPSW_RSP_GET_IRQ_ENABLE(cmd, *en);
9599 +int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
9600 + uint32_t cmd_flags,
9602 + uint8_t irq_index,
9605 + struct mc_command cmd = { 0 };
9607 + /* prepare command */
9608 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IRQ_MASK,
9611 + DPSW_CMD_SET_IRQ_MASK(cmd, irq_index, mask);
9613 + /* send command to mc*/
9614 + return mc_send_command(mc_io, &cmd);
9617 +int dpsw_get_irq_mask(struct fsl_mc_io *mc_io,
9618 + uint32_t cmd_flags,
9620 + uint8_t irq_index,
9623 + struct mc_command cmd = { 0 };
9626 + /* prepare command */
9627 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_MASK,
9630 + DPSW_CMD_GET_IRQ_MASK(cmd, irq_index);
9632 + /* send command to mc*/
9633 + err = mc_send_command(mc_io, &cmd);
9637 + /* retrieve response parameters */
9638 + DPSW_RSP_GET_IRQ_MASK(cmd, *mask);
9643 +int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
9644 + uint32_t cmd_flags,
9646 + uint8_t irq_index,
9649 + struct mc_command cmd = { 0 };
9652 + /* prepare command */
9653 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_IRQ_STATUS,
9656 + DPSW_CMD_GET_IRQ_STATUS(cmd, irq_index, *status);
9658 + /* send command to mc*/
9659 + err = mc_send_command(mc_io, &cmd);
9663 + /* retrieve response parameters */
9664 + DPSW_RSP_GET_IRQ_STATUS(cmd, *status);
9669 +int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
9670 + uint32_t cmd_flags,
9672 + uint8_t irq_index,
9675 + struct mc_command cmd = { 0 };
9677 + /* prepare command */
9678 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CLEAR_IRQ_STATUS,
9681 + DPSW_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status);
9683 + /* send command to mc*/
9684 + return mc_send_command(mc_io, &cmd);
9687 +int dpsw_get_attributes(struct fsl_mc_io *mc_io,
9688 + uint32_t cmd_flags,
9690 + struct dpsw_attr *attr)
9692 + struct mc_command cmd = { 0 };
9695 + /* prepare command */
9696 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_GET_ATTR,
9700 + /* send command to mc*/
9701 + err = mc_send_command(mc_io, &cmd);
9705 + /* retrieve response parameters */
9706 + DPSW_RSP_GET_ATTR(cmd, attr);
9711 +int dpsw_set_reflection_if(struct fsl_mc_io *mc_io,
9712 + uint32_t cmd_flags,
9716 + struct mc_command cmd = { 0 };
9718 + /* prepare command */
9719 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_REFLECTION_IF,
9722 + DPSW_CMD_SET_REFLECTION_IF(cmd, if_id);
9724 + /* send command to mc*/
9725 + return mc_send_command(mc_io, &cmd);
9728 +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
9729 + uint32_t cmd_flags,
9732 + struct dpsw_link_cfg *cfg)
9734 + struct mc_command cmd = { 0 };
9736 + /* prepare command */
9737 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_LINK_CFG,
9740 + DPSW_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg);
9742 + /* send command to mc*/
9743 + return mc_send_command(mc_io, &cmd);
9746 +int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
9747 + uint32_t cmd_flags,
9750 + struct dpsw_link_state *state)
9752 + struct mc_command cmd = { 0 };
9755 + /* prepare command */
9756 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_LINK_STATE,
9759 + DPSW_CMD_IF_GET_LINK_STATE(cmd, if_id);
9761 + /* send command to mc*/
9762 + err = mc_send_command(mc_io, &cmd);
9766 + /* retrieve response parameters */
9767 + DPSW_RSP_IF_GET_LINK_STATE(cmd, state);
9772 +int dpsw_if_set_flooding(struct fsl_mc_io *mc_io,
9773 + uint32_t cmd_flags,
9778 + struct mc_command cmd = { 0 };
9780 + /* prepare command */
9781 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_FLOODING,
9784 + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
9786 + /* send command to mc*/
9787 + return mc_send_command(mc_io, &cmd);
9790 +int dpsw_if_set_broadcast(struct fsl_mc_io *mc_io,
9791 + uint32_t cmd_flags,
9796 + struct mc_command cmd = { 0 };
9798 + /* prepare command */
9799 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_BROADCAST,
9802 + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
9804 + /* send command to mc*/
9805 + return mc_send_command(mc_io, &cmd);
9808 +int dpsw_if_set_multicast(struct fsl_mc_io *mc_io,
9809 + uint32_t cmd_flags,
9814 + struct mc_command cmd = { 0 };
9816 + /* prepare command */
9817 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_MULTICAST,
9820 + DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en);
9822 + /* send command to mc*/
9823 + return mc_send_command(mc_io, &cmd);
9826 +int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
9827 + uint32_t cmd_flags,
9830 + const struct dpsw_tci_cfg *cfg)
9832 + struct mc_command cmd = { 0 };
9834 + /* prepare command */
9835 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_TCI,
9838 + DPSW_CMD_IF_SET_TCI(cmd, if_id, cfg);
9840 + /* send command to mc*/
9841 + return mc_send_command(mc_io, &cmd);
9844 +int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
9845 + uint32_t cmd_flags,
9848 + struct dpsw_tci_cfg *cfg)
9850 + struct mc_command cmd = { 0 };
9853 + /* prepare command */
9854 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_TCI,
9857 + DPSW_CMD_IF_GET_TCI(cmd, if_id);
9859 + /* send command to mc*/
9860 + err = mc_send_command(mc_io, &cmd);
9864 + /* retrieve response parameters */
9865 + DPSW_RSP_IF_GET_TCI(cmd, cfg);
9870 +int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
9871 + uint32_t cmd_flags,
9874 + const struct dpsw_stp_cfg *cfg)
9876 + struct mc_command cmd = { 0 };
9878 + /* prepare command */
9879 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_STP,
9882 + DPSW_CMD_IF_SET_STP(cmd, if_id, cfg);
9884 + /* send command to mc*/
9885 + return mc_send_command(mc_io, &cmd);
9888 +int dpsw_if_set_accepted_frames(struct fsl_mc_io *mc_io,
9889 + uint32_t cmd_flags,
9892 + const struct dpsw_accepted_frames_cfg *cfg)
9894 + struct mc_command cmd = { 0 };
9896 + /* prepare command */
9897 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_ACCEPTED_FRAMES,
9900 + DPSW_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg);
9902 + /* send command to mc*/
9903 + return mc_send_command(mc_io, &cmd);
9906 +int dpsw_if_set_accept_all_vlan(struct fsl_mc_io *mc_io,
9907 + uint32_t cmd_flags,
9912 + struct mc_command cmd = { 0 };
9914 + /* prepare command */
9915 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_SET_IF_ACCEPT_ALL_VLAN,
9918 + DPSW_CMD_IF_SET_ACCEPT_ALL_VLAN(cmd, if_id, accept_all);
9920 + /* send command to mc*/
9921 + return mc_send_command(mc_io, &cmd);
9924 +int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
9925 + uint32_t cmd_flags,
9928 + enum dpsw_counter type,
9929 + uint64_t *counter)
9931 + struct mc_command cmd = { 0 };
9934 + /* prepare command */
9935 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_COUNTER,
9938 + DPSW_CMD_IF_GET_COUNTER(cmd, if_id, type);
9940 + /* send command to mc*/
9941 + err = mc_send_command(mc_io, &cmd);
9945 + /* retrieve response parameters */
9946 + DPSW_RSP_IF_GET_COUNTER(cmd, *counter);
9951 +int dpsw_if_set_counter(struct fsl_mc_io *mc_io,
9952 + uint32_t cmd_flags,
9955 + enum dpsw_counter type,
9958 + struct mc_command cmd = { 0 };
9960 + /* prepare command */
9961 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_COUNTER,
9964 + DPSW_CMD_IF_SET_COUNTER(cmd, if_id, type, counter);
9966 + /* send command to mc*/
9967 + return mc_send_command(mc_io, &cmd);
9970 +int dpsw_if_set_tx_selection(struct fsl_mc_io *mc_io,
9971 + uint32_t cmd_flags,
9974 + const struct dpsw_tx_selection_cfg *cfg)
9976 + struct mc_command cmd = { 0 };
9978 + /* prepare command */
9979 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_TX_SELECTION,
9982 + DPSW_CMD_IF_SET_TX_SELECTION(cmd, if_id, cfg);
9984 + /* send command to mc*/
9985 + return mc_send_command(mc_io, &cmd);
9988 +int dpsw_if_add_reflection(struct fsl_mc_io *mc_io,
9989 + uint32_t cmd_flags,
9992 + const struct dpsw_reflection_cfg *cfg)
9994 + struct mc_command cmd = { 0 };
9996 + /* prepare command */
9997 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_ADD_REFLECTION,
10000 + DPSW_CMD_IF_ADD_REFLECTION(cmd, if_id, cfg);
10002 + /* send command to mc*/
10003 + return mc_send_command(mc_io, &cmd);
10006 +int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io,
10007 + uint32_t cmd_flags,
10010 + const struct dpsw_reflection_cfg *cfg)
10012 + struct mc_command cmd = { 0 };
10014 + /* prepare command */
10015 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_REMOVE_REFLECTION,
10018 + DPSW_CMD_IF_REMOVE_REFLECTION(cmd, if_id, cfg);
10020 + /* send command to mc*/
10021 + return mc_send_command(mc_io, &cmd);
10024 +int dpsw_if_set_flooding_metering(struct fsl_mc_io *mc_io,
10025 + uint32_t cmd_flags,
10028 + const struct dpsw_metering_cfg *cfg)
10030 + struct mc_command cmd = { 0 };
10032 + /* prepare command */
10033 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_FLOODING_METERING,
10036 + DPSW_CMD_IF_SET_FLOODING_METERING(cmd, if_id, cfg);
10038 + /* send command to mc*/
10039 + return mc_send_command(mc_io, &cmd);
10042 +int dpsw_if_set_metering(struct fsl_mc_io *mc_io,
10043 + uint32_t cmd_flags,
10047 + const struct dpsw_metering_cfg *cfg)
10049 + struct mc_command cmd = { 0 };
10051 + /* prepare command */
10052 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_METERING,
10055 + DPSW_CMD_IF_SET_METERING(cmd, if_id, tc_id, cfg);
10057 + /* send command to mc*/
10058 + return mc_send_command(mc_io, &cmd);
10061 +void dpsw_prepare_early_drop(const struct dpsw_early_drop_cfg *cfg,
10062 + uint8_t *early_drop_buf)
10064 + uint64_t *ext_params = (uint64_t *)early_drop_buf;
10066 + DPSW_PREP_EARLY_DROP(ext_params, cfg);
10069 +int dpsw_if_set_early_drop(struct fsl_mc_io *mc_io,
10070 + uint32_t cmd_flags,
10074 + uint64_t early_drop_iova)
10076 + struct mc_command cmd = { 0 };
10078 + /* prepare command */
10079 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_EARLY_DROP,
10082 + DPSW_CMD_IF_SET_EARLY_DROP(cmd, if_id, tc_id, early_drop_iova);
10084 + /* send command to mc*/
10085 + return mc_send_command(mc_io, &cmd);
10088 +int dpsw_add_custom_tpid(struct fsl_mc_io *mc_io,
10089 + uint32_t cmd_flags,
10091 + const struct dpsw_custom_tpid_cfg *cfg)
10093 + struct mc_command cmd = { 0 };
10095 + /* prepare command */
10096 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ADD_CUSTOM_TPID,
10099 + DPSW_CMD_ADD_CUSTOM_TPID(cmd, cfg);
10101 + /* send command to mc*/
10102 + return mc_send_command(mc_io, &cmd);
10105 +int dpsw_remove_custom_tpid(struct fsl_mc_io *mc_io,
10106 + uint32_t cmd_flags,
10108 + const struct dpsw_custom_tpid_cfg *cfg)
10110 + struct mc_command cmd = { 0 };
10112 + /* prepare command */
10113 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_REMOVE_CUSTOM_TPID,
10116 + DPSW_CMD_REMOVE_CUSTOM_TPID(cmd, cfg);
10118 + /* send command to mc*/
10119 + return mc_send_command(mc_io, &cmd);
10122 +int dpsw_if_enable(struct fsl_mc_io *mc_io,
10123 + uint32_t cmd_flags,
10127 + struct mc_command cmd = { 0 };
10129 + /* prepare command */
10130 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_ENABLE,
10133 + DPSW_CMD_IF_ENABLE(cmd, if_id);
10135 + /* send command to mc*/
10136 + return mc_send_command(mc_io, &cmd);
10139 +int dpsw_if_disable(struct fsl_mc_io *mc_io,
10140 + uint32_t cmd_flags,
10144 + struct mc_command cmd = { 0 };
10146 + /* prepare command */
10147 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_DISABLE,
10150 + DPSW_CMD_IF_DISABLE(cmd, if_id);
10152 + /* send command to mc*/
10153 + return mc_send_command(mc_io, &cmd);
10156 +int dpsw_if_get_attributes(struct fsl_mc_io *mc_io,
10157 + uint32_t cmd_flags,
10160 + struct dpsw_if_attr *attr)
10162 + struct mc_command cmd = { 0 };
10165 + /* prepare command */
10166 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_ATTR,
10169 + DPSW_CMD_IF_GET_ATTR(cmd, if_id);
10171 + /* send command to mc*/
10172 + err = mc_send_command(mc_io, &cmd);
10176 + /* retrieve response parameters */
10177 + DPSW_RSP_IF_GET_ATTR(cmd, attr);
10182 +int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
10183 + uint32_t cmd_flags,
10186 + uint16_t frame_length)
10188 + struct mc_command cmd = { 0 };
10190 + /* prepare command */
10191 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH,
10194 + DPSW_CMD_IF_SET_MAX_FRAME_LENGTH(cmd, if_id, frame_length);
10196 + /* send command to mc*/
10197 + return mc_send_command(mc_io, &cmd);
10200 +int dpsw_if_get_max_frame_length(struct fsl_mc_io *mc_io,
10201 + uint32_t cmd_flags,
10204 + uint16_t *frame_length)
10206 + struct mc_command cmd = { 0 };
10209 + /* prepare command */
10210 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_IF_GET_MAX_FRAME_LENGTH,
10213 + DPSW_CMD_IF_GET_MAX_FRAME_LENGTH(cmd, if_id);
10215 + /* send command to mc*/
10216 + err = mc_send_command(mc_io, &cmd);
10220 + DPSW_RSP_IF_GET_MAX_FRAME_LENGTH(cmd, *frame_length);
10225 +int dpsw_vlan_add(struct fsl_mc_io *mc_io,
10226 + uint32_t cmd_flags,
10228 + uint16_t vlan_id,
10229 + const struct dpsw_vlan_cfg *cfg)
10231 + struct mc_command cmd = { 0 };
10233 + /* prepare command */
10234 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD,
10237 + DPSW_CMD_VLAN_ADD(cmd, vlan_id, cfg);
10239 + /* send command to mc*/
10240 + return mc_send_command(mc_io, &cmd);
10243 +int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
10244 + uint32_t cmd_flags,
10246 + uint16_t vlan_id,
10247 + const struct dpsw_vlan_if_cfg *cfg)
10249 + struct mc_command cmd = { 0 };
10251 + /* prepare command */
10252 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10253 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF,
10256 + DPSW_CMD_VLAN_ADD_IF(cmd, vlan_id);
10258 + /* send command to mc*/
10259 + return mc_send_command(mc_io, &cmd);
10262 +int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
10263 + uint32_t cmd_flags,
10265 + uint16_t vlan_id,
10266 + const struct dpsw_vlan_if_cfg *cfg)
10268 + struct mc_command cmd = { 0 };
10270 + /* prepare command */
10271 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10272 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF_UNTAGGED,
10275 + DPSW_CMD_VLAN_ADD_IF_UNTAGGED(cmd, vlan_id);
10277 + /* send command to mc*/
10278 + return mc_send_command(mc_io, &cmd);
10281 +int dpsw_vlan_add_if_flooding(struct fsl_mc_io *mc_io,
10282 + uint32_t cmd_flags,
10284 + uint16_t vlan_id,
10285 + const struct dpsw_vlan_if_cfg *cfg)
10287 + struct mc_command cmd = { 0 };
10289 + /* prepare command */
10290 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10291 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_ADD_IF_FLOODING,
10294 + DPSW_CMD_VLAN_ADD_IF_FLOODING(cmd, vlan_id);
10296 + /* send command to mc*/
10297 + return mc_send_command(mc_io, &cmd);
10300 +int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
10301 + uint32_t cmd_flags,
10303 + uint16_t vlan_id,
10304 + const struct dpsw_vlan_if_cfg *cfg)
10306 + struct mc_command cmd = { 0 };
10308 + /* prepare command */
10309 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10310 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF,
10313 + DPSW_CMD_VLAN_REMOVE_IF(cmd, vlan_id);
10315 + /* send command to mc*/
10316 + return mc_send_command(mc_io, &cmd);
10319 +int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
10320 + uint32_t cmd_flags,
10322 + uint16_t vlan_id,
10323 + const struct dpsw_vlan_if_cfg *cfg)
10325 + struct mc_command cmd = { 0 };
10327 + /* prepare command */
10328 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10329 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED,
10332 + DPSW_CMD_VLAN_REMOVE_IF_UNTAGGED(cmd, vlan_id);
10334 + /* send command to mc*/
10335 + return mc_send_command(mc_io, &cmd);
10338 +int dpsw_vlan_remove_if_flooding(struct fsl_mc_io *mc_io,
10339 + uint32_t cmd_flags,
10341 + uint16_t vlan_id,
10342 + const struct dpsw_vlan_if_cfg *cfg)
10344 + struct mc_command cmd = { 0 };
10346 + /* prepare command */
10347 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10348 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE_IF_FLOODING,
10351 + DPSW_CMD_VLAN_REMOVE_IF_FLOODING(cmd, vlan_id);
10353 + /* send command to mc*/
10354 + return mc_send_command(mc_io, &cmd);
10357 +int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
10358 + uint32_t cmd_flags,
10360 + uint16_t vlan_id)
10362 + struct mc_command cmd = { 0 };
10364 + /* prepare command */
10365 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_REMOVE,
10368 + DPSW_CMD_VLAN_REMOVE(cmd, vlan_id);
10370 + /* send command to mc*/
10371 + return mc_send_command(mc_io, &cmd);
10374 +int dpsw_vlan_get_attributes(struct fsl_mc_io *mc_io,
10375 + uint32_t cmd_flags,
10377 + uint16_t vlan_id,
10378 + struct dpsw_vlan_attr *attr)
10380 + struct mc_command cmd = { 0 };
10383 + /* prepare command */
10384 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_ATTRIBUTES,
10387 + DPSW_CMD_VLAN_GET_ATTR(cmd, vlan_id);
10389 + /* send command to mc*/
10390 + err = mc_send_command(mc_io, &cmd);
10394 + /* retrieve response parameters */
10395 + DPSW_RSP_VLAN_GET_ATTR(cmd, attr);
10400 +int dpsw_vlan_get_if(struct fsl_mc_io *mc_io,
10401 + uint32_t cmd_flags,
10403 + uint16_t vlan_id,
10404 + struct dpsw_vlan_if_cfg *cfg)
10406 + struct mc_command cmd = { 0 };
10409 + /* prepare command */
10410 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF,
10413 + DPSW_CMD_VLAN_GET_IF(cmd, vlan_id);
10415 + /* send command to mc*/
10416 + err = mc_send_command(mc_io, &cmd);
10420 + /* retrieve response parameters */
10421 + DPSW_RSP_VLAN_GET_IF(cmd, cfg);
10422 + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
10427 +int dpsw_vlan_get_if_flooding(struct fsl_mc_io *mc_io,
10428 + uint32_t cmd_flags,
10430 + uint16_t vlan_id,
10431 + struct dpsw_vlan_if_cfg *cfg)
10433 + struct mc_command cmd = { 0 };
10436 + /* prepare command */
10437 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF_FLOODING,
10440 + DPSW_CMD_VLAN_GET_IF_FLOODING(cmd, vlan_id);
10442 + /* send command to mc*/
10443 + err = mc_send_command(mc_io, &cmd);
10447 + /* retrieve response parameters */
10448 + DPSW_RSP_VLAN_GET_IF_FLOODING(cmd, cfg);
10449 + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
10454 +int dpsw_vlan_get_if_untagged(struct fsl_mc_io *mc_io,
10455 + uint32_t cmd_flags,
10457 + uint16_t vlan_id,
10458 + struct dpsw_vlan_if_cfg *cfg)
10460 + struct mc_command cmd = { 0 };
10463 + /* prepare command */
10464 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_VLAN_GET_IF_UNTAGGED,
10467 + DPSW_CMD_VLAN_GET_IF_UNTAGGED(cmd, vlan_id);
10469 + /* send command to mc*/
10470 + err = mc_send_command(mc_io, &cmd);
10474 + /* retrieve response parameters */
10475 + DPSW_RSP_VLAN_GET_IF(cmd, cfg);
10476 + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 1);
10481 +int dpsw_fdb_add(struct fsl_mc_io *mc_io,
10482 + uint32_t cmd_flags,
10484 + uint16_t *fdb_id,
10485 + const struct dpsw_fdb_cfg *cfg)
10487 + struct mc_command cmd = { 0 };
10490 + /* prepare command */
10491 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD,
10494 + DPSW_CMD_FDB_ADD(cmd, cfg);
10496 + /* send command to mc*/
10497 + err = mc_send_command(mc_io, &cmd);
10501 + /* retrieve response parameters */
10502 + DPSW_RSP_FDB_ADD(cmd, *fdb_id);
10507 +int dpsw_fdb_remove(struct fsl_mc_io *mc_io,
10508 + uint32_t cmd_flags,
10512 + struct mc_command cmd = { 0 };
10514 + /* prepare command */
10515 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE,
10518 + DPSW_CMD_FDB_REMOVE(cmd, fdb_id);
10520 + /* send command to mc*/
10521 + return mc_send_command(mc_io, &cmd);
10524 +int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
10525 + uint32_t cmd_flags,
10528 + const struct dpsw_fdb_unicast_cfg *cfg)
10530 + struct mc_command cmd = { 0 };
10532 + /* prepare command */
10533 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD_UNICAST,
10536 + DPSW_CMD_FDB_ADD_UNICAST(cmd, fdb_id, cfg);
10538 + /* send command to mc*/
10539 + return mc_send_command(mc_io, &cmd);
10542 +int dpsw_fdb_get_unicast(struct fsl_mc_io *mc_io,
10543 + uint32_t cmd_flags,
10546 + struct dpsw_fdb_unicast_cfg *cfg)
10548 + struct mc_command cmd = { 0 };
10551 + /* prepare command */
10552 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_UNICAST,
10555 + DPSW_CMD_FDB_GET_UNICAST(cmd, fdb_id);
10557 + /* send command to mc*/
10558 + err = mc_send_command(mc_io, &cmd);
10562 + /* retrieve response parameters */
10563 + DPSW_RSP_FDB_GET_UNICAST(cmd, cfg);
10568 +int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
10569 + uint32_t cmd_flags,
10572 + const struct dpsw_fdb_unicast_cfg *cfg)
10574 + struct mc_command cmd = { 0 };
10576 + /* prepare command */
10577 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE_UNICAST,
10580 + DPSW_CMD_FDB_REMOVE_UNICAST(cmd, fdb_id, cfg);
10582 + /* send command to mc*/
10583 + return mc_send_command(mc_io, &cmd);
10586 +int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
10587 + uint32_t cmd_flags,
10590 + const struct dpsw_fdb_multicast_cfg *cfg)
10592 + struct mc_command cmd = { 0 };
10594 + /* prepare command */
10595 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 2);
10596 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_ADD_MULTICAST,
10599 + DPSW_CMD_FDB_ADD_MULTICAST(cmd, fdb_id, cfg);
10601 + /* send command to mc*/
10602 + return mc_send_command(mc_io, &cmd);
10605 +int dpsw_fdb_get_multicast(struct fsl_mc_io *mc_io,
10606 + uint32_t cmd_flags,
10609 + struct dpsw_fdb_multicast_cfg *cfg)
10611 + struct mc_command cmd = { 0 };
10614 + /* prepare command */
10615 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_MULTICAST,
10618 + DPSW_CMD_FDB_GET_MULTICAST(cmd, fdb_id);
10620 + /* send command to mc*/
10621 + err = mc_send_command(mc_io, &cmd);
10625 + /* retrieve response parameters */
10626 + DPSW_RSP_FDB_GET_MULTICAST(cmd, cfg);
10627 + read_if_id_bitmap(cfg->if_id, &cfg->num_ifs, &cmd, 2);
10632 +int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
10633 + uint32_t cmd_flags,
10636 + const struct dpsw_fdb_multicast_cfg *cfg)
10638 + struct mc_command cmd = { 0 };
10640 + /* prepare command */
10641 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 2);
10642 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_REMOVE_MULTICAST,
10645 + DPSW_CMD_FDB_REMOVE_MULTICAST(cmd, fdb_id, cfg);
10647 + /* send command to mc*/
10648 + return mc_send_command(mc_io, &cmd);
10651 +int dpsw_fdb_set_learning_mode(struct fsl_mc_io *mc_io,
10652 + uint32_t cmd_flags,
10655 + enum dpsw_fdb_learning_mode mode)
10657 + struct mc_command cmd = { 0 };
10659 + /* prepare command */
10660 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_SET_LEARNING_MODE,
10663 + DPSW_CMD_FDB_SET_LEARNING_MODE(cmd, fdb_id, mode);
10665 + /* send command to mc*/
10666 + return mc_send_command(mc_io, &cmd);
10669 +int dpsw_fdb_get_attributes(struct fsl_mc_io *mc_io,
10670 + uint32_t cmd_flags,
10673 + struct dpsw_fdb_attr *attr)
10675 + struct mc_command cmd = { 0 };
10678 + /* prepare command */
10679 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_FDB_GET_ATTR,
10682 + DPSW_CMD_FDB_GET_ATTR(cmd, fdb_id);
10684 + /* send command to mc*/
10685 + err = mc_send_command(mc_io, &cmd);
10689 + /* retrieve response parameters */
10690 + DPSW_RSP_FDB_GET_ATTR(cmd, attr);
10695 +int dpsw_acl_add(struct fsl_mc_io *mc_io,
10696 + uint32_t cmd_flags,
10698 + uint16_t *acl_id,
10699 + const struct dpsw_acl_cfg *cfg)
10701 + struct mc_command cmd = { 0 };
10704 + /* prepare command */
10705 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD,
10708 + DPSW_CMD_ACL_ADD(cmd, cfg);
10710 + /* send command to mc*/
10711 + err = mc_send_command(mc_io, &cmd);
10715 + /* retrieve response parameters */
10716 + DPSW_RSP_ACL_ADD(cmd, *acl_id);
10721 +int dpsw_acl_remove(struct fsl_mc_io *mc_io,
10722 + uint32_t cmd_flags,
10726 + struct mc_command cmd = { 0 };
10728 + /* prepare command */
10729 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE,
10732 + DPSW_CMD_ACL_REMOVE(cmd, acl_id);
10734 + /* send command to mc*/
10735 + return mc_send_command(mc_io, &cmd);
10738 +void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
10739 + uint8_t *entry_cfg_buf)
10741 + uint64_t *ext_params = (uint64_t *)entry_cfg_buf;
10743 + DPSW_PREP_ACL_ENTRY(ext_params, key);
10746 +int dpsw_acl_add_entry(struct fsl_mc_io *mc_io,
10747 + uint32_t cmd_flags,
10750 + const struct dpsw_acl_entry_cfg *cfg)
10752 + struct mc_command cmd = { 0 };
10754 + /* prepare command */
10755 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD_ENTRY,
10758 + DPSW_CMD_ACL_ADD_ENTRY(cmd, acl_id, cfg);
10760 + /* send command to mc*/
10761 + return mc_send_command(mc_io, &cmd);
10764 +int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io,
10765 + uint32_t cmd_flags,
10768 + const struct dpsw_acl_entry_cfg *cfg)
10770 + struct mc_command cmd = { 0 };
10772 + /* prepare command */
10773 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE_ENTRY,
10776 + DPSW_CMD_ACL_REMOVE_ENTRY(cmd, acl_id, cfg);
10778 + /* send command to mc*/
10779 + return mc_send_command(mc_io, &cmd);
10782 +int dpsw_acl_add_if(struct fsl_mc_io *mc_io,
10783 + uint32_t cmd_flags,
10786 + const struct dpsw_acl_if_cfg *cfg)
10788 + struct mc_command cmd = { 0 };
10790 + /* prepare command */
10791 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10792 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_ADD_IF,
10795 + DPSW_CMD_ACL_ADD_IF(cmd, acl_id, cfg);
10797 + /* send command to mc*/
10798 + return mc_send_command(mc_io, &cmd);
10801 +int dpsw_acl_remove_if(struct fsl_mc_io *mc_io,
10802 + uint32_t cmd_flags,
10805 + const struct dpsw_acl_if_cfg *cfg)
10807 + struct mc_command cmd = { 0 };
10809 + /* prepare command */
10810 + build_if_id_bitmap(cfg->if_id, cfg->num_ifs, &cmd, 1);
10811 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_REMOVE_IF,
10814 + DPSW_CMD_ACL_REMOVE_IF(cmd, acl_id, cfg);
10816 + /* send command to mc*/
10817 + return mc_send_command(mc_io, &cmd);
10820 +int dpsw_acl_get_attributes(struct fsl_mc_io *mc_io,
10821 + uint32_t cmd_flags,
10824 + struct dpsw_acl_attr *attr)
10826 + struct mc_command cmd = { 0 };
10829 + /* prepare command */
10830 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_ACL_GET_ATTR,
10833 + DPSW_CMD_ACL_GET_ATTR(cmd, acl_id);
10835 + /* send command to mc*/
10836 + err = mc_send_command(mc_io, &cmd);
10840 + /* retrieve response parameters */
10841 + DPSW_RSP_ACL_GET_ATTR(cmd, attr);
10846 +int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io,
10847 + uint32_t cmd_flags,
10849 + struct dpsw_ctrl_if_attr *attr)
10851 + struct mc_command cmd = { 0 };
10854 + /* prepare command */
10855 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_GET_ATTR,
10859 + /* send command to mc*/
10860 + err = mc_send_command(mc_io, &cmd);
10864 + /* retrieve response parameters */
10865 + DPSW_RSP_CTRL_IF_GET_ATTR(cmd, attr);
10870 +int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io,
10871 + uint32_t cmd_flags,
10873 + const struct dpsw_ctrl_if_pools_cfg *pools)
10875 + struct mc_command cmd = { 0 };
10877 + /* prepare command */
10878 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_SET_POOLS,
10881 + DPSW_CMD_CTRL_IF_SET_POOLS(cmd, pools);
10883 + /* send command to mc*/
10884 + return mc_send_command(mc_io, &cmd);
10887 +int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io,
10888 + uint32_t cmd_flags,
10891 + struct mc_command cmd = { 0 };
10893 + /* prepare command */
10894 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_ENABLE,
10898 + /* send command to mc*/
10899 + return mc_send_command(mc_io, &cmd);
10903 +* @brief Function disables control interface
10904 +* @mc_io: Pointer to MC portal's I/O object
10905 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
10906 +* @token: Token of DPSW object
10908 +* Return: '0' on Success; Error code otherwise.
10910 +int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io,
10911 + uint32_t cmd_flags,
10914 + struct mc_command cmd = { 0 };
10916 + /* prepare command */
10917 + cmd.header = mc_encode_cmd_header(DPSW_CMDID_CTRL_IF_DISABLE,
10921 + /* send command to mc*/
10922 + return mc_send_command(mc_io, &cmd);
10924 diff --git a/drivers/net/dpaa2/mc/fsl_dpaiop.h b/drivers/net/dpaa2/mc/fsl_dpaiop.h
10925 new file mode 100644
10926 index 0000000..b039b2a
10928 +++ b/drivers/net/dpaa2/mc/fsl_dpaiop.h
10930 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
10932 + * Redistribution and use in source and binary forms, with or without
10933 + * modification, are permitted provided that the following conditions are met:
10934 + * * Redistributions of source code must retain the above copyright
10935 + * notice, this list of conditions and the following disclaimer.
10936 + * * Redistributions in binary form must reproduce the above copyright
10937 + * notice, this list of conditions and the following disclaimer in the
10938 + * documentation and/or other materials provided with the distribution.
10939 + * * Neither the name of the above-listed copyright holders nor the
10940 + * names of any contributors may be used to endorse or promote products
10941 + * derived from this software without specific prior written permission.
10944 + * ALTERNATIVELY, this software may be distributed under the terms of the
10945 + * GNU General Public License ("GPL") as published by the Free Software
10946 + * Foundation, either version 2 of that License or (at your option) any
10949 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
10950 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
10951 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
10952 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
10953 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
10954 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
10955 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
10956 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
10957 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
10958 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
10959 + * POSSIBILITY OF SUCH DAMAGE.
10961 +#ifndef __FSL_DPAIOP_H
10962 +#define __FSL_DPAIOP_H
10966 +/* Data Path AIOP API
10967 + * Contains initialization APIs and runtime control APIs for DPAIOP
10971 + * dpaiop_open() - Open a control session for the specified object.
10972 + * @mc_io: Pointer to MC portal's I/O object
10973 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
10974 + * @dpaiop_id: DPAIOP unique ID
10975 + * @token: Returned token; use in subsequent API calls
10977 + * This function can be used to open a control session for an
10978 + * already created object; an object may have been declared in
10979 + * the DPL or by calling the dpaiop_create function.
10980 + * This function returns a unique authentication token,
10981 + * associated with the specific object ID and the specific MC
10982 + * portal; this token must be used in all subsequent commands for
10983 + * this specific object
10985 + * Return: '0' on Success; Error code otherwise.
10987 +int dpaiop_open(struct fsl_mc_io *mc_io,
10988 + uint32_t cmd_flags,
10990 + uint16_t *token);
10993 + * dpaiop_close() - Close the control session of the object
10994 + * @mc_io: Pointer to MC portal's I/O object
10995 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
10996 + * @token: Token of DPAIOP object
10998 + * After this function is called, no further operations are
10999 + * allowed on the object without opening a new control session.
11001 + * Return: '0' on Success; Error code otherwise.
11003 +int dpaiop_close(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token);
11006 + * struct dpaiop_cfg - Structure representing DPAIOP configuration
11007 + * @aiop_id: AIOP ID
11008 + * @aiop_container_id: AIOP container ID
11010 +struct dpaiop_cfg {
11012 + int aiop_container_id;
11016 + * dpaiop_create() - Create the DPAIOP object.
11017 + * @mc_io: Pointer to MC portal's I/O object
11018 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11019 + * @cfg: Configuration structure
11020 + * @token: Returned token; use in subsequent API calls
11022 + * Create the DPAIOP object, allocate required resources and
11023 + * perform required initialization.
11025 + * The object can be created either by declaring it in the
11026 + * DPL file, or by calling this function.
11027 + * This function returns a unique authentication token,
11028 + * associated with the specific object ID and the specific MC
11029 + * portal; this token must be used in all subsequent calls to
11030 + * this specific object. For objects that are created using the
11031 + * DPL file, call dpaiop_open function to get an authentication
11034 + * Return: '0' on Success; Error code otherwise.
11036 +int dpaiop_create(struct fsl_mc_io *mc_io,
11037 + uint32_t cmd_flags,
11038 + const struct dpaiop_cfg *cfg,
11039 + uint16_t *token);
11042 + * dpaiop_destroy() - Destroy the DPAIOP object and release all its resources.
11043 + * @mc_io: Pointer to MC portal's I/O object
11044 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11045 + * @token: Token of DPAIOP object
11047 + * Return: '0' on Success; error code otherwise.
11049 +int dpaiop_destroy(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token);
11052 + * dpaiop_reset() - Reset the DPAIOP, returns the object to initial state.
11053 + * @mc_io: Pointer to MC portal's I/O object
11054 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11055 + * @token: Token of DPAIOP object
11057 + * Return: '0' on Success; Error code otherwise.
11059 +int dpaiop_reset(struct fsl_mc_io *mc_io, uint32_t cmd_flags, uint16_t token);
11062 + * struct dpaiop_irq_cfg - IRQ configuration
11063 + * @addr: Address that must be written to signal a message-based interrupt
11064 + * @val: Value to write into irq_addr address
11065 + * @irq_num: A user defined number associated with this IRQ
11067 +struct dpaiop_irq_cfg {
11074 + * dpaiop_set_irq() - Set IRQ information for the DPAIOP to trigger an interrupt.
11075 + * @mc_io: Pointer to MC portal's I/O object
11076 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11077 + * @token: Token of DPAIOP object
11078 + * @irq_index: Identifies the interrupt index to configure
11079 + * @irq_cfg: IRQ configuration
11081 + * Return: '0' on Success; Error code otherwise.
11083 +int dpaiop_set_irq(struct fsl_mc_io *mc_io,
11084 + uint32_t cmd_flags,
11086 + uint8_t irq_index,
11087 + struct dpaiop_irq_cfg *irq_cfg);
11090 + * dpaiop_get_irq() - Get IRQ information from the DPAIOP.
11091 + * @mc_io: Pointer to MC portal's I/O object
11092 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11093 + * @token: Token of DPAIOP object
11094 + * @irq_index: The interrupt index to configure
11095 + * @type: Interrupt type: 0 represents message interrupt
11096 + * type (both irq_addr and irq_val are valid)
11097 + * @irq_cfg: IRQ attributes
11099 + * Return: '0' on Success; Error code otherwise.
11101 +int dpaiop_get_irq(struct fsl_mc_io *mc_io,
11102 + uint32_t cmd_flags,
11104 + uint8_t irq_index,
11106 + struct dpaiop_irq_cfg *irq_cfg);
11109 + * dpaiop_set_irq_enable() - Set overall interrupt state.
11110 + * @mc_io: Pointer to MC portal's I/O object
11111 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11112 + * @token: Token of DPAIOP object
11113 + * @irq_index: The interrupt index to configure
11114 + * @en: Interrupt state - enable = 1, disable = 0
11116 + * Allows GPP software to control when interrupts are generated.
11117 + * Each interrupt can have up to 32 causes. The enable/disable control's the
11118 + * overall interrupt state. if the interrupt is disabled no causes will cause
11121 + * Return: '0' on Success; Error code otherwise.
11123 +int dpaiop_set_irq_enable(struct fsl_mc_io *mc_io,
11124 + uint32_t cmd_flags,
11126 + uint8_t irq_index,
11130 + * dpaiop_get_irq_enable() - Get overall interrupt state
11131 + * @mc_io: Pointer to MC portal's I/O object
11132 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11133 + * @token: Token of DPAIOP object
11134 + * @irq_index: The interrupt index to configure
11135 + * @en: Returned interrupt state - enable = 1, disable = 0
11137 + * Return: '0' on Success; Error code otherwise.
11139 +int dpaiop_get_irq_enable(struct fsl_mc_io *mc_io,
11140 + uint32_t cmd_flags,
11142 + uint8_t irq_index,
11146 + * dpaiop_set_irq_mask() - Set interrupt mask.
11147 + * @mc_io: Pointer to MC portal's I/O object
11148 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11149 + * @token: Token of DPAIOP object
11150 + * @irq_index: The interrupt index to configure
11151 + * @mask: Event mask to trigger interrupt;
11153 + * 0 = ignore event
11154 + * 1 = consider event for asserting IRQ
11156 + * Every interrupt can have up to 32 causes and the interrupt model supports
11157 + * masking/unmasking each cause independently
11159 + * Return: '0' on Success; Error code otherwise.
11161 +int dpaiop_set_irq_mask(struct fsl_mc_io *mc_io,
11162 + uint32_t cmd_flags,
11164 + uint8_t irq_index,
11168 + * dpaiop_get_irq_mask() - Get interrupt mask.
11169 + * @mc_io: Pointer to MC portal's I/O object
11170 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11171 + * @token: Token of DPAIOP object
11172 + * @irq_index: The interrupt index to configure
11173 + * @mask: Returned event mask to trigger interrupt
11175 + * Every interrupt can have up to 32 causes and the interrupt model supports
11176 + * masking/unmasking each cause independently
11178 + * Return: '0' on Success; Error code otherwise.
11180 +int dpaiop_get_irq_mask(struct fsl_mc_io *mc_io,
11181 + uint32_t cmd_flags,
11183 + uint8_t irq_index,
11187 + * dpaiop_get_irq_status() - Get the current status of any pending interrupts.
11189 + * @mc_io: Pointer to MC portal's I/O object
11190 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11191 + * @token: Token of DPAIOP object
11192 + * @irq_index: The interrupt index to configure
11193 + * @status: Returned interrupts status - one bit per cause:
11194 + * 0 = no interrupt pending
11195 + * 1 = interrupt pending
11197 + * Return: '0' on Success; Error code otherwise.
11199 +int dpaiop_get_irq_status(struct fsl_mc_io *mc_io,
11200 + uint32_t cmd_flags,
11202 + uint8_t irq_index,
11203 + uint32_t *status);
11206 + * dpaiop_clear_irq_status() - Clear a pending interrupt's status
11208 + * @mc_io: Pointer to MC portal's I/O object
11209 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11210 + * @token: Token of DPAIOP object
11211 + * @irq_index: The interrupt index to configure
11212 + * @status: Bits to clear (W1C) - one bit per cause:
11213 + * 0 = don't change
11214 + * 1 = clear status bit
11216 + * Return: '0' on Success; Error code otherwise.
11218 +int dpaiop_clear_irq_status(struct fsl_mc_io *mc_io,
11219 + uint32_t cmd_flags,
11221 + uint8_t irq_index,
11222 + uint32_t status);
11225 + * struct dpaiop_attr - Structure representing DPAIOP attributes
11227 + * @version: DPAIOP version
11229 +struct dpaiop_attr {
11232 + * struct version - Structure representing DPAIOP version
11233 + * @major: DPAIOP major version
11234 + * @minor: DPAIOP minor version
11243 + * dpaiop_get_attributes - Retrieve DPAIOP attributes.
11245 + * @mc_io: Pointer to MC portal's I/O object
11246 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11247 + * @token: Token of DPAIOP object
11248 + * @attr: Returned object's attributes
11250 + * Return: '0' on Success; Error code otherwise.
11252 +int dpaiop_get_attributes(struct fsl_mc_io *mc_io,
11253 + uint32_t cmd_flags,
11255 + struct dpaiop_attr *attr);
11258 + * struct dpaiop_load_cfg - AIOP load configuration
11259 + * @options: AIOP load options
11260 + * @img_iova: I/O virtual address of AIOP ELF image
11261 + * @img_size: Size of AIOP ELF image in memory (in bytes)
11263 +struct dpaiop_load_cfg {
11264 + uint64_t options;
11265 + uint64_t img_iova;
11266 + uint32_t img_size;
11270 + * dpaiop_load_aiop() - Loads an image to AIOP
11271 + * @mc_io: Pointer to MC portal's I/O object
11272 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11273 + * @token: Token of DPAIOP object
11274 + * @cfg: AIOP load configurations
11276 + * Return: '0' on Success; Error code otherwise.
11278 +int dpaiop_load(struct fsl_mc_io *mc_io,
11279 + uint32_t cmd_flags,
11281 + struct dpaiop_load_cfg *cfg);
11283 +#define DPAIOP_RUN_OPT_DEBUG 0x0000000000000001ULL
11286 + * struct dpaiop_run_cfg - AIOP run configuration
11287 + * @cores_mask: Mask of AIOP cores to run (core 0 in most significant bit)
11288 + * @options: Execution options (currently none defined)
11289 + * @args_iova: I/O virtual address of AIOP arguments
11290 + * @args_size: Size of AIOP arguments in memory (in bytes)
11292 +struct dpaiop_run_cfg {
11293 + uint64_t cores_mask;
11294 + uint64_t options;
11295 + uint64_t args_iova;
11296 + uint32_t args_size;
11300 + * dpaiop_run_aiop() - Starts AIOP execution
11301 + * @mc_io: Pointer to MC portal's I/O object
11302 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11303 + * @token: Token of DPAIOP object
11304 + * @cfg: AIOP run configuration
11306 + * Return: '0' on Success; Error code otherwise.
11308 +int dpaiop_run(struct fsl_mc_io *mc_io,
11309 + uint32_t cmd_flags,
11311 + const struct dpaiop_run_cfg *cfg);
11314 + * struct dpaiop_sl_version - AIOP SL (Service Layer) version
11315 + * @major: AIOP SL major version number
11316 + * @minor: AIOP SL minor version number
11317 + * @revision: AIOP SL revision number
11319 +struct dpaiop_sl_version {
11322 + uint32_t revision;
11326 + * dpaiop_get_sl_version() - Get AIOP SL (Service Layer) version
11327 + * @mc_io: Pointer to MC portal's I/O object
11328 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11329 + * @token: Token of DPAIOP object
11330 + * @version: AIOP SL version number
11332 + * Return: '0' on Success; Error code otherwise.
11334 +int dpaiop_get_sl_version(struct fsl_mc_io *mc_io,
11335 + uint32_t cmd_flags,
11337 + struct dpaiop_sl_version *version);
11342 + * AIOP internal states, can be retrieved by calling dpaiop_get_state() routine
11346 + * AIOP reset successfully completed.
11348 +#define DPAIOP_STATE_RESET_DONE 0x00000000
11350 + * AIOP reset is ongoing.
11352 +#define DPAIOP_STATE_RESET_ONGOING 0x00000001
11355 + * AIOP image loading successfully completed.
11357 +#define DPAIOP_STATE_LOAD_DONE 0x00000002
11359 + * AIOP image loading is ongoing.
11361 +#define DPAIOP_STATE_LOAD_ONGIONG 0x00000004
11363 + * AIOP image loading completed with error.
11365 +#define DPAIOP_STATE_LOAD_ERROR 0x00000008
11368 + * Boot process of AIOP cores is ongoing.
11370 +#define DPAIOP_STATE_BOOT_ONGOING 0x00000010
11372 + * Boot process of AIOP cores completed with an error.
11374 +#define DPAIOP_STATE_BOOT_ERROR 0x00000020
11376 + * AIOP cores are functional and running
11378 +#define DPAIOP_STATE_RUNNING 0x00000040
11382 + * dpaiop_get_state() - Get AIOP state
11383 + * @mc_io: Pointer to MC portal's I/O object
11384 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11385 + * @token: Token of DPAIOP object
11386 + * @state: AIOP state
11388 + * Return: '0' on Success; Error code otherwise.
11390 +int dpaiop_get_state(struct fsl_mc_io *mc_io,
11391 + uint32_t cmd_flags,
11393 + uint32_t *state);
11396 + * dpaiop_set_time_of_day() - Set AIOP internal time-of-day
11397 + * @mc_io: Pointer to MC portal's I/O object
11398 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11399 + * @token: Token of DPAIOP object
11400 + * @time_of_day: Current number of milliseconds since the Epoch
11402 + * Return: '0' on Success; Error code otherwise.
11404 +int dpaiop_set_time_of_day(struct fsl_mc_io *mc_io,
11405 + uint32_t cmd_flags,
11407 + uint64_t time_of_day);
11410 + * dpaiop_get_time_of_day() - Get AIOP internal time-of-day
11411 + * @mc_io: Pointer to MC portal's I/O object
11412 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11413 + * @token: Token of DPAIOP object
11414 + * @time_of_day: Current number of milliseconds since the Epoch
11416 + * Return: '0' on Success; Error code otherwise.
11418 +int dpaiop_get_time_of_day(struct fsl_mc_io *mc_io,
11419 + uint32_t cmd_flags,
11421 + uint64_t *time_of_day);
11423 +#endif /* __FSL_DPAIOP_H */
11424 diff --git a/drivers/net/dpaa2/mc/fsl_dpaiop_cmd.h b/drivers/net/dpaa2/mc/fsl_dpaiop_cmd.h
11425 new file mode 100644
11426 index 0000000..5b77bb8
11428 +++ b/drivers/net/dpaa2/mc/fsl_dpaiop_cmd.h
11430 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
11432 + * Redistribution and use in source and binary forms, with or without
11433 + * modification, are permitted provided that the following conditions are met:
11434 + * * Redistributions of source code must retain the above copyright
11435 + * notice, this list of conditions and the following disclaimer.
11436 + * * Redistributions in binary form must reproduce the above copyright
11437 + * notice, this list of conditions and the following disclaimer in the
11438 + * documentation and/or other materials provided with the distribution.
11439 + * * Neither the name of the above-listed copyright holders nor the
11440 + * names of any contributors may be used to endorse or promote products
11441 + * derived from this software without specific prior written permission.
11444 + * ALTERNATIVELY, this software may be distributed under the terms of the
11445 + * GNU General Public License ("GPL") as published by the Free Software
11446 + * Foundation, either version 2 of that License or (at your option) any
11449 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
11450 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11451 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
11452 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
11453 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11454 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
11455 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
11456 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
11457 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
11458 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
11459 + * POSSIBILITY OF SUCH DAMAGE.
11461 +#ifndef _FSL_DPAIOP_CMD_H
11462 +#define _FSL_DPAIOP_CMD_H
11464 +/* DPAIOP Version */
11465 +#define DPAIOP_VER_MAJOR 1
11466 +#define DPAIOP_VER_MINOR 2
11469 +#define DPAIOP_CMDID_CLOSE 0x800
11470 +#define DPAIOP_CMDID_OPEN 0x80a
11471 +#define DPAIOP_CMDID_CREATE 0x90a
11472 +#define DPAIOP_CMDID_DESTROY 0x900
11474 +#define DPAIOP_CMDID_GET_ATTR 0x004
11475 +#define DPAIOP_CMDID_RESET 0x005
11477 +#define DPAIOP_CMDID_SET_IRQ 0x010
11478 +#define DPAIOP_CMDID_GET_IRQ 0x011
11479 +#define DPAIOP_CMDID_SET_IRQ_ENABLE 0x012
11480 +#define DPAIOP_CMDID_GET_IRQ_ENABLE 0x013
11481 +#define DPAIOP_CMDID_SET_IRQ_MASK 0x014
11482 +#define DPAIOP_CMDID_GET_IRQ_MASK 0x015
11483 +#define DPAIOP_CMDID_GET_IRQ_STATUS 0x016
11484 +#define DPAIOP_CMDID_CLEAR_IRQ_STATUS 0x017
11486 +#define DPAIOP_CMDID_LOAD 0x280
11487 +#define DPAIOP_CMDID_RUN 0x281
11488 +#define DPAIOP_CMDID_GET_SL_VERSION 0x282
11489 +#define DPAIOP_CMDID_GET_STATE 0x283
11490 +#define DPAIOP_CMDID_SET_TIME_OF_DAY 0x284
11491 +#define DPAIOP_CMDID_GET_TIME_OF_DAY 0x285
11493 +/* cmd, param, offset, width, type, arg_name */
11494 +#define DPAIOP_CMD_OPEN(cmd, dpaiop_id) \
11495 + MC_CMD_OP(cmd, 0, 0, 32, int, dpaiop_id)
11497 +/* cmd, param, offset, width, type, arg_name */
11498 +#define DPAIOP_CMD_CREATE(cmd, cfg) \
11500 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->aiop_id);\
11501 + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->aiop_container_id);\
11504 +/* cmd, param, offset, width, type, arg_name */
11505 +#define DPAIOP_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
11507 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
11508 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
11509 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
11510 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
11513 +/* cmd, param, offset, width, type, arg_name */
11514 +#define DPAIOP_CMD_GET_IRQ(cmd, irq_index) \
11515 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
11517 +/* cmd, param, offset, width, type, arg_name */
11518 +#define DPAIOP_RSP_GET_IRQ(cmd, type, irq_cfg) \
11520 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
11521 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
11522 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
11523 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
11526 +/* cmd, param, offset, width, type, arg_name */
11527 +#define DPAIOP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
11529 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
11530 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
11533 +/* cmd, param, offset, width, type, arg_name */
11534 +#define DPAIOP_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
11535 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
11537 +/* cmd, param, offset, width, type, arg_name */
11538 +#define DPAIOP_RSP_GET_IRQ_ENABLE(cmd, en) \
11539 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
11541 +/* cmd, param, offset, width, type, arg_name */
11542 +#define DPAIOP_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
11544 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\
11545 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
11548 +/* cmd, param, offset, width, type, arg_name */
11549 +#define DPAIOP_CMD_GET_IRQ_MASK(cmd, irq_index) \
11550 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
11552 +/* cmd, param, offset, width, type, arg_name */
11553 +#define DPAIOP_RSP_GET_IRQ_MASK(cmd, mask) \
11554 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
11556 +/* cmd, param, offset, width, type, arg_name */
11557 +#define DPAIOP_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
11559 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
11560 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
11563 +/* cmd, param, offset, width, type, arg_name */
11564 +#define DPAIOP_RSP_GET_IRQ_STATUS(cmd, status) \
11565 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
11567 +/* cmd, param, offset, width, type, arg_name */
11568 +#define DPAIOP_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
11570 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
11571 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
11574 +/* cmd, param, offset, width, type, arg_name */
11575 +#define DPAIOP_RSP_GET_ATTRIBUTES(cmd, attr) \
11577 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
11578 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
11579 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
11582 +/* cmd, param, offset, width, type, arg_name */
11583 +#define DPAIOP_CMD_LOAD(cmd, cfg) \
11585 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->img_size); \
11586 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->img_iova); \
11587 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options); \
11590 +/* cmd, param, offset, width, type, arg_name */
11591 +#define DPAIOP_CMD_RUN(cmd, cfg) \
11593 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->args_size); \
11594 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->cores_mask); \
11595 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options); \
11596 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->args_iova); \
11599 +/* cmd, param, offset, width, type, arg_name */
11600 +#define DPAIOP_RSP_GET_SL_VERSION(cmd, version) \
11602 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, version->major);\
11603 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, version->minor);\
11604 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, version->revision);\
11607 +/* cmd, param, offset, width, type, arg_name */
11608 +#define DPAIOP_RSP_GET_STATE(cmd, state) \
11609 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, state)
11611 +/* cmd, param, offset, width, type, arg_name */
11612 +#define DPAIOP_CMD_SET_TIME_OF_DAY(cmd, time_of_day) \
11613 + MC_CMD_OP(cmd, 0, 0, 64, uint64_t, time_of_day)
11615 +/* cmd, param, offset, width, type, arg_name */
11616 +#define DPAIOP_RSP_GET_TIME_OF_DAY(cmd, time_of_day) \
11617 + MC_RSP_OP(cmd, 0, 0, 64, uint64_t, time_of_day)
11619 +#endif /* _FSL_DPAIOP_CMD_H */
11620 diff --git a/drivers/net/dpaa2/mc/fsl_dpbp.h b/drivers/net/dpaa2/mc/fsl_dpbp.h
11621 new file mode 100644
11622 index 0000000..9856bb8
11624 +++ b/drivers/net/dpaa2/mc/fsl_dpbp.h
11626 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
11628 + * Redistribution and use in source and binary forms, with or without
11629 + * modification, are permitted provided that the following conditions are met:
11630 + * * Redistributions of source code must retain the above copyright
11631 + * notice, this list of conditions and the following disclaimer.
11632 + * * Redistributions in binary form must reproduce the above copyright
11633 + * notice, this list of conditions and the following disclaimer in the
11634 + * documentation and/or other materials provided with the distribution.
11635 + * * Neither the name of the above-listed copyright holders nor the
11636 + * names of any contributors may be used to endorse or promote products
11637 + * derived from this software without specific prior written permission.
11640 + * ALTERNATIVELY, this software may be distributed under the terms of the
11641 + * GNU General Public License ("GPL") as published by the Free Software
11642 + * Foundation, either version 2 of that License or (at your option) any
11645 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
11646 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
11647 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
11648 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
11649 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
11650 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
11651 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
11652 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
11653 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
11654 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
11655 + * POSSIBILITY OF SUCH DAMAGE.
11657 +#ifndef __FSL_DPBP_H
11658 +#define __FSL_DPBP_H
11660 +/* Data Path Buffer Pool API
11661 + * Contains initialization APIs and runtime control APIs for DPBP
11667 + * dpbp_open() - Open a control session for the specified object.
11668 + * @mc_io: Pointer to MC portal's I/O object
11669 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11670 + * @dpbp_id: DPBP unique ID
11671 + * @token: Returned token; use in subsequent API calls
11673 + * This function can be used to open a control session for an
11674 + * already created object; an object may have been declared in
11675 + * the DPL or by calling the dpbp_create function.
11676 + * This function returns a unique authentication token,
11677 + * associated with the specific object ID and the specific MC
11678 + * portal; this token must be used in all subsequent commands for
11679 + * this specific object
11681 + * Return: '0' on Success; Error code otherwise.
11683 +int dpbp_open(struct fsl_mc_io *mc_io,
11684 + uint32_t cmd_flags,
11686 + uint16_t *token);
11689 + * dpbp_close() - Close the control session of the object
11690 + * @mc_io: Pointer to MC portal's I/O object
11691 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11692 + * @token: Token of DPBP object
11694 + * After this function is called, no further operations are
11695 + * allowed on the object without opening a new control session.
11697 + * Return: '0' on Success; Error code otherwise.
11699 +int dpbp_close(struct fsl_mc_io *mc_io,
11700 + uint32_t cmd_flags,
11704 + * struct dpbp_cfg - Structure representing DPBP configuration
11705 + * @options: place holder
11708 + uint32_t options;
11712 + * dpbp_create() - Create the DPBP object.
11713 + * @mc_io: Pointer to MC portal's I/O object
11714 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11715 + * @cfg: Configuration structure
11716 + * @token: Returned token; use in subsequent API calls
11718 + * Create the DPBP object, allocate required resources and
11719 + * perform required initialization.
11721 + * The object can be created either by declaring it in the
11722 + * DPL file, or by calling this function.
11723 + * This function returns a unique authentication token,
11724 + * associated with the specific object ID and the specific MC
11725 + * portal; this token must be used in all subsequent calls to
11726 + * this specific object. For objects that are created using the
11727 + * DPL file, call dpbp_open function to get an authentication
11730 + * Return: '0' on Success; Error code otherwise.
11732 +int dpbp_create(struct fsl_mc_io *mc_io,
11733 + uint32_t cmd_flags,
11734 + const struct dpbp_cfg *cfg,
11735 + uint16_t *token);
11738 + * dpbp_destroy() - Destroy the DPBP object and release all its resources.
11739 + * @mc_io: Pointer to MC portal's I/O object
11740 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11741 + * @token: Token of DPBP object
11743 + * Return: '0' on Success; error code otherwise.
11745 +int dpbp_destroy(struct fsl_mc_io *mc_io,
11746 + uint32_t cmd_flags,
11750 + * dpbp_enable() - Enable the DPBP.
11751 + * @mc_io: Pointer to MC portal's I/O object
11752 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11753 + * @token: Token of DPBP object
11755 + * Return: '0' on Success; Error code otherwise.
11757 +int dpbp_enable(struct fsl_mc_io *mc_io,
11758 + uint32_t cmd_flags,
11762 + * dpbp_disable() - Disable the DPBP.
11763 + * @mc_io: Pointer to MC portal's I/O object
11764 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11765 + * @token: Token of DPBP object
11767 + * Return: '0' on Success; Error code otherwise.
11769 +int dpbp_disable(struct fsl_mc_io *mc_io,
11770 + uint32_t cmd_flags,
11774 + * dpbp_is_enabled() - Check if the DPBP is enabled.
11775 + * @mc_io: Pointer to MC portal's I/O object
11776 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11777 + * @token: Token of DPBP object
11778 + * @en: Returns '1' if object is enabled; '0' otherwise
11780 + * Return: '0' on Success; Error code otherwise.
11782 +int dpbp_is_enabled(struct fsl_mc_io *mc_io,
11783 + uint32_t cmd_flags,
11788 + * dpbp_reset() - Reset the DPBP, returns the object to initial state.
11789 + * @mc_io: Pointer to MC portal's I/O object
11790 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11791 + * @token: Token of DPBP object
11793 + * Return: '0' on Success; Error code otherwise.
11795 +int dpbp_reset(struct fsl_mc_io *mc_io,
11796 + uint32_t cmd_flags,
11800 + * struct dpbp_irq_cfg - IRQ configuration
11801 + * @addr: Address that must be written to signal a message-based interrupt
11802 + * @val: Value to write into irq_addr address
11803 + * @irq_num: A user defined number associated with this IRQ
11805 +struct dpbp_irq_cfg {
11812 + * dpbp_set_irq() - Set IRQ information for the DPBP to trigger an interrupt.
11813 + * @mc_io: Pointer to MC portal's I/O object
11814 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11815 + * @token: Token of DPBP object
11816 + * @irq_index: Identifies the interrupt index to configure
11817 + * @irq_cfg: IRQ configuration
11819 + * Return: '0' on Success; Error code otherwise.
11821 +int dpbp_set_irq(struct fsl_mc_io *mc_io,
11822 + uint32_t cmd_flags,
11824 + uint8_t irq_index,
11825 + struct dpbp_irq_cfg *irq_cfg);
11828 + * dpbp_get_irq() - Get IRQ information from the DPBP.
11829 + * @mc_io: Pointer to MC portal's I/O object
11830 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11831 + * @token: Token of DPBP object
11832 + * @irq_index: The interrupt index to configure
11833 + * @type: Interrupt type: 0 represents message interrupt
11834 + * type (both irq_addr and irq_val are valid)
11835 + * @irq_cfg: IRQ attributes
11837 + * Return: '0' on Success; Error code otherwise.
11839 +int dpbp_get_irq(struct fsl_mc_io *mc_io,
11840 + uint32_t cmd_flags,
11842 + uint8_t irq_index,
11844 + struct dpbp_irq_cfg *irq_cfg);
11847 + * dpbp_set_irq_enable() - Set overall interrupt state.
11848 + * @mc_io: Pointer to MC portal's I/O object
11849 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11850 + * @token: Token of DPBP object
11851 + * @irq_index: The interrupt index to configure
11852 + * @en: Interrupt state - enable = 1, disable = 0
11854 + * Allows GPP software to control when interrupts are generated.
11855 + * Each interrupt can have up to 32 causes. The enable/disable control's the
11856 + * overall interrupt state. if the interrupt is disabled no causes will cause
11859 + * Return: '0' on Success; Error code otherwise.
11861 +int dpbp_set_irq_enable(struct fsl_mc_io *mc_io,
11862 + uint32_t cmd_flags,
11864 + uint8_t irq_index,
11868 + * dpbp_get_irq_enable() - Get overall interrupt state
11869 + * @mc_io: Pointer to MC portal's I/O object
11870 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11871 + * @token: Token of DPBP object
11872 + * @irq_index: The interrupt index to configure
11873 + * @en: Returned interrupt state - enable = 1, disable = 0
11875 + * Return: '0' on Success; Error code otherwise.
11877 +int dpbp_get_irq_enable(struct fsl_mc_io *mc_io,
11878 + uint32_t cmd_flags,
11880 + uint8_t irq_index,
11884 + * dpbp_set_irq_mask() - Set interrupt mask.
11885 + * @mc_io: Pointer to MC portal's I/O object
11886 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11887 + * @token: Token of DPBP object
11888 + * @irq_index: The interrupt index to configure
11889 + * @mask: Event mask to trigger interrupt;
11891 + * 0 = ignore event
11892 + * 1 = consider event for asserting IRQ
11894 + * Every interrupt can have up to 32 causes and the interrupt model supports
11895 + * masking/unmasking each cause independently
11897 + * Return: '0' on Success; Error code otherwise.
11899 +int dpbp_set_irq_mask(struct fsl_mc_io *mc_io,
11900 + uint32_t cmd_flags,
11902 + uint8_t irq_index,
11906 + * dpbp_get_irq_mask() - Get interrupt mask.
11907 + * @mc_io: Pointer to MC portal's I/O object
11908 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11909 + * @token: Token of DPBP object
11910 + * @irq_index: The interrupt index to configure
11911 + * @mask: Returned event mask to trigger interrupt
11913 + * Every interrupt can have up to 32 causes and the interrupt model supports
11914 + * masking/unmasking each cause independently
11916 + * Return: '0' on Success; Error code otherwise.
11918 +int dpbp_get_irq_mask(struct fsl_mc_io *mc_io,
11919 + uint32_t cmd_flags,
11921 + uint8_t irq_index,
11925 + * dpbp_get_irq_status() - Get the current status of any pending interrupts.
11927 + * @mc_io: Pointer to MC portal's I/O object
11928 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11929 + * @token: Token of DPBP object
11930 + * @irq_index: The interrupt index to configure
11931 + * @status: Returned interrupts status - one bit per cause:
11932 + * 0 = no interrupt pending
11933 + * 1 = interrupt pending
11935 + * Return: '0' on Success; Error code otherwise.
11937 +int dpbp_get_irq_status(struct fsl_mc_io *mc_io,
11938 + uint32_t cmd_flags,
11940 + uint8_t irq_index,
11941 + uint32_t *status);
11944 + * dpbp_clear_irq_status() - Clear a pending interrupt's status
11946 + * @mc_io: Pointer to MC portal's I/O object
11947 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11948 + * @token: Token of DPBP object
11949 + * @irq_index: The interrupt index to configure
11950 + * @status: Bits to clear (W1C) - one bit per cause:
11951 + * 0 = don't change
11952 + * 1 = clear status bit
11954 + * Return: '0' on Success; Error code otherwise.
11956 +int dpbp_clear_irq_status(struct fsl_mc_io *mc_io,
11957 + uint32_t cmd_flags,
11959 + uint8_t irq_index,
11960 + uint32_t status);
11963 + * struct dpbp_attr - Structure representing DPBP attributes
11964 + * @id: DPBP object ID
11965 + * @version: DPBP version
11966 + * @bpid: Hardware buffer pool ID; should be used as an argument in
11967 + * acquire/release operations on buffers
11969 +struct dpbp_attr {
11972 + * struct version - Structure representing DPBP version
11973 + * @major: DPBP major version
11974 + * @minor: DPBP minor version
11984 + * dpbp_get_attributes - Retrieve DPBP attributes.
11986 + * @mc_io: Pointer to MC portal's I/O object
11987 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
11988 + * @token: Token of DPBP object
11989 + * @attr: Returned object's attributes
11991 + * Return: '0' on Success; Error code otherwise.
11993 +int dpbp_get_attributes(struct fsl_mc_io *mc_io,
11994 + uint32_t cmd_flags,
11996 + struct dpbp_attr *attr);
11999 + * DPBP notifications options
12003 + * BPSCN write will attempt to allocate into a cache (coherent write)
12005 +#define DPBP_NOTIF_OPT_COHERENT_WRITE 0x00000001
12008 + * struct dpbp_notification_cfg - Structure representing DPBP notifications
12009 + * towards software
12010 + * @depletion_entry: below this threshold the pool is "depleted";
12011 + * set it to '0' to disable it
12012 + * @depletion_exit: greater than or equal to this threshold the pool exit its
12013 + * "depleted" state
12014 + * @surplus_entry: above this threshold the pool is in "surplus" state;
12015 + * set it to '0' to disable it
12016 + * @surplus_exit: less than or equal to this threshold the pool exit its
12017 + * "surplus" state
12018 + * @message_iova: MUST be given if either 'depletion_entry' or 'surplus_entry'
12019 + * is not '0' (enable); I/O virtual address (must be in DMA-able memory),
12020 + * must be 16B aligned.
12021 + * @message_ctx: The context that will be part of the BPSCN message and will
12022 + * be written to 'message_iova'
12023 + * @options: Mask of available options; use 'DPBP_NOTIF_OPT_<X>' values
12025 +struct dpbp_notification_cfg {
12026 + uint32_t depletion_entry;
12027 + uint32_t depletion_exit;
12028 + uint32_t surplus_entry;
12029 + uint32_t surplus_exit;
12030 + uint64_t message_iova;
12031 + uint64_t message_ctx;
12032 + uint16_t options;
12036 + * dpbp_set_notifications() - Set notifications towards software
12037 + * @mc_io: Pointer to MC portal's I/O object
12038 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12039 + * @token: Token of DPBP object
12040 + * @cfg: notifications configuration
12042 + * Return: '0' on Success; Error code otherwise.
12044 +int dpbp_set_notifications(struct fsl_mc_io *mc_io,
12045 + uint32_t cmd_flags,
12047 + struct dpbp_notification_cfg *cfg);
12050 + * dpbp_get_notifications() - Get the notifications configuration
12051 + * @mc_io: Pointer to MC portal's I/O object
12052 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12053 + * @token: Token of DPBP object
12054 + * @cfg: notifications configuration
12056 + * Return: '0' on Success; Error code otherwise.
12058 +int dpbp_get_notifications(struct fsl_mc_io *mc_io,
12059 + uint32_t cmd_flags,
12061 + struct dpbp_notification_cfg *cfg);
12063 +#endif /* __FSL_DPBP_H */
12064 diff --git a/drivers/net/dpaa2/mc/fsl_dpbp_cmd.h b/drivers/net/dpaa2/mc/fsl_dpbp_cmd.h
12065 new file mode 100644
12066 index 0000000..71ad96a
12068 +++ b/drivers/net/dpaa2/mc/fsl_dpbp_cmd.h
12070 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
12072 + * Redistribution and use in source and binary forms, with or without
12073 + * modification, are permitted provided that the following conditions are met:
12074 + * * Redistributions of source code must retain the above copyright
12075 + * notice, this list of conditions and the following disclaimer.
12076 + * * Redistributions in binary form must reproduce the above copyright
12077 + * notice, this list of conditions and the following disclaimer in the
12078 + * documentation and/or other materials provided with the distribution.
12079 + * * Neither the name of the above-listed copyright holders nor the
12080 + * names of any contributors may be used to endorse or promote products
12081 + * derived from this software without specific prior written permission.
12084 + * ALTERNATIVELY, this software may be distributed under the terms of the
12085 + * GNU General Public License ("GPL") as published by the Free Software
12086 + * Foundation, either version 2 of that License or (at your option) any
12089 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12090 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12091 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
12092 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
12093 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12094 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
12095 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
12096 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
12097 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
12098 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
12099 + * POSSIBILITY OF SUCH DAMAGE.
12101 +#ifndef _FSL_DPBP_CMD_H
12102 +#define _FSL_DPBP_CMD_H
12104 +/* DPBP Version */
12105 +#define DPBP_VER_MAJOR 2
12106 +#define DPBP_VER_MINOR 2
12109 +#define DPBP_CMDID_CLOSE 0x800
12110 +#define DPBP_CMDID_OPEN 0x804
12111 +#define DPBP_CMDID_CREATE 0x904
12112 +#define DPBP_CMDID_DESTROY 0x900
12114 +#define DPBP_CMDID_ENABLE 0x002
12115 +#define DPBP_CMDID_DISABLE 0x003
12116 +#define DPBP_CMDID_GET_ATTR 0x004
12117 +#define DPBP_CMDID_RESET 0x005
12118 +#define DPBP_CMDID_IS_ENABLED 0x006
12120 +#define DPBP_CMDID_SET_IRQ 0x010
12121 +#define DPBP_CMDID_GET_IRQ 0x011
12122 +#define DPBP_CMDID_SET_IRQ_ENABLE 0x012
12123 +#define DPBP_CMDID_GET_IRQ_ENABLE 0x013
12124 +#define DPBP_CMDID_SET_IRQ_MASK 0x014
12125 +#define DPBP_CMDID_GET_IRQ_MASK 0x015
12126 +#define DPBP_CMDID_GET_IRQ_STATUS 0x016
12127 +#define DPBP_CMDID_CLEAR_IRQ_STATUS 0x017
12129 +#define DPBP_CMDID_SET_NOTIFICATIONS 0x01b0
12130 +#define DPBP_CMDID_GET_NOTIFICATIONS 0x01b1
12132 +/* cmd, param, offset, width, type, arg_name */
12133 +#define DPBP_CMD_OPEN(cmd, dpbp_id) \
12134 + MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
12136 +/* cmd, param, offset, width, type, arg_name */
12137 +#define DPBP_RSP_IS_ENABLED(cmd, en) \
12138 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
12140 +/* cmd, param, offset, width, type, arg_name */
12141 +#define DPBP_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
12143 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
12144 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
12145 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
12146 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
12149 +/* cmd, param, offset, width, type, arg_name */
12150 +#define DPBP_CMD_GET_IRQ(cmd, irq_index) \
12151 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12153 +/* cmd, param, offset, width, type, arg_name */
12154 +#define DPBP_RSP_GET_IRQ(cmd, type, irq_cfg) \
12156 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
12157 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
12158 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
12159 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
12162 +/* cmd, param, offset, width, type, arg_name */
12163 +#define DPBP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
12165 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
12166 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12169 +/* cmd, param, offset, width, type, arg_name */
12170 +#define DPBP_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
12171 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12173 +/* cmd, param, offset, width, type, arg_name */
12174 +#define DPBP_RSP_GET_IRQ_ENABLE(cmd, en) \
12175 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
12177 +/* cmd, param, offset, width, type, arg_name */
12178 +#define DPBP_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
12180 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\
12181 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12184 +/* cmd, param, offset, width, type, arg_name */
12185 +#define DPBP_CMD_GET_IRQ_MASK(cmd, irq_index) \
12186 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12188 +/* cmd, param, offset, width, type, arg_name */
12189 +#define DPBP_RSP_GET_IRQ_MASK(cmd, mask) \
12190 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
12192 +/* cmd, param, offset, width, type, arg_name */
12193 +#define DPBP_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
12195 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
12196 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12198 +/* cmd, param, offset, width, type, arg_name */
12199 +#define DPBP_RSP_GET_IRQ_STATUS(cmd, status) \
12200 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
12202 +/* cmd, param, offset, width, type, arg_name */
12203 +#define DPBP_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
12205 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
12206 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12209 +/* cmd, param, offset, width, type, arg_name */
12210 +#define DPBP_RSP_GET_ATTRIBUTES(cmd, attr) \
12212 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->bpid); \
12213 + MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
12214 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
12215 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
12218 +/* cmd, param, offset, width, type, arg_name */
12219 +#define DPBP_CMD_SET_NOTIFICATIONS(cmd, cfg) \
12221 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->depletion_entry); \
12222 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->depletion_exit);\
12223 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->surplus_entry);\
12224 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->surplus_exit);\
12225 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->options);\
12226 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx);\
12227 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova);\
12230 +/* cmd, param, offset, width, type, arg_name */
12231 +#define DPBP_CMD_GET_NOTIFICATIONS(cmd, cfg) \
12233 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, cfg->depletion_entry); \
12234 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, cfg->depletion_exit);\
12235 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->surplus_entry);\
12236 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, cfg->surplus_exit);\
12237 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, cfg->options);\
12238 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx);\
12239 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova);\
12241 +#endif /* _FSL_DPBP_CMD_H */
12242 diff --git a/drivers/net/dpaa2/mc/fsl_dpci.h b/drivers/net/dpaa2/mc/fsl_dpci.h
12243 new file mode 100644
12244 index 0000000..d885935
12246 +++ b/drivers/net/dpaa2/mc/fsl_dpci.h
12248 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
12250 + * Redistribution and use in source and binary forms, with or without
12251 + * modification, are permitted provided that the following conditions are met:
12252 + * * Redistributions of source code must retain the above copyright
12253 + * notice, this list of conditions and the following disclaimer.
12254 + * * Redistributions in binary form must reproduce the above copyright
12255 + * notice, this list of conditions and the following disclaimer in the
12256 + * documentation and/or other materials provided with the distribution.
12257 + * * Neither the name of the above-listed copyright holders nor the
12258 + * names of any contributors may be used to endorse or promote products
12259 + * derived from this software without specific prior written permission.
12262 + * ALTERNATIVELY, this software may be distributed under the terms of the
12263 + * GNU General Public License ("GPL") as published by the Free Software
12264 + * Foundation, either version 2 of that License or (at your option) any
12267 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12268 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12269 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
12270 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
12271 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12272 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
12273 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
12274 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
12275 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
12276 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
12277 + * POSSIBILITY OF SUCH DAMAGE.
12279 +#ifndef __FSL_DPCI_H
12280 +#define __FSL_DPCI_H
12282 +/* Data Path Communication Interface API
12283 + * Contains initialization APIs and runtime control APIs for DPCI
12288 +/** General DPCI macros */
12291 + * Maximum number of Tx/Rx priorities per DPCI object
12293 +#define DPCI_PRIO_NUM 2
12296 + * Indicates an invalid frame queue
12298 +#define DPCI_FQID_NOT_VALID (uint32_t)(-1)
12301 + * All queues considered; see dpci_set_rx_queue()
12303 +#define DPCI_ALL_QUEUES (uint8_t)(-1)
12306 + * dpci_open() - Open a control session for the specified object
12307 + * @mc_io: Pointer to MC portal's I/O object
12308 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12309 + * @dpci_id: DPCI unique ID
12310 + * @token: Returned token; use in subsequent API calls
12312 + * This function can be used to open a control session for an
12313 + * already created object; an object may have been declared in
12314 + * the DPL or by calling the dpci_create() function.
12315 + * This function returns a unique authentication token,
12316 + * associated with the specific object ID and the specific MC
12317 + * portal; this token must be used in all subsequent commands for
12318 + * this specific object.
12320 + * Return: '0' on Success; Error code otherwise.
12322 +int dpci_open(struct fsl_mc_io *mc_io,
12323 + uint32_t cmd_flags,
12325 + uint16_t *token);
12328 + * dpci_close() - Close the control session of the object
12329 + * @mc_io: Pointer to MC portal's I/O object
12330 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12331 + * @token: Token of DPCI object
12333 + * After this function is called, no further operations are
12334 + * allowed on the object without opening a new control session.
12336 + * Return: '0' on Success; Error code otherwise.
12338 +int dpci_close(struct fsl_mc_io *mc_io,
12339 + uint32_t cmd_flags,
12343 + * struct dpci_cfg - Structure representing DPCI configuration
12344 + * @num_of_priorities: Number of receive priorities (queues) for the DPCI;
12345 + * note, that the number of transmit priorities (queues)
12346 + * is determined by the number of receive priorities of
12347 + * the peer DPCI object
12350 + uint8_t num_of_priorities;
12354 + * dpci_create() - Create the DPCI object.
12355 + * @mc_io: Pointer to MC portal's I/O object
12356 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12357 + * @cfg: Configuration structure
12358 + * @token: Returned token; use in subsequent API calls
12360 + * Create the DPCI object, allocate required resources and perform required
12361 + * initialization.
12363 + * The object can be created either by declaring it in the
12364 + * DPL file, or by calling this function.
12366 + * This function returns a unique authentication token,
12367 + * associated with the specific object ID and the specific MC
12368 + * portal; this token must be used in all subsequent calls to
12369 + * this specific object. For objects that are created using the
12370 + * DPL file, call dpci_open() function to get an authentication
12373 + * Return: '0' on Success; Error code otherwise.
12375 +int dpci_create(struct fsl_mc_io *mc_io,
12376 + uint32_t cmd_flags,
12377 + const struct dpci_cfg *cfg,
12378 + uint16_t *token);
12381 + * dpci_destroy() - Destroy the DPCI object and release all its resources.
12382 + * @mc_io: Pointer to MC portal's I/O object
12383 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12384 + * @token: Token of DPCI object
12386 + * Return: '0' on Success; error code otherwise.
12388 +int dpci_destroy(struct fsl_mc_io *mc_io,
12389 + uint32_t cmd_flags,
12393 + * dpci_enable() - Enable the DPCI, allow sending and receiving frames.
12394 + * @mc_io: Pointer to MC portal's I/O object
12395 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12396 + * @token: Token of DPCI object
12398 + * Return: '0' on Success; Error code otherwise.
12400 +int dpci_enable(struct fsl_mc_io *mc_io,
12401 + uint32_t cmd_flags,
12405 + * dpci_disable() - Disable the DPCI, stop sending and receiving frames.
12406 + * @mc_io: Pointer to MC portal's I/O object
12407 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12408 + * @token: Token of DPCI object
12410 + * Return: '0' on Success; Error code otherwise.
12412 +int dpci_disable(struct fsl_mc_io *mc_io,
12413 + uint32_t cmd_flags,
12417 + * dpci_is_enabled() - Check if the DPCI is enabled.
12418 + * @mc_io: Pointer to MC portal's I/O object
12419 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12420 + * @token: Token of DPCI object
12421 + * @en: Returns '1' if object is enabled; '0' otherwise
12423 + * Return: '0' on Success; Error code otherwise.
12425 +int dpci_is_enabled(struct fsl_mc_io *mc_io,
12426 + uint32_t cmd_flags,
12431 + * dpci_reset() - Reset the DPCI, returns the object to initial state.
12432 + * @mc_io: Pointer to MC portal's I/O object
12433 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12434 + * @token: Token of DPCI object
12436 + * Return: '0' on Success; Error code otherwise.
12438 +int dpci_reset(struct fsl_mc_io *mc_io,
12439 + uint32_t cmd_flags,
12442 +/** DPCI IRQ Index and Events */
12447 +#define DPCI_IRQ_INDEX 0
12450 + * IRQ event - indicates a change in link state
12452 +#define DPCI_IRQ_EVENT_LINK_CHANGED 0x00000001
12454 + * IRQ event - indicates a connection event
12456 +#define DPCI_IRQ_EVENT_CONNECTED 0x00000002
12458 + * IRQ event - indicates a disconnection event
12460 +#define DPCI_IRQ_EVENT_DISCONNECTED 0x00000004
12463 + * struct dpci_irq_cfg - IRQ configuration
12464 + * @addr: Address that must be written to signal a message-based interrupt
12465 + * @val: Value to write into irq_addr address
12466 + * @irq_num: A user defined number associated with this IRQ
12468 +struct dpci_irq_cfg {
12475 + * dpci_set_irq() - Set IRQ information for the DPCI to trigger an interrupt.
12476 + * @mc_io: Pointer to MC portal's I/O object
12477 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12478 + * @token: Token of DPCI object
12479 + * @irq_index: Identifies the interrupt index to configure
12480 + * @irq_cfg: IRQ configuration
12482 + * Return: '0' on Success; Error code otherwise.
12484 +int dpci_set_irq(struct fsl_mc_io *mc_io,
12485 + uint32_t cmd_flags,
12487 + uint8_t irq_index,
12488 + struct dpci_irq_cfg *irq_cfg);
12491 + * dpci_get_irq() - Get IRQ information from the DPCI.
12492 + * @mc_io: Pointer to MC portal's I/O object
12493 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12494 + * @token: Token of DPCI object
12495 + * @irq_index: The interrupt index to configure
12496 + * @type: Interrupt type: 0 represents message interrupt
12497 + * type (both irq_addr and irq_val are valid)
12498 + * @irq_cfg: IRQ attributes
12500 + * Return: '0' on Success; Error code otherwise.
12502 +int dpci_get_irq(struct fsl_mc_io *mc_io,
12503 + uint32_t cmd_flags,
12505 + uint8_t irq_index,
12507 + struct dpci_irq_cfg *irq_cfg);
12510 + * dpci_set_irq_enable() - Set overall interrupt state.
12511 + * @mc_io: Pointer to MC portal's I/O object
12512 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12513 + * @token: Token of DPCI object
12514 + * @irq_index: The interrupt index to configure
12515 + * @en: Interrupt state - enable = 1, disable = 0
12517 + * Allows GPP software to control when interrupts are generated.
12518 + * Each interrupt can have up to 32 causes. The enable/disable control's the
12519 + * overall interrupt state. if the interrupt is disabled no causes will cause
12522 + * Return: '0' on Success; Error code otherwise.
12524 +int dpci_set_irq_enable(struct fsl_mc_io *mc_io,
12525 + uint32_t cmd_flags,
12527 + uint8_t irq_index,
12531 + * dpci_get_irq_enable() - Get overall interrupt state.
12532 + * @mc_io: Pointer to MC portal's I/O object
12533 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12534 + * @token: Token of DPCI object
12535 + * @irq_index: The interrupt index to configure
12536 + * @en: Returned interrupt state - enable = 1, disable = 0
12538 + * Return: '0' on Success; Error code otherwise.
12540 +int dpci_get_irq_enable(struct fsl_mc_io *mc_io,
12541 + uint32_t cmd_flags,
12543 + uint8_t irq_index,
12547 + * dpci_set_irq_mask() - Set interrupt mask.
12548 + * @mc_io: Pointer to MC portal's I/O object
12549 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12550 + * @token: Token of DPCI object
12551 + * @irq_index: The interrupt index to configure
12552 + * @mask: event mask to trigger interrupt;
12554 + * 0 = ignore event
12555 + * 1 = consider event for asserting IRQ
12557 + * Every interrupt can have up to 32 causes and the interrupt model supports
12558 + * masking/unmasking each cause independently
12560 + * Return: '0' on Success; Error code otherwise.
12562 +int dpci_set_irq_mask(struct fsl_mc_io *mc_io,
12563 + uint32_t cmd_flags,
12565 + uint8_t irq_index,
12569 + * dpci_get_irq_mask() - Get interrupt mask.
12570 + * @mc_io: Pointer to MC portal's I/O object
12571 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12572 + * @token: Token of DPCI object
12573 + * @irq_index: The interrupt index to configure
12574 + * @mask: Returned event mask to trigger interrupt
12576 + * Every interrupt can have up to 32 causes and the interrupt model supports
12577 + * masking/unmasking each cause independently
12579 + * Return: '0' on Success; Error code otherwise.
12581 +int dpci_get_irq_mask(struct fsl_mc_io *mc_io,
12582 + uint32_t cmd_flags,
12584 + uint8_t irq_index,
12588 + * dpci_get_irq_status() - Get the current status of any pending interrupts.
12589 + * @mc_io: Pointer to MC portal's I/O object
12590 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12591 + * @token: Token of DPCI object
12592 + * @irq_index: The interrupt index to configure
12593 + * @status: Returned interrupts status - one bit per cause:
12594 + * 0 = no interrupt pending
12595 + * 1 = interrupt pending
12597 + * Return: '0' on Success; Error code otherwise.
12599 +int dpci_get_irq_status(struct fsl_mc_io *mc_io,
12600 + uint32_t cmd_flags,
12602 + uint8_t irq_index,
12603 + uint32_t *status);
12606 + * dpci_clear_irq_status() - Clear a pending interrupt's status
12607 + * @mc_io: Pointer to MC portal's I/O object
12608 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12609 + * @token: Token of DPCI object
12610 + * @irq_index: The interrupt index to configure
12611 + * @status: bits to clear (W1C) - one bit per cause:
12612 + * 0 = don't change
12613 + * 1 = clear status bit
12615 + * Return: '0' on Success; Error code otherwise.
12617 +int dpci_clear_irq_status(struct fsl_mc_io *mc_io,
12618 + uint32_t cmd_flags,
12620 + uint8_t irq_index,
12621 + uint32_t status);
12624 + * struct dpci_attr - Structure representing DPCI attributes
12625 + * @id: DPCI object ID
12626 + * @version: DPCI version
12627 + * @num_of_priorities: Number of receive priorities
12629 +struct dpci_attr {
12632 + * struct version - Structure representing DPCI attributes
12633 + * @major: DPCI major version
12634 + * @minor: DPCI minor version
12640 + uint8_t num_of_priorities;
12644 + * dpci_get_attributes() - Retrieve DPCI attributes.
12645 + * @mc_io: Pointer to MC portal's I/O object
12646 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12647 + * @token: Token of DPCI object
12648 + * @attr: Returned object's attributes
12650 + * Return: '0' on Success; Error code otherwise.
12652 +int dpci_get_attributes(struct fsl_mc_io *mc_io,
12653 + uint32_t cmd_flags,
12655 + struct dpci_attr *attr);
12658 + * struct dpci_peer_attr - Structure representing the peer DPCI attributes
12659 + * @peer_id: DPCI peer id; if no peer is connected returns (-1)
12660 + * @num_of_priorities: The pper's number of receive priorities; determines the
12661 + * number of transmit priorities for the local DPCI object
12663 +struct dpci_peer_attr {
12665 + uint8_t num_of_priorities;
12669 + * dpci_get_peer_attributes() - Retrieve peer DPCI attributes.
12670 + * @mc_io: Pointer to MC portal's I/O object
12671 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12672 + * @token: Token of DPCI object
12673 + * @attr: Returned peer attributes
12675 + * Return: '0' on Success; Error code otherwise.
12677 +int dpci_get_peer_attributes(struct fsl_mc_io *mc_io,
12678 + uint32_t cmd_flags,
12680 + struct dpci_peer_attr *attr);
12683 + * dpci_get_link_state() - Retrieve the DPCI link state.
12684 + * @mc_io: Pointer to MC portal's I/O object
12685 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12686 + * @token: Token of DPCI object
12687 + * @up: Returned link state; returns '1' if link is up, '0' otherwise
12689 + * DPCI can be connected to another DPCI, together they
12690 + * create a 'link'. In order to use the DPCI Tx and Rx queues,
12691 + * both objects must be enabled.
12693 + * Return: '0' on Success; Error code otherwise.
12695 +int dpci_get_link_state(struct fsl_mc_io *mc_io,
12696 + uint32_t cmd_flags,
12701 + * enum dpci_dest - DPCI destination types
12702 + * @DPCI_DEST_NONE: Unassigned destination; The queue is set in parked mode
12703 + * and does not generate FQDAN notifications; user is
12704 + * expected to dequeue from the queue based on polling or
12705 + * other user-defined method
12706 + * @DPCI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
12707 + * notifications to the specified DPIO; user is expected
12708 + * to dequeue from the queue only after notification is
12710 + * @DPCI_DEST_DPCON: The queue is set in schedule mode and does not generate
12711 + * FQDAN notifications, but is connected to the specified
12713 + * user is expected to dequeue from the DPCON channel
12716 + DPCI_DEST_NONE = 0,
12717 + DPCI_DEST_DPIO = 1,
12718 + DPCI_DEST_DPCON = 2
12722 + * struct dpci_dest_cfg - Structure representing DPCI destination configuration
12723 + * @dest_type: Destination type
12724 + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
12725 + * @priority: Priority selection within the DPIO or DPCON channel; valid
12726 + * values are 0-1 or 0-7, depending on the number of priorities
12727 + * in that channel; not relevant for 'DPCI_DEST_NONE' option
12729 +struct dpci_dest_cfg {
12730 + enum dpci_dest dest_type;
12732 + uint8_t priority;
12735 +/** DPCI queue modification options */
12738 + * Select to modify the user's context associated with the queue
12740 +#define DPCI_QUEUE_OPT_USER_CTX 0x00000001
12743 + * Select to modify the queue's destination
12745 +#define DPCI_QUEUE_OPT_DEST 0x00000002
12748 + * struct dpci_rx_queue_cfg - Structure representing RX queue configuration
12749 + * @options: Flags representing the suggested modifications to the queue;
12750 + * Use any combination of 'DPCI_QUEUE_OPT_<X>' flags
12751 + * @user_ctx: User context value provided in the frame descriptor of each
12752 + * dequeued frame;
12753 + * valid only if 'DPCI_QUEUE_OPT_USER_CTX' is contained in
12755 + * @dest_cfg: Queue destination parameters;
12756 + * valid only if 'DPCI_QUEUE_OPT_DEST' is contained in 'options'
12758 +struct dpci_rx_queue_cfg {
12759 + uint32_t options;
12760 + uint64_t user_ctx;
12761 + struct dpci_dest_cfg dest_cfg;
12765 + * dpci_set_rx_queue() - Set Rx queue configuration
12766 + * @mc_io: Pointer to MC portal's I/O object
12767 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12768 + * @token: Token of DPCI object
12769 + * @priority: Select the queue relative to number of
12770 + * priorities configured at DPCI creation; use
12771 + * DPCI_ALL_QUEUES to configure all Rx queues
12773 + * @cfg: Rx queue configuration
12775 + * Return: '0' on Success; Error code otherwise.
12777 +int dpci_set_rx_queue(struct fsl_mc_io *mc_io,
12778 + uint32_t cmd_flags,
12780 + uint8_t priority,
12781 + const struct dpci_rx_queue_cfg *cfg);
12784 + * struct dpci_rx_queue_attr - Structure representing Rx queue attributes
12785 + * @user_ctx: User context value provided in the frame descriptor of each
12787 + * @dest_cfg: Queue destination configuration
12788 + * @fqid: Virtual FQID value to be used for dequeue operations
12790 +struct dpci_rx_queue_attr {
12791 + uint64_t user_ctx;
12792 + struct dpci_dest_cfg dest_cfg;
12797 + * dpci_get_rx_queue() - Retrieve Rx queue attributes.
12798 + * @mc_io: Pointer to MC portal's I/O object
12799 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12800 + * @token: Token of DPCI object
12801 + * @priority: Select the queue relative to number of
12802 + * priorities configured at DPCI creation
12803 + * @attr: Returned Rx queue attributes
12805 + * Return: '0' on Success; Error code otherwise.
12807 +int dpci_get_rx_queue(struct fsl_mc_io *mc_io,
12808 + uint32_t cmd_flags,
12810 + uint8_t priority,
12811 + struct dpci_rx_queue_attr *attr);
12814 + * struct dpci_tx_queue_attr - Structure representing attributes of Tx queues
12815 + * @fqid: Virtual FQID to be used for sending frames to peer DPCI;
12816 + * returns 'DPCI_FQID_NOT_VALID' if a no peer is connected or if
12817 + * the selected priority exceeds the number of priorities of the
12818 + * peer DPCI object
12820 +struct dpci_tx_queue_attr {
12825 + * dpci_get_tx_queue() - Retrieve Tx queue attributes.
12826 + * @mc_io: Pointer to MC portal's I/O object
12827 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
12828 + * @token: Token of DPCI object
12829 + * @priority: Select the queue relative to number of
12830 + * priorities of the peer DPCI object
12831 + * @attr: Returned Tx queue attributes
12833 + * Return: '0' on Success; Error code otherwise.
12835 +int dpci_get_tx_queue(struct fsl_mc_io *mc_io,
12836 + uint32_t cmd_flags,
12838 + uint8_t priority,
12839 + struct dpci_tx_queue_attr *attr);
12841 +#endif /* __FSL_DPCI_H */
12842 diff --git a/drivers/net/dpaa2/mc/fsl_dpci_cmd.h b/drivers/net/dpaa2/mc/fsl_dpci_cmd.h
12843 new file mode 100644
12844 index 0000000..f45e435
12846 +++ b/drivers/net/dpaa2/mc/fsl_dpci_cmd.h
12848 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
12850 + * Redistribution and use in source and binary forms, with or without
12851 + * modification, are permitted provided that the following conditions are met:
12852 + * * Redistributions of source code must retain the above copyright
12853 + * notice, this list of conditions and the following disclaimer.
12854 + * * Redistributions in binary form must reproduce the above copyright
12855 + * notice, this list of conditions and the following disclaimer in the
12856 + * documentation and/or other materials provided with the distribution.
12857 + * * Neither the name of the above-listed copyright holders nor the
12858 + * names of any contributors may be used to endorse or promote products
12859 + * derived from this software without specific prior written permission.
12862 + * ALTERNATIVELY, this software may be distributed under the terms of the
12863 + * GNU General Public License ("GPL") as published by the Free Software
12864 + * Foundation, either version 2 of that License or (at your option) any
12867 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
12868 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
12869 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
12870 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
12871 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
12872 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
12873 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
12874 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
12875 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
12876 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
12877 + * POSSIBILITY OF SUCH DAMAGE.
12879 +#ifndef _FSL_DPCI_CMD_H
12880 +#define _FSL_DPCI_CMD_H
12882 +/* DPCI Version */
12883 +#define DPCI_VER_MAJOR 2
12884 +#define DPCI_VER_MINOR 2
12887 +#define DPCI_CMDID_CLOSE 0x800
12888 +#define DPCI_CMDID_OPEN 0x807
12889 +#define DPCI_CMDID_CREATE 0x907
12890 +#define DPCI_CMDID_DESTROY 0x900
12892 +#define DPCI_CMDID_ENABLE 0x002
12893 +#define DPCI_CMDID_DISABLE 0x003
12894 +#define DPCI_CMDID_GET_ATTR 0x004
12895 +#define DPCI_CMDID_RESET 0x005
12896 +#define DPCI_CMDID_IS_ENABLED 0x006
12898 +#define DPCI_CMDID_SET_IRQ 0x010
12899 +#define DPCI_CMDID_GET_IRQ 0x011
12900 +#define DPCI_CMDID_SET_IRQ_ENABLE 0x012
12901 +#define DPCI_CMDID_GET_IRQ_ENABLE 0x013
12902 +#define DPCI_CMDID_SET_IRQ_MASK 0x014
12903 +#define DPCI_CMDID_GET_IRQ_MASK 0x015
12904 +#define DPCI_CMDID_GET_IRQ_STATUS 0x016
12905 +#define DPCI_CMDID_CLEAR_IRQ_STATUS 0x017
12907 +#define DPCI_CMDID_SET_RX_QUEUE 0x0e0
12908 +#define DPCI_CMDID_GET_LINK_STATE 0x0e1
12909 +#define DPCI_CMDID_GET_PEER_ATTR 0x0e2
12910 +#define DPCI_CMDID_GET_RX_QUEUE 0x0e3
12911 +#define DPCI_CMDID_GET_TX_QUEUE 0x0e4
12913 +/* cmd, param, offset, width, type, arg_name */
12914 +#define DPCI_CMD_OPEN(cmd, dpci_id) \
12915 + MC_CMD_OP(cmd, 0, 0, 32, int, dpci_id)
12917 +/* cmd, param, offset, width, type, arg_name */
12918 +#define DPCI_CMD_CREATE(cmd, cfg) \
12919 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_of_priorities)
12921 +/* cmd, param, offset, width, type, arg_name */
12922 +#define DPCI_RSP_IS_ENABLED(cmd, en) \
12923 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
12925 +/* cmd, param, offset, width, type, arg_name */
12926 +#define DPCI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
12928 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
12929 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
12930 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
12931 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
12934 +/* cmd, param, offset, width, type, arg_name */
12935 +#define DPCI_CMD_GET_IRQ(cmd, irq_index) \
12936 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12938 +/* cmd, param, offset, width, type, arg_name */
12939 +#define DPCI_RSP_GET_IRQ(cmd, type, irq_cfg) \
12941 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
12942 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
12943 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
12944 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
12947 +/* cmd, param, offset, width, type, arg_name */
12948 +#define DPCI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
12950 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
12951 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12954 +/* cmd, param, offset, width, type, arg_name */
12955 +#define DPCI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
12956 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12958 +/* cmd, param, offset, width, type, arg_name */
12959 +#define DPCI_RSP_GET_IRQ_ENABLE(cmd, en) \
12960 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
12962 +/* cmd, param, offset, width, type, arg_name */
12963 +#define DPCI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
12965 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
12966 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12969 +/* cmd, param, offset, width, type, arg_name */
12970 +#define DPCI_CMD_GET_IRQ_MASK(cmd, irq_index) \
12971 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
12973 +/* cmd, param, offset, width, type, arg_name */
12974 +#define DPCI_RSP_GET_IRQ_MASK(cmd, mask) \
12975 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
12977 +/* cmd, param, offset, width, type, arg_name */
12978 +#define DPCI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
12980 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
12981 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12983 +/* cmd, param, offset, width, type, arg_name */
12984 +#define DPCI_RSP_GET_IRQ_STATUS(cmd, status) \
12985 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
12987 +/* cmd, param, offset, width, type, arg_name */
12988 +#define DPCI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
12990 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
12991 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
12994 +/* cmd, param, offset, width, type, arg_name */
12995 +#define DPCI_RSP_GET_ATTR(cmd, attr) \
12997 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
12998 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_of_priorities);\
12999 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
13000 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
13003 +/* cmd, param, offset, width, type, arg_name */
13004 +#define DPCI_RSP_GET_PEER_ATTR(cmd, attr) \
13006 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->peer_id);\
13007 + MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->num_of_priorities);\
13010 +/* cmd, param, offset, width, type, arg_name */
13011 +#define DPCI_RSP_GET_LINK_STATE(cmd, up) \
13012 + MC_RSP_OP(cmd, 0, 0, 1, int, up)
13014 +/* cmd, param, offset, width, type, arg_name */
13015 +#define DPCI_CMD_SET_RX_QUEUE(cmd, priority, cfg) \
13017 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id);\
13018 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
13019 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority);\
13020 + MC_CMD_OP(cmd, 0, 48, 4, enum dpci_dest, cfg->dest_cfg.dest_type);\
13021 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx);\
13022 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
13025 +/* cmd, param, offset, width, type, arg_name */
13026 +#define DPCI_CMD_GET_RX_QUEUE(cmd, priority) \
13027 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority)
13029 +/* cmd, param, offset, width, type, arg_name */
13030 +#define DPCI_RSP_GET_RX_QUEUE(cmd, attr) \
13032 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\
13033 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
13034 + MC_RSP_OP(cmd, 0, 48, 4, enum dpci_dest, attr->dest_cfg.dest_type);\
13035 + MC_RSP_OP(cmd, 1, 0, 8, uint64_t, attr->user_ctx);\
13036 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\
13039 +/* cmd, param, offset, width, type, arg_name */
13040 +#define DPCI_CMD_GET_TX_QUEUE(cmd, priority) \
13041 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority)
13043 +/* cmd, param, offset, width, type, arg_name */
13044 +#define DPCI_RSP_GET_TX_QUEUE(cmd, attr) \
13045 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, attr->fqid)
13047 +#endif /* _FSL_DPCI_CMD_H */
13048 diff --git a/drivers/net/dpaa2/mc/fsl_dpcon.h b/drivers/net/dpaa2/mc/fsl_dpcon.h
13049 new file mode 100644
13050 index 0000000..2555be5
13052 +++ b/drivers/net/dpaa2/mc/fsl_dpcon.h
13054 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
13056 + * Redistribution and use in source and binary forms, with or without
13057 + * modification, are permitted provided that the following conditions are met:
13058 + * * Redistributions of source code must retain the above copyright
13059 + * notice, this list of conditions and the following disclaimer.
13060 + * * Redistributions in binary form must reproduce the above copyright
13061 + * notice, this list of conditions and the following disclaimer in the
13062 + * documentation and/or other materials provided with the distribution.
13063 + * * Neither the name of the above-listed copyright holders nor the
13064 + * names of any contributors may be used to endorse or promote products
13065 + * derived from this software without specific prior written permission.
13068 + * ALTERNATIVELY, this software may be distributed under the terms of the
13069 + * GNU General Public License ("GPL") as published by the Free Software
13070 + * Foundation, either version 2 of that License or (at your option) any
13073 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13074 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13075 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13076 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
13077 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
13078 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
13079 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
13080 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
13081 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
13082 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
13083 + * POSSIBILITY OF SUCH DAMAGE.
13085 +#ifndef __FSL_DPCON_H
13086 +#define __FSL_DPCON_H
13088 +/* Data Path Concentrator API
13089 + * Contains initialization APIs and runtime control APIs for DPCON
13094 +/** General DPCON macros */
13097 + * Use it to disable notifications; see dpcon_set_notification()
13099 +#define DPCON_INVALID_DPIO_ID (int)(-1)
13102 + * dpcon_open() - Open a control session for the specified object
13103 + * @mc_io: Pointer to MC portal's I/O object
13104 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13105 + * @dpcon_id: DPCON unique ID
13106 + * @token: Returned token; use in subsequent API calls
13108 + * This function can be used to open a control session for an
13109 + * already created object; an object may have been declared in
13110 + * the DPL or by calling the dpcon_create() function.
13111 + * This function returns a unique authentication token,
13112 + * associated with the specific object ID and the specific MC
13113 + * portal; this token must be used in all subsequent commands for
13114 + * this specific object.
13116 + * Return: '0' on Success; Error code otherwise.
13118 +int dpcon_open(struct fsl_mc_io *mc_io,
13119 + uint32_t cmd_flags,
13121 + uint16_t *token);
13124 + * dpcon_close() - Close the control session of the object
13125 + * @mc_io: Pointer to MC portal's I/O object
13126 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13127 + * @token: Token of DPCON object
13129 + * After this function is called, no further operations are
13130 + * allowed on the object without opening a new control session.
13132 + * Return: '0' on Success; Error code otherwise.
13134 +int dpcon_close(struct fsl_mc_io *mc_io,
13135 + uint32_t cmd_flags,
13139 + * struct dpcon_cfg - Structure representing DPCON configuration
13140 + * @num_priorities: Number of priorities for the DPCON channel (1-8)
13142 +struct dpcon_cfg {
13143 + uint8_t num_priorities;
13147 + * dpcon_create() - Create the DPCON object.
13148 + * @mc_io: Pointer to MC portal's I/O object
13149 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13150 + * @cfg: Configuration structure
13151 + * @token: Returned token; use in subsequent API calls
13153 + * Create the DPCON object, allocate required resources and
13154 + * perform required initialization.
13156 + * The object can be created either by declaring it in the
13157 + * DPL file, or by calling this function.
13159 + * This function returns a unique authentication token,
13160 + * associated with the specific object ID and the specific MC
13161 + * portal; this token must be used in all subsequent calls to
13162 + * this specific object. For objects that are created using the
13163 + * DPL file, call dpcon_open() function to get an authentication
13166 + * Return: '0' on Success; Error code otherwise.
13168 +int dpcon_create(struct fsl_mc_io *mc_io,
13169 + uint32_t cmd_flags,
13170 + const struct dpcon_cfg *cfg,
13171 + uint16_t *token);
13174 + * dpcon_destroy() - Destroy the DPCON object and release all its resources.
13175 + * @mc_io: Pointer to MC portal's I/O object
13176 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13177 + * @token: Token of DPCON object
13179 + * Return: '0' on Success; error code otherwise.
13181 +int dpcon_destroy(struct fsl_mc_io *mc_io,
13182 + uint32_t cmd_flags,
13186 + * dpcon_enable() - Enable the DPCON
13187 + * @mc_io: Pointer to MC portal's I/O object
13188 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13189 + * @token: Token of DPCON object
13191 + * Return: '0' on Success; Error code otherwise
13193 +int dpcon_enable(struct fsl_mc_io *mc_io,
13194 + uint32_t cmd_flags,
13198 + * dpcon_disable() - Disable the DPCON
13199 + * @mc_io: Pointer to MC portal's I/O object
13200 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13201 + * @token: Token of DPCON object
13203 + * Return: '0' on Success; Error code otherwise
13205 +int dpcon_disable(struct fsl_mc_io *mc_io,
13206 + uint32_t cmd_flags,
13210 + * dpcon_is_enabled() - Check if the DPCON is enabled.
13211 + * @mc_io: Pointer to MC portal's I/O object
13212 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13213 + * @token: Token of DPCON object
13214 + * @en: Returns '1' if object is enabled; '0' otherwise
13216 + * Return: '0' on Success; Error code otherwise.
13218 +int dpcon_is_enabled(struct fsl_mc_io *mc_io,
13219 + uint32_t cmd_flags,
13224 + * dpcon_reset() - Reset the DPCON, returns the object to initial state.
13225 + * @mc_io: Pointer to MC portal's I/O object
13226 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13227 + * @token: Token of DPCON object
13229 + * Return: '0' on Success; Error code otherwise.
13231 +int dpcon_reset(struct fsl_mc_io *mc_io,
13232 + uint32_t cmd_flags,
13236 + * struct dpcon_irq_cfg - IRQ configuration
13237 + * @addr: Address that must be written to signal a message-based interrupt
13238 + * @val: Value to write into irq_addr address
13239 + * @irq_num: A user defined number associated with this IRQ
13241 +struct dpcon_irq_cfg {
13248 + * dpcon_set_irq() - Set IRQ information for the DPCON to trigger an interrupt.
13249 + * @mc_io: Pointer to MC portal's I/O object
13250 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13251 + * @token: Token of DPCON object
13252 + * @irq_index: Identifies the interrupt index to configure
13253 + * @irq_cfg: IRQ configuration
13254 + * Return: '0' on Success; Error code otherwise.
13256 +int dpcon_set_irq(struct fsl_mc_io *mc_io,
13257 + uint32_t cmd_flags,
13259 + uint8_t irq_index,
13260 + struct dpcon_irq_cfg *irq_cfg);
13263 + * dpcon_get_irq() - Get IRQ information from the DPCON.
13265 + * @mc_io: Pointer to MC portal's I/O object
13266 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13267 + * @token: Token of DPCON object
13268 + * @irq_index: The interrupt index to configure
13269 + * @type: Interrupt type: 0 represents message interrupt
13270 + * type (both irq_addr and irq_val are valid)
13271 + * @irq_cfg: IRQ attributes
13273 + * Return: '0' on Success; Error code otherwise.
13275 +int dpcon_get_irq(struct fsl_mc_io *mc_io,
13276 + uint32_t cmd_flags,
13278 + uint8_t irq_index,
13280 + struct dpcon_irq_cfg *irq_cfg);
13283 + * dpcon_set_irq_enable() - Set overall interrupt state.
13284 + * @mc_io: Pointer to MC portal's I/O object
13285 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13286 + * @token: Token of DPCON object
13287 + * @irq_index: The interrupt index to configure
13288 + * @en: Interrupt state - enable = 1, disable = 0
13290 + * Allows GPP software to control when interrupts are generated.
13291 + * Each interrupt can have up to 32 causes. The enable/disable control's the
13292 + * overall interrupt state. if the interrupt is disabled no causes will cause
13295 + * Return: '0' on Success; Error code otherwise.
13297 +int dpcon_set_irq_enable(struct fsl_mc_io *mc_io,
13298 + uint32_t cmd_flags,
13300 + uint8_t irq_index,
13304 + * dpcon_get_irq_enable() - Get overall interrupt state.
13305 + * @mc_io: Pointer to MC portal's I/O object
13306 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13307 + * @token: Token of DPCON object
13308 + * @irq_index: The interrupt index to configure
13309 + * @en: Returned interrupt state - enable = 1, disable = 0
13311 + * Return: '0' on Success; Error code otherwise.
13313 +int dpcon_get_irq_enable(struct fsl_mc_io *mc_io,
13314 + uint32_t cmd_flags,
13316 + uint8_t irq_index,
13320 + * dpcon_set_irq_mask() - Set interrupt mask.
13321 + * @mc_io: Pointer to MC portal's I/O object
13322 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13323 + * @token: Token of DPCON object
13324 + * @irq_index: The interrupt index to configure
13325 + * @mask: Event mask to trigger interrupt;
13327 + * 0 = ignore event
13328 + * 1 = consider event for asserting IRQ
13330 + * Every interrupt can have up to 32 causes and the interrupt model supports
13331 + * masking/unmasking each cause independently
13333 + * Return: '0' on Success; Error code otherwise.
13335 +int dpcon_set_irq_mask(struct fsl_mc_io *mc_io,
13336 + uint32_t cmd_flags,
13338 + uint8_t irq_index,
13342 + * dpcon_get_irq_mask() - Get interrupt mask.
13343 + * @mc_io: Pointer to MC portal's I/O object
13344 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13345 + * @token: Token of DPCON object
13346 + * @irq_index: The interrupt index to configure
13347 + * @mask: Returned event mask to trigger interrupt
13349 + * Every interrupt can have up to 32 causes and the interrupt model supports
13350 + * masking/unmasking each cause independently
13352 + * Return: '0' on Success; Error code otherwise.
13354 +int dpcon_get_irq_mask(struct fsl_mc_io *mc_io,
13355 + uint32_t cmd_flags,
13357 + uint8_t irq_index,
13361 + * dpcon_get_irq_status() - Get the current status of any pending interrupts.
13362 + * @mc_io: Pointer to MC portal's I/O object
13363 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13364 + * @token: Token of DPCON object
13365 + * @irq_index: The interrupt index to configure
13366 + * @status: interrupts status - one bit per cause:
13367 + * 0 = no interrupt pending
13368 + * 1 = interrupt pending
13370 + * Return: '0' on Success; Error code otherwise.
13372 +int dpcon_get_irq_status(struct fsl_mc_io *mc_io,
13373 + uint32_t cmd_flags,
13375 + uint8_t irq_index,
13376 + uint32_t *status);
13379 + * dpcon_clear_irq_status() - Clear a pending interrupt's status
13380 + * @mc_io: Pointer to MC portal's I/O object
13381 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13382 + * @token: Token of DPCON object
13383 + * @irq_index: The interrupt index to configure
13384 + * @status: bits to clear (W1C) - one bit per cause:
13385 + * 0 = don't change
13386 + * 1 = clear status bit
13388 + * Return: '0' on Success; Error code otherwise.
13390 +int dpcon_clear_irq_status(struct fsl_mc_io *mc_io,
13391 + uint32_t cmd_flags,
13393 + uint8_t irq_index,
13394 + uint32_t status);
13397 + * struct dpcon_attr - Structure representing DPCON attributes
13398 + * @id: DPCON object ID
13399 + * @version: DPCON version
13400 + * @qbman_ch_id: Channel ID to be used by dequeue operation
13401 + * @num_priorities: Number of priorities for the DPCON channel (1-8)
13403 +struct dpcon_attr {
13406 + * struct version - DPCON version
13407 + * @major: DPCON major version
13408 + * @minor: DPCON minor version
13414 + uint16_t qbman_ch_id;
13415 + uint8_t num_priorities;
13419 + * dpcon_get_attributes() - Retrieve DPCON attributes.
13420 + * @mc_io: Pointer to MC portal's I/O object
13421 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13422 + * @token: Token of DPCON object
13423 + * @attr: Object's attributes
13425 + * Return: '0' on Success; Error code otherwise.
13427 +int dpcon_get_attributes(struct fsl_mc_io *mc_io,
13428 + uint32_t cmd_flags,
13430 + struct dpcon_attr *attr);
13433 + * struct dpcon_notification_cfg - Structure representing notification parameters
13434 + * @dpio_id: DPIO object ID; must be configured with a notification channel;
13435 + * to disable notifications set it to 'DPCON_INVALID_DPIO_ID';
13436 + * @priority: Priority selection within the DPIO channel; valid values
13437 + * are 0-7, depending on the number of priorities in that channel
13438 + * @user_ctx: User context value provided with each CDAN message
13440 +struct dpcon_notification_cfg {
13442 + uint8_t priority;
13443 + uint64_t user_ctx;
13447 + * dpcon_set_notification() - Set DPCON notification destination
13448 + * @mc_io: Pointer to MC portal's I/O object
13449 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13450 + * @token: Token of DPCON object
13451 + * @cfg: Notification parameters
13453 + * Return: '0' on Success; Error code otherwise
13455 +int dpcon_set_notification(struct fsl_mc_io *mc_io,
13456 + uint32_t cmd_flags,
13458 + struct dpcon_notification_cfg *cfg);
13460 +#endif /* __FSL_DPCON_H */
13461 diff --git a/drivers/net/dpaa2/mc/fsl_dpcon_cmd.h b/drivers/net/dpaa2/mc/fsl_dpcon_cmd.h
13462 new file mode 100644
13463 index 0000000..ecb40d0
13465 +++ b/drivers/net/dpaa2/mc/fsl_dpcon_cmd.h
13467 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
13469 + * Redistribution and use in source and binary forms, with or without
13470 + * modification, are permitted provided that the following conditions are met:
13471 + * * Redistributions of source code must retain the above copyright
13472 + * notice, this list of conditions and the following disclaimer.
13473 + * * Redistributions in binary form must reproduce the above copyright
13474 + * notice, this list of conditions and the following disclaimer in the
13475 + * documentation and/or other materials provided with the distribution.
13476 + * * Neither the name of the above-listed copyright holders nor the
13477 + * names of any contributors may be used to endorse or promote products
13478 + * derived from this software without specific prior written permission.
13481 + * ALTERNATIVELY, this software may be distributed under the terms of the
13482 + * GNU General Public License ("GPL") as published by the Free Software
13483 + * Foundation, either version 2 of that License or (at your option) any
13486 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13487 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13488 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13489 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
13490 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
13491 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
13492 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
13493 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
13494 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
13495 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
13496 + * POSSIBILITY OF SUCH DAMAGE.
13498 +#ifndef _FSL_DPCON_CMD_H
13499 +#define _FSL_DPCON_CMD_H
13501 +/* DPCON Version */
13502 +#define DPCON_VER_MAJOR 2
13503 +#define DPCON_VER_MINOR 2
13506 +#define DPCON_CMDID_CLOSE 0x800
13507 +#define DPCON_CMDID_OPEN 0x808
13508 +#define DPCON_CMDID_CREATE 0x908
13509 +#define DPCON_CMDID_DESTROY 0x900
13511 +#define DPCON_CMDID_ENABLE 0x002
13512 +#define DPCON_CMDID_DISABLE 0x003
13513 +#define DPCON_CMDID_GET_ATTR 0x004
13514 +#define DPCON_CMDID_RESET 0x005
13515 +#define DPCON_CMDID_IS_ENABLED 0x006
13517 +#define DPCON_CMDID_SET_IRQ 0x010
13518 +#define DPCON_CMDID_GET_IRQ 0x011
13519 +#define DPCON_CMDID_SET_IRQ_ENABLE 0x012
13520 +#define DPCON_CMDID_GET_IRQ_ENABLE 0x013
13521 +#define DPCON_CMDID_SET_IRQ_MASK 0x014
13522 +#define DPCON_CMDID_GET_IRQ_MASK 0x015
13523 +#define DPCON_CMDID_GET_IRQ_STATUS 0x016
13524 +#define DPCON_CMDID_CLEAR_IRQ_STATUS 0x017
13526 +#define DPCON_CMDID_SET_NOTIFICATION 0x100
13528 +/* cmd, param, offset, width, type, arg_name */
13529 +#define DPCON_CMD_OPEN(cmd, dpcon_id) \
13530 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id)
13532 +/* cmd, param, offset, width, type, arg_name */
13533 +#define DPCON_CMD_CREATE(cmd, cfg) \
13534 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_priorities)
13536 +/* cmd, param, offset, width, type, arg_name */
13537 +#define DPCON_RSP_IS_ENABLED(cmd, en) \
13538 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
13540 +/* cmd, param, offset, width, type, arg_name */
13541 +#define DPCON_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
13543 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
13544 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
13545 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
13546 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
13549 +/* cmd, param, offset, width, type, arg_name */
13550 +#define DPCON_CMD_GET_IRQ(cmd, irq_index) \
13551 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
13553 +/* cmd, param, offset, width, type, arg_name */
13554 +#define DPCON_RSP_GET_IRQ(cmd, type, irq_cfg) \
13556 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val);\
13557 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
13558 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
13559 + MC_RSP_OP(cmd, 2, 32, 32, int, type);\
13562 +/* cmd, param, offset, width, type, arg_name */
13563 +#define DPCON_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
13565 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
13566 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
13569 +/* cmd, param, offset, width, type, arg_name */
13570 +#define DPCON_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
13571 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
13573 +/* cmd, param, offset, width, type, arg_name */
13574 +#define DPCON_RSP_GET_IRQ_ENABLE(cmd, en) \
13575 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
13577 +/* cmd, param, offset, width, type, arg_name */
13578 +#define DPCON_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
13580 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
13581 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
13584 +/* cmd, param, offset, width, type, arg_name */
13585 +#define DPCON_CMD_GET_IRQ_MASK(cmd, irq_index) \
13586 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
13588 +/* cmd, param, offset, width, type, arg_name */
13589 +#define DPCON_RSP_GET_IRQ_MASK(cmd, mask) \
13590 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
13592 +/* cmd, param, offset, width, type, arg_name */
13593 +#define DPCON_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
13595 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
13596 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
13599 +/* cmd, param, offset, width, type, arg_name */
13600 +#define DPCON_RSP_GET_IRQ_STATUS(cmd, status) \
13601 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
13603 +/* cmd, param, offset, width, type, arg_name */
13604 +#define DPCON_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
13606 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
13607 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
13610 +/* cmd, param, offset, width, type, arg_name */
13611 +#define DPCON_RSP_GET_ATTR(cmd, attr) \
13613 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
13614 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_ch_id);\
13615 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
13616 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
13617 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
13620 +/* cmd, param, offset, width, type, arg_name */
13621 +#define DPCON_CMD_SET_NOTIFICATION(cmd, cfg) \
13623 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dpio_id);\
13624 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->priority);\
13625 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx);\
13628 +#endif /* _FSL_DPCON_CMD_H */
13629 diff --git a/drivers/net/dpaa2/mc/fsl_dpdbg.h b/drivers/net/dpaa2/mc/fsl_dpdbg.h
13630 new file mode 100644
13631 index 0000000..ead22e8
13633 +++ b/drivers/net/dpaa2/mc/fsl_dpdbg.h
13635 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
13637 + * Redistribution and use in source and binary forms, with or without
13638 + * modification, are permitted provided that the following conditions are met:
13639 + * * Redistributions of source code must retain the above copyright
13640 + * notice, this list of conditions and the following disclaimer.
13641 + * * Redistributions in binary form must reproduce the above copyright
13642 + * notice, this list of conditions and the following disclaimer in the
13643 + * documentation and/or other materials provided with the distribution.
13644 + * * Neither the name of the above-listed copyright holders nor the
13645 + * names of any contributors may be used to endorse or promote products
13646 + * derived from this software without specific prior written permission.
13649 + * ALTERNATIVELY, this software may be distributed under the terms of the
13650 + * GNU General Public License ("GPL") as published by the Free Software
13651 + * Foundation, either version 2 of that License or (at your option) any
13654 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
13655 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
13656 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
13657 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
13658 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
13659 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
13660 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
13661 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
13662 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
13663 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
13664 + * POSSIBILITY OF SUCH DAMAGE.
13666 +#ifndef __FSL_DPDBG_H
13667 +#define __FSL_DPDBG_H
13669 +#include <fsl_dpkg.h>
13670 +#include <fsl_dpmac.h>
13671 +#include <fsl_dpni.h>
13673 +/* Data Path Debug API
13674 + * Contains initialization APIs and runtime control APIs for DPDBG
13680 + * dpdbg_open() - Open a control session for the specified object.
13681 + * @mc_io: Pointer to MC portal's I/O object
13682 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13683 + * @dpdbg_id: DPDBG unique ID
13684 + * @token: Returned token; use in subsequent API calls
13686 + * This function can be used to open a control session for an
13687 + * already created object;
13688 + * This function returns a unique authentication token,
13689 + * associated with the specific object ID and the specific MC
13690 + * portal; this token must be used in all subsequent commands for
13691 + * this specific object
13693 + * Return: '0' on Success; Error code otherwise.
13695 +int dpdbg_open(struct fsl_mc_io *mc_io,
13696 + uint32_t cmd_flags,
13698 + uint16_t *token);
13701 + * dpdbg_close() - Close the control session of the object
13702 + * @mc_io: Pointer to MC portal's I/O object
13703 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13704 + * @token: Token of DPDBG object
13706 + * After this function is called, no further operations are
13707 + * allowed on the object without opening a new control session.
13709 + * Return: '0' on Success; Error code otherwise.
13711 +int dpdbg_close(struct fsl_mc_io *mc_io,
13712 + uint32_t cmd_flags,
13716 + * struct dpdbg_attr - Structure representing DPDBG attributes
13717 + * @id: DPDBG object ID
13718 + * @version: DPDBG version
13720 +struct dpdbg_attr {
13723 + * struct version - Structure representing DPDBG version
13724 + * @major: DPDBG major version
13725 + * @minor: DPDBG minor version
13734 + * dpdbg_get_attributes - Retrieve DPDBG attributes.
13735 + * @mc_io: Pointer to MC portal's I/O object
13736 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13737 + * @token: Token of DPDBG object
13738 + * @attr: Returned object's attributes
13740 + * Return: '0' on Success; Error code otherwise.
13742 +int dpdbg_get_attributes(struct fsl_mc_io *mc_io,
13743 + uint32_t cmd_flags,
13745 + struct dpdbg_attr *attr);
13748 + * struct dpdbg_dpni_info - Info of DPNI
13749 + * @max_senders: Maximum number of different senders; used as the number
13750 + * of dedicated Tx flows; Non-power-of-2 values are rounded
13751 + * up to the next power-of-2 value as hardware demands it;
13752 + * '0' will be treated as '1'
13753 + * @qdid: Virtual QDID.
13754 + * @err_fqid: Virtual FQID for error queues
13755 + * @tx_conf_fqid: Virtual FQID for global TX confirmation queue
13757 +struct dpdbg_dpni_info {
13758 + uint8_t max_senders;
13760 + uint32_t err_fqid;
13761 + uint32_t tx_conf_fqid;
13765 + * dpdbg_get_dpni_info() - Retrieve info for a specific DPNI
13766 + * @mc_io: Pointer to MC portal's I/O object
13767 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13768 + * @token: Token of DPDBG object
13769 + * @dpni_id: The requested DPNI ID
13770 + * @info: The returned info
13772 + * Return: '0' on Success; Error code otherwise.
13774 +int dpdbg_get_dpni_info(struct fsl_mc_io *mc_io,
13775 + uint32_t cmd_flags,
13778 + struct dpdbg_dpni_info *info);
13781 + * dpdbg_get_dpni_private_fqid() - Retrieve the virtual TX confirmation queue
13782 + * FQID of the required DPNI
13783 + * @mc_io: Pointer to MC portal's I/O object
13784 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13785 + * @token: Token of DPDBG object
13786 + * @dpni_id: The requested DPNI ID
13787 + * @sender_id: The requested sender ID
13788 + * @fqid: The returned virtual private TX confirmation FQID.
13790 + * Return: '0' on Success; Error code otherwise.
13792 +int dpdbg_get_dpni_priv_tx_conf_fqid(struct fsl_mc_io *mc_io,
13793 + uint32_t cmd_flags,
13796 + uint8_t sender_id,
13800 + * struct dpdbg_dpcon_info - Info of DPCON
13801 + * @ch_id: Channel ID
13803 +struct dpdbg_dpcon_info {
13808 + * dpdbg_get_dpcon_info() - Retrieve info of DPCON
13809 + * @mc_io: Pointer to MC portal's I/O object
13810 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13811 + * @token: Token of DPDBG object
13812 + * @dpcon_id: The requested DPCON ID
13813 + * @info: The returned info.
13815 + * Return: '0' on Success; Error code otherwise.
13817 +int dpdbg_get_dpcon_info(struct fsl_mc_io *mc_io,
13818 + uint32_t cmd_flags,
13821 + struct dpdbg_dpcon_info *info);
13824 + * struct dpdbg_dpbp_info - Info of DPBP
13825 + * @bpid: Virtual buffer pool ID
13827 +struct dpdbg_dpbp_info {
13832 + * dpdbg_get_dpbp_info() - Retrieve info of DPBP
13833 + * @mc_io: Pointer to MC portal's I/O object
13834 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13835 + * @token: Token of DPDBG object
13836 + * @dpbp_id: The requested DPBP ID
13837 + * @info: The returned info.
13839 + * Return: '0' on Success; Error code otherwise.
13841 +int dpdbg_get_dpbp_info(struct fsl_mc_io *mc_io,
13842 + uint32_t cmd_flags,
13845 + struct dpdbg_dpbp_info *info);
13848 + * dpdbg_get_dpci_fqid() - Retrieve the virtual FQID of the required DPCI
13849 + * @mc_io: Pointer to MC portal's I/O object
13850 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13851 + * @token: Token of DPDBG object
13852 + * @dpci_id: The requested DPCI ID
13853 + * @priority: Select the queue relative to number of priorities configured at
13855 + * @fqid: The returned virtual FQID.
13857 + * Return: '0' on Success; Error code otherwise.
13859 +int dpdbg_get_dpci_fqid(struct fsl_mc_io *mc_io,
13860 + uint32_t cmd_flags,
13863 + uint8_t priority,
13867 + * Maximum size for rule match (in bytes)
13869 +#define DPDBG_MAX_RULE_SIZE 56
13871 + * Disable marking
13873 +#define DPDBG_DISABLE_MARKING 0xFF
13876 + * dpdbg_prepare_ctlu_global_rule() - function prepare extract parameters
13877 + * @dpkg_rule: defining a full Key Generation profile (rule)
13878 + * @rule_buf: Zeroed 256 bytes of memory before mapping it to DMA
13880 + * This function has to be called before dpdbg_set_global_marking()
13882 +int dpdbg_prepare_ctlu_global_rule(struct dpkg_profile_cfg *dpkg_rule,
13883 + uint8_t *rule_buf);
13886 + * struct dpdbg_rule_cfg - Rule configuration for table lookup
13887 + * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
13888 + * @rule_iova: I/O virtual address of the rule (must be in DMA-able memory)
13889 + * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
13890 + * @key_size: key and mask size (in bytes)
13892 +struct dpdbg_rule_cfg {
13893 + uint64_t key_iova;
13894 + uint64_t mask_iova;
13895 + uint64_t rule_iova;
13896 + uint8_t key_size;
13900 + * dpdbg_set_ctlu_global_marking() - Set marking for all match rule frames
13901 + * @mc_io: Pointer to MC portal's I/O object
13902 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13903 + * @token: Token of DPDBG object
13904 + * @marking: The requested Debug marking
13905 + * @cfg: Marking rule to add
13907 + * Warning: must be called after dpdbg_prepare_global_rule()
13909 + * Return: '0' on Success; Error code otherwise.
13911 +int dpdbg_set_ctlu_global_marking(struct fsl_mc_io *mc_io,
13912 + uint32_t cmd_flags,
13915 + struct dpdbg_rule_cfg *cfg);
13918 + * All traffic classes considered
13920 +#define DPDBG_DPNI_ALL_TCS (uint8_t)(-1)
13922 + * All flows within traffic class considered
13924 +#define DPDBG_DPNI_ALL_TC_FLOWS (uint8_t)(-1)
13926 + * All buffer pools considered
13928 +#define DPDBG_DPNI_ALL_DPBP (uint8_t)(-1)
13931 + * struct dpdbg_dpni_rx_marking_cfg - Ingress frame configuration
13932 + * @tc_id: Traffic class ID (0-7); DPDBG_DPNI_ALL_TCS for all traffic classes.
13933 + * @flow_id: Rx flow id within the traffic class; use
13934 + * 'DPDBG_DPNI_ALL_TC_FLOWS' to set all flows within this tc_id;
13935 + * ignored if tc_id is set to 'DPDBG_DPNI_ALL_TCS';
13936 + * @dpbp_id: buffer pool ID; 'DPDBG_DPNI_ALL_DPBP' to set all DPBP
13937 + * @marking: Marking for match frames;
13938 + * 'DPDBG_DISABLE_MARKING' for disable marking
13940 +struct dpdbg_dpni_rx_marking_cfg {
13942 + uint16_t flow_id;
13943 + uint16_t dpbp_id;
13948 + * dpdbg_set_dpni_rx_marking() - Set Rx frame marking for DPNI
13949 + * @mc_io: Pointer to MC portal's I/O object
13950 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13951 + * @token: Token of DPDBG object
13952 + * @dpni_id: The requested DPNI ID
13953 + * @cfg: RX frame marking configuration
13955 + * Return: '0' on Success; Error code otherwise.
13957 +int dpdbg_set_dpni_rx_marking(struct fsl_mc_io *mc_io,
13958 + uint32_t cmd_flags,
13961 + struct dpdbg_dpni_rx_marking_cfg *cfg);
13963 +/* selects global confirmation queues */
13964 +#define DPDBG_DPNI_GLOBAL_TX_CONF_QUEUE (uint16_t)(-1)
13967 + * dpdbg_set_dpni_tx_conf_marking() - Set Tx frame marking for DPNI
13969 + * @mc_io: Pointer to MC portal's I/O object
13970 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13971 + * @token: Token of DPDBG object
13972 + * @dpni_id: The requested DPNI ID
13973 + * @sender_id: Sender Id for the confirmation queue;
13974 + * 'DPDBG_DPNI_GLOBAL_TX_CONF_QUEUE' for global confirmation queue
13975 + * @marking: The requested marking;
13976 + * 'DPDBG_DISABLE_MARKING' for disable marking
13978 + * Return: '0' on Success; Error code otherwise.
13980 +int dpdbg_set_dpni_tx_conf_marking(struct fsl_mc_io *mc_io,
13981 + uint32_t cmd_flags,
13984 + uint16_t sender_id,
13985 + uint8_t marking);
13988 + * dpdbg_set_dpio_marking() - Set debug frame marking on enqueue
13989 + * @mc_io: Pointer to MC portal's I/O object
13990 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
13991 + * @token: Token of DPDBG object
13992 + * @dpio_id: The requested DPIO ID
13993 + * @marking: The requested marking;
13994 + * 'DPDBG_DISABLE_MARKING' for disable marking
13995 + * Return: '0' on Success; Error code otherwise.
13997 +int dpdbg_set_dpio_marking(struct fsl_mc_io *mc_io,
13998 + uint32_t cmd_flags,
14001 + uint8_t marking);
14004 + * enum dpdbg_verbosity_level - Trace verbosity level
14005 + * @DPDBG_VERBOSITY_LEVEL_DISABLE: Trace disabled
14006 + * @DPDBG_VERBOSITY_LEVEL_TERSE: Terse trace
14007 + * @DPDBG_VERBOSITY_LEVEL_VERBOSE: Verbose trace
14009 +enum dpdbg_verbosity_level {
14010 + DPDBG_VERBOSITY_LEVEL_DISABLE = 0,
14011 + DPDBG_VERBOSITY_LEVEL_TERSE,
14012 + DPDBG_VERBOSITY_LEVEL_VERBOSE
14016 + * dpdbg_set_ctlu_global_trace() - Set global trace configuration for CTLU trace
14018 + * @mc_io: Pointer to MC portal's I/O object
14019 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14020 + * @token: Token of DPDBG object
14021 + * @cfg: trace rule to add
14023 + * Warning: must be called after dpdbg_prepare_global_rule()
14025 + * Return: '0' on Success; Error code otherwise.
14027 +int dpdbg_set_ctlu_global_trace(struct fsl_mc_io *mc_io,
14028 + uint32_t cmd_flags,
14030 + struct dpdbg_rule_cfg *cfg);
14033 + * Number of DPIO trace points
14035 +#define DPDBG_NUM_OF_DPIO_TRACE_POINTS 2
14038 + * enum dpdbg_dpio_trace_type - Define Trace point type
14039 + * @DPDBG_DPIO_TRACE_TYPE_ENQUEUE: This trace point triggers when an enqueue
14040 + * command, received via this portal,
14041 + * and containing a marked frame, is executed
14042 + * @DPDBG_DPIO_TRACE_TYPE_DEFERRED: This trace point triggers when the deferred
14043 + * enqueue of a marked frame received via this
14044 + * portal completes
14046 +enum dpdbg_dpio_trace_type {
14047 + DPDBG_DPIO_TRACE_TYPE_ENQUEUE = 0,
14048 + DPDBG_DPIO_TRACE_TYPE_DEFERRED = 1
14052 + * struct dpdbg_dpio_trace_cfg - Configure the behavior of a trace point
14053 + * when a frame marked with the specified DD code point is
14055 + * @marking: this field will be written into the DD field of every FD
14056 + * enqueued in this DPIO.
14057 + * 'DPDBG_DISABLE_MARKING' for disable marking
14058 + * @verbosity: Verbosity level
14059 + * @enqueue_type: Enqueue trace point type defining a full Key Generation
14062 +struct dpdbg_dpio_trace_cfg {
14064 + enum dpdbg_verbosity_level verbosity;
14065 + enum dpdbg_dpio_trace_type enqueue_type;
14069 + * dpdbg_set_dpio_trace() - Set trace for DPIO for every enqueued frame to
14072 + * @mc_io: Pointer to MC portal's I/O object
14073 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14074 + * @token: Token of DPDBG object
14075 + * @dpio_id: The requested DPIO ID
14076 + * @trace_point: Trace points configuration
14078 + * Return: '0' on Success; Error code otherwise.
14080 +int dpdbg_set_dpio_trace(struct fsl_mc_io *mc_io,
14081 + uint32_t cmd_flags,
14084 + struct dpdbg_dpio_trace_cfg
14085 + trace_point[DPDBG_NUM_OF_DPIO_TRACE_POINTS]);
14088 + * struct dpdbg_dpni_trace_cfg - Configure the behavior of a trace point when a
14089 + * @tc_id: Traffic class ID (0-7); DPDBG_DPNI_ALL_TCS for all traffic classes.
14090 + * @flow_id: Rx flow id within the traffic class; use
14091 + * 'DPDBG_DPNI_ALL_TC_FLOWS' to set all flows within this tc_id;
14092 + * ignored if tc_id is set to 'DPDBG_DPNI_ALL_TCS';
14093 + * @dpbp_id: buffer pool ID; 'DPDBG_DPNI_ALL_DPBP' to set all DPBP
14094 + * @marking: Marking for match frames;
14095 + * 'DPDBG_DISABLE_MARKING' for disable marking
14097 +struct dpdbg_dpni_rx_trace_cfg {
14099 + uint16_t flow_id;
14100 + uint16_t dpbp_id;
14105 + * dpdbg_set_dpni_rx_trace() - Set trace for DPNI ingress (WRIOP ingress).
14106 + * in case of multiple requests for different DPNIs - the trace
14107 + * will be for the latest DPNI requested.
14109 + * @mc_io: Pointer to MC portal's I/O object
14110 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14111 + * @token: Token of DPDBG object
14112 + * @dpni_id: The requested DPNI ID
14113 + * @trace_cfg: Trace configuration
14115 + * Return: '0' on Success; Error code otherwise.
14117 +int dpdbg_set_dpni_rx_trace(struct fsl_mc_io *mc_io,
14118 + uint32_t cmd_flags,
14121 + struct dpdbg_dpni_rx_trace_cfg *trace_cfg);
14124 + * All DPNI senders
14126 +#define DPDBG_DPNI_ALL_SENDERS (uint16_t)(-1)
14129 + * struct dpdbg_dpni_trace_cfg - Configure the behavior of a trace point when a
14130 + * frame marked with the specified DD code point is encountered
14131 + * @marking: The requested debug marking;
14132 + * 'DPDBG_DISABLE_MARKING' for disable marking
14134 +struct dpdbg_dpni_tx_trace_cfg {
14139 + * dpdbg_set_dpni_tx_trace() - Set trace for DPNI dequeued frames
14141 + * @mc_io: Pointer to MC portal's I/O object
14142 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14143 + * @token: Token of DPDBG object
14144 + * @dpni_id: The requested DPNI ID
14145 + * @sender_id: Sender ID; 'DPDBG_DPNI_ALL_SENDERS' for all senders
14146 + * @trace_cfg: Trace configuration
14148 + * Return: '0' on Success; Error code otherwise.
14150 +int dpdbg_set_dpni_tx_trace(struct fsl_mc_io *mc_io,
14151 + uint32_t cmd_flags,
14154 + uint16_t sender_id,
14155 + struct dpdbg_dpni_tx_trace_cfg *trace_cfg);
14158 + * Number of DPCON trace points
14160 +#define DPDBG_NUM_OF_DPCON_TRACE_POINTS 2
14163 + * struct dpdbg_dpcon_trace_cfg - Configure the behavior of a trace point when a
14164 + * frame marked with the specified DD code point is encountered
14165 + * @marking: The requested debug marking;
14166 + * 'DPDBG_DISABLE_MARKING' for disable marking
14167 + * @verbosity: Verbosity level
14169 +struct dpdbg_dpcon_trace_cfg {
14171 + enum dpdbg_verbosity_level verbosity;
14175 + * dpdbg_set_dpcon_trace() - Set trace for DPCON when a frame marked with a
14176 + * specified marking is dequeued from a WQ in the
14177 + * channel selected
14179 + * @mc_io: Pointer to MC portal's I/O object
14180 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14181 + * @token: Token of DPDBG object
14182 + * @dpcon_id: The requested DPCON ID
14183 + * @trace_point: Trace points configuration
14185 + * Return: '0' on Success; Error code otherwise.
14187 +int dpdbg_set_dpcon_trace(struct fsl_mc_io *mc_io,
14188 + uint32_t cmd_flags,
14191 + struct dpdbg_dpcon_trace_cfg
14192 + trace_point[DPDBG_NUM_OF_DPCON_TRACE_POINTS]);
14195 + * Number of DPSECI trace points
14197 +#define DPDBG_NUM_OF_DPSECI_TRACE_POINTS 2
14200 + * struct dpdbg_dpseci_trace_cfg - Configure the behavior of a trace point when
14201 + * a frame marked with the specified DD code point is
14203 + * @marking: The requested debug marking;
14204 + * 'DPDBG_DISABLE_MARKING' for disable marking
14205 + * @verbosity: Verbosity level
14207 +struct dpdbg_dpseci_trace_cfg {
14209 + enum dpdbg_verbosity_level verbosity;
14213 + * dpdbg_set_dpseci_trace() - Set trace for DPSECI when a frame marked with the
14214 + * specific marking is enqueued via this portal.
14216 + * @mc_io: Pointer to MC portal's I/O object
14217 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14218 + * @token: Token of DPDBG object
14219 + * @dpseci_id: The requested DPSECI ID
14220 + * @trace_point: Trace points configuration
14222 + * Return: '0' on Success; Error code otherwise.
14224 +int dpdbg_set_dpseci_trace(struct fsl_mc_io *mc_io,
14225 + uint32_t cmd_flags,
14228 + struct dpdbg_dpseci_trace_cfg
14229 + trace_point[DPDBG_NUM_OF_DPSECI_TRACE_POINTS]);
14232 + * dpdbg_get_dpmac_counter() - DPMAC packet throughput
14234 + * @mc_io: Pointer to MC portal's I/O object
14235 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14236 + * @token: Token of DPDBG object
14237 + * @dpmac_id: The requested DPMAC ID
14238 + * @counter_type: The requested DPMAC counter
14239 + * @counter: Returned counter value
14241 + * Return: '0' on Success; Error code otherwise.
14243 +int dpdbg_get_dpmac_counter(struct fsl_mc_io *mc_io,
14244 + uint32_t cmd_flags,
14247 + enum dpmac_counter counter_type,
14248 + uint64_t *counter);
14251 + * dpdbg_get_dpni_counter() - DPNI packet throughput
14253 + * @mc_io: Pointer to MC portal's I/O object
14254 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14255 + * @token: Token of DPDBG object
14256 + * @dpni_id: The requested DPNI ID
14257 + * @counter_type: The requested DPNI counter
14258 + * @counter: Returned counter value
14260 + * Return: '0' on Success; Error code otherwise.
14262 +int dpdbg_get_dpni_counter(struct fsl_mc_io *mc_io,
14263 + uint32_t cmd_flags,
14266 + enum dpni_counter counter_type,
14267 + uint64_t *counter);
14269 +#endif /* __FSL_DPDBG_H */
14270 diff --git a/drivers/net/dpaa2/mc/fsl_dpdbg_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdbg_cmd.h
14271 new file mode 100644
14272 index 0000000..b672788
14274 +++ b/drivers/net/dpaa2/mc/fsl_dpdbg_cmd.h
14276 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
14278 + * Redistribution and use in source and binary forms, with or without
14279 + * modification, are permitted provided that the following conditions are met:
14280 + * * Redistributions of source code must retain the above copyright
14281 + * notice, this list of conditions and the following disclaimer.
14282 + * * Redistributions in binary form must reproduce the above copyright
14283 + * notice, this list of conditions and the following disclaimer in the
14284 + * documentation and/or other materials provided with the distribution.
14285 + * * Neither the name of the above-listed copyright holders nor the
14286 + * names of any contributors may be used to endorse or promote products
14287 + * derived from this software without specific prior written permission.
14290 + * ALTERNATIVELY, this software may be distributed under the terms of the
14291 + * GNU General Public License ("GPL") as published by the Free Software
14292 + * Foundation, either version 2 of that License or (at your option) any
14295 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14296 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14297 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14298 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
14299 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
14300 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
14301 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
14302 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
14303 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
14304 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
14305 + * POSSIBILITY OF SUCH DAMAGE.
14307 +#ifndef _FSL_DPDBG_CMD_H
14308 +#define _FSL_DPDBG_CMD_H
14310 +/* DPDBG Version */
14311 +#define DPDBG_VER_MAJOR 1
14312 +#define DPDBG_VER_MINOR 0
14315 +#define DPDBG_CMDID_CLOSE 0x800
14316 +#define DPDBG_CMDID_OPEN 0x80F
14318 +#define DPDBG_CMDID_GET_ATTR 0x004
14320 +#define DPDBG_CMDID_GET_DPNI_INFO 0x130
14321 +#define DPDBG_CMDID_GET_DPNI_PRIV_TX_CONF_FQID 0x131
14322 +#define DPDBG_CMDID_GET_DPCON_INFO 0x132
14323 +#define DPDBG_CMDID_GET_DPBP_INFO 0x133
14324 +#define DPDBG_CMDID_GET_DPCI_FQID 0x134
14326 +#define DPDBG_CMDID_SET_CTLU_GLOBAL_MARKING 0x135
14327 +#define DPDBG_CMDID_SET_DPNI_RX_MARKING 0x136
14328 +#define DPDBG_CMDID_SET_DPNI_TX_CONF_MARKING 0x137
14329 +#define DPDBG_CMDID_SET_DPIO_MARKING 0x138
14331 +#define DPDBG_CMDID_SET_CTLU_GLOBAL_TRACE 0x140
14332 +#define DPDBG_CMDID_SET_DPIO_TRACE 0x141
14333 +#define DPDBG_CMDID_SET_DPNI_RX_TRACE 0x142
14334 +#define DPDBG_CMDID_SET_DPNI_TX_TRACE 0x143
14335 +#define DPDBG_CMDID_SET_DPCON_TRACE 0x145
14336 +#define DPDBG_CMDID_SET_DPSECI_TRACE 0x146
14338 +#define DPDBG_CMDID_GET_DPMAC_COUNTER 0x150
14339 +#define DPDBG_CMDID_GET_DPNI_COUNTER 0x151
14341 +/* cmd, param, offset, width, type, arg_name */
14342 +#define DPDBG_CMD_OPEN(cmd, dpdbg_id) \
14343 + MC_CMD_OP(cmd, 0, 0, 32, int, dpdbg_id)
14345 +/* cmd, param, offset, width, type, arg_name */
14346 +#define DPDBG_RSP_GET_ATTRIBUTES(cmd, attr) \
14348 + MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
14349 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
14350 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
14353 +/* cmd, param, offset, width, type, arg_name */
14354 +#define DPDBG_CMD_GET_DPNI_INFO(cmd, dpni_id) \
14355 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
14357 +/* cmd, param, offset, width, type, arg_name */
14358 +#define DPDBG_RSP_GET_DPNI_INFO(cmd, info) \
14360 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, info->qdid);\
14361 + MC_RSP_OP(cmd, 1, 32, 8, uint8_t, info->max_senders);\
14362 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, info->err_fqid);\
14363 + MC_RSP_OP(cmd, 2, 32, 32, uint32_t, info->tx_conf_fqid);\
14366 +/* cmd, param, offset, width, type, arg_name */
14367 +#define DPDBG_CMD_GET_DPNI_PRIV_TX_CONF_FQID(cmd, dpni_id, sender_id) \
14369 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14370 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, sender_id);\
14373 +/* cmd, param, offset, width, type, arg_name */
14374 +#define DPDBG_RSP_GET_DPNI_PRIV_TX_CONF_FQID(cmd, fqid) \
14375 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, fqid)
14377 +/* cmd, param, offset, width, type, arg_name */
14378 +#define DPDBG_CMD_GET_DPCON_INFO(cmd, dpcon_id) \
14379 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id)
14381 +/* cmd, param, offset, width, type, arg_name */
14382 +#define DPDBG_RSP_GET_DPCON_INFO(cmd, info) \
14383 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, info->ch_id)
14385 +/* cmd, param, offset, width, type, arg_name */
14386 +#define DPDBG_CMD_GET_DPBP_INFO(cmd, dpbp_id) \
14387 + MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
14389 +/* cmd, param, offset, width, type, arg_name */
14390 +#define DPDBG_RSP_GET_DPBP_INFO(cmd, info) \
14391 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, info->bpid)
14393 +/* cmd, param, offset, width, type, arg_name */
14394 +#define DPDBG_CMD_GET_DPCI_FQID(cmd, dpci_id, priority) \
14396 + MC_CMD_OP(cmd, 0, 0, 32, int, dpci_id);\
14397 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, priority);\
14399 +/* cmd, param, offset, width, type, arg_name */
14400 +#define DPDBG_RSP_GET_DPCI_FQID(cmd, fqid) \
14401 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, fqid)
14403 +/* cmd, param, offset, width, type, arg_name */
14404 +#define DPDBG_CMD_SET_CTLU_GLOBAL_MARKING(cmd, marking, cfg) \
14406 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, marking);\
14407 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->key_size); \
14408 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
14409 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
14410 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->rule_iova); \
14413 +#define DPDBG_CMD_SET_DPNI_RX_MARKING(cmd, dpni_id, cfg) \
14415 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14416 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->tc_id);\
14417 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, cfg->flow_id);\
14418 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->dpbp_id);\
14419 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->marking);\
14422 +#define DPDBG_CMD_SET_DPNI_TX_CONF_MARKING(cmd, dpni_id, sender_id, marking) \
14424 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14425 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, sender_id);\
14426 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, marking);\
14429 +#define DPDBG_CMD_SET_DPIO_MARKING(cmd, dpio_id, marking) \
14431 + MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id);\
14432 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, marking);\
14435 +/* cmd, param, offset, width, type, arg_name */
14436 +#define DPDBG_CMD_SET_CTLU_GLOBAL_TRACE(cmd, cfg) \
14438 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->key_size); \
14439 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
14440 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
14441 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->rule_iova); \
14444 +/* cmd, param, offset, width, type, arg_name */
14445 +#define DPDBG_CMD_SET_DPIO_TRACE(cmd, dpio_id, trace_point) \
14447 + MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id);\
14448 + MC_CMD_OP(cmd, 1, 0, 4, enum dpdbg_verbosity_level, \
14449 + trace_point[0].verbosity); \
14450 + MC_CMD_OP(cmd, 1, 4, 4, enum dpdbg_dpio_trace_type, \
14451 + trace_point[0].enqueue_type); \
14452 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, trace_point[0].marking); \
14453 + MC_CMD_OP(cmd, 1, 32, 4, enum dpdbg_verbosity_level, \
14454 + trace_point[1].verbosity); \
14455 + MC_CMD_OP(cmd, 1, 36, 4, enum dpdbg_dpio_trace_type, \
14456 + trace_point[1].enqueue_type); \
14457 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, trace_point[1].marking); \
14460 +/* cmd, param, offset, width, type, arg_name */
14461 +#define DPDBG_CMD_SET_DPNI_RX_TRACE(cmd, dpni_id, trace_cfg) \
14463 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14464 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, trace_cfg->tc_id);\
14465 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, trace_cfg->flow_id);\
14466 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, trace_cfg->dpbp_id);\
14467 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, trace_cfg->marking);\
14470 +/* cmd, param, offset, width, type, arg_name */
14471 +#define DPDBG_CMD_SET_DPNI_TX_TRACE(cmd, dpni_id, sender_id, trace_cfg) \
14473 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14474 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, sender_id);\
14475 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, trace_cfg->marking);\
14478 +/* cmd, param, offset, width, type, arg_name */
14479 +#define DPDBG_CMD_SET_DPCON_TRACE(cmd, dpcon_id, trace_point) \
14481 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id);\
14482 + MC_CMD_OP(cmd, 1, 0, 4, enum dpdbg_verbosity_level, \
14483 + trace_point[0].verbosity); \
14484 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, trace_point[0].marking); \
14485 + MC_CMD_OP(cmd, 1, 32, 4, enum dpdbg_verbosity_level, \
14486 + trace_point[1].verbosity); \
14487 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, trace_point[1].marking); \
14490 +/* cmd, param, offset, width, type, arg_name */
14491 +#define DPDBG_CMD_SET_DPSECI_TRACE(cmd, dpseci_id, trace_point) \
14493 + MC_CMD_OP(cmd, 0, 0, 32, int, dpseci_id);\
14494 + MC_CMD_OP(cmd, 1, 0, 4, enum dpdbg_verbosity_level, \
14495 + trace_point[0].verbosity); \
14496 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, trace_point[0].marking); \
14497 + MC_CMD_OP(cmd, 1, 32, 4, enum dpdbg_verbosity_level, \
14498 + trace_point[1].verbosity); \
14499 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, trace_point[1].marking); \
14502 +/* cmd, param, offset, width, type, arg_name */
14503 +#define DPDBG_CMD_GET_DPMAC_COUNTER(cmd, dpmac_id, counter_type) \
14505 + MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id);\
14506 + MC_CMD_OP(cmd, 0, 32, 16, enum dpmac_counter, counter_type);\
14509 +/* cmd, param, offset, width, type, arg_name */
14510 +#define DPDBG_RSP_GET_DPMAC_COUNTER(cmd, counter) \
14511 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
14513 +/* cmd, param, offset, width, type, arg_name */
14514 +#define DPDBG_CMD_GET_DPNI_COUNTER(cmd, dpni_id, counter_type) \
14516 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id);\
14517 + MC_CMD_OP(cmd, 0, 32, 16, enum dpni_counter, counter_type);\
14520 +/* cmd, param, offset, width, type, arg_name */
14521 +#define DPDBG_RSP_GET_DPNI_COUNTER(cmd, counter) \
14522 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
14524 +#endif /* _FSL_DPDBG_CMD_H */
14525 diff --git a/drivers/net/dpaa2/mc/fsl_dpdcei.h b/drivers/net/dpaa2/mc/fsl_dpdcei.h
14526 new file mode 100644
14527 index 0000000..319795c
14529 +++ b/drivers/net/dpaa2/mc/fsl_dpdcei.h
14531 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
14533 + * Redistribution and use in source and binary forms, with or without
14534 + * modification, are permitted provided that the following conditions are met:
14535 + * * Redistributions of source code must retain the above copyright
14536 + * notice, this list of conditions and the following disclaimer.
14537 + * * Redistributions in binary form must reproduce the above copyright
14538 + * notice, this list of conditions and the following disclaimer in the
14539 + * documentation and/or other materials provided with the distribution.
14540 + * * Neither the name of the above-listed copyright holders nor the
14541 + * names of any contributors may be used to endorse or promote products
14542 + * derived from this software without specific prior written permission.
14545 + * ALTERNATIVELY, this software may be distributed under the terms of the
14546 + * GNU General Public License ("GPL") as published by the Free Software
14547 + * Foundation, either version 2 of that License or (at your option) any
14550 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14551 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14552 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14553 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
14554 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
14555 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
14556 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
14557 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
14558 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
14559 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
14560 + * POSSIBILITY OF SUCH DAMAGE.
14562 +#ifndef __FSL_DPDCEI_H
14563 +#define __FSL_DPDCEI_H
14565 +/* Data Path DCE Interface API
14566 + * Contains initialization APIs and runtime control APIs for DPDCEI
14571 +/** General DPDCEI macros */
14574 + * Indicates an invalid frame queue
14576 +#define DPDCEI_FQID_NOT_VALID (uint32_t)(-1)
14579 + * enum dpdcei_engine - DCE engine block
14580 + * @DPDCEI_ENGINE_COMPRESSION: Engine compression
14581 + * @DPDCEI_ENGINE_DECOMPRESSION: Engine decompression
14583 +enum dpdcei_engine {
14584 + DPDCEI_ENGINE_COMPRESSION,
14585 + DPDCEI_ENGINE_DECOMPRESSION
14589 + * dpdcei_open() - Open a control session for the specified object
14590 + * @mc_io: Pointer to MC portal's I/O object
14591 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14592 + * @token: Token of DPDCEI object
14593 + * @dpdcei_id: DPDCEI unique ID
14595 + * This function can be used to open a control session for an
14596 + * already created object; an object may have been declared in
14597 + * the DPL or by calling the dpdcei_create() function.
14598 + * This function returns a unique authentication token,
14599 + * associated with the specific object ID and the specific MC
14600 + * portal; this token must be used in all subsequent commands for
14601 + * this specific object.
14603 + * Return: '0' on Success; Error code otherwise.
14605 +int dpdcei_open(struct fsl_mc_io *mc_io,
14606 + uint32_t cmd_flags,
14608 + uint16_t *token);
14611 + * dpdcei_close() - Close the control session of the object
14612 + * @mc_io: Pointer to MC portal's I/O object
14613 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14614 + * @token: Token of DPDCEI object
14616 + * After this function is called, no further operations are
14617 + * allowed on the object without opening a new control session.
14619 + * Return: '0' on Success; Error code otherwise.
14621 +int dpdcei_close(struct fsl_mc_io *mc_io,
14622 + uint32_t cmd_flags,
14626 + * struct dpdcei_cfg - Structure representing DPDCEI configuration
14627 + * @engine: compression or decompression engine to be selected
14628 + * @priority: Priority for the DCE hardware processing (valid values 1-8).
14630 +struct dpdcei_cfg {
14631 + enum dpdcei_engine engine;
14632 + uint8_t priority;
14636 + * dpdcei_create() - Create the DPDCEI object
14637 + * @mc_io: Pointer to MC portal's I/O object
14638 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14639 + * @token: Token of DPDCEI object
14640 + * @cfg: configuration parameters
14642 + * Create the DPDCEI object, allocate required resources and
14643 + * perform required initialization.
14645 + * The object can be created either by declaring it in the
14646 + * DPL file, or by calling this function.
14648 + * This function returns a unique authentication token,
14649 + * associated with the specific object ID and the specific MC
14650 + * portal; this token must be used in all subsequent calls to
14651 + * this specific object. For objects that are created using the
14652 + * DPL file, call dpdcei_open() function to get an authentication
14655 + * Return: '0' on Success; Error code otherwise.
14657 +int dpdcei_create(struct fsl_mc_io *mc_io,
14658 + uint32_t cmd_flags,
14659 + const struct dpdcei_cfg *cfg,
14660 + uint16_t *token);
14663 + * dpdcei_destroy() - Destroy the DPDCEI object and release all its resources.
14664 + * @mc_io: Pointer to MC portal's I/O object
14665 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14666 + * @token: Token of DPDCEI object
14668 + * Return: '0' on Success; error code otherwise.
14670 +int dpdcei_destroy(struct fsl_mc_io *mc_io,
14671 + uint32_t cmd_flags,
14675 + * dpdcei_enable() - Enable the DPDCEI, allow sending and receiving frames.
14676 + * @mc_io: Pointer to MC portal's I/O object
14677 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14678 + * @token: Token of DPDCEI object
14680 + * Return: '0' on Success; Error code otherwise.
14682 +int dpdcei_enable(struct fsl_mc_io *mc_io,
14683 + uint32_t cmd_flags,
14687 + * dpdcei_disable() - Disable the DPDCEI, stop sending and receiving frames.
14688 + * @mc_io: Pointer to MC portal's I/O object
14689 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14690 + * @token: Token of DPDCEI object
14692 + * Return: '0' on Success; Error code otherwise.
14694 +int dpdcei_disable(struct fsl_mc_io *mc_io,
14695 + uint32_t cmd_flags,
14699 + * dpdcei_is_enabled() - Check if the DPDCEI is enabled.
14700 + * @mc_io: Pointer to MC portal's I/O object
14701 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14702 + * @token: Token of DPDCEI object
14703 + * @en: Return '1' for object enabled/'0' otherwise
14705 + * Return: '0' on Success; Error code otherwise.
14707 +int dpdcei_is_enabled(struct fsl_mc_io *mc_io,
14708 + uint32_t cmd_flags,
14713 + * dpdcei_reset() - Reset the DPDCEI, returns the object to initial state.
14714 + * @mc_io: Pointer to MC portal's I/O object
14715 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14716 + * @token: Token of DPDCEI object
14718 + * Return: '0' on Success; Error code otherwise.
14720 +int dpdcei_reset(struct fsl_mc_io *mc_io,
14721 + uint32_t cmd_flags,
14725 + * struct dpdcei_irq_cfg - IRQ configuration
14726 + * @addr: Address that must be written to signal a message-based interrupt
14727 + * @val: Value to write into irq_addr address
14728 + * @irq_num: A user defined number associated with this IRQ
14730 +struct dpdcei_irq_cfg {
14737 + * dpdcei_set_irq() - Set IRQ information for the DPDCEI to trigger an interrupt
14738 + * @mc_io: Pointer to MC portal's I/O object
14739 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14740 + * @token: Token of DPDCEI object
14741 + * @irq_index: Identifies the interrupt index to configure
14742 + * @irq_cfg: IRQ configuration
14744 + * Return: '0' on Success; Error code otherwise.
14746 +int dpdcei_set_irq(struct fsl_mc_io *mc_io,
14747 + uint32_t cmd_flags,
14749 + uint8_t irq_index,
14750 + struct dpdcei_irq_cfg *irq_cfg);
14753 + * dpdcei_get_irq() - Get IRQ information from the DPDCEI
14755 + * @mc_io: Pointer to MC portal's I/O object
14756 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14757 + * @token: Token of DPDCEI object
14758 + * @irq_index: The interrupt index to configure
14759 + * @type: Interrupt type: 0 represents message interrupt
14760 + * type (both irq_addr and irq_val are valid)
14761 + * @irq_cfg: IRQ attributes
14763 + * Return: '0' on Success; Error code otherwise.
14765 +int dpdcei_get_irq(struct fsl_mc_io *mc_io,
14766 + uint32_t cmd_flags,
14768 + uint8_t irq_index,
14770 + struct dpdcei_irq_cfg *irq_cfg);
14773 + * dpdcei_set_irq_enable() - Set overall interrupt state.
14774 + * @mc_io: Pointer to MC portal's I/O object
14775 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14776 + * @token: Token of DPCI object
14777 + * @irq_index: The interrupt index to configure
14778 + * @en: Interrupt state - enable = 1, disable = 0
14780 + * Allows GPP software to control when interrupts are generated.
14781 + * Each interrupt can have up to 32 causes. The enable/disable control's the
14782 + * overall interrupt state. if the interrupt is disabled no causes will cause
14785 + * Return: '0' on Success; Error code otherwise.
14787 +int dpdcei_set_irq_enable(struct fsl_mc_io *mc_io,
14788 + uint32_t cmd_flags,
14790 + uint8_t irq_index,
14794 + * dpdcei_get_irq_enable() - Get overall interrupt state
14795 + * @mc_io: Pointer to MC portal's I/O object
14796 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14797 + * @token: Token of DPDCEI object
14798 + * @irq_index: The interrupt index to configure
14799 + * @en: Returned Interrupt state - enable = 1, disable = 0
14801 + * Return: '0' on Success; Error code otherwise.
14803 +int dpdcei_get_irq_enable(struct fsl_mc_io *mc_io,
14804 + uint32_t cmd_flags,
14806 + uint8_t irq_index,
14810 + * dpdcei_set_irq_mask() - Set interrupt mask.
14811 + * @mc_io: Pointer to MC portal's I/O object
14812 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14813 + * @token: Token of DPCI object
14814 + * @irq_index: The interrupt index to configure
14815 + * @mask: event mask to trigger interrupt;
14817 + * 0 = ignore event
14818 + * 1 = consider event for asserting IRQ
14820 + * Every interrupt can have up to 32 causes and the interrupt model supports
14821 + * masking/unmasking each cause independently
14823 + * Return: '0' on Success; Error code otherwise.
14825 +int dpdcei_set_irq_mask(struct fsl_mc_io *mc_io,
14826 + uint32_t cmd_flags,
14828 + uint8_t irq_index,
14832 + * dpdcei_get_irq_mask() - Get interrupt mask.
14833 + * @mc_io: Pointer to MC portal's I/O object
14834 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14835 + * @token: Token of DPDCEI object
14836 + * @irq_index: The interrupt index to configure
14837 + * @mask: Returned event mask to trigger interrupt
14839 + * Every interrupt can have up to 32 causes and the interrupt model supports
14840 + * masking/unmasking each cause independently
14842 + * Return: '0' on Success; Error code otherwise.
14844 +int dpdcei_get_irq_mask(struct fsl_mc_io *mc_io,
14845 + uint32_t cmd_flags,
14847 + uint8_t irq_index,
14851 + * dpdcei_get_irq_status() - Get the current status of any pending interrupts
14852 + * @mc_io: Pointer to MC portal's I/O object
14853 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14854 + * @token: Token of DPDCEI object
14855 + * @irq_index: The interrupt index to configure
14856 + * @status: Returned interrupts status - one bit per cause:
14857 + * 0 = no interrupt pending
14858 + * 1 = interrupt pending
14860 + * Return: '0' on Success; Error code otherwise.
14862 +int dpdcei_get_irq_status(struct fsl_mc_io *mc_io,
14863 + uint32_t cmd_flags,
14865 + uint8_t irq_index,
14866 + uint32_t *status);
14869 + * dpdcei_clear_irq_status() - Clear a pending interrupt's status
14870 + * @mc_io: Pointer to MC portal's I/O object
14871 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14872 + * @token: Token of DPDCEI object
14873 + * @irq_index: The interrupt index to configure
14874 + * @status: bits to clear (W1C) - one bit per cause:
14875 + * 0 = don't change
14876 + * 1 = clear status bit
14878 + * Return: '0' on Success; Error code otherwise.
14880 +int dpdcei_clear_irq_status(struct fsl_mc_io *mc_io,
14881 + uint32_t cmd_flags,
14883 + uint8_t irq_index,
14884 + uint32_t status);
14886 + * struct dpdcei_attr - Structure representing DPDCEI attributes
14887 + * @id: DPDCEI object ID
14888 + * @engine: DCE engine block
14889 + * @version: DPDCEI version
14891 +struct dpdcei_attr {
14893 + enum dpdcei_engine engine;
14895 + * struct version - DPDCEI version
14896 + * @major: DPDCEI major version
14897 + * @minor: DPDCEI minor version
14906 + * dpdcei_get_attributes() - Retrieve DPDCEI attributes.
14907 + * @mc_io: Pointer to MC portal's I/O object
14908 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14909 + * @token: Token of DPDCEI object
14910 + * @attr: Returned object's attributes
14912 + * Return: '0' on Success; Error code otherwise.
14914 +int dpdcei_get_attributes(struct fsl_mc_io *mc_io,
14915 + uint32_t cmd_flags,
14917 + struct dpdcei_attr *attr);
14920 + * enum dpdcei_dest - DPDCEI destination types
14921 + * @DPDCEI_DEST_NONE: Unassigned destination; The queue is set in parked mode
14922 + * and does not generate FQDAN notifications;
14923 + * user is expected to dequeue from the queue based on
14924 + * polling or other user-defined method
14925 + * @DPDCEI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
14926 + * notifications to the specified DPIO; user is expected to
14927 + * dequeue from the queue only after notification is
14929 + * @DPDCEI_DEST_DPCON: The queue is set in schedule mode and does not generate
14930 + * FQDAN notifications, but is connected to the specified
14932 + * user is expected to dequeue from the DPCON channel
14934 +enum dpdcei_dest {
14935 + DPDCEI_DEST_NONE = 0,
14936 + DPDCEI_DEST_DPIO = 1,
14937 + DPDCEI_DEST_DPCON = 2
14941 + * struct dpdcei_dest_cfg - Structure representing DPDCEI destination parameters
14942 + * @dest_type: Destination type
14943 + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
14944 + * @priority: Priority selection within the DPIO or DPCON channel; valid values
14945 + * are 0-1 or 0-7, depending on the number of priorities in that
14946 + * channel; not relevant for 'DPDCEI_DEST_NONE' option
14948 +struct dpdcei_dest_cfg {
14949 + enum dpdcei_dest dest_type;
14951 + uint8_t priority;
14954 +/** DPDCEI queue modification options */
14957 + * Select to modify the user's context associated with the queue
14959 +#define DPDCEI_QUEUE_OPT_USER_CTX 0x00000001
14962 + * Select to modify the queue's destination
14964 +#define DPDCEI_QUEUE_OPT_DEST 0x00000002
14967 + * struct dpdcei_rx_queue_cfg - RX queue configuration
14968 + * @options: Flags representing the suggested modifications to the queue;
14969 + * Use any combination of 'DPDCEI_QUEUE_OPT_<X>' flags
14970 + * @user_ctx: User context value provided in the frame descriptor of each
14971 + * dequeued frame;
14972 + * valid only if 'DPDCEI_QUEUE_OPT_USER_CTX' is contained in 'options'
14973 + * @dest_cfg: Queue destination parameters;
14974 + * valid only if 'DPDCEI_QUEUE_OPT_DEST' is contained in 'options'
14976 +struct dpdcei_rx_queue_cfg {
14977 + uint32_t options;
14978 + uint64_t user_ctx;
14979 + struct dpdcei_dest_cfg dest_cfg;
14983 + * dpdcei_set_rx_queue() - Set Rx queue configuration
14984 + * @mc_io: Pointer to MC portal's I/O object
14985 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
14986 + * @token: Token of DPDCEI object
14987 + * @cfg: Rx queue configuration
14989 + * Return: '0' on Success; Error code otherwise.
14991 +int dpdcei_set_rx_queue(struct fsl_mc_io *mc_io,
14992 + uint32_t cmd_flags,
14994 + const struct dpdcei_rx_queue_cfg *cfg);
14997 + * struct dpdcei_rx_queue_attr - Structure representing attributes of Rx queues
14998 + * @user_ctx: User context value provided in the frame descriptor of each
15000 + * @dest_cfg: Queue destination configuration
15001 + * @fqid: Virtual FQID value to be used for dequeue operations
15003 +struct dpdcei_rx_queue_attr {
15004 + uint64_t user_ctx;
15005 + struct dpdcei_dest_cfg dest_cfg;
15010 + * dpdcei_get_rx_queue() - Retrieve Rx queue attributes.
15011 + * @mc_io: Pointer to MC portal's I/O object
15012 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15013 + * @token: Token of DPDCEI object
15014 + * @attr: Returned Rx queue attributes
15016 + * Return: '0' on Success; Error code otherwise.
15018 +int dpdcei_get_rx_queue(struct fsl_mc_io *mc_io,
15019 + uint32_t cmd_flags,
15021 + struct dpdcei_rx_queue_attr *attr);
15024 + * struct dpdcei_tx_queue_attr - Structure representing attributes of Tx queues
15025 + * @fqid: Virtual FQID to be used for sending frames to DCE hardware
15027 +struct dpdcei_tx_queue_attr {
15032 + * dpdcei_get_tx_queue() - Retrieve Tx queue attributes.
15033 + * @mc_io: Pointer to MC portal's I/O object
15034 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15035 + * @token: Token of DPDCEI object
15036 + * @attr: Returned Tx queue attributes
15038 + * Return: '0' on Success; Error code otherwise.
15040 +int dpdcei_get_tx_queue(struct fsl_mc_io *mc_io,
15041 + uint32_t cmd_flags,
15043 + struct dpdcei_tx_queue_attr *attr);
15045 +#endif /* __FSL_DPDCEI_H */
15046 diff --git a/drivers/net/dpaa2/mc/fsl_dpdcei_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdcei_cmd.h
15047 new file mode 100644
15048 index 0000000..8452d88
15050 +++ b/drivers/net/dpaa2/mc/fsl_dpdcei_cmd.h
15052 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
15054 + * Redistribution and use in source and binary forms, with or without
15055 + * modification, are permitted provided that the following conditions are met:
15056 + * * Redistributions of source code must retain the above copyright
15057 + * notice, this list of conditions and the following disclaimer.
15058 + * * Redistributions in binary form must reproduce the above copyright
15059 + * notice, this list of conditions and the following disclaimer in the
15060 + * documentation and/or other materials provided with the distribution.
15061 + * * Neither the name of the above-listed copyright holders nor the
15062 + * names of any contributors may be used to endorse or promote products
15063 + * derived from this software without specific prior written permission.
15066 + * ALTERNATIVELY, this software may be distributed under the terms of the
15067 + * GNU General Public License ("GPL") as published by the Free Software
15068 + * Foundation, either version 2 of that License or (at your option) any
15071 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15072 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15073 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15074 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
15075 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
15076 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15077 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
15078 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
15079 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
15080 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
15081 + * POSSIBILITY OF SUCH DAMAGE.
15083 +#ifndef _FSL_DPDCEI_CMD_H
15084 +#define _FSL_DPDCEI_CMD_H
15086 +/* DPDCEI Version */
15087 +#define DPDCEI_VER_MAJOR 1
15088 +#define DPDCEI_VER_MINOR 2
15091 +#define DPDCEI_CMDID_CLOSE 0x800
15092 +#define DPDCEI_CMDID_OPEN 0x80D
15093 +#define DPDCEI_CMDID_CREATE 0x90D
15094 +#define DPDCEI_CMDID_DESTROY 0x900
15096 +#define DPDCEI_CMDID_ENABLE 0x002
15097 +#define DPDCEI_CMDID_DISABLE 0x003
15098 +#define DPDCEI_CMDID_GET_ATTR 0x004
15099 +#define DPDCEI_CMDID_RESET 0x005
15100 +#define DPDCEI_CMDID_IS_ENABLED 0x006
15102 +#define DPDCEI_CMDID_SET_IRQ 0x010
15103 +#define DPDCEI_CMDID_GET_IRQ 0x011
15104 +#define DPDCEI_CMDID_SET_IRQ_ENABLE 0x012
15105 +#define DPDCEI_CMDID_GET_IRQ_ENABLE 0x013
15106 +#define DPDCEI_CMDID_SET_IRQ_MASK 0x014
15107 +#define DPDCEI_CMDID_GET_IRQ_MASK 0x015
15108 +#define DPDCEI_CMDID_GET_IRQ_STATUS 0x016
15109 +#define DPDCEI_CMDID_CLEAR_IRQ_STATUS 0x017
15111 +#define DPDCEI_CMDID_SET_RX_QUEUE 0x1B0
15112 +#define DPDCEI_CMDID_GET_RX_QUEUE 0x1B1
15113 +#define DPDCEI_CMDID_GET_TX_QUEUE 0x1B2
15115 +/* cmd, param, offset, width, type, arg_name */
15116 +#define DPDCEI_CMD_OPEN(cmd, dpdcei_id) \
15117 + MC_CMD_OP(cmd, 0, 0, 32, int, dpdcei_id)
15119 +/* cmd, param, offset, width, type, arg_name */
15120 +#define DPDCEI_CMD_CREATE(cmd, cfg) \
15122 + MC_CMD_OP(cmd, 0, 8, 8, enum dpdcei_engine, cfg->engine);\
15123 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->priority);\
15126 +/* cmd, param, offset, width, type, arg_name */
15127 +#define DPDCEI_RSP_IS_ENABLED(cmd, en) \
15128 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
15130 +/* cmd, param, offset, width, type, arg_name */
15131 +#define DPDCEI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
15133 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
15134 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
15135 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
15136 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
15139 +/* cmd, param, offset, width, type, arg_name */
15140 +#define DPDCEI_CMD_GET_IRQ(cmd, irq_index) \
15141 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15143 +/* cmd, param, offset, width, type, arg_name */
15144 +#define DPDCEI_RSP_GET_IRQ(cmd, type, irq_cfg) \
15146 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
15147 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
15148 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
15149 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
15152 +/* cmd, param, offset, width, type, arg_name */
15153 +#define DPDCEI_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \
15155 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \
15156 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15159 +/* cmd, param, offset, width, type, arg_name */
15160 +#define DPDCEI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
15161 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15163 +/* cmd, param, offset, width, type, arg_name */
15164 +#define DPDCEI_RSP_GET_IRQ_ENABLE(cmd, enable_state) \
15165 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state)
15167 +/* cmd, param, offset, width, type, arg_name */
15168 +#define DPDCEI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
15170 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
15171 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15174 +/* cmd, param, offset, width, type, arg_name */
15175 +#define DPDCEI_CMD_GET_IRQ_MASK(cmd, irq_index) \
15176 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15178 +/* cmd, param, offset, width, type, arg_name */
15179 +#define DPDCEI_RSP_GET_IRQ_MASK(cmd, mask) \
15180 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
15182 +/* cmd, param, offset, width, type, arg_name */
15183 +#define DPDCEI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
15185 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
15186 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
15189 +/* cmd, param, offset, width, type, arg_name */
15190 +#define DPDCEI_RSP_GET_IRQ_STATUS(cmd, status) \
15191 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
15193 +/* cmd, param, offset, width, type, arg_name */
15194 +#define DPDCEI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
15196 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
15197 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15200 +/* cmd, param, offset, width, type, arg_name */
15201 +#define DPDCEI_RSP_GET_ATTR(cmd, attr) \
15203 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id); \
15204 + MC_RSP_OP(cmd, 0, 32, 8, enum dpdcei_engine, attr->engine); \
15205 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
15206 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
15209 +/* cmd, param, offset, width, type, arg_name */
15210 +#define DPDCEI_CMD_SET_RX_QUEUE(cmd, cfg) \
15212 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
15213 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority); \
15214 + MC_CMD_OP(cmd, 0, 48, 4, enum dpdcei_dest, cfg->dest_cfg.dest_type); \
15215 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
15216 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
15219 +/* cmd, param, offset, width, type, arg_name */
15220 +#define DPDCEI_RSP_GET_RX_QUEUE(cmd, attr) \
15222 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\
15223 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
15224 + MC_RSP_OP(cmd, 0, 48, 4, enum dpdcei_dest, attr->dest_cfg.dest_type);\
15225 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx);\
15226 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\
15229 +/* cmd, param, offset, width, type, arg_name */
15230 +#define DPDCEI_RSP_GET_TX_QUEUE(cmd, attr) \
15231 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, attr->fqid)
15233 +#endif /* _FSL_DPDCEI_CMD_H */
15234 diff --git a/drivers/net/dpaa2/mc/fsl_dpdmai.h b/drivers/net/dpaa2/mc/fsl_dpdmai.h
15235 new file mode 100644
15236 index 0000000..e931ce1
15238 +++ b/drivers/net/dpaa2/mc/fsl_dpdmai.h
15240 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
15242 + * Redistribution and use in source and binary forms, with or without
15243 + * modification, are permitted provided that the following conditions are met:
15244 + * * Redistributions of source code must retain the above copyright
15245 + * notice, this list of conditions and the following disclaimer.
15246 + * * Redistributions in binary form must reproduce the above copyright
15247 + * notice, this list of conditions and the following disclaimer in the
15248 + * documentation and/or other materials provided with the distribution.
15249 + * * Neither the name of the above-listed copyright holders nor the
15250 + * names of any contributors may be used to endorse or promote products
15251 + * derived from this software without specific prior written permission.
15254 + * ALTERNATIVELY, this software may be distributed under the terms of the
15255 + * GNU General Public License ("GPL") as published by the Free Software
15256 + * Foundation, either version 2 of that License or (at your option) any
15259 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15260 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15261 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15262 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
15263 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
15264 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15265 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
15266 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
15267 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
15268 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
15269 + * POSSIBILITY OF SUCH DAMAGE.
15271 +#ifndef __FSL_DPDMAI_H
15272 +#define __FSL_DPDMAI_H
15276 +/* Data Path DMA Interface API
15277 + * Contains initialization APIs and runtime control APIs for DPDMAI
15280 +/* General DPDMAI macros */
15283 + * Maximum number of Tx/Rx priorities per DPDMAI object
15285 +#define DPDMAI_PRIO_NUM 2
15288 + * All queues considered; see dpdmai_set_rx_queue()
15290 +#define DPDMAI_ALL_QUEUES (uint8_t)(-1)
15293 + * dpdmai_open() - Open a control session for the specified object
15294 + * @mc_io: Pointer to MC portal's I/O object
15295 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15296 + * @dpdmai_id: DPDMAI unique ID
15297 + * @token: Returned token; use in subsequent API calls
15299 + * This function can be used to open a control session for an
15300 + * already created object; an object may have been declared in
15301 + * the DPL or by calling the dpdmai_create() function.
15302 + * This function returns a unique authentication token,
15303 + * associated with the specific object ID and the specific MC
15304 + * portal; this token must be used in all subsequent commands for
15305 + * this specific object.
15307 + * Return: '0' on Success; Error code otherwise.
15309 +int dpdmai_open(struct fsl_mc_io *mc_io,
15310 + uint32_t cmd_flags,
15312 + uint16_t *token);
15315 + * dpdmai_close() - Close the control session of the object
15316 + * @mc_io: Pointer to MC portal's I/O object
15317 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15318 + * @token: Token of DPDMAI object
15320 + * After this function is called, no further operations are
15321 + * allowed on the object without opening a new control session.
15323 + * Return: '0' on Success; Error code otherwise.
15325 +int dpdmai_close(struct fsl_mc_io *mc_io,
15326 + uint32_t cmd_flags,
15330 + * struct dpdmai_cfg - Structure representing DPDMAI configuration
15331 + * @priorities: Priorities for the DMA hardware processing; valid priorities are
15332 + * configured with values 1-8; the entry following last valid entry
15333 + * should be configured with 0
15335 +struct dpdmai_cfg {
15336 + uint8_t priorities[DPDMAI_PRIO_NUM];
15340 + * dpdmai_create() - Create the DPDMAI object
15341 + * @mc_io: Pointer to MC portal's I/O object
15342 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15343 + * @cfg: Configuration structure
15344 + * @token: Returned token; use in subsequent API calls
15346 + * Create the DPDMAI object, allocate required resources and
15347 + * perform required initialization.
15349 + * The object can be created either by declaring it in the
15350 + * DPL file, or by calling this function.
15352 + * This function returns a unique authentication token,
15353 + * associated with the specific object ID and the specific MC
15354 + * portal; this token must be used in all subsequent calls to
15355 + * this specific object. For objects that are created using the
15356 + * DPL file, call dpdmai_open() function to get an authentication
15359 + * Return: '0' on Success; Error code otherwise.
15361 +int dpdmai_create(struct fsl_mc_io *mc_io,
15362 + uint32_t cmd_flags,
15363 + const struct dpdmai_cfg *cfg,
15364 + uint16_t *token);
15367 + * dpdmai_destroy() - Destroy the DPDMAI object and release all its resources.
15368 + * @mc_io: Pointer to MC portal's I/O object
15369 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15370 + * @token: Token of DPDMAI object
15372 + * Return: '0' on Success; error code otherwise.
15374 +int dpdmai_destroy(struct fsl_mc_io *mc_io,
15375 + uint32_t cmd_flags,
15379 + * dpdmai_enable() - Enable the DPDMAI, allow sending and receiving frames.
15380 + * @mc_io: Pointer to MC portal's I/O object
15381 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15382 + * @token: Token of DPDMAI object
15384 + * Return: '0' on Success; Error code otherwise.
15386 +int dpdmai_enable(struct fsl_mc_io *mc_io,
15387 + uint32_t cmd_flags,
15391 + * dpdmai_disable() - Disable the DPDMAI, stop sending and receiving frames.
15392 + * @mc_io: Pointer to MC portal's I/O object
15393 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15394 + * @token: Token of DPDMAI object
15396 + * Return: '0' on Success; Error code otherwise.
15398 +int dpdmai_disable(struct fsl_mc_io *mc_io,
15399 + uint32_t cmd_flags,
15403 + * dpdmai_is_enabled() - Check if the DPDMAI is enabled.
15404 + * @mc_io: Pointer to MC portal's I/O object
15405 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15406 + * @token: Token of DPDMAI object
15407 + * @en: Returns '1' if object is enabled; '0' otherwise
15409 + * Return: '0' on Success; Error code otherwise.
15411 +int dpdmai_is_enabled(struct fsl_mc_io *mc_io,
15412 + uint32_t cmd_flags,
15417 + * dpdmai_reset() - Reset the DPDMAI, returns the object to initial state.
15418 + * @mc_io: Pointer to MC portal's I/O object
15419 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15420 + * @token: Token of DPDMAI object
15422 + * Return: '0' on Success; Error code otherwise.
15424 +int dpdmai_reset(struct fsl_mc_io *mc_io,
15425 + uint32_t cmd_flags,
15429 + * struct dpdmai_irq_cfg - IRQ configuration
15430 + * @addr: Address that must be written to signal a message-based interrupt
15431 + * @val: Value to write into irq_addr address
15432 + * @irq_num: A user defined number associated with this IRQ
15434 +struct dpdmai_irq_cfg {
15441 + * dpdmai_set_irq() - Set IRQ information for the DPDMAI to trigger an interrupt.
15442 + * @mc_io: Pointer to MC portal's I/O object
15443 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15444 + * @token: Token of DPDMAI object
15445 + * @irq_index: Identifies the interrupt index to configure
15446 + * @irq_cfg: IRQ configuration
15448 + * Return: '0' on Success; Error code otherwise.
15450 +int dpdmai_set_irq(struct fsl_mc_io *mc_io,
15451 + uint32_t cmd_flags,
15453 + uint8_t irq_index,
15454 + struct dpdmai_irq_cfg *irq_cfg);
15457 + * dpdmai_get_irq() - Get IRQ information from the DPDMAI
15459 + * @mc_io: Pointer to MC portal's I/O object
15460 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15461 + * @token: Token of DPDMAI object
15462 + * @irq_index: The interrupt index to configure
15463 + * @type: Interrupt type: 0 represents message interrupt
15464 + * type (both irq_addr and irq_val are valid)
15465 + * @irq_cfg: IRQ attributes
15467 + * Return: '0' on Success; Error code otherwise.
15469 +int dpdmai_get_irq(struct fsl_mc_io *mc_io,
15470 + uint32_t cmd_flags,
15472 + uint8_t irq_index,
15474 + struct dpdmai_irq_cfg *irq_cfg);
15477 + * dpdmai_set_irq_enable() - Set overall interrupt state.
15478 + * @mc_io: Pointer to MC portal's I/O object
15479 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15480 + * @token: Token of DPDMAI object
15481 + * @irq_index: The interrupt index to configure
15482 + * @en: Interrupt state - enable = 1, disable = 0
15484 + * Allows GPP software to control when interrupts are generated.
15485 + * Each interrupt can have up to 32 causes. The enable/disable control's the
15486 + * overall interrupt state. if the interrupt is disabled no causes will cause
15489 + * Return: '0' on Success; Error code otherwise.
15491 +int dpdmai_set_irq_enable(struct fsl_mc_io *mc_io,
15492 + uint32_t cmd_flags,
15494 + uint8_t irq_index,
15498 + * dpdmai_get_irq_enable() - Get overall interrupt state
15499 + * @mc_io: Pointer to MC portal's I/O object
15500 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15501 + * @token: Token of DPDMAI object
15502 + * @irq_index: The interrupt index to configure
15503 + * @en: Returned Interrupt state - enable = 1, disable = 0
15505 + * Return: '0' on Success; Error code otherwise.
15507 +int dpdmai_get_irq_enable(struct fsl_mc_io *mc_io,
15508 + uint32_t cmd_flags,
15510 + uint8_t irq_index,
15514 + * dpdmai_set_irq_mask() - Set interrupt mask.
15515 + * @mc_io: Pointer to MC portal's I/O object
15516 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15517 + * @token: Token of DPDMAI object
15518 + * @irq_index: The interrupt index to configure
15519 + * @mask: event mask to trigger interrupt;
15521 + * 0 = ignore event
15522 + * 1 = consider event for asserting IRQ
15524 + * Every interrupt can have up to 32 causes and the interrupt model supports
15525 + * masking/unmasking each cause independently
15527 + * Return: '0' on Success; Error code otherwise.
15529 +int dpdmai_set_irq_mask(struct fsl_mc_io *mc_io,
15530 + uint32_t cmd_flags,
15532 + uint8_t irq_index,
15536 + * dpdmai_get_irq_mask() - Get interrupt mask.
15537 + * @mc_io: Pointer to MC portal's I/O object
15538 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15539 + * @token: Token of DPDMAI object
15540 + * @irq_index: The interrupt index to configure
15541 + * @mask: Returned event mask to trigger interrupt
15543 + * Every interrupt can have up to 32 causes and the interrupt model supports
15544 + * masking/unmasking each cause independently
15546 + * Return: '0' on Success; Error code otherwise.
15548 +int dpdmai_get_irq_mask(struct fsl_mc_io *mc_io,
15549 + uint32_t cmd_flags,
15551 + uint8_t irq_index,
15555 + * dpdmai_get_irq_status() - Get the current status of any pending interrupts
15556 + * @mc_io: Pointer to MC portal's I/O object
15557 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15558 + * @token: Token of DPDMAI object
15559 + * @irq_index: The interrupt index to configure
15560 + * @status: Returned interrupts status - one bit per cause:
15561 + * 0 = no interrupt pending
15562 + * 1 = interrupt pending
15564 + * Return: '0' on Success; Error code otherwise.
15566 +int dpdmai_get_irq_status(struct fsl_mc_io *mc_io,
15567 + uint32_t cmd_flags,
15569 + uint8_t irq_index,
15570 + uint32_t *status);
15573 + * dpdmai_clear_irq_status() - Clear a pending interrupt's status
15574 + * @mc_io: Pointer to MC portal's I/O object
15575 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15576 + * @token: Token of DPDMAI object
15577 + * @irq_index: The interrupt index to configure
15578 + * @status: bits to clear (W1C) - one bit per cause:
15579 + * 0 = don't change
15580 + * 1 = clear status bit
15582 + * Return: '0' on Success; Error code otherwise.
15584 +int dpdmai_clear_irq_status(struct fsl_mc_io *mc_io,
15585 + uint32_t cmd_flags,
15587 + uint8_t irq_index,
15588 + uint32_t status);
15591 + * struct dpdmai_attr - Structure representing DPDMAI attributes
15592 + * @id: DPDMAI object ID
15593 + * @version: DPDMAI version
15594 + * @num_of_priorities: number of priorities
15596 +struct dpdmai_attr {
15599 + * struct version - DPDMAI version
15600 + * @major: DPDMAI major version
15601 + * @minor: DPDMAI minor version
15607 + uint8_t num_of_priorities;
15611 + * dpdmai_get_attributes() - Retrieve DPDMAI attributes.
15612 + * @mc_io: Pointer to MC portal's I/O object
15613 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15614 + * @token: Token of DPDMAI object
15615 + * @attr: Returned object's attributes
15617 + * Return: '0' on Success; Error code otherwise.
15619 +int dpdmai_get_attributes(struct fsl_mc_io *mc_io,
15620 + uint32_t cmd_flags,
15622 + struct dpdmai_attr *attr);
15625 + * enum dpdmai_dest - DPDMAI destination types
15626 + * @DPDMAI_DEST_NONE: Unassigned destination; The queue is set in parked mode
15627 + * and does not generate FQDAN notifications; user is expected to dequeue
15628 + * from the queue based on polling or other user-defined method
15629 + * @DPDMAI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
15630 + * notifications to the specified DPIO; user is expected to dequeue
15631 + * from the queue only after notification is received
15632 + * @DPDMAI_DEST_DPCON: The queue is set in schedule mode and does not generate
15633 + * FQDAN notifications, but is connected to the specified DPCON object;
15634 + * user is expected to dequeue from the DPCON channel
15636 +enum dpdmai_dest {
15637 + DPDMAI_DEST_NONE = 0,
15638 + DPDMAI_DEST_DPIO = 1,
15639 + DPDMAI_DEST_DPCON = 2
15643 + * struct dpdmai_dest_cfg - Structure representing DPDMAI destination parameters
15644 + * @dest_type: Destination type
15645 + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
15646 + * @priority: Priority selection within the DPIO or DPCON channel; valid values
15647 + * are 0-1 or 0-7, depending on the number of priorities in that
15648 + * channel; not relevant for 'DPDMAI_DEST_NONE' option
15650 +struct dpdmai_dest_cfg {
15651 + enum dpdmai_dest dest_type;
15653 + uint8_t priority;
15656 +/* DPDMAI queue modification options */
15659 + * Select to modify the user's context associated with the queue
15661 +#define DPDMAI_QUEUE_OPT_USER_CTX 0x00000001
15664 + * Select to modify the queue's destination
15666 +#define DPDMAI_QUEUE_OPT_DEST 0x00000002
15669 + * struct dpdmai_rx_queue_cfg - DPDMAI RX queue configuration
15670 + * @options: Flags representing the suggested modifications to the queue;
15671 + * Use any combination of 'DPDMAI_QUEUE_OPT_<X>' flags
15672 + * @user_ctx: User context value provided in the frame descriptor of each
15673 + * dequeued frame;
15674 + * valid only if 'DPDMAI_QUEUE_OPT_USER_CTX' is contained in 'options'
15675 + * @dest_cfg: Queue destination parameters;
15676 + * valid only if 'DPDMAI_QUEUE_OPT_DEST' is contained in 'options'
15678 +struct dpdmai_rx_queue_cfg {
15679 + uint32_t options;
15680 + uint64_t user_ctx;
15681 + struct dpdmai_dest_cfg dest_cfg;
15686 + * dpdmai_set_rx_queue() - Set Rx queue configuration
15687 + * @mc_io: Pointer to MC portal's I/O object
15688 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15689 + * @token: Token of DPDMAI object
15690 + * @priority: Select the queue relative to number of
15691 + * priorities configured at DPDMAI creation; use
15692 + * DPDMAI_ALL_QUEUES to configure all Rx queues
15694 + * @cfg: Rx queue configuration
15696 + * Return: '0' on Success; Error code otherwise.
15698 +int dpdmai_set_rx_queue(struct fsl_mc_io *mc_io,
15699 + uint32_t cmd_flags,
15701 + uint8_t priority,
15702 + const struct dpdmai_rx_queue_cfg *cfg);
15705 + * struct dpdmai_rx_queue_attr - Structure representing attributes of Rx queues
15706 + * @user_ctx: User context value provided in the frame descriptor of each
15708 + * @dest_cfg: Queue destination configuration
15709 + * @fqid: Virtual FQID value to be used for dequeue operations
15711 +struct dpdmai_rx_queue_attr {
15712 + uint64_t user_ctx;
15713 + struct dpdmai_dest_cfg dest_cfg;
15718 + * dpdmai_get_rx_queue() - Retrieve Rx queue attributes.
15719 + * @mc_io: Pointer to MC portal's I/O object
15720 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15721 + * @token: Token of DPDMAI object
15722 + * @priority: Select the queue relative to number of
15723 + * priorities configured at DPDMAI creation
15724 + * @attr: Returned Rx queue attributes
15726 + * Return: '0' on Success; Error code otherwise.
15728 +int dpdmai_get_rx_queue(struct fsl_mc_io *mc_io,
15729 + uint32_t cmd_flags,
15731 + uint8_t priority,
15732 + struct dpdmai_rx_queue_attr *attr);
15735 + * struct dpdmai_tx_queue_attr - Structure representing attributes of Tx queues
15736 + * @fqid: Virtual FQID to be used for sending frames to DMA hardware
15739 +struct dpdmai_tx_queue_attr {
15744 + * dpdmai_get_tx_queue() - Retrieve Tx queue attributes.
15745 + * @mc_io: Pointer to MC portal's I/O object
15746 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
15747 + * @token: Token of DPDMAI object
15748 + * @priority: Select the queue relative to number of
15749 + * priorities configured at DPDMAI creation
15750 + * @attr: Returned Tx queue attributes
15752 + * Return: '0' on Success; Error code otherwise.
15754 +int dpdmai_get_tx_queue(struct fsl_mc_io *mc_io,
15755 + uint32_t cmd_flags,
15757 + uint8_t priority,
15758 + struct dpdmai_tx_queue_attr *attr);
15760 +#endif /* __FSL_DPDMAI_H */
15761 diff --git a/drivers/net/dpaa2/mc/fsl_dpdmai_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmai_cmd.h
15762 new file mode 100644
15763 index 0000000..7c4a31a
15765 +++ b/drivers/net/dpaa2/mc/fsl_dpdmai_cmd.h
15767 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
15769 + * Redistribution and use in source and binary forms, with or without
15770 + * modification, are permitted provided that the following conditions are met:
15771 + * * Redistributions of source code must retain the above copyright
15772 + * notice, this list of conditions and the following disclaimer.
15773 + * * Redistributions in binary form must reproduce the above copyright
15774 + * notice, this list of conditions and the following disclaimer in the
15775 + * documentation and/or other materials provided with the distribution.
15776 + * * Neither the name of the above-listed copyright holders nor the
15777 + * names of any contributors may be used to endorse or promote products
15778 + * derived from this software without specific prior written permission.
15781 + * ALTERNATIVELY, this software may be distributed under the terms of the
15782 + * GNU General Public License ("GPL") as published by the Free Software
15783 + * Foundation, either version 2 of that License or (at your option) any
15786 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15787 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15788 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15789 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
15790 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
15791 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15792 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
15793 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
15794 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
15795 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
15796 + * POSSIBILITY OF SUCH DAMAGE.
15798 +#ifndef _FSL_DPDMAI_CMD_H
15799 +#define _FSL_DPDMAI_CMD_H
15801 +/* DPDMAI Version */
15802 +#define DPDMAI_VER_MAJOR 2
15803 +#define DPDMAI_VER_MINOR 2
15806 +#define DPDMAI_CMDID_CLOSE 0x800
15807 +#define DPDMAI_CMDID_OPEN 0x80E
15808 +#define DPDMAI_CMDID_CREATE 0x90E
15809 +#define DPDMAI_CMDID_DESTROY 0x900
15811 +#define DPDMAI_CMDID_ENABLE 0x002
15812 +#define DPDMAI_CMDID_DISABLE 0x003
15813 +#define DPDMAI_CMDID_GET_ATTR 0x004
15814 +#define DPDMAI_CMDID_RESET 0x005
15815 +#define DPDMAI_CMDID_IS_ENABLED 0x006
15817 +#define DPDMAI_CMDID_SET_IRQ 0x010
15818 +#define DPDMAI_CMDID_GET_IRQ 0x011
15819 +#define DPDMAI_CMDID_SET_IRQ_ENABLE 0x012
15820 +#define DPDMAI_CMDID_GET_IRQ_ENABLE 0x013
15821 +#define DPDMAI_CMDID_SET_IRQ_MASK 0x014
15822 +#define DPDMAI_CMDID_GET_IRQ_MASK 0x015
15823 +#define DPDMAI_CMDID_GET_IRQ_STATUS 0x016
15824 +#define DPDMAI_CMDID_CLEAR_IRQ_STATUS 0x017
15826 +#define DPDMAI_CMDID_SET_RX_QUEUE 0x1A0
15827 +#define DPDMAI_CMDID_GET_RX_QUEUE 0x1A1
15828 +#define DPDMAI_CMDID_GET_TX_QUEUE 0x1A2
15830 +/* cmd, param, offset, width, type, arg_name */
15831 +#define DPDMAI_CMD_OPEN(cmd, dpdmai_id) \
15832 + MC_CMD_OP(cmd, 0, 0, 32, int, dpdmai_id)
15834 +/* cmd, param, offset, width, type, arg_name */
15835 +#define DPDMAI_CMD_CREATE(cmd, cfg) \
15837 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->priorities[0]);\
15838 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->priorities[1]);\
15841 +/* cmd, param, offset, width, type, arg_name */
15842 +#define DPDMAI_RSP_IS_ENABLED(cmd, en) \
15843 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
15845 +/* cmd, param, offset, width, type, arg_name */
15846 +#define DPDMAI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
15848 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
15849 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
15850 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
15851 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
15854 +/* cmd, param, offset, width, type, arg_name */
15855 +#define DPDMAI_CMD_GET_IRQ(cmd, irq_index) \
15856 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15858 +/* cmd, param, offset, width, type, arg_name */
15859 +#define DPDMAI_RSP_GET_IRQ(cmd, type, irq_cfg) \
15861 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
15862 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
15863 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
15864 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
15867 +/* cmd, param, offset, width, type, arg_name */
15868 +#define DPDMAI_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \
15870 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \
15871 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15874 +/* cmd, param, offset, width, type, arg_name */
15875 +#define DPDMAI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
15876 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15878 +/* cmd, param, offset, width, type, arg_name */
15879 +#define DPDMAI_RSP_GET_IRQ_ENABLE(cmd, enable_state) \
15880 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state)
15882 +/* cmd, param, offset, width, type, arg_name */
15883 +#define DPDMAI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
15885 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
15886 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15889 +/* cmd, param, offset, width, type, arg_name */
15890 +#define DPDMAI_CMD_GET_IRQ_MASK(cmd, irq_index) \
15891 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
15893 +/* cmd, param, offset, width, type, arg_name */
15894 +#define DPDMAI_RSP_GET_IRQ_MASK(cmd, mask) \
15895 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
15897 +/* cmd, param, offset, width, type, arg_name */
15898 +#define DPDMAI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
15900 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
15901 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
15904 +/* cmd, param, offset, width, type, arg_name */
15905 +#define DPDMAI_RSP_GET_IRQ_STATUS(cmd, status) \
15906 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
15908 +/* cmd, param, offset, width, type, arg_name */
15909 +#define DPDMAI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
15911 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
15912 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
15915 +/* cmd, param, offset, width, type, arg_name */
15916 +#define DPDMAI_RSP_GET_ATTR(cmd, attr) \
15918 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id); \
15919 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->num_of_priorities); \
15920 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
15921 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
15924 +/* cmd, param, offset, width, type, arg_name */
15925 +#define DPDMAI_CMD_SET_RX_QUEUE(cmd, priority, cfg) \
15927 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
15928 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority); \
15929 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority); \
15930 + MC_CMD_OP(cmd, 0, 48, 4, enum dpdmai_dest, cfg->dest_cfg.dest_type); \
15931 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
15932 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
15935 +/* cmd, param, offset, width, type, arg_name */
15936 +#define DPDMAI_CMD_GET_RX_QUEUE(cmd, priority) \
15937 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority)
15939 +/* cmd, param, offset, width, type, arg_name */
15940 +#define DPDMAI_RSP_GET_RX_QUEUE(cmd, attr) \
15942 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\
15943 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
15944 + MC_RSP_OP(cmd, 0, 48, 4, enum dpdmai_dest, attr->dest_cfg.dest_type);\
15945 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx);\
15946 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\
15949 +/* cmd, param, offset, width, type, arg_name */
15950 +#define DPDMAI_CMD_GET_TX_QUEUE(cmd, priority) \
15951 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, priority)
15953 +/* cmd, param, offset, width, type, arg_name */
15954 +#define DPDMAI_RSP_GET_TX_QUEUE(cmd, attr) \
15955 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->fqid)
15957 +#endif /* _FSL_DPDMAI_CMD_H */
15958 diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
15959 new file mode 100644
15960 index 0000000..455a042
15962 +++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
15964 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
15966 + * Redistribution and use in source and binary forms, with or without
15967 + * modification, are permitted provided that the following conditions are met:
15968 + * * Redistributions of source code must retain the above copyright
15969 + * notice, this list of conditions and the following disclaimer.
15970 + * * Redistributions in binary form must reproduce the above copyright
15971 + * notice, this list of conditions and the following disclaimer in the
15972 + * documentation and/or other materials provided with the distribution.
15973 + * * Neither the name of the above-listed copyright holders nor the
15974 + * names of any contributors may be used to endorse or promote products
15975 + * derived from this software without specific prior written permission.
15978 + * ALTERNATIVELY, this software may be distributed under the terms of the
15979 + * GNU General Public License ("GPL") as published by the Free Software
15980 + * Foundation, either version 2 of that License or (at your option) any
15983 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15984 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15985 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15986 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
15987 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
15988 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
15989 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
15990 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
15991 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
15992 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
15993 + * POSSIBILITY OF SUCH DAMAGE.
15995 +#ifndef __FSL_DPDMUX_H
15996 +#define __FSL_DPDMUX_H
15998 +#include <fsl_net.h>
16002 +/* Data Path Demux API
16003 + * Contains API for handling DPDMUX topology and functionality
16007 + * dpdmux_open() - Open a control session for the specified object
16008 + * @mc_io: Pointer to MC portal's I/O object
16009 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16010 + * @dpdmux_id: DPDMUX unique ID
16011 + * @token: Returned token; use in subsequent API calls
16013 + * This function can be used to open a control session for an
16014 + * already created object; an object may have been declared in
16015 + * the DPL or by calling the dpdmux_create() function.
16016 + * This function returns a unique authentication token,
16017 + * associated with the specific object ID and the specific MC
16018 + * portal; this token must be used in all subsequent commands for
16019 + * this specific object.
16021 + * Return: '0' on Success; Error code otherwise.
16023 +int dpdmux_open(struct fsl_mc_io *mc_io,
16024 + uint32_t cmd_flags,
16026 + uint16_t *token);
16029 + * dpdmux_close() - Close the control session of the object
16030 + * @mc_io: Pointer to MC portal's I/O object
16031 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16032 + * @token: Token of DPDMUX object
16034 + * After this function is called, no further operations are
16035 + * allowed on the object without opening a new control session.
16037 + * Return: '0' on Success; Error code otherwise.
16039 +int dpdmux_close(struct fsl_mc_io *mc_io,
16040 + uint32_t cmd_flags,
16044 + * DPDMUX general options
16048 + * Enable bridging between internal interfaces
16050 +#define DPDMUX_OPT_BRIDGE_EN 0x0000000000000002ULL
16052 +#define DPDMUX_IRQ_INDEX_IF 0x0000
16053 +#define DPDMUX_IRQ_INDEX 0x0001
16056 + * IRQ event - Indicates that the link state changed
16058 +#define DPDMUX_IRQ_EVENT_LINK_CHANGED 0x0001
16061 + * enum dpdmux_manip - DPDMUX manipulation operations
16062 + * @DPDMUX_MANIP_NONE: No manipulation on frames
16063 + * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
16065 +enum dpdmux_manip {
16066 + DPDMUX_MANIP_NONE = 0x0,
16067 + DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
16071 + * enum dpdmux_method - DPDMUX method options
16072 + * @DPDMUX_METHOD_NONE: no DPDMUX method
16073 + * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
16074 + * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
16075 + * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
16076 + * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
16078 +enum dpdmux_method {
16079 + DPDMUX_METHOD_NONE = 0x0,
16080 + DPDMUX_METHOD_C_VLAN_MAC = 0x1,
16081 + DPDMUX_METHOD_MAC = 0x2,
16082 + DPDMUX_METHOD_C_VLAN = 0x3,
16083 + DPDMUX_METHOD_S_VLAN = 0x4
16087 + * struct dpdmux_cfg - DPDMUX configuration parameters
16088 + * @method: Defines the operation method for the DPDMUX address table
16089 + * @manip: Required manipulation operation
16090 + * @num_ifs: Number of interfaces (excluding the uplink interface)
16091 + * @adv: Advanced parameters; default is all zeros;
16092 + * use this structure to change default settings
16094 +struct dpdmux_cfg {
16095 + enum dpdmux_method method;
16096 + enum dpdmux_manip manip;
16097 + uint16_t num_ifs;
16099 + * struct adv - Advanced parameters
16100 + * @options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags
16101 + * @max_dmat_entries: Maximum entries in DPDMUX address table
16102 + * 0 - indicates default: 64 entries per interface.
16103 + * @max_mc_groups: Number of multicast groups in DPDMUX table
16104 + * 0 - indicates default: 32 multicast groups
16105 + * @max_vlan_ids: max vlan ids allowed in the system -
16106 + * relevant only case of working in mac+vlan method.
16107 + * 0 - indicates default 16 vlan ids.
16110 + uint64_t options;
16111 + uint16_t max_dmat_entries;
16112 + uint16_t max_mc_groups;
16113 + uint16_t max_vlan_ids;
16118 + * dpdmux_create() - Create the DPDMUX object
16119 + * @mc_io: Pointer to MC portal's I/O object
16120 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16121 + * @cfg: Configuration structure
16122 + * @token: Returned token; use in subsequent API calls
16124 + * Create the DPDMUX object, allocate required resources and
16125 + * perform required initialization.
16127 + * The object can be created either by declaring it in the
16128 + * DPL file, or by calling this function.
16130 + * This function returns a unique authentication token,
16131 + * associated with the specific object ID and the specific MC
16132 + * portal; this token must be used in all subsequent calls to
16133 + * this specific object. For objects that are created using the
16134 + * DPL file, call dpdmux_open() function to get an authentication
16137 + * Return: '0' on Success; Error code otherwise.
16139 +int dpdmux_create(struct fsl_mc_io *mc_io,
16140 + uint32_t cmd_flags,
16141 + const struct dpdmux_cfg *cfg,
16142 + uint16_t *token);
16145 + * dpdmux_destroy() - Destroy the DPDMUX object and release all its resources.
16146 + * @mc_io: Pointer to MC portal's I/O object
16147 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16148 + * @token: Token of DPDMUX object
16150 + * Return: '0' on Success; error code otherwise.
16152 +int dpdmux_destroy(struct fsl_mc_io *mc_io,
16153 + uint32_t cmd_flags,
16157 + * dpdmux_enable() - Enable DPDMUX functionality
16158 + * @mc_io: Pointer to MC portal's I/O object
16159 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16160 + * @token: Token of DPDMUX object
16162 + * Return: '0' on Success; Error code otherwise.
16164 +int dpdmux_enable(struct fsl_mc_io *mc_io,
16165 + uint32_t cmd_flags,
16169 + * dpdmux_disable() - Disable DPDMUX functionality
16170 + * @mc_io: Pointer to MC portal's I/O object
16171 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16172 + * @token: Token of DPDMUX object
16174 + * Return: '0' on Success; Error code otherwise.
16176 +int dpdmux_disable(struct fsl_mc_io *mc_io,
16177 + uint32_t cmd_flags,
16181 + * dpdmux_is_enabled() - Check if the DPDMUX is enabled.
16182 + * @mc_io: Pointer to MC portal's I/O object
16183 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16184 + * @token: Token of DPDMUX object
16185 + * @en: Returns '1' if object is enabled; '0' otherwise
16187 + * Return: '0' on Success; Error code otherwise.
16189 +int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
16190 + uint32_t cmd_flags,
16195 + * dpdmux_reset() - Reset the DPDMUX, returns the object to initial state.
16196 + * @mc_io: Pointer to MC portal's I/O object
16197 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16198 + * @token: Token of DPDMUX object
16200 + * Return: '0' on Success; Error code otherwise.
16202 +int dpdmux_reset(struct fsl_mc_io *mc_io,
16203 + uint32_t cmd_flags,
16207 + * struct dpdmux_irq_cfg - IRQ configuration
16208 + * @addr: Address that must be written to signal a message-based interrupt
16209 + * @val: Value to write into irq_addr address
16210 + * @irq_num: A user defined number associated with this IRQ
16212 +struct dpdmux_irq_cfg {
16219 + * dpdmux_set_irq() - Set IRQ information for the DPDMUX to trigger an interrupt.
16220 + * @mc_io: Pointer to MC portal's I/O object
16221 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16222 + * @token: Token of DPDMUX object
16223 + * @irq_index: Identifies the interrupt index to configure
16224 + * @irq_cfg: IRQ configuration
16226 + * Return: '0' on Success; Error code otherwise.
16228 +int dpdmux_set_irq(struct fsl_mc_io *mc_io,
16229 + uint32_t cmd_flags,
16231 + uint8_t irq_index,
16232 + struct dpdmux_irq_cfg *irq_cfg);
16235 + * dpdmux_get_irq() - Get IRQ information from the DPDMUX.
16236 + * @mc_io: Pointer to MC portal's I/O object
16237 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16238 + * @token: Token of DPDMUX object
16239 + * @irq_index: The interrupt index to configure
16240 + * @type: Interrupt type: 0 represents message interrupt
16241 + * type (both irq_addr and irq_val are valid)
16242 + * @irq_cfg: IRQ attributes
16244 + * Return: '0' on Success; Error code otherwise.
16246 +int dpdmux_get_irq(struct fsl_mc_io *mc_io,
16247 + uint32_t cmd_flags,
16249 + uint8_t irq_index,
16251 + struct dpdmux_irq_cfg *irq_cfg);
16254 + * dpdmux_set_irq_enable() - Set overall interrupt state.
16255 + * @mc_io: Pointer to MC portal's I/O object
16256 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16257 + * @token: Token of DPDMUX object
16258 + * @irq_index: The interrupt index to configure
16259 + * @en: Interrupt state - enable = 1, disable = 0
16261 + * Allows GPP software to control when interrupts are generated.
16262 + * Each interrupt can have up to 32 causes. The enable/disable control's the
16263 + * overall interrupt state. if the interrupt is disabled no causes will cause
16266 + * Return: '0' on Success; Error code otherwise.
16268 +int dpdmux_set_irq_enable(struct fsl_mc_io *mc_io,
16269 + uint32_t cmd_flags,
16271 + uint8_t irq_index,
16275 + * dpdmux_get_irq_enable() - Get overall interrupt state.
16276 + * @mc_io: Pointer to MC portal's I/O object
16277 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16278 + * @token: Token of DPDMUX object
16279 + * @irq_index: The interrupt index to configure
16280 + * @en: Returned interrupt state - enable = 1, disable = 0
16282 + * Return: '0' on Success; Error code otherwise.
16284 +int dpdmux_get_irq_enable(struct fsl_mc_io *mc_io,
16285 + uint32_t cmd_flags,
16287 + uint8_t irq_index,
16291 + * dpdmux_set_irq_mask() - Set interrupt mask.
16292 + * @mc_io: Pointer to MC portal's I/O object
16293 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16294 + * @token: Token of DPDMUX object
16295 + * @irq_index: The interrupt index to configure
16296 + * @mask: event mask to trigger interrupt;
16298 + * 0 = ignore event
16299 + * 1 = consider event for asserting IRQ
16301 + * Every interrupt can have up to 32 causes and the interrupt model supports
16302 + * masking/unmasking each cause independently
16304 + * Return: '0' on Success; Error code otherwise.
16306 +int dpdmux_set_irq_mask(struct fsl_mc_io *mc_io,
16307 + uint32_t cmd_flags,
16309 + uint8_t irq_index,
16313 + * dpdmux_get_irq_mask() - Get interrupt mask.
16314 + * @mc_io: Pointer to MC portal's I/O object
16315 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16316 + * @token: Token of DPDMUX object
16317 + * @irq_index: The interrupt index to configure
16318 + * @mask: Returned event mask to trigger interrupt
16320 + * Every interrupt can have up to 32 causes and the interrupt model supports
16321 + * masking/unmasking each cause independently
16323 + * Return: '0' on Success; Error code otherwise.
16325 +int dpdmux_get_irq_mask(struct fsl_mc_io *mc_io,
16326 + uint32_t cmd_flags,
16328 + uint8_t irq_index,
16332 + * dpdmux_get_irq_status() - Get the current status of any pending interrupts.
16333 + * @mc_io: Pointer to MC portal's I/O object
16334 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16335 + * @token: Token of DPDMUX object
16336 + * @irq_index: The interrupt index to configure
16337 + * @status: Returned interrupts status - one bit per cause:
16338 + * 0 = no interrupt pending
16339 + * 1 = interrupt pending
16341 + * Return: '0' on Success; Error code otherwise.
16343 +int dpdmux_get_irq_status(struct fsl_mc_io *mc_io,
16344 + uint32_t cmd_flags,
16346 + uint8_t irq_index,
16347 + uint32_t *status);
16350 + * dpdmux_clear_irq_status() - Clear a pending interrupt's status
16351 + * @mc_io: Pointer to MC portal's I/O object
16352 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16353 + * @token: Token of DPDMUX object
16354 + * @irq_index: The interrupt index to configure
16355 + * @status: bits to clear (W1C) - one bit per cause:
16356 + * 0 = don't change
16357 + * 1 = clear status bit
16359 + * Return: '0' on Success; Error code otherwise.
16361 +int dpdmux_clear_irq_status(struct fsl_mc_io *mc_io,
16362 + uint32_t cmd_flags,
16364 + uint8_t irq_index,
16365 + uint32_t status);
16368 + * struct dpdmux_attr - Structure representing DPDMUX attributes
16369 + * @id: DPDMUX object ID
16370 + * @version: DPDMUX version
16371 + * @options: Configuration options (bitmap)
16372 + * @method: DPDMUX address table method
16373 + * @manip: DPDMUX manipulation type
16374 + * @num_ifs: Number of interfaces (excluding the uplink interface)
16375 + * @mem_size: DPDMUX frame storage memory size
16377 +struct dpdmux_attr {
16380 + * struct version - DPDMUX version
16381 + * @major: DPDMUX major version
16382 + * @minor: DPDMUX minor version
16388 + uint64_t options;
16389 + enum dpdmux_method method;
16390 + enum dpdmux_manip manip;
16391 + uint16_t num_ifs;
16392 + uint16_t mem_size;
16396 + * dpdmux_get_attributes() - Retrieve DPDMUX attributes
16397 + * @mc_io: Pointer to MC portal's I/O object
16398 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16399 + * @token: Token of DPDMUX object
16400 + * @attr: Returned object's attributes
16402 + * Return: '0' on Success; Error code otherwise.
16404 +int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
16405 + uint32_t cmd_flags,
16407 + struct dpdmux_attr *attr);
16410 + * dpdmux_ul_set_max_frame_length() - Set the maximum frame length in DPDMUX
16411 + * @mc_io: Pointer to MC portal's I/O object
16412 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16413 + * @token: Token of DPDMUX object
16414 + * @max_frame_length: The required maximum frame length
16416 + * Return: '0' on Success; Error code otherwise.
16418 +int dpdmux_ul_set_max_frame_length(struct fsl_mc_io *mc_io,
16419 + uint32_t cmd_flags,
16421 + uint16_t max_frame_length);
16424 + * enum dpdmux_counter_type - Counter types
16425 + * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
16426 + * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
16427 + * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
16428 + * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
16429 + * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
16430 + * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
16431 + * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
16432 + * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
16433 + * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
16434 + * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
16435 + * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
16437 +enum dpdmux_counter_type {
16438 + DPDMUX_CNT_ING_FRAME = 0x0,
16439 + DPDMUX_CNT_ING_BYTE = 0x1,
16440 + DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
16441 + DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
16442 + DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
16443 + DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
16444 + DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
16445 + DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
16446 + DPDMUX_CNT_EGR_FRAME = 0x8,
16447 + DPDMUX_CNT_EGR_BYTE = 0x9,
16448 + DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
16452 + * enum dpdmux_accepted_frames_type - DPDMUX frame types
16453 + * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
16454 + * priority-tagged frames
16455 + * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
16456 + * priority-tagged frames that are received on this
16458 + * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
16459 + * received on this interface are accepted
16461 +enum dpdmux_accepted_frames_type {
16462 + DPDMUX_ADMIT_ALL = 0,
16463 + DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
16464 + DPDMUX_ADMIT_ONLY_UNTAGGED = 2
16468 + * enum dpdmux_action - DPDMUX action for un-accepted frames
16469 + * @DPDMUX_ACTION_DROP: Drop un-accepted frames
16470 + * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
16471 + * control interface
16473 +enum dpdmux_action {
16474 + DPDMUX_ACTION_DROP = 0,
16475 + DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
16479 + * struct dpdmux_accepted_frames - Frame types configuration
16480 + * @type: Defines ingress accepted frames
16481 + * @unaccept_act: Defines action on frames not accepted
16483 +struct dpdmux_accepted_frames {
16484 + enum dpdmux_accepted_frames_type type;
16485 + enum dpdmux_action unaccept_act;
16489 + * dpdmux_if_set_accepted_frames() - Set the accepted frame types
16490 + * @mc_io: Pointer to MC portal's I/O object
16491 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16492 + * @token: Token of DPDMUX object
16493 + * @if_id: Interface ID (0 for uplink, or 1-num_ifs);
16494 + * @cfg: Frame types configuration
16496 + * if 'DPDMUX_ADMIT_ONLY_VLAN_TAGGED' is set - untagged frames or
16497 + * priority-tagged frames are discarded.
16498 + * if 'DPDMUX_ADMIT_ONLY_UNTAGGED' is set - untagged frames or
16499 + * priority-tagged frames are accepted.
16500 + * if 'DPDMUX_ADMIT_ALL' is set (default mode) - all VLAN tagged,
16501 + * untagged and priority-tagged frame are accepted;
16503 + * Return: '0' on Success; Error code otherwise.
16505 +int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
16506 + uint32_t cmd_flags,
16509 + const struct dpdmux_accepted_frames *cfg);
16512 + * struct dpdmux_if_attr - Structure representing frame types configuration
16513 + * @rate: Configured interface rate (in bits per second)
16514 + * @enabled: Indicates if interface is enabled
16515 + * @accept_frame_type: Indicates type of accepted frames for the interface
16517 +struct dpdmux_if_attr {
16520 + enum dpdmux_accepted_frames_type accept_frame_type;
16524 + * dpdmux_if_get_attributes() - Obtain DPDMUX interface attributes
16525 + * @mc_io: Pointer to MC portal's I/O object
16526 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16527 + * @token: Token of DPDMUX object
16528 + * @if_id: Interface ID (0 for uplink, or 1-num_ifs);
16529 + * @attr: Interface attributes
16531 + * Return: '0' on Success; Error code otherwise.
16533 +int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
16534 + uint32_t cmd_flags,
16537 + struct dpdmux_if_attr *attr);
16540 + * struct dpdmux_l2_rule - Structure representing L2 rule
16541 + * @mac_addr: MAC address
16542 + * @vlan_id: VLAN ID
16544 +struct dpdmux_l2_rule {
16545 + uint8_t mac_addr[6];
16546 + uint16_t vlan_id;
16550 + * dpdmux_if_remove_l2_rule() - Remove L2 rule from DPDMUX table
16551 + * @mc_io: Pointer to MC portal's I/O object
16552 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16553 + * @token: Token of DPDMUX object
16554 + * @if_id: Destination interface ID
16557 + * Function removes a L2 rule from DPDMUX table
16558 + * or adds an interface to an existing multicast address
16560 + * Return: '0' on Success; Error code otherwise.
16562 +int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
16563 + uint32_t cmd_flags,
16566 + const struct dpdmux_l2_rule *rule);
16569 + * dpdmux_if_add_l2_rule() - Add L2 rule into DPDMUX table
16570 + * @mc_io: Pointer to MC portal's I/O object
16571 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16572 + * @token: Token of DPDMUX object
16573 + * @if_id: Destination interface ID
16576 + * Function adds a L2 rule into DPDMUX table
16577 + * or adds an interface to an existing multicast address
16579 + * Return: '0' on Success; Error code otherwise.
16581 +int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
16582 + uint32_t cmd_flags,
16585 + const struct dpdmux_l2_rule *rule);
16588 +* dpdmux_if_get_counter() - Functions obtains specific counter of an interface
16589 +* @mc_io: Pointer to MC portal's I/O object
16590 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16591 +* @token: Token of DPDMUX object
16592 +* @if_id: Interface Id
16593 +* @counter_type: counter type
16594 +* @counter: Returned specific counter information
16596 +* Return: '0' on Success; Error code otherwise.
16598 +int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
16599 + uint32_t cmd_flags,
16602 + enum dpdmux_counter_type counter_type,
16603 + uint64_t *counter);
16606 +* dpdmux_ul_reset_counters() - Function resets the uplink counter
16607 +* @mc_io: Pointer to MC portal's I/O object
16608 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16609 +* @token: Token of DPDMUX object
16611 +* Return: '0' on Success; Error code otherwise.
16613 +int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
16614 + uint32_t cmd_flags,
16618 + * Enable auto-negotiation
16620 +#define DPDMUX_LINK_OPT_AUTONEG 0x0000000000000001ULL
16622 + * Enable half-duplex mode
16624 +#define DPDMUX_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
16626 + * Enable pause frames
16628 +#define DPDMUX_LINK_OPT_PAUSE 0x0000000000000004ULL
16630 + * Enable a-symmetric pause frames
16632 +#define DPDMUX_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
16635 + * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
16637 + * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
16639 +struct dpdmux_link_cfg {
16641 + uint64_t options;
16645 + * dpdmux_if_set_link_cfg() - set the link configuration.
16646 + * @mc_io: Pointer to MC portal's I/O object
16647 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16648 + * @token: Token of DPSW object
16649 + * @if_id: interface id
16650 + * @cfg: Link configuration
16652 + * Return: '0' on Success; Error code otherwise.
16654 +int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
16655 + uint32_t cmd_flags,
16658 + struct dpdmux_link_cfg *cfg);
16660 + * struct dpdmux_link_state - Structure representing DPDMUX link state
16662 + * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
16663 + * @up: 0 - down, 1 - up
16665 +struct dpdmux_link_state {
16667 + uint64_t options;
16672 + * dpdmux_if_get_link_state - Return the link state
16673 + * @mc_io: Pointer to MC portal's I/O object
16674 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
16675 + * @token: Token of DPSW object
16676 + * @if_id: interface id
16677 + * @state: link state
16679 + * @returns '0' on Success; Error code otherwise.
16681 +int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
16682 + uint32_t cmd_flags,
16685 + struct dpdmux_link_state *state);
16687 +#endif /* __FSL_DPDMUX_H */
16688 diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
16689 new file mode 100644
16690 index 0000000..0a5cf17
16692 +++ b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
16694 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
16696 + * Redistribution and use in source and binary forms, with or without
16697 + * modification, are permitted provided that the following conditions are met:
16698 + * * Redistributions of source code must retain the above copyright
16699 + * notice, this list of conditions and the following disclaimer.
16700 + * * Redistributions in binary form must reproduce the above copyright
16701 + * notice, this list of conditions and the following disclaimer in the
16702 + * documentation and/or other materials provided with the distribution.
16703 + * * Neither the name of the above-listed copyright holders nor the
16704 + * names of any contributors may be used to endorse or promote products
16705 + * derived from this software without specific prior written permission.
16708 + * ALTERNATIVELY, this software may be distributed under the terms of the
16709 + * GNU General Public License ("GPL") as published by the Free Software
16710 + * Foundation, either version 2 of that License or (at your option) any
16713 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16714 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16715 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16716 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16717 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
16718 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
16719 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
16720 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
16721 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
16722 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
16723 + * POSSIBILITY OF SUCH DAMAGE.
16725 +#ifndef _FSL_DPDMUX_CMD_H
16726 +#define _FSL_DPDMUX_CMD_H
16728 +/* DPDMUX Version */
16729 +#define DPDMUX_VER_MAJOR 5
16730 +#define DPDMUX_VER_MINOR 0
16733 +#define DPDMUX_CMDID_CLOSE 0x800
16734 +#define DPDMUX_CMDID_OPEN 0x806
16735 +#define DPDMUX_CMDID_CREATE 0x906
16736 +#define DPDMUX_CMDID_DESTROY 0x900
16738 +#define DPDMUX_CMDID_ENABLE 0x002
16739 +#define DPDMUX_CMDID_DISABLE 0x003
16740 +#define DPDMUX_CMDID_GET_ATTR 0x004
16741 +#define DPDMUX_CMDID_RESET 0x005
16742 +#define DPDMUX_CMDID_IS_ENABLED 0x006
16744 +#define DPDMUX_CMDID_SET_IRQ 0x010
16745 +#define DPDMUX_CMDID_GET_IRQ 0x011
16746 +#define DPDMUX_CMDID_SET_IRQ_ENABLE 0x012
16747 +#define DPDMUX_CMDID_GET_IRQ_ENABLE 0x013
16748 +#define DPDMUX_CMDID_SET_IRQ_MASK 0x014
16749 +#define DPDMUX_CMDID_GET_IRQ_MASK 0x015
16750 +#define DPDMUX_CMDID_GET_IRQ_STATUS 0x016
16751 +#define DPDMUX_CMDID_CLEAR_IRQ_STATUS 0x017
16753 +#define DPDMUX_CMDID_UL_SET_MAX_FRAME_LENGTH 0x0a1
16755 +#define DPDMUX_CMDID_UL_RESET_COUNTERS 0x0a3
16757 +#define DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES 0x0a7
16758 +#define DPDMUX_CMDID_IF_GET_ATTR 0x0a8
16760 +#define DPDMUX_CMDID_IF_ADD_L2_RULE 0x0b0
16761 +#define DPDMUX_CMDID_IF_REMOVE_L2_RULE 0x0b1
16762 +#define DPDMUX_CMDID_IF_GET_COUNTER 0x0b2
16763 +#define DPDMUX_CMDID_IF_SET_LINK_CFG 0x0b3
16764 +#define DPDMUX_CMDID_IF_GET_LINK_STATE 0x0b4
16766 +/* cmd, param, offset, width, type, arg_name */
16767 +#define DPDMUX_CMD_OPEN(cmd, dpdmux_id) \
16768 + MC_CMD_OP(cmd, 0, 0, 32, int, dpdmux_id)
16770 +/* cmd, param, offset, width, type, arg_name */
16771 +#define DPDMUX_CMD_CREATE(cmd, cfg) \
16773 + MC_CMD_OP(cmd, 0, 0, 8, enum dpdmux_method, cfg->method);\
16774 + MC_CMD_OP(cmd, 0, 8, 8, enum dpdmux_manip, cfg->manip);\
16775 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs);\
16776 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->adv.max_dmat_entries);\
16777 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, cfg->adv.max_mc_groups);\
16778 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, cfg->adv.max_vlan_ids);\
16779 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->adv.options);\
16782 +/* cmd, param, offset, width, type, arg_name */
16783 +#define DPDMUX_RSP_IS_ENABLED(cmd, en) \
16784 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
16786 +/* cmd, param, offset, width, type, arg_name */
16787 +#define DPDMUX_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
16789 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
16790 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
16791 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
16792 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
16795 +/* cmd, param, offset, width, type, arg_name */
16796 +#define DPDMUX_CMD_GET_IRQ(cmd, irq_index) \
16797 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
16799 +/* cmd, param, offset, width, type, arg_name */
16800 +#define DPDMUX_RSP_GET_IRQ(cmd, type, irq_cfg) \
16802 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
16803 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
16804 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
16805 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
16808 +/* cmd, param, offset, width, type, arg_name */
16809 +#define DPDMUX_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
16811 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en);\
16812 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
16815 +/* cmd, param, offset, width, type, arg_name */
16816 +#define DPDMUX_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
16817 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
16819 +/* cmd, param, offset, width, type, arg_name */
16820 +#define DPDMUX_RSP_GET_IRQ_ENABLE(cmd, en) \
16821 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
16823 +/* cmd, param, offset, width, type, arg_name */
16824 +#define DPDMUX_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
16826 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
16827 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
16830 +/* cmd, param, offset, width, type, arg_name */
16831 +#define DPDMUX_CMD_GET_IRQ_MASK(cmd, irq_index) \
16832 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
16834 +/* cmd, param, offset, width, type, arg_name */
16835 +#define DPDMUX_RSP_GET_IRQ_MASK(cmd, mask) \
16836 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
16838 +/* cmd, param, offset, width, type, arg_name */
16839 +#define DPDMUX_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
16841 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
16842 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
16845 +/* cmd, param, offset, width, type, arg_name */
16846 +#define DPDMUX_RSP_GET_IRQ_STATUS(cmd, status) \
16847 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status) \
16849 +/* cmd, param, offset, width, type, arg_name */
16850 +#define DPDMUX_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
16852 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
16853 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
16856 +#define DPDMUX_RSP_GET_ATTR(cmd, attr) \
16858 + MC_RSP_OP(cmd, 0, 0, 8, enum dpdmux_method, attr->method);\
16859 + MC_RSP_OP(cmd, 0, 8, 8, enum dpdmux_manip, attr->manip);\
16860 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->num_ifs);\
16861 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->mem_size);\
16862 + MC_RSP_OP(cmd, 2, 0, 32, int, attr->id);\
16863 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, attr->options);\
16864 + MC_RSP_OP(cmd, 4, 0, 16, uint16_t, attr->version.major);\
16865 + MC_RSP_OP(cmd, 4, 16, 16, uint16_t, attr->version.minor);\
16868 +/* cmd, param, offset, width, type, arg_name */
16869 +#define DPDMUX_CMD_UL_SET_MAX_FRAME_LENGTH(cmd, max_frame_length) \
16870 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, max_frame_length)
16872 +/* cmd, param, offset, width, type, arg_name */
16873 +#define DPDMUX_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg) \
16875 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
16876 + MC_CMD_OP(cmd, 0, 16, 4, enum dpdmux_accepted_frames_type, cfg->type);\
16877 + MC_CMD_OP(cmd, 0, 20, 4, enum dpdmux_unaccepted_frames_action, \
16878 + cfg->unaccept_act);\
16881 +/* cmd, param, offset, width, type, arg_name */
16882 +#define DPDMUX_CMD_IF_GET_ATTR(cmd, if_id) \
16883 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
16885 +/* cmd, param, offset, width, type, arg_name */
16886 +#define DPDMUX_RSP_IF_GET_ATTR(cmd, attr) \
16888 + MC_RSP_OP(cmd, 0, 56, 4, enum dpdmux_accepted_frames_type, \
16889 + attr->accept_frame_type);\
16890 + MC_RSP_OP(cmd, 0, 24, 1, int, attr->enabled);\
16891 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->rate);\
16894 +#define DPDMUX_CMD_IF_REMOVE_L2_RULE(cmd, if_id, l2_rule) \
16896 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
16897 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, l2_rule->mac_addr[5]);\
16898 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, l2_rule->mac_addr[4]);\
16899 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, l2_rule->mac_addr[3]);\
16900 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, l2_rule->mac_addr[2]);\
16901 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, l2_rule->mac_addr[1]);\
16902 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, l2_rule->mac_addr[0]);\
16903 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, l2_rule->vlan_id);\
16906 +#define DPDMUX_CMD_IF_ADD_L2_RULE(cmd, if_id, l2_rule) \
16908 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
16909 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, l2_rule->mac_addr[5]);\
16910 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, l2_rule->mac_addr[4]);\
16911 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, l2_rule->mac_addr[3]);\
16912 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, l2_rule->mac_addr[2]);\
16913 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, l2_rule->mac_addr[1]);\
16914 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, l2_rule->mac_addr[0]);\
16915 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, l2_rule->vlan_id);\
16918 +/* cmd, param, offset, width, type, arg_name */
16919 +#define DPDMUX_CMD_IF_GET_COUNTER(cmd, if_id, counter_type) \
16921 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
16922 + MC_CMD_OP(cmd, 0, 16, 8, enum dpdmux_counter_type, counter_type);\
16925 +/* cmd, param, offset, width, type, arg_name */
16926 +#define DPDMUX_RSP_IF_GET_COUNTER(cmd, counter) \
16927 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
16929 +/* cmd, param, offset, width, type, arg_name */
16930 +#define DPDMUX_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg) \
16932 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
16933 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
16934 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
16937 +/* cmd, param, offset, width, type, arg_name */
16938 +#define DPDMUX_CMD_IF_GET_LINK_STATE(cmd, if_id) \
16939 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
16941 +/* cmd, param, offset, width, type, arg_name */
16942 +#define DPDMUX_RSP_IF_GET_LINK_STATE(cmd, state) \
16944 + MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
16945 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
16946 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
16949 +#endif /* _FSL_DPDMUX_CMD_H */
16950 diff --git a/drivers/net/dpaa2/mc/fsl_dpio.h b/drivers/net/dpaa2/mc/fsl_dpio.h
16951 new file mode 100644
16952 index 0000000..88a492f
16954 +++ b/drivers/net/dpaa2/mc/fsl_dpio.h
16956 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
16958 + * Redistribution and use in source and binary forms, with or without
16959 + * modification, are permitted provided that the following conditions are met:
16960 + * * Redistributions of source code must retain the above copyright
16961 + * notice, this list of conditions and the following disclaimer.
16962 + * * Redistributions in binary form must reproduce the above copyright
16963 + * notice, this list of conditions and the following disclaimer in the
16964 + * documentation and/or other materials provided with the distribution.
16965 + * * Neither the name of the above-listed copyright holders nor the
16966 + * names of any contributors may be used to endorse or promote products
16967 + * derived from this software without specific prior written permission.
16970 + * ALTERNATIVELY, this software may be distributed under the terms of the
16971 + * GNU General Public License ("GPL") as published by the Free Software
16972 + * Foundation, either version 2 of that License or (at your option) any
16975 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16976 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16977 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16978 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
16979 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
16980 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
16981 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
16982 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
16983 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
16984 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
16985 + * POSSIBILITY OF SUCH DAMAGE.
16987 +#ifndef __FSL_DPIO_H
16988 +#define __FSL_DPIO_H
16990 +/* Data Path I/O Portal API
16991 + * Contains initialization APIs and runtime control APIs for DPIO
16997 + * dpio_open() - Open a control session for the specified object
16998 + * @mc_io: Pointer to MC portal's I/O object
16999 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17000 + * @dpio_id: DPIO unique ID
17001 + * @token: Returned token; use in subsequent API calls
17003 + * This function can be used to open a control session for an
17004 + * already created object; an object may have been declared in
17005 + * the DPL or by calling the dpio_create() function.
17006 + * This function returns a unique authentication token,
17007 + * associated with the specific object ID and the specific MC
17008 + * portal; this token must be used in all subsequent commands for
17009 + * this specific object.
17011 + * Return: '0' on Success; Error code otherwise.
17013 +int dpio_open(struct fsl_mc_io *mc_io,
17014 + uint32_t cmd_flags,
17016 + uint16_t *token);
17019 + * dpio_close() - Close the control session of the object
17020 + * @mc_io: Pointer to MC portal's I/O object
17021 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17022 + * @token: Token of DPIO object
17024 + * Return: '0' on Success; Error code otherwise.
17026 +int dpio_close(struct fsl_mc_io *mc_io,
17027 + uint32_t cmd_flags,
17031 + * enum dpio_channel_mode - DPIO notification channel mode
17032 + * @DPIO_NO_CHANNEL: No support for notification channel
17033 + * @DPIO_LOCAL_CHANNEL: Notifications on data availability can be received by a
17034 + * dedicated channel in the DPIO; user should point the queue's
17035 + * destination in the relevant interface to this DPIO
17037 +enum dpio_channel_mode {
17038 + DPIO_NO_CHANNEL = 0,
17039 + DPIO_LOCAL_CHANNEL = 1,
17043 + * struct dpio_cfg - Structure representing DPIO configuration
17044 + * @channel_mode: Notification channel mode
17045 + * @num_priorities: Number of priorities for the notification channel (1-8);
17046 + * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
17049 + enum dpio_channel_mode channel_mode;
17050 + uint8_t num_priorities;
17054 + * dpio_create() - Create the DPIO object.
17055 + * @mc_io: Pointer to MC portal's I/O object
17056 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17057 + * @cfg: Configuration structure
17058 + * @token: Returned token; use in subsequent API calls
17060 + * Create the DPIO object, allocate required resources and
17061 + * perform required initialization.
17063 + * The object can be created either by declaring it in the
17064 + * DPL file, or by calling this function.
17066 + * This function returns a unique authentication token,
17067 + * associated with the specific object ID and the specific MC
17068 + * portal; this token must be used in all subsequent calls to
17069 + * this specific object. For objects that are created using the
17070 + * DPL file, call dpio_open() function to get an authentication
17073 + * Return: '0' on Success; Error code otherwise.
17075 +int dpio_create(struct fsl_mc_io *mc_io,
17076 + uint32_t cmd_flags,
17077 + const struct dpio_cfg *cfg,
17078 + uint16_t *token);
17081 + * dpio_destroy() - Destroy the DPIO object and release all its resources.
17082 + * @mc_io: Pointer to MC portal's I/O object
17083 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17084 + * @token: Token of DPIO object
17086 + * Return: '0' on Success; Error code otherwise
17088 +int dpio_destroy(struct fsl_mc_io *mc_io,
17089 + uint32_t cmd_flags,
17093 + * dpio_enable() - Enable the DPIO, allow I/O portal operations.
17094 + * @mc_io: Pointer to MC portal's I/O object
17095 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17096 + * @token: Token of DPIO object
17098 + * Return: '0' on Success; Error code otherwise
17100 +int dpio_enable(struct fsl_mc_io *mc_io,
17101 + uint32_t cmd_flags,
17105 + * dpio_disable() - Disable the DPIO, stop any I/O portal operation.
17106 + * @mc_io: Pointer to MC portal's I/O object
17107 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17108 + * @token: Token of DPIO object
17110 + * Return: '0' on Success; Error code otherwise
17112 +int dpio_disable(struct fsl_mc_io *mc_io,
17113 + uint32_t cmd_flags,
17117 + * dpio_is_enabled() - Check if the DPIO is enabled.
17118 + * @mc_io: Pointer to MC portal's I/O object
17119 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17120 + * @token: Token of DPIO object
17121 + * @en: Returns '1' if object is enabled; '0' otherwise
17123 + * Return: '0' on Success; Error code otherwise.
17125 +int dpio_is_enabled(struct fsl_mc_io *mc_io,
17126 + uint32_t cmd_flags,
17131 + * dpio_reset() - Reset the DPIO, returns the object to initial state.
17132 + * @mc_io: Pointer to MC portal's I/O object
17133 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17134 + * @token: Token of DPIO object
17136 + * Return: '0' on Success; Error code otherwise.
17138 +int dpio_reset(struct fsl_mc_io *mc_io,
17139 + uint32_t cmd_flags,
17143 + * dpio_set_stashing_destination() - Set the stashing destination.
17144 + * @mc_io: Pointer to MC portal's I/O object
17145 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17146 + * @token: Token of DPIO object
17147 + * @sdest: stashing destination value
17149 + * Return: '0' on Success; Error code otherwise.
17151 +int dpio_set_stashing_destination(struct fsl_mc_io *mc_io,
17152 + uint32_t cmd_flags,
17157 + * dpio_get_stashing_destination() - Get the stashing destination..
17158 + * @mc_io: Pointer to MC portal's I/O object
17159 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17160 + * @token: Token of DPIO object
17161 + * @sdest: Returns the stashing destination value
17163 + * Return: '0' on Success; Error code otherwise.
17165 +int dpio_get_stashing_destination(struct fsl_mc_io *mc_io,
17166 + uint32_t cmd_flags,
17171 + * dpio_add_static_dequeue_channel() - Add a static dequeue channel.
17172 + * @mc_io: Pointer to MC portal's I/O object
17173 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17174 + * @token: Token of DPIO object
17175 + * @dpcon_id: DPCON object ID
17176 + * @channel_index: Returned channel index to be used in qbman API
17178 + * Return: '0' on Success; Error code otherwise.
17180 +int dpio_add_static_dequeue_channel(struct fsl_mc_io *mc_io,
17181 + uint32_t cmd_flags,
17184 + uint8_t *channel_index);
17187 + * dpio_remove_static_dequeue_channel() - Remove a static dequeue channel.
17188 + * @mc_io: Pointer to MC portal's I/O object
17189 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17190 + * @token: Token of DPIO object
17191 + * @dpcon_id: DPCON object ID
17193 + * Return: '0' on Success; Error code otherwise.
17195 +int dpio_remove_static_dequeue_channel(struct fsl_mc_io *mc_io,
17196 + uint32_t cmd_flags,
17201 + * DPIO IRQ Index and Events
17205 + * Irq software-portal index
17207 +#define DPIO_IRQ_SWP_INDEX 0
17210 + * struct dpio_irq_cfg - IRQ configuration
17211 + * @addr: Address that must be written to signal a message-based interrupt
17212 + * @val: Value to write into irq_addr address
17213 + * @irq_num: A user defined number associated with this IRQ
17215 +struct dpio_irq_cfg {
17222 + * dpio_set_irq() - Set IRQ information for the DPIO to trigger an interrupt.
17223 + * @mc_io: Pointer to MC portal's I/O object
17224 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17225 + * @token: Token of DPIO object
17226 + * @irq_index: Identifies the interrupt index to configure
17227 + * @irq_cfg: IRQ configuration
17229 + * Return: '0' on Success; Error code otherwise.
17231 +int dpio_set_irq(struct fsl_mc_io *mc_io,
17232 + uint32_t cmd_flags,
17234 + uint8_t irq_index,
17235 + struct dpio_irq_cfg *irq_cfg);
17238 + * dpio_get_irq() - Get IRQ information from the DPIO.
17240 + * @mc_io: Pointer to MC portal's I/O object
17241 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17242 + * @token: Token of DPIO object
17243 + * @irq_index: The interrupt index to configure
17244 + * @type: Interrupt type: 0 represents message interrupt
17245 + * type (both irq_addr and irq_val are valid)
17246 + * @irq_cfg: IRQ attributes
17248 + * Return: '0' on Success; Error code otherwise.
17250 +int dpio_get_irq(struct fsl_mc_io *mc_io,
17251 + uint32_t cmd_flags,
17253 + uint8_t irq_index,
17255 + struct dpio_irq_cfg *irq_cfg);
17258 + * dpio_set_irq_enable() - Set overall interrupt state.
17259 + * @mc_io: Pointer to MC portal's I/O object
17260 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17261 + * @token: Token of DPIO object
17262 + * @irq_index: The interrupt index to configure
17263 + * @en: Interrupt state - enable = 1, disable = 0
17265 + * Allows GPP software to control when interrupts are generated.
17266 + * Each interrupt can have up to 32 causes. The enable/disable control's the
17267 + * overall interrupt state. if the interrupt is disabled no causes will cause
17270 + * Return: '0' on Success; Error code otherwise.
17272 +int dpio_set_irq_enable(struct fsl_mc_io *mc_io,
17273 + uint32_t cmd_flags,
17275 + uint8_t irq_index,
17279 + * dpio_get_irq_enable() - Get overall interrupt state
17280 + * @mc_io: Pointer to MC portal's I/O object
17281 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17282 + * @token: Token of DPIO object
17283 + * @irq_index: The interrupt index to configure
17284 + * @en: Returned interrupt state - enable = 1, disable = 0
17286 + * Return: '0' on Success; Error code otherwise.
17288 +int dpio_get_irq_enable(struct fsl_mc_io *mc_io,
17289 + uint32_t cmd_flags,
17291 + uint8_t irq_index,
17295 + * dpio_set_irq_mask() - Set interrupt mask.
17296 + * @mc_io: Pointer to MC portal's I/O object
17297 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17298 + * @token: Token of DPIO object
17299 + * @irq_index: The interrupt index to configure
17300 + * @mask: event mask to trigger interrupt;
17302 + * 0 = ignore event
17303 + * 1 = consider event for asserting IRQ
17305 + * Every interrupt can have up to 32 causes and the interrupt model supports
17306 + * masking/unmasking each cause independently
17308 + * Return: '0' on Success; Error code otherwise.
17310 +int dpio_set_irq_mask(struct fsl_mc_io *mc_io,
17311 + uint32_t cmd_flags,
17313 + uint8_t irq_index,
17317 + * dpio_get_irq_mask() - Get interrupt mask.
17318 + * @mc_io: Pointer to MC portal's I/O object
17319 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17320 + * @token: Token of DPIO object
17321 + * @irq_index: The interrupt index to configure
17322 + * @mask: Returned event mask to trigger interrupt
17324 + * Every interrupt can have up to 32 causes and the interrupt model supports
17325 + * masking/unmasking each cause independently
17327 + * Return: '0' on Success; Error code otherwise.
17329 +int dpio_get_irq_mask(struct fsl_mc_io *mc_io,
17330 + uint32_t cmd_flags,
17332 + uint8_t irq_index,
17336 + * dpio_get_irq_status() - Get the current status of any pending interrupts.
17337 + * @mc_io: Pointer to MC portal's I/O object
17338 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17339 + * @token: Token of DPIO object
17340 + * @irq_index: The interrupt index to configure
17341 + * @status: Returned interrupts status - one bit per cause:
17342 + * 0 = no interrupt pending
17343 + * 1 = interrupt pending
17345 + * Return: '0' on Success; Error code otherwise.
17347 +int dpio_get_irq_status(struct fsl_mc_io *mc_io,
17348 + uint32_t cmd_flags,
17350 + uint8_t irq_index,
17351 + uint32_t *status);
17354 + * dpio_clear_irq_status() - Clear a pending interrupt's status
17355 + * @mc_io: Pointer to MC portal's I/O object
17356 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17357 + * @token: Token of DPIO object
17358 + * @irq_index: The interrupt index to configure
17359 + * @status: bits to clear (W1C) - one bit per cause:
17360 + * 0 = don't change
17361 + * 1 = clear status bit
17363 + * Return: '0' on Success; Error code otherwise.
17365 +int dpio_clear_irq_status(struct fsl_mc_io *mc_io,
17366 + uint32_t cmd_flags,
17368 + uint8_t irq_index,
17369 + uint32_t status);
17372 + * struct dpio_attr - Structure representing DPIO attributes
17373 + * @id: DPIO object ID
17374 + * @version: DPIO version
17375 + * @qbman_portal_ce_offset: offset of the software portal cache-enabled area
17376 + * @qbman_portal_ci_offset: offset of the software portal cache-inhibited area
17377 + * @qbman_portal_id: Software portal ID
17378 + * @channel_mode: Notification channel mode
17379 + * @num_priorities: Number of priorities for the notification channel (1-8);
17380 + * relevant only if 'channel_mode = DPIO_LOCAL_CHANNEL'
17381 + * @qbman_version: QBMAN version
17383 +struct dpio_attr {
17386 + * struct version - DPIO version
17387 + * @major: DPIO major version
17388 + * @minor: DPIO minor version
17394 + uint64_t qbman_portal_ce_offset;
17395 + uint64_t qbman_portal_ci_offset;
17396 + uint16_t qbman_portal_id;
17397 + enum dpio_channel_mode channel_mode;
17398 + uint8_t num_priorities;
17399 + uint32_t qbman_version;
17403 + * dpio_get_attributes() - Retrieve DPIO attributes
17404 + * @mc_io: Pointer to MC portal's I/O object
17405 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17406 + * @token: Token of DPIO object
17407 + * @attr: Returned object's attributes
17409 + * Return: '0' on Success; Error code otherwise
17411 +int dpio_get_attributes(struct fsl_mc_io *mc_io,
17412 + uint32_t cmd_flags,
17414 + struct dpio_attr *attr);
17415 +#endif /* __FSL_DPIO_H */
17416 diff --git a/drivers/net/dpaa2/mc/fsl_dpio_cmd.h b/drivers/net/dpaa2/mc/fsl_dpio_cmd.h
17417 new file mode 100644
17418 index 0000000..f339cd6
17420 +++ b/drivers/net/dpaa2/mc/fsl_dpio_cmd.h
17422 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
17424 + * Redistribution and use in source and binary forms, with or without
17425 + * modification, are permitted provided that the following conditions are met:
17426 + * * Redistributions of source code must retain the above copyright
17427 + * notice, this list of conditions and the following disclaimer.
17428 + * * Redistributions in binary form must reproduce the above copyright
17429 + * notice, this list of conditions and the following disclaimer in the
17430 + * documentation and/or other materials provided with the distribution.
17431 + * * Neither the name of the above-listed copyright holders nor the
17432 + * names of any contributors may be used to endorse or promote products
17433 + * derived from this software without specific prior written permission.
17436 + * ALTERNATIVELY, this software may be distributed under the terms of the
17437 + * GNU General Public License ("GPL") as published by the Free Software
17438 + * Foundation, either version 2 of that License or (at your option) any
17441 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17442 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17443 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17444 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
17445 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17446 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
17447 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
17448 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
17449 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
17450 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
17451 + * POSSIBILITY OF SUCH DAMAGE.
17453 +#ifndef _FSL_DPIO_CMD_H
17454 +#define _FSL_DPIO_CMD_H
17456 +/* DPIO Version */
17457 +#define DPIO_VER_MAJOR 3
17458 +#define DPIO_VER_MINOR 2
17461 +#define DPIO_CMDID_CLOSE 0x800
17462 +#define DPIO_CMDID_OPEN 0x803
17463 +#define DPIO_CMDID_CREATE 0x903
17464 +#define DPIO_CMDID_DESTROY 0x900
17466 +#define DPIO_CMDID_ENABLE 0x002
17467 +#define DPIO_CMDID_DISABLE 0x003
17468 +#define DPIO_CMDID_GET_ATTR 0x004
17469 +#define DPIO_CMDID_RESET 0x005
17470 +#define DPIO_CMDID_IS_ENABLED 0x006
17472 +#define DPIO_CMDID_SET_IRQ 0x010
17473 +#define DPIO_CMDID_GET_IRQ 0x011
17474 +#define DPIO_CMDID_SET_IRQ_ENABLE 0x012
17475 +#define DPIO_CMDID_GET_IRQ_ENABLE 0x013
17476 +#define DPIO_CMDID_SET_IRQ_MASK 0x014
17477 +#define DPIO_CMDID_GET_IRQ_MASK 0x015
17478 +#define DPIO_CMDID_GET_IRQ_STATUS 0x016
17479 +#define DPIO_CMDID_CLEAR_IRQ_STATUS 0x017
17481 +#define DPIO_CMDID_SET_STASHING_DEST 0x120
17482 +#define DPIO_CMDID_GET_STASHING_DEST 0x121
17483 +#define DPIO_CMDID_ADD_STATIC_DEQUEUE_CHANNEL 0x122
17484 +#define DPIO_CMDID_REMOVE_STATIC_DEQUEUE_CHANNEL 0x123
17486 +/* cmd, param, offset, width, type, arg_name */
17487 +#define DPIO_CMD_OPEN(cmd, dpio_id) \
17488 + MC_CMD_OP(cmd, 0, 0, 32, int, dpio_id)
17490 +/* cmd, param, offset, width, type, arg_name */
17491 +#define DPIO_CMD_CREATE(cmd, cfg) \
17493 + MC_CMD_OP(cmd, 0, 16, 2, enum dpio_channel_mode, \
17494 + cfg->channel_mode);\
17495 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->num_priorities);\
17498 +/* cmd, param, offset, width, type, arg_name */
17499 +#define DPIO_RSP_IS_ENABLED(cmd, en) \
17500 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
17502 +/* cmd, param, offset, width, type, arg_name */
17503 +#define DPIO_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
17505 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
17506 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
17507 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
17508 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
17511 +/* cmd, param, offset, width, type, arg_name */
17512 +#define DPIO_CMD_GET_IRQ(cmd, irq_index) \
17513 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
17515 +/* cmd, param, offset, width, type, arg_name */
17516 +#define DPIO_RSP_GET_IRQ(cmd, type, irq_cfg) \
17518 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
17519 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
17520 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
17521 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
17524 +/* cmd, param, offset, width, type, arg_name */
17525 +#define DPIO_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
17527 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
17528 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
17531 +/* cmd, param, offset, width, type, arg_name */
17532 +#define DPIO_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
17533 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
17535 +/* cmd, param, offset, width, type, arg_name */
17536 +#define DPIO_RSP_GET_IRQ_ENABLE(cmd, en) \
17537 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
17539 +/* cmd, param, offset, width, type, arg_name */
17540 +#define DPIO_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
17542 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
17543 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
17546 +/* cmd, param, offset, width, type, arg_name */
17547 +#define DPIO_CMD_GET_IRQ_MASK(cmd, irq_index) \
17548 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
17550 +/* cmd, param, offset, width, type, arg_name */
17551 +#define DPIO_RSP_GET_IRQ_MASK(cmd, mask) \
17552 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
17554 +/* cmd, param, offset, width, type, arg_name */
17555 +#define DPIO_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
17557 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
17558 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
17561 +/* cmd, param, offset, width, type, arg_name */
17562 +#define DPIO_RSP_GET_IRQ_STATUS(cmd, status) \
17563 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
17565 +/* cmd, param, offset, width, type, arg_name */
17566 +#define DPIO_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
17568 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
17569 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
17572 +/* cmd, param, offset, width, type, arg_name */
17573 +#define DPIO_RSP_GET_ATTR(cmd, attr) \
17575 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
17576 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qbman_portal_id);\
17577 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, attr->num_priorities);\
17578 + MC_RSP_OP(cmd, 0, 56, 4, enum dpio_channel_mode, attr->channel_mode);\
17579 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->qbman_portal_ce_offset);\
17580 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, attr->qbman_portal_ci_offset);\
17581 + MC_RSP_OP(cmd, 3, 0, 16, uint16_t, attr->version.major);\
17582 + MC_RSP_OP(cmd, 3, 16, 16, uint16_t, attr->version.minor);\
17583 + MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->qbman_version);\
17586 +/* cmd, param, offset, width, type, arg_name */
17587 +#define DPIO_CMD_SET_STASHING_DEST(cmd, sdest) \
17588 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, sdest)
17590 +/* cmd, param, offset, width, type, arg_name */
17591 +#define DPIO_RSP_GET_STASHING_DEST(cmd, sdest) \
17592 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, sdest)
17594 +/* cmd, param, offset, width, type, arg_name */
17595 +#define DPIO_CMD_ADD_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id) \
17596 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id)
17598 +/* cmd, param, offset, width, type, arg_name */
17599 +#define DPIO_RSP_ADD_STATIC_DEQUEUE_CHANNEL(cmd, channel_index) \
17600 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, channel_index)
17602 +/* cmd, param, offset, width, type, arg_name */
17603 +#define DPIO_CMD_REMOVE_STATIC_DEQUEUE_CHANNEL(cmd, dpcon_id) \
17604 + MC_CMD_OP(cmd, 0, 0, 32, int, dpcon_id)
17605 +#endif /* _FSL_DPIO_CMD_H */
17606 diff --git a/drivers/net/dpaa2/mc/fsl_dpkg.h b/drivers/net/dpaa2/mc/fsl_dpkg.h
17607 new file mode 100644
17608 index 0000000..b2bceaf
17610 +++ b/drivers/net/dpaa2/mc/fsl_dpkg.h
17612 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
17614 + * Redistribution and use in source and binary forms, with or without
17615 + * modification, are permitted provided that the following conditions are met:
17616 + * * Redistributions of source code must retain the above copyright
17617 + * notice, this list of conditions and the following disclaimer.
17618 + * * Redistributions in binary form must reproduce the above copyright
17619 + * notice, this list of conditions and the following disclaimer in the
17620 + * documentation and/or other materials provided with the distribution.
17621 + * * Neither the name of the above-listed copyright holders nor the
17622 + * names of any contributors may be used to endorse or promote products
17623 + * derived from this software without specific prior written permission.
17626 + * ALTERNATIVELY, this software may be distributed under the terms of the
17627 + * GNU General Public License ("GPL") as published by the Free Software
17628 + * Foundation, either version 2 of that License or (at your option) any
17631 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17632 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17633 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17634 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
17635 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17636 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
17637 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
17638 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
17639 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
17640 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
17641 + * POSSIBILITY OF SUCH DAMAGE.
17643 +#ifndef __FSL_DPKG_H_
17644 +#define __FSL_DPKG_H_
17646 +#include <fsl_net.h>
17648 +/* Data Path Key Generator API
17649 + * Contains initialization APIs and runtime APIs for the Key Generator
17652 +/** Key Generator properties */
17655 + * Number of masks per key extraction
17657 +#define DPKG_NUM_OF_MASKS 4
17659 + * Number of extractions per key profile
17661 +#define DPKG_MAX_NUM_OF_EXTRACTS 10
17664 + * enum dpkg_extract_from_hdr_type - Selecting extraction by header types
17665 + * @DPKG_FROM_HDR: Extract selected bytes from header, by offset
17666 + * @DPKG_FROM_FIELD: Extract selected bytes from header, by offset from field
17667 + * @DPKG_FULL_FIELD: Extract a full field
17669 +enum dpkg_extract_from_hdr_type {
17670 + DPKG_FROM_HDR = 0,
17671 + DPKG_FROM_FIELD = 1,
17672 + DPKG_FULL_FIELD = 2
17676 + * enum dpkg_extract_type - Enumeration for selecting extraction type
17677 + * @DPKG_EXTRACT_FROM_HDR: Extract from the header
17678 + * @DPKG_EXTRACT_FROM_DATA: Extract from data not in specific header
17679 + * @DPKG_EXTRACT_FROM_PARSE: Extract from parser-result;
17680 + * e.g. can be used to extract header existence;
17681 + * please refer to 'Parse Result definition' section in the parser BG
17683 +enum dpkg_extract_type {
17684 + DPKG_EXTRACT_FROM_HDR = 0,
17685 + DPKG_EXTRACT_FROM_DATA = 1,
17686 + DPKG_EXTRACT_FROM_PARSE = 3
17690 + * struct dpkg_mask - A structure for defining a single extraction mask
17691 + * @mask: Byte mask for the extracted content
17692 + * @offset: Offset within the extracted content
17694 +struct dpkg_mask {
17700 + * struct dpkg_extract - A structure for defining a single extraction
17701 + * @type: Determines how the union below is interpreted:
17702 + * DPKG_EXTRACT_FROM_HDR: selects 'from_hdr';
17703 + * DPKG_EXTRACT_FROM_DATA: selects 'from_data';
17704 + * DPKG_EXTRACT_FROM_PARSE: selects 'from_parse'
17705 + * @extract: Selects extraction method
17706 + * @num_of_byte_masks: Defines the number of valid entries in the array below;
17707 + * This is also the number of bytes to be used as masks
17708 + * @masks: Masks parameters
17710 +struct dpkg_extract {
17711 + enum dpkg_extract_type type;
17713 + * union extract - Selects extraction method
17714 + * @from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
17715 + * @from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
17716 + * @from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE'
17720 + * struct from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
17721 + * @prot: Any of the supported headers
17722 + * @type: Defines the type of header extraction:
17723 + * DPKG_FROM_HDR: use size & offset below;
17724 + * DPKG_FROM_FIELD: use field, size and offset below;
17725 + * DPKG_FULL_FIELD: use field below
17726 + * @field: One of the supported fields (NH_FLD_)
17728 + * @size: Size in bytes
17729 + * @offset: Byte offset
17730 + * @hdr_index: Clear for cases not listed below;
17731 + * Used for protocols that may have more than a single
17732 + * header, 0 indicates an outer header;
17733 + * Supported protocols (possible values):
17734 + * NET_PROT_VLAN (0, HDR_INDEX_LAST);
17735 + * NET_PROT_MPLS (0, 1, HDR_INDEX_LAST);
17736 + * NET_PROT_IP(0, HDR_INDEX_LAST);
17737 + * NET_PROT_IPv4(0, HDR_INDEX_LAST);
17738 + * NET_PROT_IPv6(0, HDR_INDEX_LAST);
17742 + enum net_prot prot;
17743 + enum dpkg_extract_from_hdr_type type;
17747 + uint8_t hdr_index;
17750 + * struct from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
17751 + * @size: Size in bytes
17752 + * @offset: Byte offset
17760 + * struct from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE'
17761 + * @size: Size in bytes
17762 + * @offset: Byte offset
17770 + uint8_t num_of_byte_masks;
17771 + struct dpkg_mask masks[DPKG_NUM_OF_MASKS];
17775 + * struct dpkg_profile_cfg - A structure for defining a full Key Generation
17777 + * @num_extracts: Defines the number of valid entries in the array below
17778 + * @extracts: Array of required extractions
17780 +struct dpkg_profile_cfg {
17781 + uint8_t num_extracts;
17782 + struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
17785 +#endif /* __FSL_DPKG_H_ */
17786 diff --git a/drivers/net/dpaa2/mc/fsl_dpmac.h b/drivers/net/dpaa2/mc/fsl_dpmac.h
17787 new file mode 100644
17788 index 0000000..ad27772
17790 +++ b/drivers/net/dpaa2/mc/fsl_dpmac.h
17792 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
17794 + * Redistribution and use in source and binary forms, with or without
17795 + * modification, are permitted provided that the following conditions are met:
17796 + * * Redistributions of source code must retain the above copyright
17797 + * notice, this list of conditions and the following disclaimer.
17798 + * * Redistributions in binary form must reproduce the above copyright
17799 + * notice, this list of conditions and the following disclaimer in the
17800 + * documentation and/or other materials provided with the distribution.
17801 + * * Neither the name of the above-listed copyright holders nor the
17802 + * names of any contributors may be used to endorse or promote products
17803 + * derived from this software without specific prior written permission.
17806 + * ALTERNATIVELY, this software may be distributed under the terms of the
17807 + * GNU General Public License ("GPL") as published by the Free Software
17808 + * Foundation, either version 2 of that License or (at your option) any
17811 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17812 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17813 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17814 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
17815 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17816 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
17817 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
17818 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
17819 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
17820 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
17821 + * POSSIBILITY OF SUCH DAMAGE.
17823 +#ifndef __FSL_DPMAC_H
17824 +#define __FSL_DPMAC_H
17826 +/* Data Path MAC API
17827 + * Contains initialization APIs and runtime control APIs for DPMAC
17833 + * dpmac_open() - Open a control session for the specified object.
17834 + * @mc_io: Pointer to MC portal's I/O object
17835 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17836 + * @dpmac_id: DPMAC unique ID
17837 + * @token: Returned token; use in subsequent API calls
17839 + * This function can be used to open a control session for an
17840 + * already created object; an object may have been declared in
17841 + * the DPL or by calling the dpmac_create function.
17842 + * This function returns a unique authentication token,
17843 + * associated with the specific object ID and the specific MC
17844 + * portal; this token must be used in all subsequent commands for
17845 + * this specific object
17847 + * Return: '0' on Success; Error code otherwise.
17849 +int dpmac_open(struct fsl_mc_io *mc_io,
17850 + uint32_t cmd_flags,
17852 + uint16_t *token);
17855 + * dpmac_close() - Close the control session of the object
17856 + * @mc_io: Pointer to MC portal's I/O object
17857 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17858 + * @token: Token of DPMAC object
17860 + * After this function is called, no further operations are
17861 + * allowed on the object without opening a new control session.
17863 + * Return: '0' on Success; Error code otherwise.
17865 +int dpmac_close(struct fsl_mc_io *mc_io,
17866 + uint32_t cmd_flags,
17870 + * enum dpmac_link_type - DPMAC link type
17871 + * @DPMAC_LINK_TYPE_NONE: No link
17872 + * @DPMAC_LINK_TYPE_FIXED: Link is fixed type
17873 + * @DPMAC_LINK_TYPE_PHY: Link by PHY ID
17874 + * @DPMAC_LINK_TYPE_BACKPLANE: Backplane link type
17876 +enum dpmac_link_type {
17877 + DPMAC_LINK_TYPE_NONE,
17878 + DPMAC_LINK_TYPE_FIXED,
17879 + DPMAC_LINK_TYPE_PHY,
17880 + DPMAC_LINK_TYPE_BACKPLANE
17884 + * enum dpmac_eth_if - DPMAC Ethrnet interface
17885 + * @DPMAC_ETH_IF_MII: MII interface
17886 + * @DPMAC_ETH_IF_RMII: RMII interface
17887 + * @DPMAC_ETH_IF_SMII: SMII interface
17888 + * @DPMAC_ETH_IF_GMII: GMII interface
17889 + * @DPMAC_ETH_IF_RGMII: RGMII interface
17890 + * @DPMAC_ETH_IF_SGMII: SGMII interface
17891 + * @DPMAC_ETH_IF_QSGMII: QSGMII interface
17892 + * @DPMAC_ETH_IF_XAUI: XAUI interface
17893 + * @DPMAC_ETH_IF_XFI: XFI interface
17895 +enum dpmac_eth_if {
17896 + DPMAC_ETH_IF_MII,
17897 + DPMAC_ETH_IF_RMII,
17898 + DPMAC_ETH_IF_SMII,
17899 + DPMAC_ETH_IF_GMII,
17900 + DPMAC_ETH_IF_RGMII,
17901 + DPMAC_ETH_IF_SGMII,
17902 + DPMAC_ETH_IF_QSGMII,
17903 + DPMAC_ETH_IF_XAUI,
17908 + * struct dpmac_cfg - Structure representing DPMAC configuration
17909 + * @mac_id: Represents the Hardware MAC ID; in case of multiple WRIOP,
17910 + * the MAC IDs are continuous.
17911 + * For example: 2 WRIOPs, 16 MACs in each:
17912 + * MAC IDs for the 1st WRIOP: 1-16,
17913 + * MAC IDs for the 2nd WRIOP: 17-32.
17915 +struct dpmac_cfg {
17920 + * dpmac_create() - Create the DPMAC object.
17921 + * @mc_io: Pointer to MC portal's I/O object
17922 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17923 + * @cfg: Configuration structure
17924 + * @token: Returned token; use in subsequent API calls
17926 + * Create the DPMAC object, allocate required resources and
17927 + * perform required initialization.
17929 + * The object can be created either by declaring it in the
17930 + * DPL file, or by calling this function.
17931 + * This function returns a unique authentication token,
17932 + * associated with the specific object ID and the specific MC
17933 + * portal; this token must be used in all subsequent calls to
17934 + * this specific object. For objects that are created using the
17935 + * DPL file, call dpmac_open function to get an authentication
17938 + * Return: '0' on Success; Error code otherwise.
17940 +int dpmac_create(struct fsl_mc_io *mc_io,
17941 + uint32_t cmd_flags,
17942 + const struct dpmac_cfg *cfg,
17943 + uint16_t *token);
17946 + * dpmac_destroy() - Destroy the DPMAC object and release all its resources.
17947 + * @mc_io: Pointer to MC portal's I/O object
17948 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17949 + * @token: Token of DPMAC object
17951 + * Return: '0' on Success; error code otherwise.
17953 +int dpmac_destroy(struct fsl_mc_io *mc_io,
17954 + uint32_t cmd_flags,
17958 + * DPMAC IRQ Index and Events
17964 +#define DPMAC_IRQ_INDEX 0
17966 + * IRQ event - indicates a change in link state
17968 +#define DPMAC_IRQ_EVENT_LINK_CFG_REQ 0x00000001
17970 + * IRQ event - Indicates that the link state changed
17972 +#define DPMAC_IRQ_EVENT_LINK_CHANGED 0x00000002
17975 + * struct dpmac_irq_cfg - IRQ configuration
17976 + * @addr: Address that must be written to signal a message-based interrupt
17977 + * @val: Value to write into irq_addr address
17978 + * @irq_num: A user defined number associated with this IRQ
17980 +struct dpmac_irq_cfg {
17987 + * dpmac_set_irq() - Set IRQ information for the DPMAC to trigger an interrupt.
17988 + * @mc_io: Pointer to MC portal's I/O object
17989 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
17990 + * @token: Token of DPMAC object
17991 + * @irq_index: Identifies the interrupt index to configure
17992 + * @irq_cfg: IRQ configuration
17994 + * Return: '0' on Success; Error code otherwise.
17996 +int dpmac_set_irq(struct fsl_mc_io *mc_io,
17997 + uint32_t cmd_flags,
17999 + uint8_t irq_index,
18000 + struct dpmac_irq_cfg *irq_cfg);
18003 + * dpmac_get_irq() - Get IRQ information from the DPMAC.
18004 + * @mc_io: Pointer to MC portal's I/O object
18005 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18006 + * @token: Token of DPMAC object
18007 + * @irq_index: The interrupt index to configure
18008 + * @type: Interrupt type: 0 represents message interrupt
18009 + * type (both irq_addr and irq_val are valid)
18010 + * @irq_cfg: IRQ attributes
18012 + * Return: '0' on Success; Error code otherwise.
18014 +int dpmac_get_irq(struct fsl_mc_io *mc_io,
18015 + uint32_t cmd_flags,
18017 + uint8_t irq_index,
18019 + struct dpmac_irq_cfg *irq_cfg);
18022 + * dpmac_set_irq_enable() - Set overall interrupt state.
18023 + * @mc_io: Pointer to MC portal's I/O object
18024 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18025 + * @token: Token of DPMAC object
18026 + * @irq_index: The interrupt index to configure
18027 + * @en: Interrupt state - enable = 1, disable = 0
18029 + * Allows GPP software to control when interrupts are generated.
18030 + * Each interrupt can have up to 32 causes. The enable/disable control's the
18031 + * overall interrupt state. if the interrupt is disabled no causes will cause
18034 + * Return: '0' on Success; Error code otherwise.
18036 +int dpmac_set_irq_enable(struct fsl_mc_io *mc_io,
18037 + uint32_t cmd_flags,
18039 + uint8_t irq_index,
18043 + * dpmac_get_irq_enable() - Get overall interrupt state
18044 + * @mc_io: Pointer to MC portal's I/O object
18045 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18046 + * @token: Token of DPMAC object
18047 + * @irq_index: The interrupt index to configure
18048 + * @en: Returned interrupt state - enable = 1, disable = 0
18050 + * Return: '0' on Success; Error code otherwise.
18052 +int dpmac_get_irq_enable(struct fsl_mc_io *mc_io,
18053 + uint32_t cmd_flags,
18055 + uint8_t irq_index,
18059 + * dpmac_set_irq_mask() - Set interrupt mask.
18060 + * @mc_io: Pointer to MC portal's I/O object
18061 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18062 + * @token: Token of DPMAC object
18063 + * @irq_index: The interrupt index to configure
18064 + * @mask: Event mask to trigger interrupt;
18066 + * 0 = ignore event
18067 + * 1 = consider event for asserting IRQ
18069 + * Every interrupt can have up to 32 causes and the interrupt model supports
18070 + * masking/unmasking each cause independently
18072 + * Return: '0' on Success; Error code otherwise.
18074 +int dpmac_set_irq_mask(struct fsl_mc_io *mc_io,
18075 + uint32_t cmd_flags,
18077 + uint8_t irq_index,
18081 + * dpmac_get_irq_mask() - Get interrupt mask.
18082 + * @mc_io: Pointer to MC portal's I/O object
18083 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18084 + * @token: Token of DPMAC object
18085 + * @irq_index: The interrupt index to configure
18086 + * @mask: Returned event mask to trigger interrupt
18088 + * Every interrupt can have up to 32 causes and the interrupt model supports
18089 + * masking/unmasking each cause independently
18091 + * Return: '0' on Success; Error code otherwise.
18093 +int dpmac_get_irq_mask(struct fsl_mc_io *mc_io,
18094 + uint32_t cmd_flags,
18096 + uint8_t irq_index,
18100 + * dpmac_get_irq_status() - Get the current status of any pending interrupts.
18102 + * @mc_io: Pointer to MC portal's I/O object
18103 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18104 + * @token: Token of DPMAC object
18105 + * @irq_index: The interrupt index to configure
18106 + * @status: Returned interrupts status - one bit per cause:
18107 + * 0 = no interrupt pending
18108 + * 1 = interrupt pending
18110 + * Return: '0' on Success; Error code otherwise.
18112 +int dpmac_get_irq_status(struct fsl_mc_io *mc_io,
18113 + uint32_t cmd_flags,
18115 + uint8_t irq_index,
18116 + uint32_t *status);
18119 + * dpmac_clear_irq_status() - Clear a pending interrupt's status
18121 + * @mc_io: Pointer to MC portal's I/O object
18122 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18123 + * @token: Token of DPMAC object
18124 + * @irq_index: The interrupt index to configure
18125 + * @status: Bits to clear (W1C) - one bit per cause:
18126 + * 0 = don't change
18127 + * 1 = clear status bit
18129 + * Return: '0' on Success; Error code otherwise.
18131 +int dpmac_clear_irq_status(struct fsl_mc_io *mc_io,
18132 + uint32_t cmd_flags,
18134 + uint8_t irq_index,
18135 + uint32_t status);
18138 + * struct dpmac_attr - Structure representing DPMAC attributes
18139 + * @id: DPMAC object ID
18140 + * @phy_id: PHY ID
18141 + * @link_type: link type
18142 + * @eth_if: Ethernet interface
18143 + * @max_rate: Maximum supported rate - in Mbps
18144 + * @version: DPMAC version
18146 +struct dpmac_attr {
18149 + enum dpmac_link_type link_type;
18150 + enum dpmac_eth_if eth_if;
18151 + uint32_t max_rate;
18153 + * struct version - Structure representing DPMAC version
18154 + * @major: DPMAC major version
18155 + * @minor: DPMAC minor version
18164 + * dpmac_get_attributes - Retrieve DPMAC attributes.
18166 + * @mc_io: Pointer to MC portal's I/O object
18167 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18168 + * @token: Token of DPMAC object
18169 + * @attr: Returned object's attributes
18171 + * Return: '0' on Success; Error code otherwise.
18173 +int dpmac_get_attributes(struct fsl_mc_io *mc_io,
18174 + uint32_t cmd_flags,
18176 + struct dpmac_attr *attr);
18179 + * struct dpmac_mdio_cfg - DPMAC MDIO read/write parameters
18180 + * @phy_addr: MDIO device address
18181 + * @reg: Address of the register within the Clause 45 PHY device from which data
18183 + * @data: Data read/write from/to MDIO
18185 +struct dpmac_mdio_cfg {
18186 + uint8_t phy_addr;
18192 + * dpmac_mdio_read() - Perform MDIO read transaction
18193 + * @mc_io: Pointer to opaque I/O object
18194 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18195 + * @token: Token of DPMAC object
18196 + * @cfg: Structure with MDIO transaction parameters
18198 + * Return: '0' on Success; Error code otherwise.
18200 +int dpmac_mdio_read(struct fsl_mc_io *mc_io,
18201 + uint32_t cmd_flags,
18203 + struct dpmac_mdio_cfg *cfg);
18206 + * dpmac_mdio_write() - Perform MDIO write transaction
18207 + * @mc_io: Pointer to opaque I/O object
18208 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18209 + * @token: Token of DPMAC object
18210 + * @cfg: Structure with MDIO transaction parameters
18212 + * Return: '0' on Success; Error code otherwise.
18214 +int dpmac_mdio_write(struct fsl_mc_io *mc_io,
18215 + uint32_t cmd_flags,
18217 + struct dpmac_mdio_cfg *cfg);
18220 + * DPMAC link configuration/state options
18224 + * Enable auto-negotiation
18226 +#define DPMAC_LINK_OPT_AUTONEG 0x0000000000000001ULL
18228 + * Enable half-duplex mode
18230 +#define DPMAC_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
18232 + * Enable pause frames
18234 +#define DPMAC_LINK_OPT_PAUSE 0x0000000000000004ULL
18236 + * Enable a-symmetric pause frames
18238 +#define DPMAC_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
18241 + * struct dpmac_link_cfg - Structure representing DPMAC link configuration
18242 + * @rate: Link's rate - in Mbps
18243 + * @options: Enable/Disable DPMAC link cfg features (bitmap)
18245 +struct dpmac_link_cfg {
18247 + uint64_t options;
18251 + * dpmac_get_link_cfg() - Get Ethernet link configuration
18252 + * @mc_io: Pointer to opaque I/O object
18253 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18254 + * @token: Token of DPMAC object
18255 + * @cfg: Returned structure with the link configuration
18257 + * Return: '0' on Success; Error code otherwise.
18259 +int dpmac_get_link_cfg(struct fsl_mc_io *mc_io,
18260 + uint32_t cmd_flags,
18262 + struct dpmac_link_cfg *cfg);
18265 + * struct dpmac_link_state - DPMAC link configuration request
18266 + * @rate: Rate in Mbps
18267 + * @options: Enable/Disable DPMAC link cfg features (bitmap)
18268 + * @up: Link state
18270 +struct dpmac_link_state {
18272 + uint64_t options;
18277 + * dpmac_set_link_state() - Set the Ethernet link status
18278 + * @mc_io: Pointer to opaque I/O object
18279 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18280 + * @token: Token of DPMAC object
18281 + * @link_state: Link state configuration
18283 + * Return: '0' on Success; Error code otherwise.
18285 +int dpmac_set_link_state(struct fsl_mc_io *mc_io,
18286 + uint32_t cmd_flags,
18288 + struct dpmac_link_state *link_state);
18291 + * enum dpmac_counter - DPMAC counter types
18292 + * @DPMAC_CNT_ING_FRAME_64: counts 64-bytes frames, good or bad.
18293 + * @DPMAC_CNT_ING_FRAME_127: counts 65- to 127-bytes frames, good or bad.
18294 + * @DPMAC_CNT_ING_FRAME_255: counts 128- to 255-bytes frames, good or bad.
18295 + * @DPMAC_CNT_ING_FRAME_511: counts 256- to 511-bytes frames, good or bad.
18296 + * @DPMAC_CNT_ING_FRAME_1023: counts 512- to 1023-bytes frames, good or bad.
18297 + * @DPMAC_CNT_ING_FRAME_1518: counts 1024- to 1518-bytes frames, good or bad.
18298 + * @DPMAC_CNT_ING_FRAME_1519_MAX: counts 1519-bytes frames and larger
18299 + * (up to max frame length specified),
18301 + * @DPMAC_CNT_ING_FRAG: counts frames which are shorter than 64 bytes received
18302 + * with a wrong CRC
18303 + * @DPMAC_CNT_ING_JABBER: counts frames longer than the maximum frame length
18304 + * specified, with a bad frame check sequence.
18305 + * @DPMAC_CNT_ING_FRAME_DISCARD: counts dropped frames due to internal errors.
18306 + * Occurs when a receive FIFO overflows.
18307 + * Includes also frames truncated as a result of
18308 + * the receive FIFO overflow.
18309 + * @DPMAC_CNT_ING_ALIGN_ERR: counts frames with an alignment error
18310 + * (optional used for wrong SFD).
18311 + * @DPMAC_CNT_EGR_UNDERSIZED: counts frames transmitted that was less than 64
18312 + * bytes long with a good CRC.
18313 + * @DPMAC_CNT_ING_OVERSIZED: counts frames longer than the maximum frame length
18314 + * specified, with a good frame check sequence.
18315 + * @DPMAC_CNT_ING_VALID_PAUSE_FRAME: counts valid pause frames (regular and PFC)
18316 + * @DPMAC_CNT_EGR_VALID_PAUSE_FRAME: counts valid pause frames transmitted
18317 + * (regular and PFC).
18318 + * @DPMAC_CNT_ING_BYTE: counts bytes received except preamble for all valid
18319 + * frames and valid pause frames.
18320 + * @DPMAC_CNT_ING_MCAST_FRAME: counts received multicast frames.
18321 + * @DPMAC_CNT_ING_BCAST_FRAME: counts received broadcast frames.
18322 + * @DPMAC_CNT_ING_ALL_FRAME: counts each good or bad frames received.
18323 + * @DPMAC_CNT_ING_UCAST_FRAME: counts received unicast frames.
18324 + * @DPMAC_CNT_ING_ERR_FRAME: counts frames received with an error
18325 + * (except for undersized/fragment frame).
18326 + * @DPMAC_CNT_EGR_BYTE: counts bytes transmitted except preamble for all valid
18327 + * frames and valid pause frames transmitted.
18328 + * @DPMAC_CNT_EGR_MCAST_FRAME: counts transmitted multicast frames.
18329 + * @DPMAC_CNT_EGR_BCAST_FRAME: counts transmitted broadcast frames.
18330 + * @DPMAC_CNT_EGR_UCAST_FRAME: counts transmitted unicast frames.
18331 + * @DPMAC_CNT_EGR_ERR_FRAME: counts frames transmitted with an error.
18332 + * @DPMAC_CNT_ING_GOOD_FRAME: counts frames received without error, including
18334 + * @DPMAC_CNT_ENG_GOOD_FRAME: counts frames transmitted without error, including
18337 +enum dpmac_counter {
18338 + DPMAC_CNT_ING_FRAME_64,
18339 + DPMAC_CNT_ING_FRAME_127,
18340 + DPMAC_CNT_ING_FRAME_255,
18341 + DPMAC_CNT_ING_FRAME_511,
18342 + DPMAC_CNT_ING_FRAME_1023,
18343 + DPMAC_CNT_ING_FRAME_1518,
18344 + DPMAC_CNT_ING_FRAME_1519_MAX,
18345 + DPMAC_CNT_ING_FRAG,
18346 + DPMAC_CNT_ING_JABBER,
18347 + DPMAC_CNT_ING_FRAME_DISCARD,
18348 + DPMAC_CNT_ING_ALIGN_ERR,
18349 + DPMAC_CNT_EGR_UNDERSIZED,
18350 + DPMAC_CNT_ING_OVERSIZED,
18351 + DPMAC_CNT_ING_VALID_PAUSE_FRAME,
18352 + DPMAC_CNT_EGR_VALID_PAUSE_FRAME,
18353 + DPMAC_CNT_ING_BYTE,
18354 + DPMAC_CNT_ING_MCAST_FRAME,
18355 + DPMAC_CNT_ING_BCAST_FRAME,
18356 + DPMAC_CNT_ING_ALL_FRAME,
18357 + DPMAC_CNT_ING_UCAST_FRAME,
18358 + DPMAC_CNT_ING_ERR_FRAME,
18359 + DPMAC_CNT_EGR_BYTE,
18360 + DPMAC_CNT_EGR_MCAST_FRAME,
18361 + DPMAC_CNT_EGR_BCAST_FRAME,
18362 + DPMAC_CNT_EGR_UCAST_FRAME,
18363 + DPMAC_CNT_EGR_ERR_FRAME,
18364 + DPMAC_CNT_ING_GOOD_FRAME,
18365 + DPMAC_CNT_ENG_GOOD_FRAME
18369 + * dpmac_get_counter() - Read a specific DPMAC counter
18370 + * @mc_io: Pointer to opaque I/O object
18371 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18372 + * @token: Token of DPMAC object
18373 + * @type: The requested counter
18374 + * @counter: Returned counter value
18376 + * Return: The requested counter; '0' otherwise.
18378 +int dpmac_get_counter(struct fsl_mc_io *mc_io,
18379 + uint32_t cmd_flags,
18381 + enum dpmac_counter type,
18382 + uint64_t *counter);
18384 +#endif /* __FSL_DPMAC_H */
18385 diff --git a/drivers/net/dpaa2/mc/fsl_dpmac_cmd.h b/drivers/net/dpaa2/mc/fsl_dpmac_cmd.h
18386 new file mode 100644
18387 index 0000000..dc00590
18389 +++ b/drivers/net/dpaa2/mc/fsl_dpmac_cmd.h
18391 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
18393 + * Redistribution and use in source and binary forms, with or without
18394 + * modification, are permitted provided that the following conditions are met:
18395 + * * Redistributions of source code must retain the above copyright
18396 + * notice, this list of conditions and the following disclaimer.
18397 + * * Redistributions in binary form must reproduce the above copyright
18398 + * notice, this list of conditions and the following disclaimer in the
18399 + * documentation and/or other materials provided with the distribution.
18400 + * * Neither the name of the above-listed copyright holders nor the
18401 + * names of any contributors may be used to endorse or promote products
18402 + * derived from this software without specific prior written permission.
18405 + * ALTERNATIVELY, this software may be distributed under the terms of the
18406 + * GNU General Public License ("GPL") as published by the Free Software
18407 + * Foundation, either version 2 of that License or (at your option) any
18410 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18411 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18412 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18413 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
18414 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18415 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18416 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18417 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
18418 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
18419 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
18420 + * POSSIBILITY OF SUCH DAMAGE.
18422 +#ifndef _FSL_DPMAC_CMD_H
18423 +#define _FSL_DPMAC_CMD_H
18425 +/* DPMAC Version */
18426 +#define DPMAC_VER_MAJOR 3
18427 +#define DPMAC_VER_MINOR 2
18430 +#define DPMAC_CMDID_CLOSE 0x800
18431 +#define DPMAC_CMDID_OPEN 0x80c
18432 +#define DPMAC_CMDID_CREATE 0x90c
18433 +#define DPMAC_CMDID_DESTROY 0x900
18435 +#define DPMAC_CMDID_GET_ATTR 0x004
18436 +#define DPMAC_CMDID_RESET 0x005
18438 +#define DPMAC_CMDID_SET_IRQ 0x010
18439 +#define DPMAC_CMDID_GET_IRQ 0x011
18440 +#define DPMAC_CMDID_SET_IRQ_ENABLE 0x012
18441 +#define DPMAC_CMDID_GET_IRQ_ENABLE 0x013
18442 +#define DPMAC_CMDID_SET_IRQ_MASK 0x014
18443 +#define DPMAC_CMDID_GET_IRQ_MASK 0x015
18444 +#define DPMAC_CMDID_GET_IRQ_STATUS 0x016
18445 +#define DPMAC_CMDID_CLEAR_IRQ_STATUS 0x017
18447 +#define DPMAC_CMDID_MDIO_READ 0x0c0
18448 +#define DPMAC_CMDID_MDIO_WRITE 0x0c1
18449 +#define DPMAC_CMDID_GET_LINK_CFG 0x0c2
18450 +#define DPMAC_CMDID_SET_LINK_STATE 0x0c3
18451 +#define DPMAC_CMDID_GET_COUNTER 0x0c4
18453 +/* cmd, param, offset, width, type, arg_name */
18454 +#define DPMAC_CMD_CREATE(cmd, cfg) \
18455 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->mac_id)
18457 +/* cmd, param, offset, width, type, arg_name */
18458 +#define DPMAC_CMD_OPEN(cmd, dpmac_id) \
18459 + MC_CMD_OP(cmd, 0, 0, 32, int, dpmac_id)
18461 +/* cmd, param, offset, width, type, arg_name */
18462 +#define DPMAC_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
18464 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
18465 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
18466 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
18467 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
18470 +/* cmd, param, offset, width, type, arg_name */
18471 +#define DPMAC_CMD_GET_IRQ(cmd, irq_index) \
18472 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
18474 +/* cmd, param, offset, width, type, arg_name */
18475 +#define DPMAC_RSP_GET_IRQ(cmd, type, irq_cfg) \
18477 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
18478 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
18479 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
18480 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
18483 +/* cmd, param, offset, width, type, arg_name */
18484 +#define DPMAC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
18486 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
18487 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
18490 +/* cmd, param, offset, width, type, arg_name */
18491 +#define DPMAC_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
18492 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
18494 +/* cmd, param, offset, width, type, arg_name */
18495 +#define DPMAC_RSP_GET_IRQ_ENABLE(cmd, en) \
18496 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
18498 +/* cmd, param, offset, width, type, arg_name */
18499 +#define DPMAC_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
18501 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\
18502 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
18505 +/* cmd, param, offset, width, type, arg_name */
18506 +#define DPMAC_CMD_GET_IRQ_MASK(cmd, irq_index) \
18507 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
18509 +/* cmd, param, offset, width, type, arg_name */
18510 +#define DPMAC_RSP_GET_IRQ_MASK(cmd, mask) \
18511 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
18513 +/* cmd, param, offset, width, type, arg_name */
18514 +#define DPMAC_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
18516 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
18517 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
18520 +/* cmd, param, offset, width, type, arg_name */
18521 +#define DPMAC_RSP_GET_IRQ_STATUS(cmd, status) \
18522 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
18524 +/* cmd, param, offset, width, type, arg_name */
18525 +#define DPMAC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
18527 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
18528 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
18531 +/* cmd, param, offset, width, type, arg_name */
18532 +#define DPMAC_RSP_GET_ATTRIBUTES(cmd, attr) \
18534 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->phy_id);\
18535 + MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
18536 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
18537 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
18538 + MC_RSP_OP(cmd, 1, 32, 8, enum dpmac_link_type, attr->link_type);\
18539 + MC_RSP_OP(cmd, 1, 40, 8, enum dpmac_eth_if, attr->eth_if);\
18540 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->max_rate);\
18543 +/* cmd, param, offset, width, type, arg_name */
18544 +#define DPMAC_CMD_MDIO_READ(cmd, cfg) \
18546 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \
18547 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \
18550 +/* cmd, param, offset, width, type, arg_name */
18551 +#define DPMAC_RSP_MDIO_READ(cmd, data) \
18552 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, data)
18554 +/* cmd, param, offset, width, type, arg_name */
18555 +#define DPMAC_CMD_MDIO_WRITE(cmd, cfg) \
18557 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->phy_addr); \
18558 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->reg); \
18559 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->data); \
18562 +/* cmd, param, offset, width, type, arg_name */
18563 +#define DPMAC_RSP_GET_LINK_CFG(cmd, cfg) \
18565 + MC_RSP_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \
18566 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \
18569 +/* cmd, param, offset, width, type, arg_name */
18570 +#define DPMAC_CMD_SET_LINK_STATE(cmd, cfg) \
18572 + MC_CMD_OP(cmd, 0, 0, 64, uint64_t, cfg->options); \
18573 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate); \
18574 + MC_CMD_OP(cmd, 2, 0, 1, int, cfg->up); \
18577 +/* cmd, param, offset, width, type, arg_name */
18578 +#define DPMAC_CMD_GET_COUNTER(cmd, type) \
18579 + MC_CMD_OP(cmd, 0, 0, 8, enum dpmac_counter, type)
18581 +/* cmd, param, offset, width, type, arg_name */
18582 +#define DPMAC_RSP_GET_COUNTER(cmd, counter) \
18583 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
18585 +#endif /* _FSL_DPMAC_CMD_H */
18586 diff --git a/drivers/net/dpaa2/mc/fsl_dpmcp.h b/drivers/net/dpaa2/mc/fsl_dpmcp.h
18587 new file mode 100644
18588 index 0000000..80f238e
18590 +++ b/drivers/net/dpaa2/mc/fsl_dpmcp.h
18592 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
18594 + * Redistribution and use in source and binary forms, with or without
18595 + * modification, are permitted provided that the following conditions are met:
18596 + * * Redistributions of source code must retain the above copyright
18597 + * notice, this list of conditions and the following disclaimer.
18598 + * * Redistributions in binary form must reproduce the above copyright
18599 + * notice, this list of conditions and the following disclaimer in the
18600 + * documentation and/or other materials provided with the distribution.
18601 + * * Neither the name of the above-listed copyright holders nor the
18602 + * names of any contributors may be used to endorse or promote products
18603 + * derived from this software without specific prior written permission.
18606 + * ALTERNATIVELY, this software may be distributed under the terms of the
18607 + * GNU General Public License ("GPL") as published by the Free Software
18608 + * Foundation, either version 2 of that License or (at your option) any
18611 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18612 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18613 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18614 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
18615 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18616 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18617 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18618 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
18619 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
18620 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
18621 + * POSSIBILITY OF SUCH DAMAGE.
18623 +#ifndef __FSL_DPMCP_H
18624 +#define __FSL_DPMCP_H
18626 +/* Data Path Management Command Portal API
18627 + * Contains initialization APIs and runtime control APIs for DPMCP
18633 + * dpmcp_open() - Open a control session for the specified object.
18634 + * @mc_io: Pointer to MC portal's I/O object
18635 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18636 + * @dpmcp_id: DPMCP unique ID
18637 + * @token: Returned token; use in subsequent API calls
18639 + * This function can be used to open a control session for an
18640 + * already created object; an object may have been declared in
18641 + * the DPL or by calling the dpmcp_create function.
18642 + * This function returns a unique authentication token,
18643 + * associated with the specific object ID and the specific MC
18644 + * portal; this token must be used in all subsequent commands for
18645 + * this specific object
18647 + * Return: '0' on Success; Error code otherwise.
18649 +int dpmcp_open(struct fsl_mc_io *mc_io,
18650 + uint32_t cmd_flags,
18652 + uint16_t *token);
18655 + * Get portal ID from pool
18657 +#define DPMCP_GET_PORTAL_ID_FROM_POOL (-1)
18660 + * dpmcp_close() - Close the control session of the object
18661 + * @mc_io: Pointer to MC portal's I/O object
18662 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18663 + * @token: Token of DPMCP object
18665 + * After this function is called, no further operations are
18666 + * allowed on the object without opening a new control session.
18668 + * Return: '0' on Success; Error code otherwise.
18670 +int dpmcp_close(struct fsl_mc_io *mc_io,
18671 + uint32_t cmd_flags,
18675 + * struct dpmcp_cfg - Structure representing DPMCP configuration
18676 + * @portal_id: Portal ID; 'DPMCP_GET_PORTAL_ID_FROM_POOL' to get the portal ID
18679 +struct dpmcp_cfg {
18684 + * dpmcp_create() - Create the DPMCP object.
18685 + * @mc_io: Pointer to MC portal's I/O object
18686 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18687 + * @cfg: Configuration structure
18688 + * @token: Returned token; use in subsequent API calls
18690 + * Create the DPMCP object, allocate required resources and
18691 + * perform required initialization.
18693 + * The object can be created either by declaring it in the
18694 + * DPL file, or by calling this function.
18695 + * This function returns a unique authentication token,
18696 + * associated with the specific object ID and the specific MC
18697 + * portal; this token must be used in all subsequent calls to
18698 + * this specific object. For objects that are created using the
18699 + * DPL file, call dpmcp_open function to get an authentication
18702 + * Return: '0' on Success; Error code otherwise.
18704 +int dpmcp_create(struct fsl_mc_io *mc_io,
18705 + uint32_t cmd_flags,
18706 + const struct dpmcp_cfg *cfg,
18707 + uint16_t *token);
18710 + * dpmcp_destroy() - Destroy the DPMCP object and release all its resources.
18711 + * @mc_io: Pointer to MC portal's I/O object
18712 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18713 + * @token: Token of DPMCP object
18715 + * Return: '0' on Success; error code otherwise.
18717 +int dpmcp_destroy(struct fsl_mc_io *mc_io,
18718 + uint32_t cmd_flags,
18722 + * dpmcp_reset() - Reset the DPMCP, returns the object to initial state.
18723 + * @mc_io: Pointer to MC portal's I/O object
18724 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18725 + * @token: Token of DPMCP object
18727 + * Return: '0' on Success; Error code otherwise.
18729 +int dpmcp_reset(struct fsl_mc_io *mc_io,
18730 + uint32_t cmd_flags,
18740 +#define DPMCP_IRQ_INDEX 0
18742 + * irq event - Indicates that the link state changed
18744 +#define DPMCP_IRQ_EVENT_CMD_DONE 0x00000001
18747 + * struct dpmcp_irq_cfg - IRQ configuration
18748 + * @addr: Address that must be written to signal a message-based interrupt
18749 + * @val: Value to write into irq_addr address
18750 + * @irq_num: A user defined number associated with this IRQ
18752 +struct dpmcp_irq_cfg {
18759 + * dpmcp_set_irq() - Set IRQ information for the DPMCP to trigger an interrupt.
18760 + * @mc_io: Pointer to MC portal's I/O object
18761 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18762 + * @token: Token of DPMCP object
18763 + * @irq_index: Identifies the interrupt index to configure
18764 + * @irq_cfg: IRQ configuration
18766 + * Return: '0' on Success; Error code otherwise.
18768 +int dpmcp_set_irq(struct fsl_mc_io *mc_io,
18769 + uint32_t cmd_flags,
18771 + uint8_t irq_index,
18772 + struct dpmcp_irq_cfg *irq_cfg);
18775 + * dpmcp_get_irq() - Get IRQ information from the DPMCP.
18776 + * @mc_io: Pointer to MC portal's I/O object
18777 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18778 + * @token: Token of DPMCP object
18779 + * @irq_index: The interrupt index to configure
18780 + * @type: Interrupt type: 0 represents message interrupt
18781 + * type (both irq_addr and irq_val are valid)
18782 + * @irq_cfg: IRQ attributes
18784 + * Return: '0' on Success; Error code otherwise.
18786 +int dpmcp_get_irq(struct fsl_mc_io *mc_io,
18787 + uint32_t cmd_flags,
18789 + uint8_t irq_index,
18791 + struct dpmcp_irq_cfg *irq_cfg);
18794 + * dpmcp_set_irq_enable() - Set overall interrupt state.
18795 + * @mc_io: Pointer to MC portal's I/O object
18796 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18797 + * @token: Token of DPMCP object
18798 + * @irq_index: The interrupt index to configure
18799 + * @en: Interrupt state - enable = 1, disable = 0
18801 + * Allows GPP software to control when interrupts are generated.
18802 + * Each interrupt can have up to 32 causes. The enable/disable control's the
18803 + * overall interrupt state. if the interrupt is disabled no causes will cause
18806 + * Return: '0' on Success; Error code otherwise.
18808 +int dpmcp_set_irq_enable(struct fsl_mc_io *mc_io,
18809 + uint32_t cmd_flags,
18811 + uint8_t irq_index,
18815 + * dpmcp_get_irq_enable() - Get overall interrupt state
18816 + * @mc_io: Pointer to MC portal's I/O object
18817 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18818 + * @token: Token of DPMCP object
18819 + * @irq_index: The interrupt index to configure
18820 + * @en: Returned interrupt state - enable = 1, disable = 0
18822 + * Return: '0' on Success; Error code otherwise.
18824 +int dpmcp_get_irq_enable(struct fsl_mc_io *mc_io,
18825 + uint32_t cmd_flags,
18827 + uint8_t irq_index,
18831 + * dpmcp_set_irq_mask() - Set interrupt mask.
18832 + * @mc_io: Pointer to MC portal's I/O object
18833 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18834 + * @token: Token of DPMCP object
18835 + * @irq_index: The interrupt index to configure
18836 + * @mask: Event mask to trigger interrupt;
18838 + * 0 = ignore event
18839 + * 1 = consider event for asserting IRQ
18841 + * Every interrupt can have up to 32 causes and the interrupt model supports
18842 + * masking/unmasking each cause independently
18844 + * Return: '0' on Success; Error code otherwise.
18846 +int dpmcp_set_irq_mask(struct fsl_mc_io *mc_io,
18847 + uint32_t cmd_flags,
18849 + uint8_t irq_index,
18853 + * dpmcp_get_irq_mask() - Get interrupt mask.
18854 + * @mc_io: Pointer to MC portal's I/O object
18855 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18856 + * @token: Token of DPMCP object
18857 + * @irq_index: The interrupt index to configure
18858 + * @mask: Returned event mask to trigger interrupt
18860 + * Every interrupt can have up to 32 causes and the interrupt model supports
18861 + * masking/unmasking each cause independently
18863 + * Return: '0' on Success; Error code otherwise.
18865 +int dpmcp_get_irq_mask(struct fsl_mc_io *mc_io,
18866 + uint32_t cmd_flags,
18868 + uint8_t irq_index,
18872 + * dpmcp_get_irq_status() - Get the current status of any pending interrupts.
18874 + * @mc_io: Pointer to MC portal's I/O object
18875 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18876 + * @token: Token of DPMCP object
18877 + * @irq_index: The interrupt index to configure
18878 + * @status: Returned interrupts status - one bit per cause:
18879 + * 0 = no interrupt pending
18880 + * 1 = interrupt pending
18882 + * Return: '0' on Success; Error code otherwise.
18884 +int dpmcp_get_irq_status(struct fsl_mc_io *mc_io,
18885 + uint32_t cmd_flags,
18887 + uint8_t irq_index,
18888 + uint32_t *status);
18891 + * struct dpmcp_attr - Structure representing DPMCP attributes
18892 + * @id: DPMCP object ID
18893 + * @version: DPMCP version
18895 +struct dpmcp_attr {
18898 + * struct version - Structure representing DPMCP version
18899 + * @major: DPMCP major version
18900 + * @minor: DPMCP minor version
18909 + * dpmcp_get_attributes - Retrieve DPMCP attributes.
18911 + * @mc_io: Pointer to MC portal's I/O object
18912 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
18913 + * @token: Token of DPMCP object
18914 + * @attr: Returned object's attributes
18916 + * Return: '0' on Success; Error code otherwise.
18918 +int dpmcp_get_attributes(struct fsl_mc_io *mc_io,
18919 + uint32_t cmd_flags,
18921 + struct dpmcp_attr *attr);
18923 +#endif /* __FSL_DPMCP_H */
18924 diff --git a/drivers/net/dpaa2/mc/fsl_dpmcp_cmd.h b/drivers/net/dpaa2/mc/fsl_dpmcp_cmd.h
18925 new file mode 100644
18926 index 0000000..8f710bd
18928 +++ b/drivers/net/dpaa2/mc/fsl_dpmcp_cmd.h
18930 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
18932 + * Redistribution and use in source and binary forms, with or without
18933 + * modification, are permitted provided that the following conditions are met:
18934 + * * Redistributions of source code must retain the above copyright
18935 + * notice, this list of conditions and the following disclaimer.
18936 + * * Redistributions in binary form must reproduce the above copyright
18937 + * notice, this list of conditions and the following disclaimer in the
18938 + * documentation and/or other materials provided with the distribution.
18939 + * * Neither the name of the above-listed copyright holders nor the
18940 + * names of any contributors may be used to endorse or promote products
18941 + * derived from this software without specific prior written permission.
18944 + * ALTERNATIVELY, this software may be distributed under the terms of the
18945 + * GNU General Public License ("GPL") as published by the Free Software
18946 + * Foundation, either version 2 of that License or (at your option) any
18949 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18950 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18951 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18952 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
18953 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18954 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18955 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
18956 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
18957 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
18958 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
18959 + * POSSIBILITY OF SUCH DAMAGE.
18961 +#ifndef _FSL_DPMCP_CMD_H
18962 +#define _FSL_DPMCP_CMD_H
18964 +/* DPMCP Version */
18965 +#define DPMCP_VER_MAJOR 3
18966 +#define DPMCP_VER_MINOR 0
18969 +#define DPMCP_CMDID_CLOSE 0x800
18970 +#define DPMCP_CMDID_OPEN 0x80b
18971 +#define DPMCP_CMDID_CREATE 0x90b
18972 +#define DPMCP_CMDID_DESTROY 0x900
18974 +#define DPMCP_CMDID_GET_ATTR 0x004
18975 +#define DPMCP_CMDID_RESET 0x005
18977 +#define DPMCP_CMDID_SET_IRQ 0x010
18978 +#define DPMCP_CMDID_GET_IRQ 0x011
18979 +#define DPMCP_CMDID_SET_IRQ_ENABLE 0x012
18980 +#define DPMCP_CMDID_GET_IRQ_ENABLE 0x013
18981 +#define DPMCP_CMDID_SET_IRQ_MASK 0x014
18982 +#define DPMCP_CMDID_GET_IRQ_MASK 0x015
18983 +#define DPMCP_CMDID_GET_IRQ_STATUS 0x016
18985 +/* cmd, param, offset, width, type, arg_name */
18986 +#define DPMCP_CMD_OPEN(cmd, dpmcp_id) \
18987 + MC_CMD_OP(cmd, 0, 0, 32, int, dpmcp_id)
18989 +/* cmd, param, offset, width, type, arg_name */
18990 +#define DPMCP_CMD_CREATE(cmd, cfg) \
18991 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->portal_id)
18993 +/* cmd, param, offset, width, type, arg_name */
18994 +#define DPMCP_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
18996 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
18997 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
18998 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
18999 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
19002 +/* cmd, param, offset, width, type, arg_name */
19003 +#define DPMCP_CMD_GET_IRQ(cmd, irq_index) \
19004 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
19006 +/* cmd, param, offset, width, type, arg_name */
19007 +#define DPMCP_RSP_GET_IRQ(cmd, type, irq_cfg) \
19009 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
19010 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
19011 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
19012 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
19015 +/* cmd, param, offset, width, type, arg_name */
19016 +#define DPMCP_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
19018 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
19019 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
19022 +/* cmd, param, offset, width, type, arg_name */
19023 +#define DPMCP_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
19024 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
19026 +/* cmd, param, offset, width, type, arg_name */
19027 +#define DPMCP_RSP_GET_IRQ_ENABLE(cmd, en) \
19028 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
19030 +/* cmd, param, offset, width, type, arg_name */
19031 +#define DPMCP_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
19033 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\
19034 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
19037 +/* cmd, param, offset, width, type, arg_name */
19038 +#define DPMCP_CMD_GET_IRQ_MASK(cmd, irq_index) \
19039 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
19041 +/* cmd, param, offset, width, type, arg_name */
19042 +#define DPMCP_RSP_GET_IRQ_MASK(cmd, mask) \
19043 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
19045 +/* cmd, param, offset, width, type, arg_name */
19046 +#define DPMCP_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
19048 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
19049 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
19052 +/* cmd, param, offset, width, type, arg_name */
19053 +#define DPMCP_RSP_GET_IRQ_STATUS(cmd, status) \
19054 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
19056 +/* cmd, param, offset, width, type, arg_name */
19057 +#define DPMCP_RSP_GET_ATTRIBUTES(cmd, attr) \
19059 + MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
19060 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
19061 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
19064 +#endif /* _FSL_DPMCP_CMD_H */
19065 diff --git a/drivers/net/dpaa2/mc/fsl_dpmng.h b/drivers/net/dpaa2/mc/fsl_dpmng.h
19066 new file mode 100644
19067 index 0000000..4468dea
19069 +++ b/drivers/net/dpaa2/mc/fsl_dpmng.h
19071 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
19073 + * Redistribution and use in source and binary forms, with or without
19074 + * modification, are permitted provided that the following conditions are met:
19075 + * * Redistributions of source code must retain the above copyright
19076 + * notice, this list of conditions and the following disclaimer.
19077 + * * Redistributions in binary form must reproduce the above copyright
19078 + * notice, this list of conditions and the following disclaimer in the
19079 + * documentation and/or other materials provided with the distribution.
19080 + * * Neither the name of the above-listed copyright holders nor the
19081 + * names of any contributors may be used to endorse or promote products
19082 + * derived from this software without specific prior written permission.
19085 + * ALTERNATIVELY, this software may be distributed under the terms of the
19086 + * GNU General Public License ("GPL") as published by the Free Software
19087 + * Foundation, either version 2 of that License or (at your option) any
19090 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19091 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19092 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19093 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19094 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19095 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19096 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19097 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19098 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19099 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
19100 + * POSSIBILITY OF SUCH DAMAGE.
19102 +#ifndef __FSL_DPMNG_H
19103 +#define __FSL_DPMNG_H
19105 +/* Management Complex General API
19106 + * Contains general API for the Management Complex firmware
19112 + * Management Complex firmware version information
19114 +#define MC_VER_MAJOR 9
19115 +#define MC_VER_MINOR 0
19118 + * struct mc_versoin
19119 + * @major: Major version number: incremented on API compatibility changes
19120 + * @minor: Minor version number: incremented on API additions (that are
19121 + * backward compatible); reset when major version is incremented
19122 + * @revision: Internal revision number: incremented on implementation changes
19123 + * and/or bug fixes that have no impact on API
19125 +struct mc_version {
19128 + uint32_t revision;
19132 + * mc_get_version() - Retrieves the Management Complex firmware
19133 + * version information
19134 + * @mc_io: Pointer to opaque I/O object
19135 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19136 + * @mc_ver_info: Returned version information structure
19138 + * Return: '0' on Success; Error code otherwise.
19140 +int mc_get_version(struct fsl_mc_io *mc_io,
19141 + uint32_t cmd_flags,
19142 + struct mc_version *mc_ver_info);
19144 +#endif /* __FSL_DPMNG_H */
19145 diff --git a/drivers/net/dpaa2/mc/fsl_dpmng_cmd.h b/drivers/net/dpaa2/mc/fsl_dpmng_cmd.h
19146 new file mode 100644
19147 index 0000000..c34ca3a
19149 +++ b/drivers/net/dpaa2/mc/fsl_dpmng_cmd.h
19151 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
19153 + * Redistribution and use in source and binary forms, with or without
19154 + * modification, are permitted provided that the following conditions are met:
19155 + * * Redistributions of source code must retain the above copyright
19156 + * notice, this list of conditions and the following disclaimer.
19157 + * * Redistributions in binary form must reproduce the above copyright
19158 + * notice, this list of conditions and the following disclaimer in the
19159 + * documentation and/or other materials provided with the distribution.
19160 + * * Neither the name of the above-listed copyright holders nor the
19161 + * names of any contributors may be used to endorse or promote products
19162 + * derived from this software without specific prior written permission.
19165 + * ALTERNATIVELY, this software may be distributed under the terms of the
19166 + * GNU General Public License ("GPL") as published by the Free Software
19167 + * Foundation, either version 2 of that License or (at your option) any
19170 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19171 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19172 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19173 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19174 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19175 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19176 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19177 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19178 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19179 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
19180 + * POSSIBILITY OF SUCH DAMAGE.
19182 +#ifndef __FSL_DPMNG_CMD_H
19183 +#define __FSL_DPMNG_CMD_H
19186 +#define DPMNG_CMDID_GET_VERSION 0x831
19188 +/* cmd, param, offset, width, type, arg_name */
19189 +#define DPMNG_RSP_GET_VERSION(cmd, mc_ver_info) \
19191 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mc_ver_info->revision); \
19192 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, mc_ver_info->major); \
19193 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, mc_ver_info->minor); \
19196 +#endif /* __FSL_DPMNG_CMD_H */
19197 diff --git a/drivers/net/dpaa2/mc/fsl_dpni.h b/drivers/net/dpaa2/mc/fsl_dpni.h
19198 new file mode 100644
19199 index 0000000..c820086
19201 +++ b/drivers/net/dpaa2/mc/fsl_dpni.h
19203 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
19205 + * Redistribution and use in source and binary forms, with or without
19206 + * modification, are permitted provided that the following conditions are met:
19207 + * * Redistributions of source code must retain the above copyright
19208 + * notice, this list of conditions and the following disclaimer.
19209 + * * Redistributions in binary form must reproduce the above copyright
19210 + * notice, this list of conditions and the following disclaimer in the
19211 + * documentation and/or other materials provided with the distribution.
19212 + * * Neither the name of the above-listed copyright holders nor the
19213 + * names of any contributors may be used to endorse or promote products
19214 + * derived from this software without specific prior written permission.
19217 + * ALTERNATIVELY, this software may be distributed under the terms of the
19218 + * GNU General Public License ("GPL") as published by the Free Software
19219 + * Foundation, either version 2 of that License or (at your option) any
19222 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19223 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19224 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19225 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
19226 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19227 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19228 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19229 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
19230 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
19231 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
19232 + * POSSIBILITY OF SUCH DAMAGE.
19234 +#ifndef __FSL_DPNI_H
19235 +#define __FSL_DPNI_H
19237 +#include <fsl_dpkg.h>
19242 + * Data Path Network Interface API
19243 + * Contains initialization APIs and runtime control APIs for DPNI
19246 +/** General DPNI macros */
19249 + * Maximum number of traffic classes
19251 +#define DPNI_MAX_TC 8
19253 + * Maximum number of buffer pools per DPNI
19255 +#define DPNI_MAX_DPBP 8
19257 + * Maximum number of storage-profiles per DPNI
19259 +#define DPNI_MAX_SP 2
19262 + * All traffic classes considered; see dpni_set_rx_flow()
19264 +#define DPNI_ALL_TCS (uint8_t)(-1)
19266 + * All flows within traffic class considered; see dpni_set_rx_flow()
19268 +#define DPNI_ALL_TC_FLOWS (uint16_t)(-1)
19270 + * Generate new flow ID; see dpni_set_tx_flow()
19272 +#define DPNI_NEW_FLOW_ID (uint16_t)(-1)
19273 +/* use for common tx-conf queue; see dpni_set_tx_conf_<x>() */
19274 +#define DPNI_COMMON_TX_CONF (uint16_t)(-1)
19277 + * dpni_open() - Open a control session for the specified object
19278 + * @mc_io: Pointer to MC portal's I/O object
19279 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19280 + * @dpni_id: DPNI unique ID
19281 + * @token: Returned token; use in subsequent API calls
19283 + * This function can be used to open a control session for an
19284 + * already created object; an object may have been declared in
19285 + * the DPL or by calling the dpni_create() function.
19286 + * This function returns a unique authentication token,
19287 + * associated with the specific object ID and the specific MC
19288 + * portal; this token must be used in all subsequent commands for
19289 + * this specific object.
19291 + * Return: '0' on Success; Error code otherwise.
19293 +int dpni_open(struct fsl_mc_io *mc_io,
19294 + uint32_t cmd_flags,
19296 + uint16_t *token);
19299 + * dpni_close() - Close the control session of the object
19300 + * @mc_io: Pointer to MC portal's I/O object
19301 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19302 + * @token: Token of DPNI object
19304 + * After this function is called, no further operations are
19305 + * allowed on the object without opening a new control session.
19307 + * Return: '0' on Success; Error code otherwise.
19309 +int dpni_close(struct fsl_mc_io *mc_io,
19310 + uint32_t cmd_flags,
19313 +/* DPNI configuration options */
19316 + * Allow different distribution key profiles for different traffic classes;
19317 + * if not set, a single key profile is assumed
19319 +#define DPNI_OPT_ALLOW_DIST_KEY_PER_TC 0x00000001
19322 + * Disable all non-error transmit confirmation; error frames are reported
19323 + * back to a common Tx error queue
19325 +#define DPNI_OPT_TX_CONF_DISABLED 0x00000002
19328 + * Disable per-sender private Tx confirmation/error queue
19330 +#define DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED 0x00000004
19333 + * Support distribution based on hashed key;
19334 + * allows statistical distribution over receive queues in a traffic class
19336 +#define DPNI_OPT_DIST_HASH 0x00000010
19339 + * DEPRECATED - if this flag is selected and and all new 'max_fs_entries' are
19340 + * '0' then backward compatibility is preserved;
19341 + * Support distribution based on flow steering;
19342 + * allows explicit control of distribution over receive queues in a traffic
19345 +#define DPNI_OPT_DIST_FS 0x00000020
19348 + * Unicast filtering support
19350 +#define DPNI_OPT_UNICAST_FILTER 0x00000080
19352 + * Multicast filtering support
19354 +#define DPNI_OPT_MULTICAST_FILTER 0x00000100
19356 + * VLAN filtering support
19358 +#define DPNI_OPT_VLAN_FILTER 0x00000200
19360 + * Support IP reassembly on received packets
19362 +#define DPNI_OPT_IPR 0x00000800
19364 + * Support IP fragmentation on transmitted packets
19366 +#define DPNI_OPT_IPF 0x00001000
19368 + * VLAN manipulation support
19370 +#define DPNI_OPT_VLAN_MANIPULATION 0x00010000
19372 + * Support masking of QoS lookup keys
19374 +#define DPNI_OPT_QOS_MASK_SUPPORT 0x00020000
19376 + * Support masking of Flow Steering lookup keys
19378 +#define DPNI_OPT_FS_MASK_SUPPORT 0x00040000
19381 + * struct dpni_extended_cfg - Structure representing extended DPNI configuration
19382 + * @tc_cfg: TCs configuration
19383 + * @ipr_cfg: IP reassembly configuration
19385 +struct dpni_extended_cfg {
19387 + * struct tc_cfg - TC configuration
19388 + * @max_dist: Maximum distribution size for Rx traffic class;
19389 + * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
19390 + * 112,128,192,224,256,384,448,512,768,896,1024;
19391 + * value '0' will be treated as '1'.
19392 + * other unsupported values will be round down to the nearest
19393 + * supported value.
19394 + * @max_fs_entries: Maximum FS entries for Rx traffic class;
19395 + * '0' means no support for this TC;
19398 + uint16_t max_dist;
19399 + uint16_t max_fs_entries;
19400 + } tc_cfg[DPNI_MAX_TC];
19402 + * struct ipr_cfg - Structure representing IP reassembly configuration
19403 + * @max_reass_frm_size: Maximum size of the reassembled frame
19404 + * @min_frag_size_ipv4: Minimum fragment size of IPv4 fragments
19405 + * @min_frag_size_ipv6: Minimum fragment size of IPv6 fragments
19406 + * @max_open_frames_ipv4: Maximum concurrent IPv4 packets in reassembly
19408 + * @max_open_frames_ipv6: Maximum concurrent IPv6 packets in reassembly
19412 + uint16_t max_reass_frm_size;
19413 + uint16_t min_frag_size_ipv4;
19414 + uint16_t min_frag_size_ipv6;
19415 + uint16_t max_open_frames_ipv4;
19416 + uint16_t max_open_frames_ipv6;
19421 + * dpni_prepare_extended_cfg() - function prepare extended parameters
19422 + * @cfg: extended structure
19423 + * @ext_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
19425 + * This function has to be called before dpni_create()
19427 +int dpni_prepare_extended_cfg(const struct dpni_extended_cfg *cfg,
19428 + uint8_t *ext_cfg_buf);
19431 + * struct dpni_cfg - Structure representing DPNI configuration
19432 + * @mac_addr: Primary MAC address
19433 + * @adv: Advanced parameters; default is all zeros;
19434 + * use this structure to change default settings
19437 + uint8_t mac_addr[6];
19439 + * struct adv - Advanced parameters
19440 + * @options: Mask of available options; use 'DPNI_OPT_<X>' values
19441 + * @start_hdr: Selects the packet starting header for parsing;
19442 + * 'NET_PROT_NONE' is treated as default: 'NET_PROT_ETH'
19443 + * @max_senders: Maximum number of different senders; used as the number
19444 + * of dedicated Tx flows; Non-power-of-2 values are rounded
19445 + * up to the next power-of-2 value as hardware demands it;
19446 + * '0' will be treated as '1'
19447 + * @max_tcs: Maximum number of traffic classes (for both Tx and Rx);
19448 + * '0' will e treated as '1'
19449 + * @max_unicast_filters: Maximum number of unicast filters;
19450 + * '0' is treated as '16'
19451 + * @max_multicast_filters: Maximum number of multicast filters;
19452 + * '0' is treated as '64'
19453 + * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in
19454 + * the QoS table; '0' is treated as '64'
19455 + * @max_qos_key_size: Maximum key size for the QoS look-up;
19456 + * '0' is treated as '24' which is enough for IPv4
19458 + * @max_dist_key_size: Maximum key size for the distribution;
19459 + * '0' is treated as '24' which is enough for IPv4 5-tuple
19460 + * @max_policers: Maximum number of policers;
19461 + * should be between '0' and max_tcs
19462 + * @max_congestion_ctrl: Maximum number of congestion control groups
19463 + * (CGs); covers early drop and congestion notification
19465 + * should be between '0' and ('max_tcs' + 'max_senders')
19466 + * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory
19467 + * filled with the extended configuration by calling
19468 + * dpni_prepare_extended_cfg()
19471 + uint32_t options;
19472 + enum net_prot start_hdr;
19473 + uint8_t max_senders;
19475 + uint8_t max_unicast_filters;
19476 + uint8_t max_multicast_filters;
19477 + uint8_t max_vlan_filters;
19478 + uint8_t max_qos_entries;
19479 + uint8_t max_qos_key_size;
19480 + uint8_t max_dist_key_size;
19481 + uint8_t max_policers;
19482 + uint8_t max_congestion_ctrl;
19483 + uint64_t ext_cfg_iova;
19488 + * dpni_create() - Create the DPNI object
19489 + * @mc_io: Pointer to MC portal's I/O object
19490 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19491 + * @cfg: Configuration structure
19492 + * @token: Returned token; use in subsequent API calls
19494 + * Create the DPNI object, allocate required resources and
19495 + * perform required initialization.
19497 + * The object can be created either by declaring it in the
19498 + * DPL file, or by calling this function.
19500 + * This function returns a unique authentication token,
19501 + * associated with the specific object ID and the specific MC
19502 + * portal; this token must be used in all subsequent calls to
19503 + * this specific object. For objects that are created using the
19504 + * DPL file, call dpni_open() function to get an authentication
19507 + * Return: '0' on Success; Error code otherwise.
19509 +int dpni_create(struct fsl_mc_io *mc_io,
19510 + uint32_t cmd_flags,
19511 + const struct dpni_cfg *cfg,
19512 + uint16_t *token);
19515 + * dpni_destroy() - Destroy the DPNI object and release all its resources.
19516 + * @mc_io: Pointer to MC portal's I/O object
19517 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19518 + * @token: Token of DPNI object
19520 + * Return: '0' on Success; error code otherwise.
19522 +int dpni_destroy(struct fsl_mc_io *mc_io,
19523 + uint32_t cmd_flags,
19527 + * struct dpni_pools_cfg - Structure representing buffer pools configuration
19528 + * @num_dpbp: Number of DPBPs
19529 + * @pools: Array of buffer pools parameters; The number of valid entries
19530 + * must match 'num_dpbp' value
19532 +struct dpni_pools_cfg {
19533 + uint8_t num_dpbp;
19535 + * struct pools - Buffer pools parameters
19536 + * @dpbp_id: DPBP object ID
19537 + * @buffer_size: Buffer size
19538 + * @backup_pool: Backup pool
19542 + uint16_t buffer_size;
19544 + } pools[DPNI_MAX_DPBP];
19548 + * dpni_set_pools() - Set buffer pools configuration
19549 + * @mc_io: Pointer to MC portal's I/O object
19550 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19551 + * @token: Token of DPNI object
19552 + * @cfg: Buffer pools configuration
19554 + * mandatory for DPNI operation
19555 + * warning:Allowed only when DPNI is disabled
19557 + * Return: '0' on Success; Error code otherwise.
19559 +int dpni_set_pools(struct fsl_mc_io *mc_io,
19560 + uint32_t cmd_flags,
19562 + const struct dpni_pools_cfg *cfg);
19565 + * dpni_enable() - Enable the DPNI, allow sending and receiving frames.
19566 + * @mc_io: Pointer to MC portal's I/O object
19567 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19568 + * @token: Token of DPNI object
19570 + * Return: '0' on Success; Error code otherwise.
19572 +int dpni_enable(struct fsl_mc_io *mc_io,
19573 + uint32_t cmd_flags,
19577 + * dpni_disable() - Disable the DPNI, stop sending and receiving frames.
19578 + * @mc_io: Pointer to MC portal's I/O object
19579 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19580 + * @token: Token of DPNI object
19582 + * Return: '0' on Success; Error code otherwise.
19584 +int dpni_disable(struct fsl_mc_io *mc_io,
19585 + uint32_t cmd_flags,
19589 + * dpni_is_enabled() - Check if the DPNI is enabled.
19590 + * @mc_io: Pointer to MC portal's I/O object
19591 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19592 + * @token: Token of DPNI object
19593 + * @en: Returns '1' if object is enabled; '0' otherwise
19595 + * Return: '0' on Success; Error code otherwise.
19597 +int dpni_is_enabled(struct fsl_mc_io *mc_io,
19598 + uint32_t cmd_flags,
19603 + * dpni_reset() - Reset the DPNI, returns the object to initial state.
19604 + * @mc_io: Pointer to MC portal's I/O object
19605 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19606 + * @token: Token of DPNI object
19608 + * Return: '0' on Success; Error code otherwise.
19610 +int dpni_reset(struct fsl_mc_io *mc_io,
19611 + uint32_t cmd_flags,
19615 + * DPNI IRQ Index and Events
19621 +#define DPNI_IRQ_INDEX 0
19623 + * IRQ event - indicates a change in link state
19625 +#define DPNI_IRQ_EVENT_LINK_CHANGED 0x00000001
19628 + * struct dpni_irq_cfg - IRQ configuration
19629 + * @addr: Address that must be written to signal a message-based interrupt
19630 + * @val: Value to write into irq_addr address
19631 + * @irq_num: A user defined number associated with this IRQ
19633 +struct dpni_irq_cfg {
19640 + * dpni_set_irq() - Set IRQ information for the DPNI to trigger an interrupt.
19641 + * @mc_io: Pointer to MC portal's I/O object
19642 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19643 + * @token: Token of DPNI object
19644 + * @irq_index: Identifies the interrupt index to configure
19645 + * @irq_cfg: IRQ configuration
19647 + * Return: '0' on Success; Error code otherwise.
19649 +int dpni_set_irq(struct fsl_mc_io *mc_io,
19650 + uint32_t cmd_flags,
19652 + uint8_t irq_index,
19653 + struct dpni_irq_cfg *irq_cfg);
19656 + * dpni_get_irq() - Get IRQ information from the DPNI.
19657 + * @mc_io: Pointer to MC portal's I/O object
19658 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19659 + * @token: Token of DPNI object
19660 + * @irq_index: The interrupt index to configure
19661 + * @type: Interrupt type: 0 represents message interrupt
19662 + * type (both irq_addr and irq_val are valid)
19663 + * @irq_cfg: IRQ attributes
19665 + * Return: '0' on Success; Error code otherwise.
19667 +int dpni_get_irq(struct fsl_mc_io *mc_io,
19668 + uint32_t cmd_flags,
19670 + uint8_t irq_index,
19672 + struct dpni_irq_cfg *irq_cfg);
19675 + * dpni_set_irq_enable() - Set overall interrupt state.
19676 + * @mc_io: Pointer to MC portal's I/O object
19677 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19678 + * @token: Token of DPNI object
19679 + * @irq_index: The interrupt index to configure
19680 + * @en: Interrupt state: - enable = 1, disable = 0
19682 + * Allows GPP software to control when interrupts are generated.
19683 + * Each interrupt can have up to 32 causes. The enable/disable control's the
19684 + * overall interrupt state. if the interrupt is disabled no causes will cause
19687 + * Return: '0' on Success; Error code otherwise.
19689 +int dpni_set_irq_enable(struct fsl_mc_io *mc_io,
19690 + uint32_t cmd_flags,
19692 + uint8_t irq_index,
19696 + * dpni_get_irq_enable() - Get overall interrupt state
19697 + * @mc_io: Pointer to MC portal's I/O object
19698 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19699 + * @token: Token of DPNI object
19700 + * @irq_index: The interrupt index to configure
19701 + * @en: Returned interrupt state - enable = 1, disable = 0
19703 + * Return: '0' on Success; Error code otherwise.
19705 +int dpni_get_irq_enable(struct fsl_mc_io *mc_io,
19706 + uint32_t cmd_flags,
19708 + uint8_t irq_index,
19712 + * dpni_set_irq_mask() - Set interrupt mask.
19713 + * @mc_io: Pointer to MC portal's I/O object
19714 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19715 + * @token: Token of DPNI object
19716 + * @irq_index: The interrupt index to configure
19717 + * @mask: event mask to trigger interrupt;
19719 + * 0 = ignore event
19720 + * 1 = consider event for asserting IRQ
19722 + * Every interrupt can have up to 32 causes and the interrupt model supports
19723 + * masking/unmasking each cause independently
19725 + * Return: '0' on Success; Error code otherwise.
19727 +int dpni_set_irq_mask(struct fsl_mc_io *mc_io,
19728 + uint32_t cmd_flags,
19730 + uint8_t irq_index,
19734 + * dpni_get_irq_mask() - Get interrupt mask.
19735 + * @mc_io: Pointer to MC portal's I/O object
19736 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19737 + * @token: Token of DPNI object
19738 + * @irq_index: The interrupt index to configure
19739 + * @mask: Returned event mask to trigger interrupt
19741 + * Every interrupt can have up to 32 causes and the interrupt model supports
19742 + * masking/unmasking each cause independently
19744 + * Return: '0' on Success; Error code otherwise.
19746 +int dpni_get_irq_mask(struct fsl_mc_io *mc_io,
19747 + uint32_t cmd_flags,
19749 + uint8_t irq_index,
19753 + * dpni_get_irq_status() - Get the current status of any pending interrupts.
19754 + * @mc_io: Pointer to MC portal's I/O object
19755 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19756 + * @token: Token of DPNI object
19757 + * @irq_index: The interrupt index to configure
19758 + * @status: Returned interrupts status - one bit per cause:
19759 + * 0 = no interrupt pending
19760 + * 1 = interrupt pending
19762 + * Return: '0' on Success; Error code otherwise.
19764 +int dpni_get_irq_status(struct fsl_mc_io *mc_io,
19765 + uint32_t cmd_flags,
19767 + uint8_t irq_index,
19768 + uint32_t *status);
19771 + * dpni_clear_irq_status() - Clear a pending interrupt's status
19772 + * @mc_io: Pointer to MC portal's I/O object
19773 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19774 + * @token: Token of DPNI object
19775 + * @irq_index: The interrupt index to configure
19776 + * @status: bits to clear (W1C) - one bit per cause:
19777 + * 0 = don't change
19778 + * 1 = clear status bit
19780 + * Return: '0' on Success; Error code otherwise.
19782 +int dpni_clear_irq_status(struct fsl_mc_io *mc_io,
19783 + uint32_t cmd_flags,
19785 + uint8_t irq_index,
19786 + uint32_t status);
19789 + * struct dpni_attr - Structure representing DPNI attributes
19790 + * @id: DPNI object ID
19791 + * @version: DPNI version
19792 + * @start_hdr: Indicates the packet starting header for parsing
19793 + * @options: Mask of available options; reflects the value as was given in
19794 + * object's creation
19795 + * @max_senders: Maximum number of different senders; used as the number
19796 + * of dedicated Tx flows;
19797 + * @max_tcs: Maximum number of traffic classes (for both Tx and Rx)
19798 + * @max_unicast_filters: Maximum number of unicast filters
19799 + * @max_multicast_filters: Maximum number of multicast filters
19800 + * @max_vlan_filters: Maximum number of VLAN filters
19801 + * @max_qos_entries: if 'max_tcs > 1', declares the maximum entries in QoS table
19802 + * @max_qos_key_size: Maximum key size for the QoS look-up
19803 + * @max_dist_key_size: Maximum key size for the distribution look-up
19804 + * @max_policers: Maximum number of policers;
19805 + * @max_congestion_ctrl: Maximum number of congestion control groups (CGs);
19806 + * @ext_cfg_iova: I/O virtual address of 256 bytes DMA-able memory;
19807 + * call dpni_extract_extended_cfg() to extract the extended configuration
19809 +struct dpni_attr {
19812 + * struct version - DPNI version
19813 + * @major: DPNI major version
19814 + * @minor: DPNI minor version
19820 + enum net_prot start_hdr;
19821 + uint32_t options;
19822 + uint8_t max_senders;
19824 + uint8_t max_unicast_filters;
19825 + uint8_t max_multicast_filters;
19826 + uint8_t max_vlan_filters;
19827 + uint8_t max_qos_entries;
19828 + uint8_t max_qos_key_size;
19829 + uint8_t max_dist_key_size;
19830 + uint8_t max_policers;
19831 + uint8_t max_congestion_ctrl;
19832 + uint64_t ext_cfg_iova;
19836 + * dpni_get_attributes() - Retrieve DPNI attributes.
19837 + * @mc_io: Pointer to MC portal's I/O object
19838 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19839 + * @token: Token of DPNI object
19840 + * @attr: Object's attributes
19842 + * Return: '0' on Success; Error code otherwise.
19844 +int dpni_get_attributes(struct fsl_mc_io *mc_io,
19845 + uint32_t cmd_flags,
19847 + struct dpni_attr *attr);
19850 + * dpni_extract_extended_cfg() - extract the extended parameters
19851 + * @cfg: extended structure
19852 + * @ext_cfg_buf: 256 bytes of DMA-able memory
19854 + * This function has to be called after dpni_get_attributes()
19856 +int dpni_extract_extended_cfg(struct dpni_extended_cfg *cfg,
19857 + const uint8_t *ext_cfg_buf);
19864 + * Extract out of frame header error
19866 +#define DPNI_ERROR_EOFHE 0x00020000
19868 + * Frame length error
19870 +#define DPNI_ERROR_FLE 0x00002000
19872 + * Frame physical error
19874 +#define DPNI_ERROR_FPE 0x00001000
19876 + * Parsing header error
19878 +#define DPNI_ERROR_PHE 0x00000020
19880 + * Parser L3 checksum error
19882 +#define DPNI_ERROR_L3CE 0x00000004
19884 + * Parser L3 checksum error
19886 +#define DPNI_ERROR_L4CE 0x00000001
19889 + * enum dpni_error_action - Defines DPNI behavior for errors
19890 + * @DPNI_ERROR_ACTION_DISCARD: Discard the frame
19891 + * @DPNI_ERROR_ACTION_CONTINUE: Continue with the normal flow
19892 + * @DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE: Send the frame to the error queue
19894 +enum dpni_error_action {
19895 + DPNI_ERROR_ACTION_DISCARD = 0,
19896 + DPNI_ERROR_ACTION_CONTINUE = 1,
19897 + DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE = 2
19901 + * struct dpni_error_cfg - Structure representing DPNI errors treatment
19902 + * @errors: Errors mask; use 'DPNI_ERROR__<X>
19903 + * @error_action: The desired action for the errors mask
19904 + * @set_frame_annotation: Set to '1' to mark the errors in frame annotation
19905 + * status (FAS); relevant only for the non-discard action
19907 +struct dpni_error_cfg {
19909 + enum dpni_error_action error_action;
19910 + int set_frame_annotation;
19914 + * dpni_set_errors_behavior() - Set errors behavior
19915 + * @mc_io: Pointer to MC portal's I/O object
19916 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19917 + * @token: Token of DPNI object
19918 + * @cfg: Errors configuration
19920 + * this function may be called numerous times with different
19923 + * Return: '0' on Success; Error code otherwise.
19925 +int dpni_set_errors_behavior(struct fsl_mc_io *mc_io,
19926 + uint32_t cmd_flags,
19928 + struct dpni_error_cfg *cfg);
19931 + * DPNI buffer layout modification options
19935 + * Select to modify the time-stamp setting
19937 +#define DPNI_BUF_LAYOUT_OPT_TIMESTAMP 0x00000001
19939 + * Select to modify the parser-result setting; not applicable for Tx
19941 +#define DPNI_BUF_LAYOUT_OPT_PARSER_RESULT 0x00000002
19943 + * Select to modify the frame-status setting
19945 +#define DPNI_BUF_LAYOUT_OPT_FRAME_STATUS 0x00000004
19947 + * Select to modify the private-data-size setting
19949 +#define DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE 0x00000008
19951 + * Select to modify the data-alignment setting
19953 +#define DPNI_BUF_LAYOUT_OPT_DATA_ALIGN 0x00000010
19955 + * Select to modify the data-head-room setting
19957 +#define DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM 0x00000020
19959 + * Select to modify the data-tail-room setting
19961 +#define DPNI_BUF_LAYOUT_OPT_DATA_TAIL_ROOM 0x00000040
19964 + * struct dpni_buffer_layout - Structure representing DPNI buffer layout
19965 + * @options: Flags representing the suggested modifications to the buffer
19966 + * layout; Use any combination of 'DPNI_BUF_LAYOUT_OPT_<X>' flags
19967 + * @pass_timestamp: Pass timestamp value
19968 + * @pass_parser_result: Pass parser results
19969 + * @pass_frame_status: Pass frame status
19970 + * @private_data_size: Size kept for private data (in bytes)
19971 + * @data_align: Data alignment
19972 + * @data_head_room: Data head room
19973 + * @data_tail_room: Data tail room
19975 +struct dpni_buffer_layout {
19976 + uint32_t options;
19977 + int pass_timestamp;
19978 + int pass_parser_result;
19979 + int pass_frame_status;
19980 + uint16_t private_data_size;
19981 + uint16_t data_align;
19982 + uint16_t data_head_room;
19983 + uint16_t data_tail_room;
19987 + * dpni_get_rx_buffer_layout() - Retrieve Rx buffer layout attributes.
19988 + * @mc_io: Pointer to MC portal's I/O object
19989 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
19990 + * @token: Token of DPNI object
19991 + * @layout: Returns buffer layout attributes
19993 + * Return: '0' on Success; Error code otherwise.
19995 +int dpni_get_rx_buffer_layout(struct fsl_mc_io *mc_io,
19996 + uint32_t cmd_flags,
19998 + struct dpni_buffer_layout *layout);
20001 + * dpni_set_rx_buffer_layout() - Set Rx buffer layout configuration.
20002 + * @mc_io: Pointer to MC portal's I/O object
20003 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20004 + * @token: Token of DPNI object
20005 + * @layout: Buffer layout configuration
20007 + * Return: '0' on Success; Error code otherwise.
20009 + * @warning Allowed only when DPNI is disabled
20011 +int dpni_set_rx_buffer_layout(struct fsl_mc_io *mc_io,
20012 + uint32_t cmd_flags,
20014 + const struct dpni_buffer_layout *layout);
20017 + * dpni_get_tx_buffer_layout() - Retrieve Tx buffer layout attributes.
20018 + * @mc_io: Pointer to MC portal's I/O object
20019 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20020 + * @token: Token of DPNI object
20021 + * @layout: Returns buffer layout attributes
20023 + * Return: '0' on Success; Error code otherwise.
20025 +int dpni_get_tx_buffer_layout(struct fsl_mc_io *mc_io,
20026 + uint32_t cmd_flags,
20028 + struct dpni_buffer_layout *layout);
20031 + * dpni_set_tx_buffer_layout() - Set Tx buffer layout configuration.
20032 + * @mc_io: Pointer to MC portal's I/O object
20033 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20034 + * @token: Token of DPNI object
20035 + * @layout: Buffer layout configuration
20037 + * Return: '0' on Success; Error code otherwise.
20039 + * @warning Allowed only when DPNI is disabled
20041 +int dpni_set_tx_buffer_layout(struct fsl_mc_io *mc_io,
20042 + uint32_t cmd_flags,
20044 + const struct dpni_buffer_layout *layout);
20047 + * dpni_get_tx_conf_buffer_layout() - Retrieve Tx confirmation buffer layout
20049 + * @mc_io: Pointer to MC portal's I/O object
20050 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20051 + * @token: Token of DPNI object
20052 + * @layout: Returns buffer layout attributes
20054 + * Return: '0' on Success; Error code otherwise.
20056 +int dpni_get_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
20057 + uint32_t cmd_flags,
20059 + struct dpni_buffer_layout *layout);
20062 + * dpni_set_tx_conf_buffer_layout() - Set Tx confirmation buffer layout
20064 + * @mc_io: Pointer to MC portal's I/O object
20065 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20066 + * @token: Token of DPNI object
20067 + * @layout: Buffer layout configuration
20069 + * Return: '0' on Success; Error code otherwise.
20071 + * @warning Allowed only when DPNI is disabled
20073 +int dpni_set_tx_conf_buffer_layout(struct fsl_mc_io *mc_io,
20074 + uint32_t cmd_flags,
20076 + const struct dpni_buffer_layout *layout);
20079 + * dpni_set_l3_chksum_validation() - Enable/disable L3 checksum validation
20080 + * @mc_io: Pointer to MC portal's I/O object
20081 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20082 + * @token: Token of DPNI object
20083 + * @en: Set to '1' to enable; '0' to disable
20085 + * Return: '0' on Success; Error code otherwise.
20087 +int dpni_set_l3_chksum_validation(struct fsl_mc_io *mc_io,
20088 + uint32_t cmd_flags,
20093 + * dpni_get_l3_chksum_validation() - Get L3 checksum validation mode
20094 + * @mc_io: Pointer to MC portal's I/O object
20095 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20096 + * @token: Token of DPNI object
20097 + * @en: Returns '1' if enabled; '0' otherwise
20099 + * Return: '0' on Success; Error code otherwise.
20101 +int dpni_get_l3_chksum_validation(struct fsl_mc_io *mc_io,
20102 + uint32_t cmd_flags,
20107 + * dpni_set_l4_chksum_validation() - Enable/disable L4 checksum validation
20108 + * @mc_io: Pointer to MC portal's I/O object
20109 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20110 + * @token: Token of DPNI object
20111 + * @en: Set to '1' to enable; '0' to disable
20113 + * Return: '0' on Success; Error code otherwise.
20115 +int dpni_set_l4_chksum_validation(struct fsl_mc_io *mc_io,
20116 + uint32_t cmd_flags,
20121 + * dpni_get_l4_chksum_validation() - Get L4 checksum validation mode
20122 + * @mc_io: Pointer to MC portal's I/O object
20123 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20124 + * @token: Token of DPNI object
20125 + * @en: Returns '1' if enabled; '0' otherwise
20127 + * Return: '0' on Success; Error code otherwise.
20129 +int dpni_get_l4_chksum_validation(struct fsl_mc_io *mc_io,
20130 + uint32_t cmd_flags,
20135 + * dpni_get_qdid() - Get the Queuing Destination ID (QDID) that should be used
20136 + * for enqueue operations
20137 + * @mc_io: Pointer to MC portal's I/O object
20138 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20139 + * @token: Token of DPNI object
20140 + * @qdid: Returned virtual QDID value that should be used as an argument
20141 + * in all enqueue operations
20143 + * Return: '0' on Success; Error code otherwise.
20145 +int dpni_get_qdid(struct fsl_mc_io *mc_io,
20146 + uint32_t cmd_flags,
20151 + * struct dpni_sp_info - Structure representing DPNI storage-profile information
20152 + * (relevant only for DPNI owned by AIOP)
20153 + * @spids: array of storage-profiles
20155 +struct dpni_sp_info {
20156 + uint16_t spids[DPNI_MAX_SP];
20160 + * dpni_get_spids() - Get the AIOP storage profile IDs associated with the DPNI
20161 + * @mc_io: Pointer to MC portal's I/O object
20162 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20163 + * @token: Token of DPNI object
20164 + * @sp_info: Returned AIOP storage-profile information
20166 + * Return: '0' on Success; Error code otherwise.
20168 + * @warning Only relevant for DPNI that belongs to AIOP container.
20170 +int dpni_get_sp_info(struct fsl_mc_io *mc_io,
20171 + uint32_t cmd_flags,
20173 + struct dpni_sp_info *sp_info);
20176 + * dpni_get_tx_data_offset() - Get the Tx data offset (from start of buffer)
20177 + * @mc_io: Pointer to MC portal's I/O object
20178 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20179 + * @token: Token of DPNI object
20180 + * @data_offset: Tx data offset (from start of buffer)
20182 + * Return: '0' on Success; Error code otherwise.
20184 +int dpni_get_tx_data_offset(struct fsl_mc_io *mc_io,
20185 + uint32_t cmd_flags,
20187 + uint16_t *data_offset);
20190 + * enum dpni_counter - DPNI counter types
20191 + * @DPNI_CNT_ING_FRAME: Counts ingress frames
20192 + * @DPNI_CNT_ING_BYTE: Counts ingress bytes
20193 + * @DPNI_CNT_ING_FRAME_DROP: Counts ingress frames dropped due to explicit
20195 + * @DPNI_CNT_ING_FRAME_DISCARD: Counts ingress frames discarded due to errors
20196 + * @DPNI_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
20197 + * @DPNI_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
20198 + * @DPNI_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
20199 + * @DPNI_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
20200 + * @DPNI_CNT_EGR_FRAME: Counts egress frames
20201 + * @DPNI_CNT_EGR_BYTE: Counts egress bytes
20202 + * @DPNI_CNT_EGR_FRAME_DISCARD: Counts egress frames discarded due to errors
20204 +enum dpni_counter {
20205 + DPNI_CNT_ING_FRAME = 0x0,
20206 + DPNI_CNT_ING_BYTE = 0x1,
20207 + DPNI_CNT_ING_FRAME_DROP = 0x2,
20208 + DPNI_CNT_ING_FRAME_DISCARD = 0x3,
20209 + DPNI_CNT_ING_MCAST_FRAME = 0x4,
20210 + DPNI_CNT_ING_MCAST_BYTE = 0x5,
20211 + DPNI_CNT_ING_BCAST_FRAME = 0x6,
20212 + DPNI_CNT_ING_BCAST_BYTES = 0x7,
20213 + DPNI_CNT_EGR_FRAME = 0x8,
20214 + DPNI_CNT_EGR_BYTE = 0x9,
20215 + DPNI_CNT_EGR_FRAME_DISCARD = 0xa
20219 + * dpni_get_counter() - Read a specific DPNI counter
20220 + * @mc_io: Pointer to MC portal's I/O object
20221 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20222 + * @token: Token of DPNI object
20223 + * @counter: The requested counter
20224 + * @value: Returned counter's current value
20226 + * Return: '0' on Success; Error code otherwise.
20228 +int dpni_get_counter(struct fsl_mc_io *mc_io,
20229 + uint32_t cmd_flags,
20231 + enum dpni_counter counter,
20232 + uint64_t *value);
20235 + * dpni_set_counter() - Set (or clear) a specific DPNI counter
20236 + * @mc_io: Pointer to MC portal's I/O object
20237 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20238 + * @token: Token of DPNI object
20239 + * @counter: The requested counter
20240 + * @value: New counter value; typically pass '0' for resetting
20243 + * Return: '0' on Success; Error code otherwise.
20245 +int dpni_set_counter(struct fsl_mc_io *mc_io,
20246 + uint32_t cmd_flags,
20248 + enum dpni_counter counter,
20252 + * Enable auto-negotiation
20254 +#define DPNI_LINK_OPT_AUTONEG 0x0000000000000001ULL
20256 + * Enable half-duplex mode
20258 +#define DPNI_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
20260 + * Enable pause frames
20262 +#define DPNI_LINK_OPT_PAUSE 0x0000000000000004ULL
20264 + * Enable a-symmetric pause frames
20266 +#define DPNI_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
20269 + * struct - Structure representing DPNI link configuration
20271 + * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
20273 +struct dpni_link_cfg {
20275 + uint64_t options;
20279 + * dpni_set_link_cfg() - set the link configuration.
20280 + * @mc_io: Pointer to MC portal's I/O object
20281 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20282 + * @token: Token of DPNI object
20283 + * @cfg: Link configuration
20285 + * Return: '0' on Success; Error code otherwise.
20287 +int dpni_set_link_cfg(struct fsl_mc_io *mc_io,
20288 + uint32_t cmd_flags,
20290 + const struct dpni_link_cfg *cfg);
20293 + * struct dpni_link_state - Structure representing DPNI link state
20295 + * @options: Mask of available options; use 'DPNI_LINK_OPT_<X>' values
20296 + * @up: Link state; '0' for down, '1' for up
20298 +struct dpni_link_state {
20300 + uint64_t options;
20305 + * dpni_get_link_state() - Return the link state (either up or down)
20306 + * @mc_io: Pointer to MC portal's I/O object
20307 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20308 + * @token: Token of DPNI object
20309 + * @state: Returned link state;
20311 + * Return: '0' on Success; Error code otherwise.
20313 +int dpni_get_link_state(struct fsl_mc_io *mc_io,
20314 + uint32_t cmd_flags,
20316 + struct dpni_link_state *state);
20319 + * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
20320 + * @rate_limit: rate in Mbps
20321 + * @max_burst_size: burst size in bytes (up to 64KB)
20323 +struct dpni_tx_shaping_cfg {
20324 + uint32_t rate_limit;
20325 + uint16_t max_burst_size;
20329 + * dpni_set_tx_shaping() - Set the transmit shaping
20330 + * @mc_io: Pointer to MC portal's I/O object
20331 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20332 + * @token: Token of DPNI object
20333 + * @tx_shaper: tx shaping configuration
20335 + * Return: '0' on Success; Error code otherwise.
20337 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
20338 + uint32_t cmd_flags,
20340 + const struct dpni_tx_shaping_cfg *tx_shaper);
20343 + * dpni_set_max_frame_length() - Set the maximum received frame length.
20344 + * @mc_io: Pointer to MC portal's I/O object
20345 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20346 + * @token: Token of DPNI object
20347 + * @max_frame_length: Maximum received frame length (in
20348 + * bytes); frame is discarded if its
20349 + * length exceeds this value
20351 + * Return: '0' on Success; Error code otherwise.
20353 +int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
20354 + uint32_t cmd_flags,
20356 + uint16_t max_frame_length);
20359 + * dpni_get_max_frame_length() - Get the maximum received frame length.
20360 + * @mc_io: Pointer to MC portal's I/O object
20361 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20362 + * @token: Token of DPNI object
20363 + * @max_frame_length: Maximum received frame length (in
20364 + * bytes); frame is discarded if its
20365 + * length exceeds this value
20367 + * Return: '0' on Success; Error code otherwise.
20369 +int dpni_get_max_frame_length(struct fsl_mc_io *mc_io,
20370 + uint32_t cmd_flags,
20372 + uint16_t *max_frame_length);
20375 + * dpni_set_mtu() - Set the MTU for the interface.
20376 + * @mc_io: Pointer to MC portal's I/O object
20377 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20378 + * @token: Token of DPNI object
20379 + * @mtu: MTU length (in bytes)
20381 + * MTU determines the maximum fragment size for performing IP
20382 + * fragmentation on egress packets.
20383 + * Return: '0' on Success; Error code otherwise.
20385 +int dpni_set_mtu(struct fsl_mc_io *mc_io,
20386 + uint32_t cmd_flags,
20391 + * dpni_get_mtu() - Get the MTU.
20392 + * @mc_io: Pointer to MC portal's I/O object
20393 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20394 + * @token: Token of DPNI object
20395 + * @mtu: Returned MTU length (in bytes)
20397 + * Return: '0' on Success; Error code otherwise.
20399 +int dpni_get_mtu(struct fsl_mc_io *mc_io,
20400 + uint32_t cmd_flags,
20405 + * dpni_set_multicast_promisc() - Enable/disable multicast promiscuous mode
20406 + * @mc_io: Pointer to MC portal's I/O object
20407 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20408 + * @token: Token of DPNI object
20409 + * @en: Set to '1' to enable; '0' to disable
20411 + * Return: '0' on Success; Error code otherwise.
20413 +int dpni_set_multicast_promisc(struct fsl_mc_io *mc_io,
20414 + uint32_t cmd_flags,
20419 + * dpni_get_multicast_promisc() - Get multicast promiscuous mode
20420 + * @mc_io: Pointer to MC portal's I/O object
20421 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20422 + * @token: Token of DPNI object
20423 + * @en: Returns '1' if enabled; '0' otherwise
20425 + * Return: '0' on Success; Error code otherwise.
20427 +int dpni_get_multicast_promisc(struct fsl_mc_io *mc_io,
20428 + uint32_t cmd_flags,
20433 + * dpni_set_unicast_promisc() - Enable/disable unicast promiscuous mode
20434 + * @mc_io: Pointer to MC portal's I/O object
20435 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20436 + * @token: Token of DPNI object
20437 + * @en: Set to '1' to enable; '0' to disable
20439 + * Return: '0' on Success; Error code otherwise.
20441 +int dpni_set_unicast_promisc(struct fsl_mc_io *mc_io,
20442 + uint32_t cmd_flags,
20447 + * dpni_get_unicast_promisc() - Get unicast promiscuous mode
20448 + * @mc_io: Pointer to MC portal's I/O object
20449 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20450 + * @token: Token of DPNI object
20451 + * @en: Returns '1' if enabled; '0' otherwise
20453 + * Return: '0' on Success; Error code otherwise.
20455 +int dpni_get_unicast_promisc(struct fsl_mc_io *mc_io,
20456 + uint32_t cmd_flags,
20461 + * dpni_set_primary_mac_addr() - Set the primary MAC address
20462 + * @mc_io: Pointer to MC portal's I/O object
20463 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20464 + * @token: Token of DPNI object
20465 + * @mac_addr: MAC address to set as primary address
20467 + * Return: '0' on Success; Error code otherwise.
20469 +int dpni_set_primary_mac_addr(struct fsl_mc_io *mc_io,
20470 + uint32_t cmd_flags,
20472 + const uint8_t mac_addr[6]);
20475 + * dpni_get_primary_mac_addr() - Get the primary MAC address
20476 + * @mc_io: Pointer to MC portal's I/O object
20477 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20478 + * @token: Token of DPNI object
20479 + * @mac_addr: Returned MAC address
20481 + * Return: '0' on Success; Error code otherwise.
20483 +int dpni_get_primary_mac_addr(struct fsl_mc_io *mc_io,
20484 + uint32_t cmd_flags,
20486 + uint8_t mac_addr[6]);
20489 + * dpni_add_mac_addr() - Add MAC address filter
20490 + * @mc_io: Pointer to MC portal's I/O object
20491 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20492 + * @token: Token of DPNI object
20493 + * @mac_addr: MAC address to add
20495 + * Return: '0' on Success; Error code otherwise.
20497 +int dpni_add_mac_addr(struct fsl_mc_io *mc_io,
20498 + uint32_t cmd_flags,
20500 + const uint8_t mac_addr[6]);
20503 + * dpni_remove_mac_addr() - Remove MAC address filter
20504 + * @mc_io: Pointer to MC portal's I/O object
20505 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20506 + * @token: Token of DPNI object
20507 + * @mac_addr: MAC address to remove
20509 + * Return: '0' on Success; Error code otherwise.
20511 +int dpni_remove_mac_addr(struct fsl_mc_io *mc_io,
20512 + uint32_t cmd_flags,
20514 + const uint8_t mac_addr[6]);
20517 + * dpni_clear_mac_filters() - Clear all unicast and/or multicast MAC filters
20518 + * @mc_io: Pointer to MC portal's I/O object
20519 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20520 + * @token: Token of DPNI object
20521 + * @unicast: Set to '1' to clear unicast addresses
20522 + * @multicast: Set to '1' to clear multicast addresses
20524 + * The primary MAC address is not cleared by this operation.
20526 + * Return: '0' on Success; Error code otherwise.
20528 +int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
20529 + uint32_t cmd_flags,
20535 + * dpni_set_vlan_filters() - Enable/disable VLAN filtering mode
20536 + * @mc_io: Pointer to MC portal's I/O object
20537 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20538 + * @token: Token of DPNI object
20539 + * @en: Set to '1' to enable; '0' to disable
20541 + * Return: '0' on Success; Error code otherwise.
20543 +int dpni_set_vlan_filters(struct fsl_mc_io *mc_io,
20544 + uint32_t cmd_flags,
20549 + * dpni_add_vlan_id() - Add VLAN ID filter
20550 + * @mc_io: Pointer to MC portal's I/O object
20551 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20552 + * @token: Token of DPNI object
20553 + * @vlan_id: VLAN ID to add
20555 + * Return: '0' on Success; Error code otherwise.
20557 +int dpni_add_vlan_id(struct fsl_mc_io *mc_io,
20558 + uint32_t cmd_flags,
20560 + uint16_t vlan_id);
20563 + * dpni_remove_vlan_id() - Remove VLAN ID filter
20564 + * @mc_io: Pointer to MC portal's I/O object
20565 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20566 + * @token: Token of DPNI object
20567 + * @vlan_id: VLAN ID to remove
20569 + * Return: '0' on Success; Error code otherwise.
20571 +int dpni_remove_vlan_id(struct fsl_mc_io *mc_io,
20572 + uint32_t cmd_flags,
20574 + uint16_t vlan_id);
20577 + * dpni_clear_vlan_filters() - Clear all VLAN filters
20578 + * @mc_io: Pointer to MC portal's I/O object
20579 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20580 + * @token: Token of DPNI object
20582 + * Return: '0' on Success; Error code otherwise.
20584 +int dpni_clear_vlan_filters(struct fsl_mc_io *mc_io,
20585 + uint32_t cmd_flags,
20589 + * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
20590 + * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
20591 + * @DPNI_TX_SCHED_WEIGHTED: weighted based scheduling
20593 +enum dpni_tx_schedule_mode {
20594 + DPNI_TX_SCHED_STRICT_PRIORITY,
20595 + DPNI_TX_SCHED_WEIGHTED,
20599 + * struct dpni_tx_schedule_cfg - Structure representing Tx
20600 + * scheduling configuration
20601 + * @mode: scheduling mode
20602 + * @delta_bandwidth: Bandwidth represented in weights from 100 to 10000;
20603 + * not applicable for 'strict-priority' mode;
20605 +struct dpni_tx_schedule_cfg {
20606 + enum dpni_tx_schedule_mode mode;
20607 + uint16_t delta_bandwidth;
20611 + * struct dpni_tx_selection_cfg - Structure representing transmission
20612 + * selection configuration
20613 + * @tc_sched: an array of traffic-classes
20615 +struct dpni_tx_selection_cfg {
20616 + struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
20620 + * dpni_set_tx_selection() - Set transmission selection configuration
20621 + * @mc_io: Pointer to MC portal's I/O object
20622 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20623 + * @token: Token of DPNI object
20624 + * @cfg: transmission selection configuration
20626 + * warning: Allowed only when DPNI is disabled
20628 + * Return: '0' on Success; Error code otherwise.
20630 +int dpni_set_tx_selection(struct fsl_mc_io *mc_io,
20631 + uint32_t cmd_flags,
20633 + const struct dpni_tx_selection_cfg *cfg);
20636 + * enum dpni_dist_mode - DPNI distribution mode
20637 + * @DPNI_DIST_MODE_NONE: No distribution
20638 + * @DPNI_DIST_MODE_HASH: Use hash distribution; only relevant if
20639 + * the 'DPNI_OPT_DIST_HASH' option was set at DPNI creation
20640 + * @DPNI_DIST_MODE_FS: Use explicit flow steering; only relevant if
20641 + * the 'DPNI_OPT_DIST_FS' option was set at DPNI creation
20643 +enum dpni_dist_mode {
20644 + DPNI_DIST_MODE_NONE = 0,
20645 + DPNI_DIST_MODE_HASH = 1,
20646 + DPNI_DIST_MODE_FS = 2
20650 + * enum dpni_fs_miss_action - DPNI Flow Steering miss action
20651 + * @DPNI_FS_MISS_DROP: In case of no-match, drop the frame
20652 + * @DPNI_FS_MISS_EXPLICIT_FLOWID: In case of no-match, use explicit flow-id
20653 + * @DPNI_FS_MISS_HASH: In case of no-match, distribute using hash
20655 +enum dpni_fs_miss_action {
20656 + DPNI_FS_MISS_DROP = 0,
20657 + DPNI_FS_MISS_EXPLICIT_FLOWID = 1,
20658 + DPNI_FS_MISS_HASH = 2
20662 + * struct dpni_fs_tbl_cfg - Flow Steering table configuration
20663 + * @miss_action: Miss action selection
20664 + * @default_flow_id: Used when 'miss_action = DPNI_FS_MISS_EXPLICIT_FLOWID'
20666 +struct dpni_fs_tbl_cfg {
20667 + enum dpni_fs_miss_action miss_action;
20668 + uint16_t default_flow_id;
20672 + * dpni_prepare_key_cfg() - function prepare extract parameters
20673 + * @cfg: defining a full Key Generation profile (rule)
20674 + * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
20676 + * This function has to be called before the following functions:
20677 + * - dpni_set_rx_tc_dist()
20678 + * - dpni_set_qos_table()
20680 +int dpni_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
20681 + uint8_t *key_cfg_buf);
20684 + * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
20685 + * @dist_size: Set the distribution size;
20686 + * supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,
20687 + * 112,128,192,224,256,384,448,512,768,896,1024
20688 + * @dist_mode: Distribution mode
20689 + * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
20690 + * the extractions to be used for the distribution key by calling
20691 + * dpni_prepare_key_cfg() relevant only when
20692 + * 'dist_mode != DPNI_DIST_MODE_NONE', otherwise it can be '0'
20693 + * @fs_cfg: Flow Steering table configuration; only relevant if
20694 + * 'dist_mode = DPNI_DIST_MODE_FS'
20696 +struct dpni_rx_tc_dist_cfg {
20697 + uint16_t dist_size;
20698 + enum dpni_dist_mode dist_mode;
20699 + uint64_t key_cfg_iova;
20700 + struct dpni_fs_tbl_cfg fs_cfg;
20704 + * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration
20705 + * @mc_io: Pointer to MC portal's I/O object
20706 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20707 + * @token: Token of DPNI object
20708 + * @tc_id: Traffic class selection (0-7)
20709 + * @cfg: Traffic class distribution configuration
20711 + * warning: if 'dist_mode != DPNI_DIST_MODE_NONE', call dpni_prepare_key_cfg()
20712 + * first to prepare the key_cfg_iova parameter
20714 + * Return: '0' on Success; error code otherwise.
20716 +int dpni_set_rx_tc_dist(struct fsl_mc_io *mc_io,
20717 + uint32_t cmd_flags,
20720 + const struct dpni_rx_tc_dist_cfg *cfg);
20723 + * Set to select color aware mode (otherwise - color blind)
20725 +#define DPNI_POLICER_OPT_COLOR_AWARE 0x00000001
20727 + * Set to discard frame with RED color
20729 +#define DPNI_POLICER_OPT_DISCARD_RED 0x00000002
20732 + * enum dpni_policer_mode - selecting the policer mode
20733 + * @DPNI_POLICER_MODE_NONE: Policer is disabled
20734 + * @DPNI_POLICER_MODE_PASS_THROUGH: Policer pass through
20735 + * @DPNI_POLICER_MODE_RFC_2698: Policer algorithm RFC 2698
20736 + * @DPNI_POLICER_MODE_RFC_4115: Policer algorithm RFC 4115
20738 +enum dpni_policer_mode {
20739 + DPNI_POLICER_MODE_NONE = 0,
20740 + DPNI_POLICER_MODE_PASS_THROUGH,
20741 + DPNI_POLICER_MODE_RFC_2698,
20742 + DPNI_POLICER_MODE_RFC_4115
20746 + * enum dpni_policer_unit - DPNI policer units
20747 + * @DPNI_POLICER_UNIT_BYTES: bytes units
20748 + * @DPNI_POLICER_UNIT_FRAMES: frames units
20750 +enum dpni_policer_unit {
20751 + DPNI_POLICER_UNIT_BYTES = 0,
20752 + DPNI_POLICER_UNIT_FRAMES
20756 + * enum dpni_policer_color - selecting the policer color
20757 + * @DPNI_POLICER_COLOR_GREEN: Green color
20758 + * @DPNI_POLICER_COLOR_YELLOW: Yellow color
20759 + * @DPNI_POLICER_COLOR_RED: Red color
20761 +enum dpni_policer_color {
20762 + DPNI_POLICER_COLOR_GREEN = 0,
20763 + DPNI_POLICER_COLOR_YELLOW,
20764 + DPNI_POLICER_COLOR_RED
20768 + * struct dpni_rx_tc_policing_cfg - Policer configuration
20769 + * @options: Mask of available options; use 'DPNI_POLICER_OPT_<X>' values
20770 + * @mode: policer mode
20771 + * @default_color: For pass-through mode the policer re-colors with this
20772 + * color any incoming packets. For Color aware non-pass-through mode:
20773 + * policer re-colors with this color all packets with FD[DROPP]>2.
20774 + * @units: Bytes or Packets
20775 + * @cir: Committed information rate (CIR) in Kbps or packets/second
20776 + * @cbs: Committed burst size (CBS) in bytes or packets
20777 + * @eir: Peak information rate (PIR, rfc2698) in Kbps or packets/second
20778 + * Excess information rate (EIR, rfc4115) in Kbps or packets/second
20779 + * @ebs: Peak burst size (PBS, rfc2698) in bytes or packets
20780 + * Excess burst size (EBS, rfc4115) in bytes or packets
20782 +struct dpni_rx_tc_policing_cfg {
20783 + uint32_t options;
20784 + enum dpni_policer_mode mode;
20785 + enum dpni_policer_unit units;
20786 + enum dpni_policer_color default_color;
20794 + * dpni_set_rx_tc_policing() - Set Rx traffic class policing configuration
20795 + * @mc_io: Pointer to MC portal's I/O object
20796 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20797 + * @token: Token of DPNI object
20798 + * @tc_id: Traffic class selection (0-7)
20799 + * @cfg: Traffic class policing configuration
20801 + * Return: '0' on Success; error code otherwise.
20803 +int dpni_set_rx_tc_policing(struct fsl_mc_io *mc_io,
20804 + uint32_t cmd_flags,
20807 + const struct dpni_rx_tc_policing_cfg *cfg);
20810 + * dpni_get_rx_tc_policing() - Get Rx traffic class policing configuration
20811 + * @mc_io: Pointer to MC portal's I/O object
20812 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20813 + * @token: Token of DPNI object
20814 + * @tc_id: Traffic class selection (0-7)
20815 + * @cfg: Traffic class policing configuration
20817 + * Return: '0' on Success; error code otherwise.
20819 +int dpni_get_rx_tc_policing(struct fsl_mc_io *mc_io,
20820 + uint32_t cmd_flags,
20823 + struct dpni_rx_tc_policing_cfg *cfg);
20826 + * enum dpni_congestion_unit - DPNI congestion units
20827 + * @DPNI_CONGESTION_UNIT_BYTES: bytes units
20828 + * @DPNI_CONGESTION_UNIT_FRAMES: frames units
20830 +enum dpni_congestion_unit {
20831 + DPNI_CONGESTION_UNIT_BYTES = 0,
20832 + DPNI_CONGESTION_UNIT_FRAMES
20836 + * enum dpni_early_drop_mode - DPNI early drop mode
20837 + * @DPNI_EARLY_DROP_MODE_NONE: early drop is disabled
20838 + * @DPNI_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
20839 + * @DPNI_EARLY_DROP_MODE_WRED: early drop in WRED mode
20841 +enum dpni_early_drop_mode {
20842 + DPNI_EARLY_DROP_MODE_NONE = 0,
20843 + DPNI_EARLY_DROP_MODE_TAIL,
20844 + DPNI_EARLY_DROP_MODE_WRED
20848 + * struct dpni_wred_cfg - WRED configuration
20849 + * @max_threshold: maximum threshold that packets may be discarded. Above this
20850 + * threshold all packets are discarded; must be less than 2^39;
20851 + * approximated to be expressed as (x+256)*2^(y-1) due to HW
20852 + * implementation.
20853 + * @min_threshold: minimum threshold that packets may be discarded at
20854 + * @drop_probability: probability that a packet will be discarded (1-100,
20855 + * associated with the max_threshold).
20857 +struct dpni_wred_cfg {
20858 + uint64_t max_threshold;
20859 + uint64_t min_threshold;
20860 + uint8_t drop_probability;
20864 + * struct dpni_early_drop_cfg - early-drop configuration
20865 + * @mode: drop mode
20866 + * @units: units type
20867 + * @green: WRED - 'green' configuration
20868 + * @yellow: WRED - 'yellow' configuration
20869 + * @red: WRED - 'red' configuration
20870 + * @tail_drop_threshold: tail drop threshold
20872 +struct dpni_early_drop_cfg {
20873 + enum dpni_early_drop_mode mode;
20874 + enum dpni_congestion_unit units;
20876 + struct dpni_wred_cfg green;
20877 + struct dpni_wred_cfg yellow;
20878 + struct dpni_wred_cfg red;
20880 + uint32_t tail_drop_threshold;
20884 + * dpni_prepare_early_drop() - prepare an early drop.
20885 + * @cfg: Early-drop configuration
20886 + * @early_drop_buf: Zeroed 256 bytes of memory before mapping it to DMA
20888 + * This function has to be called before dpni_set_rx_tc_early_drop or
20889 + * dpni_set_tx_tc_early_drop
20892 +void dpni_prepare_early_drop(const struct dpni_early_drop_cfg *cfg,
20893 + uint8_t *early_drop_buf);
20896 + * dpni_extract_early_drop() - extract the early drop configuration.
20897 + * @cfg: Early-drop configuration
20898 + * @early_drop_buf: Zeroed 256 bytes of memory before mapping it to DMA
20900 + * This function has to be called after dpni_get_rx_tc_early_drop or
20901 + * dpni_get_tx_tc_early_drop
20904 +void dpni_extract_early_drop(struct dpni_early_drop_cfg *cfg,
20905 + const uint8_t *early_drop_buf);
20908 + * dpni_set_rx_tc_early_drop() - Set Rx traffic class early-drop configuration
20909 + * @mc_io: Pointer to MC portal's I/O object
20910 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20911 + * @token: Token of DPNI object
20912 + * @tc_id: Traffic class selection (0-7)
20913 + * @early_drop_iova: I/O virtual address of 256 bytes DMA-able memory filled
20914 + * with the early-drop configuration by calling dpni_prepare_early_drop()
20916 + * warning: Before calling this function, call dpni_prepare_early_drop() to
20917 + * prepare the early_drop_iova parameter
20919 + * Return: '0' on Success; error code otherwise.
20921 +int dpni_set_rx_tc_early_drop(struct fsl_mc_io *mc_io,
20922 + uint32_t cmd_flags,
20925 + uint64_t early_drop_iova);
20928 + * dpni_get_rx_tc_early_drop() - Get Rx traffic class early-drop configuration
20929 + * @mc_io: Pointer to MC portal's I/O object
20930 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20931 + * @token: Token of DPNI object
20932 + * @tc_id: Traffic class selection (0-7)
20933 + * @early_drop_iova: I/O virtual address of 256 bytes DMA-able memory
20935 + * warning: After calling this function, call dpni_extract_early_drop() to
20936 + * get the early drop configuration
20938 + * Return: '0' on Success; error code otherwise.
20940 +int dpni_get_rx_tc_early_drop(struct fsl_mc_io *mc_io,
20941 + uint32_t cmd_flags,
20944 + uint64_t early_drop_iova);
20947 + * dpni_set_tx_tc_early_drop() - Set Tx traffic class early-drop configuration
20948 + * @mc_io: Pointer to MC portal's I/O object
20949 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20950 + * @token: Token of DPNI object
20951 + * @tc_id: Traffic class selection (0-7)
20952 + * @early_drop_iova: I/O virtual address of 256 bytes DMA-able memory filled
20953 + * with the early-drop configuration by calling dpni_prepare_early_drop()
20955 + * warning: Before calling this function, call dpni_prepare_early_drop() to
20956 + * prepare the early_drop_iova parameter
20958 + * Return: '0' on Success; error code otherwise.
20960 +int dpni_set_tx_tc_early_drop(struct fsl_mc_io *mc_io,
20961 + uint32_t cmd_flags,
20964 + uint64_t early_drop_iova);
20967 + * dpni_get_tx_tc_early_drop() - Get Tx traffic class early-drop configuration
20968 + * @mc_io: Pointer to MC portal's I/O object
20969 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
20970 + * @token: Token of DPNI object
20971 + * @tc_id: Traffic class selection (0-7)
20972 + * @early_drop_iova: I/O virtual address of 256 bytes DMA-able memory
20974 + * warning: After calling this function, call dpni_extract_early_drop() to
20975 + * get the early drop configuration
20977 + * Return: '0' on Success; error code otherwise.
20979 +int dpni_get_tx_tc_early_drop(struct fsl_mc_io *mc_io,
20980 + uint32_t cmd_flags,
20983 + uint64_t early_drop_iova);
20986 + * enum dpni_dest - DPNI destination types
20987 + * @DPNI_DEST_NONE: Unassigned destination; The queue is set in parked mode and
20988 + * does not generate FQDAN notifications; user is expected to
20989 + * dequeue from the queue based on polling or other user-defined
20991 + * @DPNI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
20992 + * notifications to the specified DPIO; user is expected to dequeue
20993 + * from the queue only after notification is received
20994 + * @DPNI_DEST_DPCON: The queue is set in schedule mode and does not generate
20995 + * FQDAN notifications, but is connected to the specified DPCON
20996 + * object; user is expected to dequeue from the DPCON channel
20999 + DPNI_DEST_NONE = 0,
21000 + DPNI_DEST_DPIO = 1,
21001 + DPNI_DEST_DPCON = 2
21005 + * struct dpni_dest_cfg - Structure representing DPNI destination parameters
21006 + * @dest_type: Destination type
21007 + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
21008 + * @priority: Priority selection within the DPIO or DPCON channel; valid values
21009 + * are 0-1 or 0-7, depending on the number of priorities in that
21010 + * channel; not relevant for 'DPNI_DEST_NONE' option
21012 +struct dpni_dest_cfg {
21013 + enum dpni_dest dest_type;
21015 + uint8_t priority;
21018 +/* DPNI congestion options */
21021 + * CSCN message is written to message_iova once entering a
21022 + * congestion state (see 'threshold_entry')
21024 +#define DPNI_CONG_OPT_WRITE_MEM_ON_ENTER 0x00000001
21026 + * CSCN message is written to message_iova once exiting a
21027 + * congestion state (see 'threshold_exit')
21029 +#define DPNI_CONG_OPT_WRITE_MEM_ON_EXIT 0x00000002
21031 + * CSCN write will attempt to allocate into a cache (coherent write);
21032 + * valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is selected
21034 +#define DPNI_CONG_OPT_COHERENT_WRITE 0x00000004
21036 + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
21037 + * DPIO/DPCON's WQ channel once entering a congestion state
21038 + * (see 'threshold_entry')
21040 +#define DPNI_CONG_OPT_NOTIFY_DEST_ON_ENTER 0x00000008
21042 + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' CSCN message is sent to
21043 + * DPIO/DPCON's WQ channel once exiting a congestion state
21044 + * (see 'threshold_exit')
21046 +#define DPNI_CONG_OPT_NOTIFY_DEST_ON_EXIT 0x00000010
21048 + * if 'dest_cfg.dest_type != DPNI_DEST_NONE' when the CSCN is written to the
21049 + * sw-portal's DQRR, the DQRI interrupt is asserted immediately (if enabled)
21051 +#define DPNI_CONG_OPT_INTR_COALESCING_DISABLED 0x00000020
21054 + * struct dpni_congestion_notification_cfg - congestion notification
21056 + * @units: units type
21057 + * @threshold_entry: above this threshold we enter a congestion state.
21058 + * set it to '0' to disable it
21059 + * @threshold_exit: below this threshold we exit the congestion state.
21060 + * @message_ctx: The context that will be part of the CSCN message
21061 + * @message_iova: I/O virtual address (must be in DMA-able memory),
21062 + * must be 16B aligned; valid only if 'DPNI_CONG_OPT_WRITE_MEM_<X>' is
21063 + * contained in 'options'
21064 + * @dest_cfg: CSCN can be send to either DPIO or DPCON WQ channel
21065 + * @options: Mask of available options; use 'DPNI_CONG_OPT_<X>' values
21068 +struct dpni_congestion_notification_cfg {
21069 + enum dpni_congestion_unit units;
21070 + uint32_t threshold_entry;
21071 + uint32_t threshold_exit;
21072 + uint64_t message_ctx;
21073 + uint64_t message_iova;
21074 + struct dpni_dest_cfg dest_cfg;
21075 + uint16_t options;
21079 + * dpni_set_rx_tc_congestion_notification() - Set Rx traffic class congestion
21080 + * notification configuration
21081 + * @mc_io: Pointer to MC portal's I/O object
21082 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21083 + * @token: Token of DPNI object
21084 + * @tc_id: Traffic class selection (0-7)
21085 + * @cfg: congestion notification configuration
21087 + * Return: '0' on Success; error code otherwise.
21089 +int dpni_set_rx_tc_congestion_notification(struct fsl_mc_io *mc_io,
21090 + uint32_t cmd_flags,
21093 + const struct dpni_congestion_notification_cfg *cfg);
21096 + * dpni_get_rx_tc_congestion_notification() - Get Rx traffic class congestion
21097 + * notification configuration
21098 + * @mc_io: Pointer to MC portal's I/O object
21099 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21100 + * @token: Token of DPNI object
21101 + * @tc_id: Traffic class selection (0-7)
21102 + * @cfg: congestion notification configuration
21104 + * Return: '0' on Success; error code otherwise.
21106 +int dpni_get_rx_tc_congestion_notification(struct fsl_mc_io *mc_io,
21107 + uint32_t cmd_flags,
21110 + struct dpni_congestion_notification_cfg *cfg);
21113 + * dpni_set_tx_tc_congestion_notification() - Set Tx traffic class congestion
21114 + * notification configuration
21115 + * @mc_io: Pointer to MC portal's I/O object
21116 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21117 + * @token: Token of DPNI object
21118 + * @tc_id: Traffic class selection (0-7)
21119 + * @cfg: congestion notification configuration
21121 + * Return: '0' on Success; error code otherwise.
21123 +int dpni_set_tx_tc_congestion_notification(struct fsl_mc_io *mc_io,
21124 + uint32_t cmd_flags,
21127 + const struct dpni_congestion_notification_cfg *cfg);
21130 + * dpni_get_tx_tc_congestion_notification() - Get Tx traffic class congestion
21131 + * notification configuration
21132 + * @mc_io: Pointer to MC portal's I/O object
21133 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21134 + * @token: Token of DPNI object
21135 + * @tc_id: Traffic class selection (0-7)
21136 + * @cfg: congestion notification configuration
21138 + * Return: '0' on Success; error code otherwise.
21140 +int dpni_get_tx_tc_congestion_notification(struct fsl_mc_io *mc_io,
21141 + uint32_t cmd_flags,
21144 + struct dpni_congestion_notification_cfg *cfg);
21147 + * enum dpni_flc_type - DPNI FLC types
21148 + * @DPNI_FLC_USER_DEFINED: select the FLC to be used for user defined value
21149 + * @DPNI_FLC_STASH: select the FLC to be used for stash control
21151 +enum dpni_flc_type {
21152 + DPNI_FLC_USER_DEFINED = 0,
21153 + DPNI_FLC_STASH = 1,
21157 + * enum dpni_stash_size - DPNI FLC stashing size
21158 + * @DPNI_STASH_SIZE_0B: no stash
21159 + * @DPNI_STASH_SIZE_64B: stashes 64 bytes
21160 + * @DPNI_STASH_SIZE_128B: stashes 128 bytes
21161 + * @DPNI_STASH_SIZE_192B: stashes 192 bytes
21163 +enum dpni_stash_size {
21164 + DPNI_STASH_SIZE_0B = 0,
21165 + DPNI_STASH_SIZE_64B = 1,
21166 + DPNI_STASH_SIZE_128B = 2,
21167 + DPNI_STASH_SIZE_192B = 3,
21170 +/* DPNI FLC stash options */
21173 + * stashes the whole annotation area (up to 192 bytes)
21175 +#define DPNI_FLC_STASH_FRAME_ANNOTATION 0x00000001
21178 + * struct dpni_flc_cfg - Structure representing DPNI FLC configuration
21179 + * @flc_type: FLC type
21180 + * @options: Mask of available options;
21181 + * use 'DPNI_FLC_STASH_<X>' values
21182 + * @frame_data_size: Size of frame data to be stashed
21183 + * @flow_context_size: Size of flow context to be stashed
21184 + * @flow_context: 1. In case flc_type is 'DPNI_FLC_USER_DEFINED':
21185 + * this value will be provided in the frame descriptor
21187 + * 2. In case flc_type is 'DPNI_FLC_STASH':
21188 + * this value will be I/O virtual address of the
21190 + * Must be cacheline-aligned and DMA-able memory
21192 +struct dpni_flc_cfg {
21193 + enum dpni_flc_type flc_type;
21194 + uint32_t options;
21195 + enum dpni_stash_size frame_data_size;
21196 + enum dpni_stash_size flow_context_size;
21197 + uint64_t flow_context;
21201 + * DPNI queue modification options
21205 + * Select to modify the user's context associated with the queue
21207 +#define DPNI_QUEUE_OPT_USER_CTX 0x00000001
21209 + * Select to modify the queue's destination
21211 +#define DPNI_QUEUE_OPT_DEST 0x00000002
21212 +/** Select to modify the flow-context parameters;
21213 + * not applicable for Tx-conf/Err queues as the FD comes from the user
21215 +#define DPNI_QUEUE_OPT_FLC 0x00000004
21217 + * Select to modify the queue's order preservation
21219 +#define DPNI_QUEUE_OPT_ORDER_PRESERVATION 0x00000008
21220 +/* Select to modify the queue's tail-drop threshold */
21221 +#define DPNI_QUEUE_OPT_TAILDROP_THRESHOLD 0x00000010
21224 + * struct dpni_queue_cfg - Structure representing queue configuration
21225 + * @options: Flags representing the suggested modifications to the queue;
21226 + * Use any combination of 'DPNI_QUEUE_OPT_<X>' flags
21227 + * @user_ctx: User context value provided in the frame descriptor of each
21228 + * dequeued frame; valid only if 'DPNI_QUEUE_OPT_USER_CTX'
21229 + * is contained in 'options'
21230 + * @dest_cfg: Queue destination parameters;
21231 + * valid only if 'DPNI_QUEUE_OPT_DEST' is contained in 'options'
21232 + * @flc_cfg: Flow context configuration; in case the TC's distribution
21233 + * is either NONE or HASH the FLC's settings of flow#0 are used.
21234 + * in the case of FS (flow-steering) the flow's FLC settings
21236 + * valid only if 'DPNI_QUEUE_OPT_FLC' is contained in 'options'
21237 + * @order_preservation_en: enable/disable order preservation;
21238 + * valid only if 'DPNI_QUEUE_OPT_ORDER_PRESERVATION' is contained
21240 + * @tail_drop_threshold: set the queue's tail drop threshold in bytes;
21241 + * '0' value disable the threshold; maximum value is 0xE000000;
21242 + * valid only if 'DPNI_QUEUE_OPT_TAILDROP_THRESHOLD' is contained
21245 +struct dpni_queue_cfg {
21246 + uint32_t options;
21247 + uint64_t user_ctx;
21248 + struct dpni_dest_cfg dest_cfg;
21249 + struct dpni_flc_cfg flc_cfg;
21250 + int order_preservation_en;
21251 + uint32_t tail_drop_threshold;
21255 + * struct dpni_queue_attr - Structure representing queue attributes
21256 + * @user_ctx: User context value provided in the frame descriptor of each
21258 + * @dest_cfg: Queue destination configuration
21259 + * @flc_cfg: Flow context configuration
21260 + * @order_preservation_en: enable/disable order preservation
21261 + * @tail_drop_threshold: queue's tail drop threshold in bytes;
21262 + * @fqid: Virtual fqid value to be used for dequeue operations
21264 +struct dpni_queue_attr {
21265 + uint64_t user_ctx;
21266 + struct dpni_dest_cfg dest_cfg;
21267 + struct dpni_flc_cfg flc_cfg;
21268 + int order_preservation_en;
21269 + uint32_t tail_drop_threshold;
21275 + * DPNI Tx flow modification options
21279 + * Select to modify the settings for dedicate Tx confirmation/error
21281 +#define DPNI_TX_FLOW_OPT_TX_CONF_ERROR 0x00000001
21283 + * Select to modify the L3 checksum generation setting
21285 +#define DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN 0x00000010
21287 + * Select to modify the L4 checksum generation setting
21289 +#define DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN 0x00000020
21292 + * struct dpni_tx_flow_cfg - Structure representing Tx flow configuration
21293 + * @options: Flags representing the suggested modifications to the Tx flow;
21294 + * Use any combination 'DPNI_TX_FLOW_OPT_<X>' flags
21295 + * @use_common_tx_conf_queue: Set to '1' to use the common (default) Tx
21296 + * confirmation and error queue; Set to '0' to use the private
21297 + * Tx confirmation and error queue; valid only if
21298 + * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' wasn't set at DPNI creation
21299 + * and 'DPNI_TX_FLOW_OPT_TX_CONF_ERROR' is contained in 'options'
21300 + * @l3_chksum_gen: Set to '1' to enable L3 checksum generation; '0' to disable;
21301 + * valid only if 'DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN' is contained in 'options'
21302 + * @l4_chksum_gen: Set to '1' to enable L4 checksum generation; '0' to disable;
21303 + * valid only if 'DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN' is contained in 'options'
21305 +struct dpni_tx_flow_cfg {
21306 + uint32_t options;
21307 + int use_common_tx_conf_queue;
21308 + int l3_chksum_gen;
21309 + int l4_chksum_gen;
21313 + * dpni_set_tx_flow() - Set Tx flow configuration
21314 + * @mc_io: Pointer to MC portal's I/O object
21315 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21316 + * @token: Token of DPNI object
21317 + * @flow_id: Provides (or returns) the sender's flow ID;
21318 + * for each new sender set (*flow_id) to 'DPNI_NEW_FLOW_ID' to generate
21319 + * a new flow_id; this ID should be used as the QDBIN argument
21320 + * in enqueue operations
21321 + * @cfg: Tx flow configuration
21323 + * Return: '0' on Success; Error code otherwise.
21325 +int dpni_set_tx_flow(struct fsl_mc_io *mc_io,
21326 + uint32_t cmd_flags,
21328 + uint16_t *flow_id,
21329 + const struct dpni_tx_flow_cfg *cfg);
21332 + * struct dpni_tx_flow_attr - Structure representing Tx flow attributes
21333 + * @use_common_tx_conf_queue: '1' if using common (default) Tx confirmation and
21334 + * error queue; '0' if using private Tx confirmation and error queue
21335 + * @l3_chksum_gen: '1' if L3 checksum generation is enabled; '0' if disabled
21336 + * @l4_chksum_gen: '1' if L4 checksum generation is enabled; '0' if disabled
21338 +struct dpni_tx_flow_attr {
21339 + int use_common_tx_conf_queue;
21340 + int l3_chksum_gen;
21341 + int l4_chksum_gen;
21345 + * dpni_get_tx_flow() - Get Tx flow attributes
21346 + * @mc_io: Pointer to MC portal's I/O object
21347 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21348 + * @token: Token of DPNI object
21349 + * @flow_id: The sender's flow ID, as returned by the
21350 + * dpni_set_tx_flow() function
21351 + * @attr: Returned Tx flow attributes
21353 + * Return: '0' on Success; Error code otherwise.
21355 +int dpni_get_tx_flow(struct fsl_mc_io *mc_io,
21356 + uint32_t cmd_flags,
21358 + uint16_t flow_id,
21359 + struct dpni_tx_flow_attr *attr);
21362 + * struct dpni_tx_conf_cfg - Structure representing Tx conf configuration
21363 + * @errors_only: Set to '1' to report back only error frames;
21364 + * Set to '0' to confirm transmission/error for all transmitted frames;
21365 + * @queue_cfg: Queue configuration
21367 +struct dpni_tx_conf_cfg {
21369 + struct dpni_queue_cfg queue_cfg;
21373 + * dpni_set_tx_conf() - Set Tx confirmation and error queue configuration
21374 + * @mc_io: Pointer to MC portal's I/O object
21375 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21376 + * @token: Token of DPNI object
21377 + * @flow_id: The sender's flow ID, as returned by the
21378 + * dpni_set_tx_flow() function;
21379 + * use 'DPNI_COMMON_TX_CONF' for common tx-conf
21380 + * @cfg: Queue configuration
21382 + * If either 'DPNI_OPT_TX_CONF_DISABLED' or
21383 + * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
21384 + * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
21385 + * i.e. only serve the common tx-conf-err queue;
21386 + * if 'DPNI_OPT_TX_CONF_DISABLED' was selected, only error frames are reported
21387 + * back - successfully transmitted frames are not confirmed. Otherwise, all
21388 + * transmitted frames are sent for confirmation.
21390 + * Return: '0' on Success; Error code otherwise.
21392 +int dpni_set_tx_conf(struct fsl_mc_io *mc_io,
21393 + uint32_t cmd_flags,
21395 + uint16_t flow_id,
21396 + const struct dpni_tx_conf_cfg *cfg);
21399 + * struct dpni_tx_conf_attr - Structure representing Tx conf attributes
21400 + * @errors_only: '1' if only error frames are reported back; '0' if all
21401 + * transmitted frames are confirmed
21402 + * @queue_attr: Queue attributes
21404 +struct dpni_tx_conf_attr {
21406 + struct dpni_queue_attr queue_attr;
21410 + * dpni_get_tx_conf() - Get Tx confirmation and error queue attributes
21411 + * @mc_io: Pointer to MC portal's I/O object
21412 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21413 + * @token: Token of DPNI object
21414 + * @flow_id: The sender's flow ID, as returned by the
21415 + * dpni_set_tx_flow() function;
21416 + * use 'DPNI_COMMON_TX_CONF' for common tx-conf
21417 + * @attr: Returned tx-conf attributes
21419 + * If either 'DPNI_OPT_TX_CONF_DISABLED' or
21420 + * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
21421 + * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
21422 + * i.e. only serve the common tx-conf-err queue;
21424 + * Return: '0' on Success; Error code otherwise.
21426 +int dpni_get_tx_conf(struct fsl_mc_io *mc_io,
21427 + uint32_t cmd_flags,
21429 + uint16_t flow_id,
21430 + struct dpni_tx_conf_attr *attr);
21433 + * dpni_set_tx_conf_congestion_notification() - Set Tx conf congestion
21434 + * notification configuration
21435 + * @mc_io: Pointer to MC portal's I/O object
21436 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21437 + * @token: Token of DPNI object
21438 + * @flow_id: The sender's flow ID, as returned by the
21439 + * dpni_set_tx_flow() function;
21440 + * use 'DPNI_COMMON_TX_CONF' for common tx-conf
21441 + * @cfg: congestion notification configuration
21443 + * If either 'DPNI_OPT_TX_CONF_DISABLED' or
21444 + * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
21445 + * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
21446 + * i.e. only serve the common tx-conf-err queue;
21448 + * Return: '0' on Success; error code otherwise.
21450 +int dpni_set_tx_conf_congestion_notification(struct fsl_mc_io *mc_io,
21451 + uint32_t cmd_flags,
21453 + uint16_t flow_id,
21454 + const struct dpni_congestion_notification_cfg *cfg);
21457 + * dpni_get_tx_conf_congestion_notification() - Get Tx conf congestion
21458 + * notification configuration
21459 + * @mc_io: Pointer to MC portal's I/O object
21460 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21461 + * @token: Token of DPNI object
21462 + * @flow_id: The sender's flow ID, as returned by the
21463 + * dpni_set_tx_flow() function;
21464 + * use 'DPNI_COMMON_TX_CONF' for common tx-conf
21465 + * @cfg: congestion notification
21467 + * If either 'DPNI_OPT_TX_CONF_DISABLED' or
21468 + * 'DPNI_OPT_PRIVATE_TX_CONF_ERROR_DISABLED' were selected at DPNI creation,
21469 + * this function can ONLY be used with 'flow_id == DPNI_COMMON_TX_CONF';
21470 + * i.e. only serve the common tx-conf-err queue;
21472 + * Return: '0' on Success; error code otherwise.
21474 +int dpni_get_tx_conf_congestion_notification(struct fsl_mc_io *mc_io,
21475 + uint32_t cmd_flags,
21477 + uint16_t flow_id,
21478 + struct dpni_congestion_notification_cfg *cfg);
21481 + * dpni_set_tx_conf_revoke() - Tx confirmation revocation
21482 + * @mc_io: Pointer to MC portal's I/O object
21483 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21484 + * @token: Token of DPNI object
21485 + * @revoke: revoke or not
21487 + * This function is useful only when 'DPNI_OPT_TX_CONF_DISABLED' is not
21488 + * selected at DPNI creation.
21489 + * Calling this function with 'revoke' set to '1' disables all transmit
21490 + * confirmation (including the private confirmation queues), regardless of
21491 + * previous settings; Note that in this case, Tx error frames are still
21492 + * enqueued to the general transmit errors queue.
21493 + * Calling this function with 'revoke' set to '0' restores the previous
21494 + * settings for both general and private transmit confirmation.
21496 + * Return: '0' on Success; Error code otherwise.
21498 +int dpni_set_tx_conf_revoke(struct fsl_mc_io *mc_io,
21499 + uint32_t cmd_flags,
21504 + * dpni_set_rx_flow() - Set Rx flow configuration
21505 + * @mc_io: Pointer to MC portal's I/O object
21506 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21507 + * @token: Token of DPNI object
21508 + * @tc_id: Traffic class selection (0-7);
21509 + * use 'DPNI_ALL_TCS' to set all TCs and all flows
21510 + * @flow_id: Rx flow id within the traffic class; use
21511 + * 'DPNI_ALL_TC_FLOWS' to set all flows within
21512 + * this tc_id; ignored if tc_id is set to
21513 + * 'DPNI_ALL_TCS';
21514 + * @cfg: Rx flow configuration
21516 + * Return: '0' on Success; Error code otherwise.
21518 +int dpni_set_rx_flow(struct fsl_mc_io *mc_io,
21519 + uint32_t cmd_flags,
21522 + uint16_t flow_id,
21523 + const struct dpni_queue_cfg *cfg);
21526 + * dpni_get_rx_flow() - Get Rx flow attributes
21527 + * @mc_io: Pointer to MC portal's I/O object
21528 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21529 + * @token: Token of DPNI object
21530 + * @tc_id: Traffic class selection (0-7)
21531 + * @flow_id: Rx flow id within the traffic class
21532 + * @attr: Returned Rx flow attributes
21534 + * Return: '0' on Success; Error code otherwise.
21536 +int dpni_get_rx_flow(struct fsl_mc_io *mc_io,
21537 + uint32_t cmd_flags,
21540 + uint16_t flow_id,
21541 + struct dpni_queue_attr *attr);
21544 + * dpni_set_rx_err_queue() - Set Rx error queue configuration
21545 + * @mc_io: Pointer to MC portal's I/O object
21546 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21547 + * @token: Token of DPNI object
21548 + * @cfg: Queue configuration
21550 + * Return: '0' on Success; Error code otherwise.
21552 +int dpni_set_rx_err_queue(struct fsl_mc_io *mc_io,
21553 + uint32_t cmd_flags,
21555 + const struct dpni_queue_cfg *cfg);
21558 + * dpni_get_rx_err_queue() - Get Rx error queue attributes
21559 + * @mc_io: Pointer to MC portal's I/O object
21560 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21561 + * @token: Token of DPNI object
21562 + * @attr: Returned Queue attributes
21564 + * Return: '0' on Success; Error code otherwise.
21566 +int dpni_get_rx_err_queue(struct fsl_mc_io *mc_io,
21567 + uint32_t cmd_flags,
21569 + struct dpni_queue_attr *attr);
21572 + * struct dpni_qos_tbl_cfg - Structure representing QOS table configuration
21573 + * @key_cfg_iova: I/O virtual address of 256 bytes DMA-able memory filled with
21574 + * key extractions to be used as the QoS criteria by calling
21575 + * dpni_prepare_key_cfg()
21576 + * @discard_on_miss: Set to '1' to discard frames in case of no match (miss);
21577 + * '0' to use the 'default_tc' in such cases
21578 + * @default_tc: Used in case of no-match and 'discard_on_miss'= 0
21580 +struct dpni_qos_tbl_cfg {
21581 + uint64_t key_cfg_iova;
21582 + int discard_on_miss;
21583 + uint8_t default_tc;
21587 + * dpni_set_qos_table() - Set QoS mapping table
21588 + * @mc_io: Pointer to MC portal's I/O object
21589 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21590 + * @token: Token of DPNI object
21591 + * @cfg: QoS table configuration
21593 + * This function and all QoS-related functions require that
21594 + *'max_tcs > 1' was set at DPNI creation.
21596 + * warning: Before calling this function, call dpni_prepare_key_cfg() to
21597 + * prepare the key_cfg_iova parameter
21599 + * Return: '0' on Success; Error code otherwise.
21601 +int dpni_set_qos_table(struct fsl_mc_io *mc_io,
21602 + uint32_t cmd_flags,
21604 + const struct dpni_qos_tbl_cfg *cfg);
21607 + * struct dpni_rule_cfg - Rule configuration for table lookup
21608 + * @key_iova: I/O virtual address of the key (must be in DMA-able memory)
21609 + * @mask_iova: I/O virtual address of the mask (must be in DMA-able memory)
21610 + * @key_size: key and mask size (in bytes)
21612 +struct dpni_rule_cfg {
21613 + uint64_t key_iova;
21614 + uint64_t mask_iova;
21615 + uint8_t key_size;
21619 + * dpni_add_qos_entry() - Add QoS mapping entry (to select a traffic class)
21620 + * @mc_io: Pointer to MC portal's I/O object
21621 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21622 + * @token: Token of DPNI object
21623 + * @cfg: QoS rule to add
21624 + * @tc_id: Traffic class selection (0-7)
21626 + * Return: '0' on Success; Error code otherwise.
21628 +int dpni_add_qos_entry(struct fsl_mc_io *mc_io,
21629 + uint32_t cmd_flags,
21631 + const struct dpni_rule_cfg *cfg,
21635 + * dpni_remove_qos_entry() - Remove QoS mapping entry
21636 + * @mc_io: Pointer to MC portal's I/O object
21637 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21638 + * @token: Token of DPNI object
21639 + * @cfg: QoS rule to remove
21641 + * Return: '0' on Success; Error code otherwise.
21643 +int dpni_remove_qos_entry(struct fsl_mc_io *mc_io,
21644 + uint32_t cmd_flags,
21646 + const struct dpni_rule_cfg *cfg);
21649 + * dpni_clear_qos_table() - Clear all QoS mapping entries
21650 + * @mc_io: Pointer to MC portal's I/O object
21651 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21652 + * @token: Token of DPNI object
21654 + * Following this function call, all frames are directed to
21655 + * the default traffic class (0)
21657 + * Return: '0' on Success; Error code otherwise.
21659 +int dpni_clear_qos_table(struct fsl_mc_io *mc_io,
21660 + uint32_t cmd_flags,
21664 + * dpni_add_fs_entry() - Add Flow Steering entry for a specific traffic class
21665 + * (to select a flow ID)
21666 + * @mc_io: Pointer to MC portal's I/O object
21667 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21668 + * @token: Token of DPNI object
21669 + * @tc_id: Traffic class selection (0-7)
21670 + * @cfg: Flow steering rule to add
21671 + * @flow_id: Flow id selection (must be smaller than the
21672 + * distribution size of the traffic class)
21674 + * Return: '0' on Success; Error code otherwise.
21676 +int dpni_add_fs_entry(struct fsl_mc_io *mc_io,
21677 + uint32_t cmd_flags,
21680 + const struct dpni_rule_cfg *cfg,
21681 + uint16_t flow_id);
21684 + * dpni_remove_fs_entry() - Remove Flow Steering entry from a specific
21686 + * @mc_io: Pointer to MC portal's I/O object
21687 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21688 + * @token: Token of DPNI object
21689 + * @tc_id: Traffic class selection (0-7)
21690 + * @cfg: Flow steering rule to remove
21692 + * Return: '0' on Success; Error code otherwise.
21694 +int dpni_remove_fs_entry(struct fsl_mc_io *mc_io,
21695 + uint32_t cmd_flags,
21698 + const struct dpni_rule_cfg *cfg);
21701 + * dpni_clear_fs_entries() - Clear all Flow Steering entries of a specific
21703 + * @mc_io: Pointer to MC portal's I/O object
21704 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21705 + * @token: Token of DPNI object
21706 + * @tc_id: Traffic class selection (0-7)
21708 + * Return: '0' on Success; Error code otherwise.
21710 +int dpni_clear_fs_entries(struct fsl_mc_io *mc_io,
21711 + uint32_t cmd_flags,
21716 + * dpni_set_vlan_insertion() - Enable/disable VLAN insertion for egress frames
21717 + * @mc_io: Pointer to MC portal's I/O object
21718 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21719 + * @token: Token of DPNI object
21720 + * @en: Set to '1' to enable; '0' to disable
21722 + * Requires that the 'DPNI_OPT_VLAN_MANIPULATION' option is set
21723 + * at DPNI creation.
21725 + * Return: '0' on Success; Error code otherwise.
21727 +int dpni_set_vlan_insertion(struct fsl_mc_io *mc_io,
21728 + uint32_t cmd_flags,
21733 + * dpni_set_vlan_removal() - Enable/disable VLAN removal for ingress frames
21734 + * @mc_io: Pointer to MC portal's I/O object
21735 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21736 + * @token: Token of DPNI object
21737 + * @en: Set to '1' to enable; '0' to disable
21739 + * Requires that the 'DPNI_OPT_VLAN_MANIPULATION' option is set
21740 + * at DPNI creation.
21742 + * Return: '0' on Success; Error code otherwise.
21744 +int dpni_set_vlan_removal(struct fsl_mc_io *mc_io,
21745 + uint32_t cmd_flags,
21750 + * dpni_set_ipr() - Enable/disable IP reassembly of ingress frames
21751 + * @mc_io: Pointer to MC portal's I/O object
21752 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21753 + * @token: Token of DPNI object
21754 + * @en: Set to '1' to enable; '0' to disable
21756 + * Requires that the 'DPNI_OPT_IPR' option is set at DPNI creation.
21758 + * Return: '0' on Success; Error code otherwise.
21760 +int dpni_set_ipr(struct fsl_mc_io *mc_io,
21761 + uint32_t cmd_flags,
21766 + * dpni_set_ipf() - Enable/disable IP fragmentation of egress frames
21767 + * @mc_io: Pointer to MC portal's I/O object
21768 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
21769 + * @token: Token of DPNI object
21770 + * @en: Set to '1' to enable; '0' to disable
21772 + * Requires that the 'DPNI_OPT_IPF' option is set at DPNI
21773 + * creation. Fragmentation is performed according to MTU value
21774 + * set by dpni_set_mtu() function
21776 + * Return: '0' on Success; Error code otherwise.
21778 +int dpni_set_ipf(struct fsl_mc_io *mc_io,
21779 + uint32_t cmd_flags,
21783 +#endif /* __FSL_DPNI_H */
21784 diff --git a/drivers/net/dpaa2/mc/fsl_dpni_cmd.h b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
21785 new file mode 100644
21786 index 0000000..c0f8af0
21788 +++ b/drivers/net/dpaa2/mc/fsl_dpni_cmd.h
21790 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
21792 + * Redistribution and use in source and binary forms, with or without
21793 + * modification, are permitted provided that the following conditions are met:
21794 + * * Redistributions of source code must retain the above copyright
21795 + * notice, this list of conditions and the following disclaimer.
21796 + * * Redistributions in binary form must reproduce the above copyright
21797 + * notice, this list of conditions and the following disclaimer in the
21798 + * documentation and/or other materials provided with the distribution.
21799 + * * Neither the name of the above-listed copyright holders nor the
21800 + * names of any contributors may be used to endorse or promote products
21801 + * derived from this software without specific prior written permission.
21804 + * ALTERNATIVELY, this software may be distributed under the terms of the
21805 + * GNU General Public License ("GPL") as published by the Free Software
21806 + * Foundation, either version 2 of that License or (at your option) any
21809 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21810 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21811 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21812 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
21813 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21814 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21815 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21816 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21817 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21818 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21819 + * POSSIBILITY OF SUCH DAMAGE.
21821 +#ifndef _FSL_DPNI_CMD_H
21822 +#define _FSL_DPNI_CMD_H
21824 +/* DPNI Version */
21825 +#define DPNI_VER_MAJOR 6
21826 +#define DPNI_VER_MINOR 0
21829 +#define DPNI_CMDID_OPEN 0x801
21830 +#define DPNI_CMDID_CLOSE 0x800
21831 +#define DPNI_CMDID_CREATE 0x901
21832 +#define DPNI_CMDID_DESTROY 0x900
21834 +#define DPNI_CMDID_ENABLE 0x002
21835 +#define DPNI_CMDID_DISABLE 0x003
21836 +#define DPNI_CMDID_GET_ATTR 0x004
21837 +#define DPNI_CMDID_RESET 0x005
21838 +#define DPNI_CMDID_IS_ENABLED 0x006
21840 +#define DPNI_CMDID_SET_IRQ 0x010
21841 +#define DPNI_CMDID_GET_IRQ 0x011
21842 +#define DPNI_CMDID_SET_IRQ_ENABLE 0x012
21843 +#define DPNI_CMDID_GET_IRQ_ENABLE 0x013
21844 +#define DPNI_CMDID_SET_IRQ_MASK 0x014
21845 +#define DPNI_CMDID_GET_IRQ_MASK 0x015
21846 +#define DPNI_CMDID_GET_IRQ_STATUS 0x016
21847 +#define DPNI_CMDID_CLEAR_IRQ_STATUS 0x017
21849 +#define DPNI_CMDID_SET_POOLS 0x200
21850 +#define DPNI_CMDID_GET_RX_BUFFER_LAYOUT 0x201
21851 +#define DPNI_CMDID_SET_RX_BUFFER_LAYOUT 0x202
21852 +#define DPNI_CMDID_GET_TX_BUFFER_LAYOUT 0x203
21853 +#define DPNI_CMDID_SET_TX_BUFFER_LAYOUT 0x204
21854 +#define DPNI_CMDID_SET_TX_CONF_BUFFER_LAYOUT 0x205
21855 +#define DPNI_CMDID_GET_TX_CONF_BUFFER_LAYOUT 0x206
21856 +#define DPNI_CMDID_SET_L3_CHKSUM_VALIDATION 0x207
21857 +#define DPNI_CMDID_GET_L3_CHKSUM_VALIDATION 0x208
21858 +#define DPNI_CMDID_SET_L4_CHKSUM_VALIDATION 0x209
21859 +#define DPNI_CMDID_GET_L4_CHKSUM_VALIDATION 0x20A
21860 +#define DPNI_CMDID_SET_ERRORS_BEHAVIOR 0x20B
21861 +#define DPNI_CMDID_SET_TX_CONF_REVOKE 0x20C
21863 +#define DPNI_CMDID_GET_QDID 0x210
21864 +#define DPNI_CMDID_GET_SP_INFO 0x211
21865 +#define DPNI_CMDID_GET_TX_DATA_OFFSET 0x212
21866 +#define DPNI_CMDID_GET_COUNTER 0x213
21867 +#define DPNI_CMDID_SET_COUNTER 0x214
21868 +#define DPNI_CMDID_GET_LINK_STATE 0x215
21869 +#define DPNI_CMDID_SET_MAX_FRAME_LENGTH 0x216
21870 +#define DPNI_CMDID_GET_MAX_FRAME_LENGTH 0x217
21871 +#define DPNI_CMDID_SET_MTU 0x218
21872 +#define DPNI_CMDID_GET_MTU 0x219
21873 +#define DPNI_CMDID_SET_LINK_CFG 0x21A
21874 +#define DPNI_CMDID_SET_TX_SHAPING 0x21B
21876 +#define DPNI_CMDID_SET_MCAST_PROMISC 0x220
21877 +#define DPNI_CMDID_GET_MCAST_PROMISC 0x221
21878 +#define DPNI_CMDID_SET_UNICAST_PROMISC 0x222
21879 +#define DPNI_CMDID_GET_UNICAST_PROMISC 0x223
21880 +#define DPNI_CMDID_SET_PRIM_MAC 0x224
21881 +#define DPNI_CMDID_GET_PRIM_MAC 0x225
21882 +#define DPNI_CMDID_ADD_MAC_ADDR 0x226
21883 +#define DPNI_CMDID_REMOVE_MAC_ADDR 0x227
21884 +#define DPNI_CMDID_CLR_MAC_FILTERS 0x228
21886 +#define DPNI_CMDID_SET_VLAN_FILTERS 0x230
21887 +#define DPNI_CMDID_ADD_VLAN_ID 0x231
21888 +#define DPNI_CMDID_REMOVE_VLAN_ID 0x232
21889 +#define DPNI_CMDID_CLR_VLAN_FILTERS 0x233
21891 +#define DPNI_CMDID_SET_RX_TC_DIST 0x235
21892 +#define DPNI_CMDID_SET_TX_FLOW 0x236
21893 +#define DPNI_CMDID_GET_TX_FLOW 0x237
21894 +#define DPNI_CMDID_SET_RX_FLOW 0x238
21895 +#define DPNI_CMDID_GET_RX_FLOW 0x239
21896 +#define DPNI_CMDID_SET_RX_ERR_QUEUE 0x23A
21897 +#define DPNI_CMDID_GET_RX_ERR_QUEUE 0x23B
21899 +#define DPNI_CMDID_SET_RX_TC_POLICING 0x23E
21900 +#define DPNI_CMDID_SET_RX_TC_EARLY_DROP 0x23F
21902 +#define DPNI_CMDID_SET_QOS_TBL 0x240
21903 +#define DPNI_CMDID_ADD_QOS_ENT 0x241
21904 +#define DPNI_CMDID_REMOVE_QOS_ENT 0x242
21905 +#define DPNI_CMDID_CLR_QOS_TBL 0x243
21906 +#define DPNI_CMDID_ADD_FS_ENT 0x244
21907 +#define DPNI_CMDID_REMOVE_FS_ENT 0x245
21908 +#define DPNI_CMDID_CLR_FS_ENT 0x246
21909 +#define DPNI_CMDID_SET_VLAN_INSERTION 0x247
21910 +#define DPNI_CMDID_SET_VLAN_REMOVAL 0x248
21911 +#define DPNI_CMDID_SET_IPR 0x249
21912 +#define DPNI_CMDID_SET_IPF 0x24A
21914 +#define DPNI_CMDID_SET_TX_SELECTION 0x250
21915 +#define DPNI_CMDID_GET_RX_TC_POLICING 0x251
21916 +#define DPNI_CMDID_GET_RX_TC_EARLY_DROP 0x252
21917 +#define DPNI_CMDID_SET_RX_TC_CONGESTION_NOTIFICATION 0x253
21918 +#define DPNI_CMDID_GET_RX_TC_CONGESTION_NOTIFICATION 0x254
21919 +#define DPNI_CMDID_SET_TX_TC_CONGESTION_NOTIFICATION 0x255
21920 +#define DPNI_CMDID_GET_TX_TC_CONGESTION_NOTIFICATION 0x256
21921 +#define DPNI_CMDID_SET_TX_CONF 0x257
21922 +#define DPNI_CMDID_GET_TX_CONF 0x258
21923 +#define DPNI_CMDID_SET_TX_CONF_CONGESTION_NOTIFICATION 0x259
21924 +#define DPNI_CMDID_GET_TX_CONF_CONGESTION_NOTIFICATION 0x25A
21925 +#define DPNI_CMDID_SET_TX_TC_EARLY_DROP 0x25B
21926 +#define DPNI_CMDID_GET_TX_TC_EARLY_DROP 0x25C
21928 +/* cmd, param, offset, width, type, arg_name */
21929 +#define DPNI_CMD_OPEN(cmd, dpni_id) \
21930 + MC_CMD_OP(cmd, 0, 0, 32, int, dpni_id)
21932 +#define DPNI_PREP_EXTENDED_CFG(ext, cfg) \
21934 + MC_PREP_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
21935 + MC_PREP_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
21936 + MC_PREP_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
21937 + MC_PREP_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
21938 + MC_PREP_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
21939 + MC_PREP_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
21940 + MC_PREP_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
21941 + MC_PREP_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
21942 + MC_PREP_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
21943 + MC_PREP_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
21944 + MC_PREP_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
21945 + MC_PREP_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
21946 + MC_PREP_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
21947 + MC_PREP_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
21948 + MC_PREP_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
21949 + MC_PREP_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
21950 + MC_PREP_OP(ext, 4, 0, 16, uint16_t, \
21951 + cfg->ipr_cfg.max_open_frames_ipv4); \
21952 + MC_PREP_OP(ext, 4, 16, 16, uint16_t, \
21953 + cfg->ipr_cfg.max_open_frames_ipv6); \
21954 + MC_PREP_OP(ext, 4, 32, 16, uint16_t, \
21955 + cfg->ipr_cfg.max_reass_frm_size); \
21956 + MC_PREP_OP(ext, 5, 0, 16, uint16_t, \
21957 + cfg->ipr_cfg.min_frag_size_ipv4); \
21958 + MC_PREP_OP(ext, 5, 16, 16, uint16_t, \
21959 + cfg->ipr_cfg.min_frag_size_ipv6); \
21962 +#define DPNI_EXT_EXTENDED_CFG(ext, cfg) \
21964 + MC_EXT_OP(ext, 0, 0, 16, uint16_t, cfg->tc_cfg[0].max_dist); \
21965 + MC_EXT_OP(ext, 0, 16, 16, uint16_t, cfg->tc_cfg[0].max_fs_entries); \
21966 + MC_EXT_OP(ext, 0, 32, 16, uint16_t, cfg->tc_cfg[1].max_dist); \
21967 + MC_EXT_OP(ext, 0, 48, 16, uint16_t, cfg->tc_cfg[1].max_fs_entries); \
21968 + MC_EXT_OP(ext, 1, 0, 16, uint16_t, cfg->tc_cfg[2].max_dist); \
21969 + MC_EXT_OP(ext, 1, 16, 16, uint16_t, cfg->tc_cfg[2].max_fs_entries); \
21970 + MC_EXT_OP(ext, 1, 32, 16, uint16_t, cfg->tc_cfg[3].max_dist); \
21971 + MC_EXT_OP(ext, 1, 48, 16, uint16_t, cfg->tc_cfg[3].max_fs_entries); \
21972 + MC_EXT_OP(ext, 2, 0, 16, uint16_t, cfg->tc_cfg[4].max_dist); \
21973 + MC_EXT_OP(ext, 2, 16, 16, uint16_t, cfg->tc_cfg[4].max_fs_entries); \
21974 + MC_EXT_OP(ext, 2, 32, 16, uint16_t, cfg->tc_cfg[5].max_dist); \
21975 + MC_EXT_OP(ext, 2, 48, 16, uint16_t, cfg->tc_cfg[5].max_fs_entries); \
21976 + MC_EXT_OP(ext, 3, 0, 16, uint16_t, cfg->tc_cfg[6].max_dist); \
21977 + MC_EXT_OP(ext, 3, 16, 16, uint16_t, cfg->tc_cfg[6].max_fs_entries); \
21978 + MC_EXT_OP(ext, 3, 32, 16, uint16_t, cfg->tc_cfg[7].max_dist); \
21979 + MC_EXT_OP(ext, 3, 48, 16, uint16_t, cfg->tc_cfg[7].max_fs_entries); \
21980 + MC_EXT_OP(ext, 4, 0, 16, uint16_t, \
21981 + cfg->ipr_cfg.max_open_frames_ipv4); \
21982 + MC_EXT_OP(ext, 4, 16, 16, uint16_t, \
21983 + cfg->ipr_cfg.max_open_frames_ipv6); \
21984 + MC_EXT_OP(ext, 4, 32, 16, uint16_t, \
21985 + cfg->ipr_cfg.max_reass_frm_size); \
21986 + MC_EXT_OP(ext, 5, 0, 16, uint16_t, \
21987 + cfg->ipr_cfg.min_frag_size_ipv4); \
21988 + MC_EXT_OP(ext, 5, 16, 16, uint16_t, \
21989 + cfg->ipr_cfg.min_frag_size_ipv6); \
21992 +/* cmd, param, offset, width, type, arg_name */
21993 +#define DPNI_CMD_CREATE(cmd, cfg) \
21995 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->adv.max_tcs); \
21996 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->adv.max_senders); \
21997 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]); \
21998 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]); \
21999 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]); \
22000 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]); \
22001 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]); \
22002 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]); \
22003 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->adv.options); \
22004 + MC_CMD_OP(cmd, 2, 0, 8, uint8_t, cfg->adv.max_unicast_filters); \
22005 + MC_CMD_OP(cmd, 2, 8, 8, uint8_t, cfg->adv.max_multicast_filters); \
22006 + MC_CMD_OP(cmd, 2, 16, 8, uint8_t, cfg->adv.max_vlan_filters); \
22007 + MC_CMD_OP(cmd, 2, 24, 8, uint8_t, cfg->adv.max_qos_entries); \
22008 + MC_CMD_OP(cmd, 2, 32, 8, uint8_t, cfg->adv.max_qos_key_size); \
22009 + MC_CMD_OP(cmd, 2, 48, 8, uint8_t, cfg->adv.max_dist_key_size); \
22010 + MC_CMD_OP(cmd, 2, 56, 8, enum net_prot, cfg->adv.start_hdr); \
22011 + MC_CMD_OP(cmd, 4, 48, 8, uint8_t, cfg->adv.max_policers); \
22012 + MC_CMD_OP(cmd, 4, 56, 8, uint8_t, cfg->adv.max_congestion_ctrl); \
22013 + MC_CMD_OP(cmd, 5, 0, 64, uint64_t, cfg->adv.ext_cfg_iova); \
22016 +/* cmd, param, offset, width, type, arg_name */
22017 +#define DPNI_CMD_SET_POOLS(cmd, cfg) \
22019 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
22020 + MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
22021 + MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
22022 + MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
22023 + MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
22024 + MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
22025 + MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
22026 + MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
22027 + MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
22028 + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
22029 + MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
22030 + MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
22031 + MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
22032 + MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
22033 + MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
22034 + MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
22035 + MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
22036 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
22037 + MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
22038 + MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
22039 + MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
22040 + MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
22041 + MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
22042 + MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
22043 + MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
22046 +/* cmd, param, offset, width, type, arg_name */
22047 +#define DPNI_RSP_IS_ENABLED(cmd, en) \
22048 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
22050 +/* cmd, param, offset, width, type, arg_name */
22051 +#define DPNI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
22053 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
22054 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
22055 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
22056 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
22059 +/* cmd, param, offset, width, type, arg_name */
22060 +#define DPNI_CMD_GET_IRQ(cmd, irq_index) \
22061 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
22063 +/* cmd, param, offset, width, type, arg_name */
22064 +#define DPNI_RSP_GET_IRQ(cmd, type, irq_cfg) \
22066 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
22067 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
22068 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
22069 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
22072 +/* cmd, param, offset, width, type, arg_name */
22073 +#define DPNI_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
22075 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
22076 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
22079 +/* cmd, param, offset, width, type, arg_name */
22080 +#define DPNI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
22081 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
22083 +/* cmd, param, offset, width, type, arg_name */
22084 +#define DPNI_RSP_GET_IRQ_ENABLE(cmd, en) \
22085 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
22087 +/* cmd, param, offset, width, type, arg_name */
22088 +#define DPNI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
22090 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
22091 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
22094 +/* cmd, param, offset, width, type, arg_name */
22095 +#define DPNI_CMD_GET_IRQ_MASK(cmd, irq_index) \
22096 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
22098 +/* cmd, param, offset, width, type, arg_name */
22099 +#define DPNI_RSP_GET_IRQ_MASK(cmd, mask) \
22100 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
22102 +/* cmd, param, offset, width, type, arg_name */
22103 +#define DPNI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
22105 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
22106 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
22109 +/* cmd, param, offset, width, type, arg_name */
22110 +#define DPNI_RSP_GET_IRQ_STATUS(cmd, status) \
22111 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
22113 +/* cmd, param, offset, width, type, arg_name */
22114 +#define DPNI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
22116 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
22117 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
22120 +/* cmd, param, offset, width, type, arg_name */
22121 +#define DPNI_CMD_GET_ATTR(cmd, attr) \
22122 + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, attr->ext_cfg_iova)
22124 +/* cmd, param, offset, width, type, arg_name */
22125 +#define DPNI_RSP_GET_ATTR(cmd, attr) \
22127 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id);\
22128 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->max_tcs); \
22129 + MC_RSP_OP(cmd, 0, 40, 8, uint8_t, attr->max_senders); \
22130 + MC_RSP_OP(cmd, 0, 48, 8, enum net_prot, attr->start_hdr); \
22131 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options); \
22132 + MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->max_unicast_filters); \
22133 + MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->max_multicast_filters);\
22134 + MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->max_vlan_filters); \
22135 + MC_RSP_OP(cmd, 2, 24, 8, uint8_t, attr->max_qos_entries); \
22136 + MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->max_qos_key_size); \
22137 + MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->max_dist_key_size); \
22138 + MC_RSP_OP(cmd, 4, 48, 8, uint8_t, attr->max_policers); \
22139 + MC_RSP_OP(cmd, 4, 56, 8, uint8_t, attr->max_congestion_ctrl); \
22140 + MC_RSP_OP(cmd, 5, 32, 16, uint16_t, attr->version.major);\
22141 + MC_RSP_OP(cmd, 5, 48, 16, uint16_t, attr->version.minor);\
22144 +/* cmd, param, offset, width, type, arg_name */
22145 +#define DPNI_CMD_SET_ERRORS_BEHAVIOR(cmd, cfg) \
22147 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->errors); \
22148 + MC_CMD_OP(cmd, 0, 32, 4, enum dpni_error_action, cfg->error_action); \
22149 + MC_CMD_OP(cmd, 0, 36, 1, int, cfg->set_frame_annotation); \
22152 +/* cmd, param, offset, width, type, arg_name */
22153 +#define DPNI_RSP_GET_RX_BUFFER_LAYOUT(cmd, layout) \
22155 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22156 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22157 + MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22158 + MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22159 + MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22160 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22161 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22164 +/* cmd, param, offset, width, type, arg_name */
22165 +#define DPNI_CMD_SET_RX_BUFFER_LAYOUT(cmd, layout) \
22167 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22168 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22169 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
22170 + MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22171 + MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22172 + MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22173 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22174 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22177 +/* cmd, param, offset, width, type, arg_name */
22178 +#define DPNI_RSP_GET_TX_BUFFER_LAYOUT(cmd, layout) \
22180 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22181 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22182 + MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22183 + MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22184 + MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22185 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22186 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22189 +/* cmd, param, offset, width, type, arg_name */
22190 +#define DPNI_CMD_SET_TX_BUFFER_LAYOUT(cmd, layout) \
22192 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22193 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22194 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
22195 + MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22196 + MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22197 + MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22198 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22199 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22202 +/* cmd, param, offset, width, type, arg_name */
22203 +#define DPNI_RSP_GET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
22205 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22206 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22207 + MC_RSP_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22208 + MC_RSP_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22209 + MC_RSP_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22210 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22211 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22214 +/* cmd, param, offset, width, type, arg_name */
22215 +#define DPNI_CMD_SET_TX_CONF_BUFFER_LAYOUT(cmd, layout) \
22217 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, layout->private_data_size); \
22218 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, layout->data_align); \
22219 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, layout->options); \
22220 + MC_CMD_OP(cmd, 1, 0, 1, int, layout->pass_timestamp); \
22221 + MC_CMD_OP(cmd, 1, 1, 1, int, layout->pass_parser_result); \
22222 + MC_CMD_OP(cmd, 1, 2, 1, int, layout->pass_frame_status); \
22223 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, layout->data_head_room); \
22224 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, layout->data_tail_room); \
22227 +/* cmd, param, offset, width, type, arg_name */
22228 +#define DPNI_CMD_SET_L3_CHKSUM_VALIDATION(cmd, en) \
22229 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22231 +/* cmd, param, offset, width, type, arg_name */
22232 +#define DPNI_RSP_GET_L3_CHKSUM_VALIDATION(cmd, en) \
22233 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
22235 +/* cmd, param, offset, width, type, arg_name */
22236 +#define DPNI_CMD_SET_L4_CHKSUM_VALIDATION(cmd, en) \
22237 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22239 +/* cmd, param, offset, width, type, arg_name */
22240 +#define DPNI_RSP_GET_L4_CHKSUM_VALIDATION(cmd, en) \
22241 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
22243 +/* cmd, param, offset, width, type, arg_name */
22244 +#define DPNI_RSP_GET_QDID(cmd, qdid) \
22245 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, qdid)
22247 +/* cmd, param, offset, width, type, arg_name */
22248 +#define DPNI_RSP_GET_SP_INFO(cmd, sp_info) \
22250 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, sp_info->spids[0]); \
22251 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, sp_info->spids[1]); \
22254 +/* cmd, param, offset, width, type, arg_name */
22255 +#define DPNI_RSP_GET_TX_DATA_OFFSET(cmd, data_offset) \
22256 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, data_offset)
22258 +/* cmd, param, offset, width, type, arg_name */
22259 +#define DPNI_CMD_GET_COUNTER(cmd, counter) \
22260 + MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter)
22262 +/* cmd, param, offset, width, type, arg_name */
22263 +#define DPNI_RSP_GET_COUNTER(cmd, value) \
22264 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, value)
22266 +/* cmd, param, offset, width, type, arg_name */
22267 +#define DPNI_CMD_SET_COUNTER(cmd, counter, value) \
22269 + MC_CMD_OP(cmd, 0, 0, 16, enum dpni_counter, counter); \
22270 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, value); \
22273 +/* cmd, param, offset, width, type, arg_name */
22274 +#define DPNI_CMD_SET_LINK_CFG(cmd, cfg) \
22276 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
22277 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
22280 +/* cmd, param, offset, width, type, arg_name */
22281 +#define DPNI_RSP_GET_LINK_STATE(cmd, state) \
22283 + MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
22284 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
22285 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
22288 +/* cmd, param, offset, width, type, arg_name */
22289 +#define DPNI_CMD_SET_TX_SHAPING(cmd, tx_shaper) \
22291 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, tx_shaper->max_burst_size);\
22292 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, tx_shaper->rate_limit);\
22295 +/* cmd, param, offset, width, type, arg_name */
22296 +#define DPNI_CMD_SET_MAX_FRAME_LENGTH(cmd, max_frame_length) \
22297 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, max_frame_length)
22299 +/* cmd, param, offset, width, type, arg_name */
22300 +#define DPNI_RSP_GET_MAX_FRAME_LENGTH(cmd, max_frame_length) \
22301 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, max_frame_length)
22303 +/* cmd, param, offset, width, type, arg_name */
22304 +#define DPNI_CMD_SET_MTU(cmd, mtu) \
22305 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, mtu)
22307 +/* cmd, param, offset, width, type, arg_name */
22308 +#define DPNI_RSP_GET_MTU(cmd, mtu) \
22309 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, mtu)
22311 +/* cmd, param, offset, width, type, arg_name */
22312 +#define DPNI_CMD_SET_MULTICAST_PROMISC(cmd, en) \
22313 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22315 +/* cmd, param, offset, width, type, arg_name */
22316 +#define DPNI_RSP_GET_MULTICAST_PROMISC(cmd, en) \
22317 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
22319 +/* cmd, param, offset, width, type, arg_name */
22320 +#define DPNI_CMD_SET_UNICAST_PROMISC(cmd, en) \
22321 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22323 +/* cmd, param, offset, width, type, arg_name */
22324 +#define DPNI_RSP_GET_UNICAST_PROMISC(cmd, en) \
22325 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
22327 +/* cmd, param, offset, width, type, arg_name */
22328 +#define DPNI_CMD_SET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
22330 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
22331 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
22332 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
22333 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
22334 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
22335 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
22338 +/* cmd, param, offset, width, type, arg_name */
22339 +#define DPNI_RSP_GET_PRIMARY_MAC_ADDR(cmd, mac_addr) \
22341 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
22342 + MC_RSP_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
22343 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
22344 + MC_RSP_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
22345 + MC_RSP_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
22346 + MC_RSP_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
22349 +/* cmd, param, offset, width, type, arg_name */
22350 +#define DPNI_CMD_ADD_MAC_ADDR(cmd, mac_addr) \
22352 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
22353 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
22354 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
22355 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
22356 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
22357 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
22360 +/* cmd, param, offset, width, type, arg_name */
22361 +#define DPNI_CMD_REMOVE_MAC_ADDR(cmd, mac_addr) \
22363 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, mac_addr[5]); \
22364 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, mac_addr[4]); \
22365 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, mac_addr[3]); \
22366 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, mac_addr[2]); \
22367 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, mac_addr[1]); \
22368 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, mac_addr[0]); \
22371 +/* cmd, param, offset, width, type, arg_name */
22372 +#define DPNI_CMD_CLEAR_MAC_FILTERS(cmd, unicast, multicast) \
22374 + MC_CMD_OP(cmd, 0, 0, 1, int, unicast); \
22375 + MC_CMD_OP(cmd, 0, 1, 1, int, multicast); \
22378 +/* cmd, param, offset, width, type, arg_name */
22379 +#define DPNI_CMD_SET_VLAN_FILTERS(cmd, en) \
22380 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22382 +/* cmd, param, offset, width, type, arg_name */
22383 +#define DPNI_CMD_ADD_VLAN_ID(cmd, vlan_id) \
22384 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, vlan_id)
22386 +/* cmd, param, offset, width, type, arg_name */
22387 +#define DPNI_CMD_REMOVE_VLAN_ID(cmd, vlan_id) \
22388 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, vlan_id)
22390 +/* cmd, param, offset, width, type, arg_name */
22391 +#define DPNI_CMD_SET_TX_SELECTION(cmd, cfg) \
22393 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->tc_sched[0].delta_bandwidth);\
22394 + MC_CMD_OP(cmd, 0, 16, 4, enum dpni_tx_schedule_mode, \
22395 + cfg->tc_sched[0].mode); \
22396 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->tc_sched[1].delta_bandwidth);\
22397 + MC_CMD_OP(cmd, 0, 48, 4, enum dpni_tx_schedule_mode, \
22398 + cfg->tc_sched[1].mode); \
22399 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->tc_sched[2].delta_bandwidth);\
22400 + MC_CMD_OP(cmd, 1, 16, 4, enum dpni_tx_schedule_mode, \
22401 + cfg->tc_sched[2].mode); \
22402 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, cfg->tc_sched[3].delta_bandwidth);\
22403 + MC_CMD_OP(cmd, 1, 48, 4, enum dpni_tx_schedule_mode, \
22404 + cfg->tc_sched[3].mode); \
22405 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->tc_sched[4].delta_bandwidth);\
22406 + MC_CMD_OP(cmd, 2, 16, 4, enum dpni_tx_schedule_mode, \
22407 + cfg->tc_sched[4].mode); \
22408 + MC_CMD_OP(cmd, 2, 32, 16, uint16_t, cfg->tc_sched[5].delta_bandwidth);\
22409 + MC_CMD_OP(cmd, 2, 48, 4, enum dpni_tx_schedule_mode, \
22410 + cfg->tc_sched[5].mode); \
22411 + MC_CMD_OP(cmd, 3, 0, 16, uint16_t, cfg->tc_sched[6].delta_bandwidth);\
22412 + MC_CMD_OP(cmd, 3, 16, 4, enum dpni_tx_schedule_mode, \
22413 + cfg->tc_sched[6].mode); \
22414 + MC_CMD_OP(cmd, 3, 32, 16, uint16_t, cfg->tc_sched[7].delta_bandwidth);\
22415 + MC_CMD_OP(cmd, 3, 48, 4, enum dpni_tx_schedule_mode, \
22416 + cfg->tc_sched[7].mode); \
22419 +/* cmd, param, offset, width, type, arg_name */
22420 +#define DPNI_CMD_SET_RX_TC_DIST(cmd, tc_id, cfg) \
22422 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->dist_size); \
22423 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22424 + MC_CMD_OP(cmd, 0, 24, 4, enum dpni_dist_mode, cfg->dist_mode); \
22425 + MC_CMD_OP(cmd, 0, 28, 4, enum dpni_fs_miss_action, \
22426 + cfg->fs_cfg.miss_action); \
22427 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, cfg->fs_cfg.default_flow_id); \
22428 + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_cfg_iova); \
22431 +/* cmd, param, offset, width, type, arg_name */
22432 +#define DPNI_CMD_SET_TX_FLOW(cmd, flow_id, cfg) \
22434 + MC_CMD_OP(cmd, 0, 43, 1, int, cfg->l3_chksum_gen);\
22435 + MC_CMD_OP(cmd, 0, 44, 1, int, cfg->l4_chksum_gen);\
22436 + MC_CMD_OP(cmd, 0, 45, 1, int, cfg->use_common_tx_conf_queue);\
22437 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id);\
22438 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
22441 +/* cmd, param, offset, width, type, arg_name */
22442 +#define DPNI_RSP_SET_TX_FLOW(cmd, flow_id) \
22443 + MC_RSP_OP(cmd, 0, 48, 16, uint16_t, flow_id)
22445 +/* cmd, param, offset, width, type, arg_name */
22446 +#define DPNI_CMD_GET_TX_FLOW(cmd, flow_id) \
22447 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
22449 +/* cmd, param, offset, width, type, arg_name */
22450 +#define DPNI_RSP_GET_TX_FLOW(cmd, attr) \
22452 + MC_RSP_OP(cmd, 0, 43, 1, int, attr->l3_chksum_gen);\
22453 + MC_RSP_OP(cmd, 0, 44, 1, int, attr->l4_chksum_gen);\
22454 + MC_RSP_OP(cmd, 0, 45, 1, int, attr->use_common_tx_conf_queue);\
22457 +/* cmd, param, offset, width, type, arg_name */
22458 +#define DPNI_CMD_SET_RX_FLOW(cmd, tc_id, flow_id, cfg) \
22460 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
22461 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
22462 + MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
22463 + MC_CMD_OP(cmd, 0, 42, 1, int, cfg->order_preservation_en);\
22464 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
22465 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
22466 + MC_CMD_OP(cmd, 2, 16, 8, uint8_t, tc_id); \
22467 + MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->options); \
22468 + MC_CMD_OP(cmd, 3, 0, 4, enum dpni_flc_type, cfg->flc_cfg.flc_type); \
22469 + MC_CMD_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
22470 + cfg->flc_cfg.frame_data_size);\
22471 + MC_CMD_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
22472 + cfg->flc_cfg.flow_context_size);\
22473 + MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
22474 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->flc_cfg.flow_context);\
22475 + MC_CMD_OP(cmd, 5, 0, 32, uint32_t, cfg->tail_drop_threshold); \
22478 +/* cmd, param, offset, width, type, arg_name */
22479 +#define DPNI_CMD_GET_RX_FLOW(cmd, tc_id, flow_id) \
22481 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22482 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
22485 +/* cmd, param, offset, width, type, arg_name */
22486 +#define DPNI_RSP_GET_RX_FLOW(cmd, attr) \
22488 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
22489 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
22490 + MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type); \
22491 + MC_RSP_OP(cmd, 0, 42, 1, int, attr->order_preservation_en);\
22492 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
22493 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tail_drop_threshold); \
22494 + MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
22495 + MC_RSP_OP(cmd, 3, 0, 4, enum dpni_flc_type, attr->flc_cfg.flc_type); \
22496 + MC_RSP_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
22497 + attr->flc_cfg.frame_data_size);\
22498 + MC_RSP_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
22499 + attr->flc_cfg.flow_context_size);\
22500 + MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
22501 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, attr->flc_cfg.flow_context);\
22504 +/* cmd, param, offset, width, type, arg_name */
22505 +#define DPNI_CMD_SET_RX_ERR_QUEUE(cmd, cfg) \
22507 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
22508 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority);\
22509 + MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, cfg->dest_cfg.dest_type);\
22510 + MC_CMD_OP(cmd, 0, 42, 1, int, cfg->order_preservation_en);\
22511 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
22512 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options); \
22513 + MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->tail_drop_threshold); \
22514 + MC_CMD_OP(cmd, 3, 0, 4, enum dpni_flc_type, cfg->flc_cfg.flc_type); \
22515 + MC_CMD_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
22516 + cfg->flc_cfg.frame_data_size);\
22517 + MC_CMD_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
22518 + cfg->flc_cfg.flow_context_size);\
22519 + MC_CMD_OP(cmd, 3, 32, 32, uint32_t, cfg->flc_cfg.options);\
22520 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->flc_cfg.flow_context);\
22523 +/* cmd, param, offset, width, type, arg_name */
22524 +#define DPNI_RSP_GET_RX_ERR_QUEUE(cmd, attr) \
22526 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id); \
22527 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
22528 + MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, attr->dest_cfg.dest_type);\
22529 + MC_RSP_OP(cmd, 0, 42, 1, int, attr->order_preservation_en);\
22530 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->user_ctx); \
22531 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tail_drop_threshold); \
22532 + MC_RSP_OP(cmd, 2, 32, 32, uint32_t, attr->fqid); \
22533 + MC_RSP_OP(cmd, 3, 0, 4, enum dpni_flc_type, attr->flc_cfg.flc_type); \
22534 + MC_RSP_OP(cmd, 3, 4, 4, enum dpni_stash_size, \
22535 + attr->flc_cfg.frame_data_size);\
22536 + MC_RSP_OP(cmd, 3, 8, 4, enum dpni_stash_size, \
22537 + attr->flc_cfg.flow_context_size);\
22538 + MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->flc_cfg.options);\
22539 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, attr->flc_cfg.flow_context);\
22542 +/* cmd, param, offset, width, type, arg_name */
22543 +#define DPNI_CMD_SET_TX_CONF_REVOKE(cmd, revoke) \
22544 + MC_CMD_OP(cmd, 0, 0, 1, int, revoke)
22546 +/* cmd, param, offset, width, type, arg_name */
22547 +#define DPNI_CMD_SET_QOS_TABLE(cmd, cfg) \
22549 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->default_tc); \
22550 + MC_CMD_OP(cmd, 0, 40, 1, int, cfg->discard_on_miss); \
22551 + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_cfg_iova); \
22554 +/* cmd, param, offset, width, type, arg_name */
22555 +#define DPNI_CMD_ADD_QOS_ENTRY(cmd, cfg, tc_id) \
22557 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22558 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->key_size); \
22559 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
22560 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
22563 +/* cmd, param, offset, width, type, arg_name */
22564 +#define DPNI_CMD_REMOVE_QOS_ENTRY(cmd, cfg) \
22566 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->key_size); \
22567 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
22568 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
22571 +/* cmd, param, offset, width, type, arg_name */
22572 +#define DPNI_CMD_ADD_FS_ENTRY(cmd, tc_id, cfg, flow_id) \
22574 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22575 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
22576 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->key_size); \
22577 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
22578 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
22581 +/* cmd, param, offset, width, type, arg_name */
22582 +#define DPNI_CMD_REMOVE_FS_ENTRY(cmd, tc_id, cfg) \
22584 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22585 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->key_size); \
22586 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->key_iova); \
22587 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->mask_iova); \
22590 +/* cmd, param, offset, width, type, arg_name */
22591 +#define DPNI_CMD_CLEAR_FS_ENTRIES(cmd, tc_id) \
22592 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id)
22594 +/* cmd, param, offset, width, type, arg_name */
22595 +#define DPNI_CMD_SET_VLAN_INSERTION(cmd, en) \
22596 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22598 +/* cmd, param, offset, width, type, arg_name */
22599 +#define DPNI_CMD_SET_VLAN_REMOVAL(cmd, en) \
22600 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22602 +/* cmd, param, offset, width, type, arg_name */
22603 +#define DPNI_CMD_SET_IPR(cmd, en) \
22604 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22606 +/* cmd, param, offset, width, type, arg_name */
22607 +#define DPNI_CMD_SET_IPF(cmd, en) \
22608 + MC_CMD_OP(cmd, 0, 0, 1, int, en)
22610 +/* cmd, param, offset, width, type, arg_name */
22611 +#define DPNI_CMD_SET_RX_TC_POLICING(cmd, tc_id, cfg) \
22613 + MC_CMD_OP(cmd, 0, 0, 4, enum dpni_policer_mode, cfg->mode); \
22614 + MC_CMD_OP(cmd, 0, 4, 4, enum dpni_policer_color, cfg->default_color); \
22615 + MC_CMD_OP(cmd, 0, 8, 4, enum dpni_policer_unit, cfg->units); \
22616 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id); \
22617 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->options); \
22618 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->cir); \
22619 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs); \
22620 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->eir); \
22621 + MC_CMD_OP(cmd, 2, 32, 32, uint32_t, cfg->ebs);\
22624 +/* cmd, param, offset, width, type, arg_name */
22625 +#define DPNI_CMD_GET_RX_TC_POLICING(cmd, tc_id) \
22626 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id)
22628 +/* cmd, param, offset, width, type, arg_name */
22629 +#define DPNI_RSP_GET_RX_TC_POLICING(cmd, cfg) \
22631 + MC_RSP_OP(cmd, 0, 0, 4, enum dpni_policer_mode, cfg->mode); \
22632 + MC_RSP_OP(cmd, 0, 4, 4, enum dpni_policer_color, cfg->default_color); \
22633 + MC_RSP_OP(cmd, 0, 8, 4, enum dpni_policer_unit, cfg->units); \
22634 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, cfg->options); \
22635 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->cir); \
22636 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs); \
22637 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, cfg->eir); \
22638 + MC_RSP_OP(cmd, 2, 32, 32, uint32_t, cfg->ebs);\
22641 +/* cmd, param, offset, width, type, arg_name */
22642 +#define DPNI_PREP_EARLY_DROP(ext, cfg) \
22644 + MC_PREP_OP(ext, 0, 0, 2, enum dpni_early_drop_mode, cfg->mode); \
22645 + MC_PREP_OP(ext, 0, 2, 2, \
22646 + enum dpni_congestion_unit, cfg->units); \
22647 + MC_PREP_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
22648 + MC_PREP_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
22649 + MC_PREP_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
22650 + MC_PREP_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
22651 + MC_PREP_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
22652 + MC_PREP_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
22653 + MC_PREP_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
22654 + MC_PREP_OP(ext, 9, 0, 8, uint8_t, cfg->red.drop_probability); \
22655 + MC_PREP_OP(ext, 10, 0, 64, uint64_t, cfg->red.max_threshold); \
22656 + MC_PREP_OP(ext, 11, 0, 64, uint64_t, cfg->red.min_threshold); \
22659 +/* cmd, param, offset, width, type, arg_name */
22660 +#define DPNI_EXT_EARLY_DROP(ext, cfg) \
22662 + MC_EXT_OP(ext, 0, 0, 2, enum dpni_early_drop_mode, cfg->mode); \
22663 + MC_EXT_OP(ext, 0, 2, 2, \
22664 + enum dpni_congestion_unit, cfg->units); \
22665 + MC_EXT_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
22666 + MC_EXT_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
22667 + MC_EXT_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
22668 + MC_EXT_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
22669 + MC_EXT_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
22670 + MC_EXT_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
22671 + MC_EXT_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
22672 + MC_EXT_OP(ext, 9, 0, 8, uint8_t, cfg->red.drop_probability); \
22673 + MC_EXT_OP(ext, 10, 0, 64, uint64_t, cfg->red.max_threshold); \
22674 + MC_EXT_OP(ext, 11, 0, 64, uint64_t, cfg->red.min_threshold); \
22677 +/* cmd, param, offset, width, type, arg_name */
22678 +#define DPNI_CMD_SET_RX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova) \
22680 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22681 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
22684 +/* cmd, param, offset, width, type, arg_name */
22685 +#define DPNI_CMD_GET_RX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova) \
22687 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22688 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
22691 +/* cmd, param, offset, width, type, arg_name */
22692 +#define DPNI_CMD_SET_TX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova) \
22694 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22695 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
22698 +/* cmd, param, offset, width, type, arg_name */
22699 +#define DPNI_CMD_GET_TX_TC_EARLY_DROP(cmd, tc_id, early_drop_iova) \
22701 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22702 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
22705 +#define DPNI_CMD_SET_RX_TC_CONGESTION_NOTIFICATION(cmd, tc_id, cfg) \
22707 + MC_CMD_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22708 + MC_CMD_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22709 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22710 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22711 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22712 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22713 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22714 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22715 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22716 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22719 +#define DPNI_CMD_GET_RX_TC_CONGESTION_NOTIFICATION(cmd, tc_id) \
22720 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id)
22722 +#define DPNI_RSP_GET_RX_TC_CONGESTION_NOTIFICATION(cmd, cfg) \
22724 + MC_RSP_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22725 + MC_RSP_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22726 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22727 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22728 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22729 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22730 + MC_RSP_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22731 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22732 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22735 +#define DPNI_CMD_SET_TX_TC_CONGESTION_NOTIFICATION(cmd, tc_id, cfg) \
22737 + MC_CMD_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22738 + MC_CMD_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22739 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
22740 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22741 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22742 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22743 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22744 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22745 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22746 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22749 +#define DPNI_CMD_GET_TX_TC_CONGESTION_NOTIFICATION(cmd, tc_id) \
22750 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id)
22752 +#define DPNI_RSP_GET_TX_TC_CONGESTION_NOTIFICATION(cmd, cfg) \
22754 + MC_RSP_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22755 + MC_RSP_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22756 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22757 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22758 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22759 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22760 + MC_RSP_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22761 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22762 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22765 +#define DPNI_CMD_SET_TX_CONF(cmd, flow_id, cfg) \
22767 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->queue_cfg.dest_cfg.priority); \
22768 + MC_CMD_OP(cmd, 0, 40, 2, enum dpni_dest, \
22769 + cfg->queue_cfg.dest_cfg.dest_type); \
22770 + MC_CMD_OP(cmd, 0, 42, 1, int, cfg->errors_only); \
22771 + MC_CMD_OP(cmd, 0, 46, 1, int, cfg->queue_cfg.order_preservation_en); \
22772 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
22773 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->queue_cfg.user_ctx); \
22774 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->queue_cfg.options); \
22775 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->queue_cfg.dest_cfg.dest_id); \
22776 + MC_CMD_OP(cmd, 3, 0, 32, uint32_t, \
22777 + cfg->queue_cfg.tail_drop_threshold); \
22778 + MC_CMD_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
22779 + cfg->queue_cfg.flc_cfg.flc_type); \
22780 + MC_CMD_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
22781 + cfg->queue_cfg.flc_cfg.frame_data_size); \
22782 + MC_CMD_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
22783 + cfg->queue_cfg.flc_cfg.flow_context_size); \
22784 + MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->queue_cfg.flc_cfg.options); \
22785 + MC_CMD_OP(cmd, 5, 0, 64, uint64_t, \
22786 + cfg->queue_cfg.flc_cfg.flow_context); \
22789 +#define DPNI_CMD_GET_TX_CONF(cmd, flow_id) \
22790 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
22792 +#define DPNI_RSP_GET_TX_CONF(cmd, attr) \
22794 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, \
22795 + attr->queue_attr.dest_cfg.priority); \
22796 + MC_RSP_OP(cmd, 0, 40, 2, enum dpni_dest, \
22797 + attr->queue_attr.dest_cfg.dest_type); \
22798 + MC_RSP_OP(cmd, 0, 42, 1, int, attr->errors_only); \
22799 + MC_RSP_OP(cmd, 0, 46, 1, int, \
22800 + attr->queue_attr.order_preservation_en); \
22801 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, attr->queue_attr.user_ctx); \
22802 + MC_RSP_OP(cmd, 2, 32, 32, int, attr->queue_attr.dest_cfg.dest_id); \
22803 + MC_RSP_OP(cmd, 3, 0, 32, uint32_t, \
22804 + attr->queue_attr.tail_drop_threshold); \
22805 + MC_RSP_OP(cmd, 3, 32, 32, uint32_t, attr->queue_attr.fqid); \
22806 + MC_RSP_OP(cmd, 4, 0, 4, enum dpni_flc_type, \
22807 + attr->queue_attr.flc_cfg.flc_type); \
22808 + MC_RSP_OP(cmd, 4, 4, 4, enum dpni_stash_size, \
22809 + attr->queue_attr.flc_cfg.frame_data_size); \
22810 + MC_RSP_OP(cmd, 4, 8, 4, enum dpni_stash_size, \
22811 + attr->queue_attr.flc_cfg.flow_context_size); \
22812 + MC_RSP_OP(cmd, 4, 32, 32, uint32_t, attr->queue_attr.flc_cfg.options); \
22813 + MC_RSP_OP(cmd, 5, 0, 64, uint64_t, \
22814 + attr->queue_attr.flc_cfg.flow_context); \
22817 +#define DPNI_CMD_SET_TX_CONF_CONGESTION_NOTIFICATION(cmd, flow_id, cfg) \
22819 + MC_CMD_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22820 + MC_CMD_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22821 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22822 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id); \
22823 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22824 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22825 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22826 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22827 + MC_CMD_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22828 + MC_CMD_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22831 +#define DPNI_CMD_GET_TX_CONF_CONGESTION_NOTIFICATION(cmd, flow_id) \
22832 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, flow_id)
22834 +#define DPNI_RSP_GET_TX_CONF_CONGESTION_NOTIFICATION(cmd, cfg) \
22836 + MC_RSP_OP(cmd, 0, 0, 2, enum dpni_congestion_unit, cfg->units); \
22837 + MC_RSP_OP(cmd, 0, 4, 4, enum dpni_dest, cfg->dest_cfg.dest_type); \
22838 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, cfg->dest_cfg.priority); \
22839 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, cfg->threshold_entry); \
22840 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, cfg->threshold_exit); \
22841 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, cfg->options); \
22842 + MC_RSP_OP(cmd, 2, 32, 32, int, cfg->dest_cfg.dest_id); \
22843 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, cfg->message_ctx); \
22844 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, cfg->message_iova); \
22847 +#endif /* _FSL_DPNI_CMD_H */
22848 diff --git a/drivers/net/dpaa2/mc/fsl_dprc.h b/drivers/net/dpaa2/mc/fsl_dprc.h
22849 new file mode 100644
22850 index 0000000..c831f46
22852 +++ b/drivers/net/dpaa2/mc/fsl_dprc.h
22854 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
22856 + * Redistribution and use in source and binary forms, with or without
22857 + * modification, are permitted provided that the following conditions are met:
22858 + * * Redistributions of source code must retain the above copyright
22859 + * notice, this list of conditions and the following disclaimer.
22860 + * * Redistributions in binary form must reproduce the above copyright
22861 + * notice, this list of conditions and the following disclaimer in the
22862 + * documentation and/or other materials provided with the distribution.
22863 + * * Neither the name of the above-listed copyright holders nor the
22864 + * names of any contributors may be used to endorse or promote products
22865 + * derived from this software without specific prior written permission.
22868 + * ALTERNATIVELY, this software may be distributed under the terms of the
22869 + * GNU General Public License ("GPL") as published by the Free Software
22870 + * Foundation, either version 2 of that License or (at your option) any
22873 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22874 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22875 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22876 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
22877 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22878 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22879 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22880 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22881 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22882 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
22883 + * POSSIBILITY OF SUCH DAMAGE.
22885 +#ifndef _FSL_DPRC_H
22886 +#define _FSL_DPRC_H
22888 +/* Data Path Resource Container API
22889 + * Contains DPRC API for managing and querying DPAA resources
22895 + * Set this value as the icid value in dprc_cfg structure when creating a
22896 + * container, in case the ICID is not selected by the user and should be
22897 + * allocated by the DPRC from the pool of ICIDs.
22899 +#define DPRC_GET_ICID_FROM_POOL (uint16_t)(~(0))
22902 + * Set this value as the portal_id value in dprc_cfg structure when creating a
22903 + * container, in case the portal ID is not specifically selected by the
22904 + * user and should be allocated by the DPRC from the pool of portal ids.
22906 +#define DPRC_GET_PORTAL_ID_FROM_POOL (int)(~(0))
22909 + * dprc_get_container_id() - Get container ID associated with a given portal.
22910 + * @mc_io: Pointer to MC portal's I/O object
22911 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
22912 + * @container_id: Requested container ID
22914 + * Return: '0' on Success; Error code otherwise.
22916 +int dprc_get_container_id(struct fsl_mc_io *mc_io,
22917 + uint32_t cmd_flags,
22918 + int *container_id);
22921 + * dprc_open() - Open DPRC object for use
22922 + * @mc_io: Pointer to MC portal's I/O object
22923 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
22924 + * @container_id: Container ID to open
22925 + * @token: Returned token of DPRC object
22927 + * Return: '0' on Success; Error code otherwise.
22929 + * @warning Required before any operation on the object.
22931 +int dprc_open(struct fsl_mc_io *mc_io,
22932 + uint32_t cmd_flags,
22933 + int container_id,
22934 + uint16_t *token);
22937 + * dprc_close() - Close the control session of the object
22938 + * @mc_io: Pointer to MC portal's I/O object
22939 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
22940 + * @token: Token of DPRC object
22942 + * After this function is called, no further operations are
22943 + * allowed on the object without opening a new control session.
22945 + * Return: '0' on Success; Error code otherwise.
22947 +int dprc_close(struct fsl_mc_io *mc_io,
22948 + uint32_t cmd_flags,
22952 + * Container general options
22954 + * These options may be selected at container creation by the container creator
22955 + * and can be retrieved using dprc_get_attributes()
22959 + * Spawn Policy Option allowed - Indicates that the new container is allowed
22960 + * to spawn and have its own child containers.
22962 +#define DPRC_CFG_OPT_SPAWN_ALLOWED 0x00000001
22965 + * General Container allocation policy - Indicates that the new container is
22966 + * allowed to allocate requested resources from its parent container; if not
22967 + * set, the container is only allowed to use resources in its own pools; Note
22968 + * that this is a container's global policy, but the parent container may
22969 + * override it and set specific quota per resource type.
22971 +#define DPRC_CFG_OPT_ALLOC_ALLOWED 0x00000002
22974 + * Object initialization allowed - software context associated with this
22975 + * container is allowed to invoke object initialization operations.
22977 +#define DPRC_CFG_OPT_OBJ_CREATE_ALLOWED 0x00000004
22980 + * Topology change allowed - software context associated with this
22981 + * container is allowed to invoke topology operations, such as attach/detach
22982 + * of network objects.
22984 +#define DPRC_CFG_OPT_TOPOLOGY_CHANGES_ALLOWED 0x00000008
22987 + * AIOP - Indicates that container belongs to AIOP.
22989 +#define DPRC_CFG_OPT_AIOP 0x00000020
22992 + * IRQ Config - Indicates that the container allowed to configure its IRQs.
22994 +#define DPRC_CFG_OPT_IRQ_CFG_ALLOWED 0x00000040
22997 + * struct dprc_cfg - Container configuration options
22998 + * @icid: Container's ICID; if set to 'DPRC_GET_ICID_FROM_POOL', a free
22999 + * ICID value is allocated by the DPRC
23000 + * @portal_id: Portal ID; if set to 'DPRC_GET_PORTAL_ID_FROM_POOL', a free
23001 + * portal ID is allocated by the DPRC
23002 + * @options: Combination of 'DPRC_CFG_OPT_<X>' options
23003 + * @label: Object's label
23008 + uint64_t options;
23013 + * dprc_create_container() - Create child container
23014 + * @mc_io: Pointer to MC portal's I/O object
23015 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23016 + * @token: Token of DPRC object
23017 + * @cfg: Child container configuration
23018 + * @child_container_id: Returned child container ID
23019 + * @child_portal_offset: Returned child portal offset from MC portal base
23022 + * Return: '0' on Success; Error code otherwise.
23024 +int dprc_create_container(struct fsl_mc_io *mc_io,
23025 + uint32_t cmd_flags,
23027 + struct dprc_cfg *cfg,
23028 + int *child_container_id,
23029 + uint64_t *child_portal_offset);
23032 + * dprc_destroy_container() - Destroy child container.
23033 + * @mc_io: Pointer to MC portal's I/O object
23034 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23035 + * @token: Token of DPRC object
23036 + * @child_container_id: ID of the container to destroy
23038 + * This function terminates the child container, so following this call the
23039 + * child container ID becomes invalid.
23042 + * - All resources and objects of the destroyed container are returned to the
23043 + * parent container or destroyed if were created be the destroyed container.
23044 + * - This function destroy all the child containers of the specified
23045 + * container prior to destroying the container itself.
23047 + * warning: Only the parent container is allowed to destroy a child policy
23048 + * Container 0 can't be destroyed
23050 + * Return: '0' on Success; Error code otherwise.
23053 +int dprc_destroy_container(struct fsl_mc_io *mc_io,
23054 + uint32_t cmd_flags,
23056 + int child_container_id);
23059 + * dprc_reset_container - Reset child container.
23060 + * @mc_io: Pointer to MC portal's I/O object
23061 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23062 + * @token: Token of DPRC object
23063 + * @child_container_id: ID of the container to reset
23065 + * In case a software context crashes or becomes non-responsive, the parent
23066 + * may wish to reset its resources container before the software context is
23069 + * This routine informs all objects assigned to the child container that the
23070 + * container is being reset, so they may perform any cleanup operations that are
23071 + * needed. All objects handles that were owned by the child container shall be
23074 + * Note that such request may be submitted even if the child software context
23075 + * has not crashed, but the resulting object cleanup operations will not be
23078 + * Return: '0' on Success; Error code otherwise.
23080 +int dprc_reset_container(struct fsl_mc_io *mc_io,
23081 + uint32_t cmd_flags,
23083 + int child_container_id);
23086 + * DPRC IRQ Index and Events
23092 +#define DPRC_IRQ_INDEX 0
23095 + * Number of dprc's IRQs
23097 +#define DPRC_NUM_OF_IRQS 1
23099 +/* DPRC IRQ events */
23101 + * IRQ event - Indicates that a new object added to the container
23103 +#define DPRC_IRQ_EVENT_OBJ_ADDED 0x00000001
23105 + * IRQ event - Indicates that an object was removed from the container
23107 +#define DPRC_IRQ_EVENT_OBJ_REMOVED 0x00000002
23109 + * IRQ event - Indicates that resources added to the container
23111 +#define DPRC_IRQ_EVENT_RES_ADDED 0x00000004
23113 + * IRQ event - Indicates that resources removed from the container
23115 +#define DPRC_IRQ_EVENT_RES_REMOVED 0x00000008
23117 + * IRQ event - Indicates that one of the descendant containers that opened by
23118 + * this container is destroyed
23120 +#define DPRC_IRQ_EVENT_CONTAINER_DESTROYED 0x00000010
23122 + * IRQ event - Indicates that on one of the container's opened object is
23125 +#define DPRC_IRQ_EVENT_OBJ_DESTROYED 0x00000020
23127 + * Irq event - Indicates that object is created at the container
23129 +#define DPRC_IRQ_EVENT_OBJ_CREATED 0x00000040
23132 + * struct dprc_irq_cfg - IRQ configuration
23133 + * @addr: Address that must be written to signal a message-based interrupt
23134 + * @val: Value to write into irq_addr address
23135 + * @irq_num: A user defined number associated with this IRQ
23137 +struct dprc_irq_cfg {
23144 + * dprc_set_irq() - Set IRQ information for the DPRC to trigger an interrupt.
23145 + * @mc_io: Pointer to MC portal's I/O object
23146 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23147 + * @token: Token of DPRC object
23148 + * @irq_index: Identifies the interrupt index to configure
23149 + * @irq_cfg: IRQ configuration
23151 + * Return: '0' on Success; Error code otherwise.
23153 +int dprc_set_irq(struct fsl_mc_io *mc_io,
23154 + uint32_t cmd_flags,
23156 + uint8_t irq_index,
23157 + struct dprc_irq_cfg *irq_cfg);
23160 + * dprc_get_irq() - Get IRQ information from the DPRC.
23161 + * @mc_io: Pointer to MC portal's I/O object
23162 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23163 + * @token: Token of DPRC object
23164 + * @irq_index: The interrupt index to configure
23165 + * @type: Interrupt type: 0 represents message interrupt
23166 + * type (both irq_addr and irq_val are valid)
23167 + * @irq_cfg: IRQ attributes
23169 + * Return: '0' on Success; Error code otherwise.
23171 +int dprc_get_irq(struct fsl_mc_io *mc_io,
23172 + uint32_t cmd_flags,
23174 + uint8_t irq_index,
23176 + struct dprc_irq_cfg *irq_cfg);
23179 + * dprc_set_irq_enable() - Set overall interrupt state.
23180 + * @mc_io: Pointer to MC portal's I/O object
23181 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23182 + * @token: Token of DPRC object
23183 + * @irq_index: The interrupt index to configure
23184 + * @en: Interrupt state - enable = 1, disable = 0
23186 + * Allows GPP software to control when interrupts are generated.
23187 + * Each interrupt can have up to 32 causes. The enable/disable control's the
23188 + * overall interrupt state. if the interrupt is disabled no causes will cause
23191 + * Return: '0' on Success; Error code otherwise.
23193 +int dprc_set_irq_enable(struct fsl_mc_io *mc_io,
23194 + uint32_t cmd_flags,
23196 + uint8_t irq_index,
23200 + * dprc_get_irq_enable() - Get overall interrupt state.
23201 + * @mc_io: Pointer to MC portal's I/O object
23202 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23203 + * @token: Token of DPRC object
23204 + * @irq_index: The interrupt index to configure
23205 + * @en: Returned interrupt state - enable = 1, disable = 0
23207 + * Return: '0' on Success; Error code otherwise.
23209 +int dprc_get_irq_enable(struct fsl_mc_io *mc_io,
23210 + uint32_t cmd_flags,
23212 + uint8_t irq_index,
23216 + * dprc_set_irq_mask() - Set interrupt mask.
23217 + * @mc_io: Pointer to MC portal's I/O object
23218 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23219 + * @token: Token of DPRC object
23220 + * @irq_index: The interrupt index to configure
23221 + * @mask: event mask to trigger interrupt;
23223 + * 0 = ignore event
23224 + * 1 = consider event for asserting IRQ
23226 + * Every interrupt can have up to 32 causes and the interrupt model supports
23227 + * masking/unmasking each cause independently
23229 + * Return: '0' on Success; Error code otherwise.
23231 +int dprc_set_irq_mask(struct fsl_mc_io *mc_io,
23232 + uint32_t cmd_flags,
23234 + uint8_t irq_index,
23238 + * dprc_get_irq_mask() - Get interrupt mask.
23239 + * @mc_io: Pointer to MC portal's I/O object
23240 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23241 + * @token: Token of DPRC object
23242 + * @irq_index: The interrupt index to configure
23243 + * @mask: Returned event mask to trigger interrupt
23245 + * Every interrupt can have up to 32 causes and the interrupt model supports
23246 + * masking/unmasking each cause independently
23248 + * Return: '0' on Success; Error code otherwise.
23250 +int dprc_get_irq_mask(struct fsl_mc_io *mc_io,
23251 + uint32_t cmd_flags,
23253 + uint8_t irq_index,
23257 + * dprc_get_irq_status() - Get the current status of any pending interrupts.
23258 + * @mc_io: Pointer to MC portal's I/O object
23259 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23260 + * @token: Token of DPRC object
23261 + * @irq_index: The interrupt index to configure
23262 + * @status: Returned interrupts status - one bit per cause:
23263 + * 0 = no interrupt pending
23264 + * 1 = interrupt pending
23266 + * Return: '0' on Success; Error code otherwise.
23268 +int dprc_get_irq_status(struct fsl_mc_io *mc_io,
23269 + uint32_t cmd_flags,
23271 + uint8_t irq_index,
23272 + uint32_t *status);
23275 + * dprc_clear_irq_status() - Clear a pending interrupt's status
23276 + * @mc_io: Pointer to MC portal's I/O object
23277 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23278 + * @token: Token of DPRC object
23279 + * @irq_index: The interrupt index to configure
23280 + * @status: bits to clear (W1C) - one bit per cause:
23281 + * 0 = don't change
23282 + * 1 = clear status bit
23284 + * Return: '0' on Success; Error code otherwise.
23286 +int dprc_clear_irq_status(struct fsl_mc_io *mc_io,
23287 + uint32_t cmd_flags,
23289 + uint8_t irq_index,
23290 + uint32_t status);
23293 + * struct dprc_attributes - Container attributes
23294 + * @container_id: Container's ID
23295 + * @icid: Container's ICID
23296 + * @portal_id: Container's portal ID
23297 + * @options: Container's options as set at container's creation
23298 + * @version: DPRC version
23300 +struct dprc_attributes {
23301 + int container_id;
23304 + uint64_t options;
23306 + * struct version - DPRC version
23307 + * @major: DPRC major version
23308 + * @minor: DPRC minor version
23317 + * dprc_get_attributes() - Obtains container attributes
23318 + * @mc_io: Pointer to MC portal's I/O object
23319 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23320 + * @token: Token of DPRC object
23321 + * @attributes: Returned container attributes
23323 + * Return: '0' on Success; Error code otherwise.
23325 +int dprc_get_attributes(struct fsl_mc_io *mc_io,
23326 + uint32_t cmd_flags,
23328 + struct dprc_attributes *attributes);
23331 + * dprc_set_res_quota() - Set allocation policy for a specific resource/object
23332 + * type in a child container
23333 + * @mc_io: Pointer to MC portal's I/O object
23334 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23335 + * @token: Token of DPRC object
23336 + * @child_container_id: ID of the child container
23337 + * @type: Resource/object type
23338 + * @quota: Sets the maximum number of resources of the selected type
23339 + * that the child container is allowed to allocate from its parent;
23340 + * when quota is set to -1, the policy is the same as container's
23341 + * general policy.
23343 + * Allocation policy determines whether or not a container may allocate
23344 + * resources from its parent. Each container has a 'global' allocation policy
23345 + * that is set when the container is created.
23347 + * This function sets allocation policy for a specific resource type.
23348 + * The default policy for all resource types matches the container's 'global'
23349 + * allocation policy.
23351 + * Return: '0' on Success; Error code otherwise.
23353 + * @warning Only the parent container is allowed to change a child policy.
23355 +int dprc_set_res_quota(struct fsl_mc_io *mc_io,
23356 + uint32_t cmd_flags,
23358 + int child_container_id,
23363 + * dprc_get_res_quota() - Gets the allocation policy of a specific
23364 + * resource/object type in a child container
23365 + * @mc_io: Pointer to MC portal's I/O object
23366 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23367 + * @token: Token of DPRC object
23368 + * @child_container_id: ID of the child container
23369 + * @type: resource/object type
23370 + * @quota: Returnes the maximum number of resources of the selected type
23371 + * that the child container is allowed to allocate from the parent;
23372 + * when quota is set to -1, the policy is the same as container's
23373 + * general policy.
23375 + * Return: '0' on Success; Error code otherwise.
23377 +int dprc_get_res_quota(struct fsl_mc_io *mc_io,
23378 + uint32_t cmd_flags,
23380 + int child_container_id,
23382 + uint16_t *quota);
23384 +/* Resource request options */
23387 + * Explicit resource ID request - The requested objects/resources
23388 + * are explicit and sequential (in case of resources).
23389 + * The base ID is given at res_req at base_align field
23391 +#define DPRC_RES_REQ_OPT_EXPLICIT 0x00000001
23394 + * Aligned resources request - Relevant only for resources
23395 + * request (and not objects). Indicates that resources base ID should be
23396 + * sequential and aligned to the value given at dprc_res_req base_align field
23398 +#define DPRC_RES_REQ_OPT_ALIGNED 0x00000002
23401 + * Plugged Flag - Relevant only for object assignment request.
23402 + * Indicates that after all objects assigned. An interrupt will be invoked at
23403 + * the relevant GPP. The assigned object will be marked as plugged.
23404 + * plugged objects can't be assigned from their container
23406 +#define DPRC_RES_REQ_OPT_PLUGGED 0x00000004
23409 + * struct dprc_res_req - Resource request descriptor, to be used in assignment
23410 + * or un-assignment of resources and objects.
23411 + * @type: Resource/object type: Represent as a NULL terminated string.
23412 + * This string may received by using dprc_get_pool() to get resource
23413 + * type and dprc_get_obj() to get object type;
23414 + * Note: it is not possible to assign/un-assign DPRC objects
23415 + * @num: Number of resources
23416 + * @options: Request options: combination of DPRC_RES_REQ_OPT_ options
23417 + * @id_base_align: In case of explicit assignment (DPRC_RES_REQ_OPT_EXPLICIT
23418 + * is set at option), this field represents the required base ID
23419 + * for resource allocation; In case of aligned assignment
23420 + * (DPRC_RES_REQ_OPT_ALIGNED is set at option), this field
23421 + * indicates the required alignment for the resource ID(s) -
23422 + * use 0 if there is no alignment or explicit ID requirements
23424 +struct dprc_res_req {
23427 + uint32_t options;
23428 + int id_base_align;
23432 + * dprc_assign() - Assigns objects or resource to a child container.
23433 + * @mc_io: Pointer to MC portal's I/O object
23434 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23435 + * @token: Token of DPRC object
23436 + * @container_id: ID of the child container
23437 + * @res_req: Describes the type and amount of resources to
23438 + * assign to the given container
23440 + * Assignment is usually done by a parent (this DPRC) to one of its child
23443 + * According to the DPRC allocation policy, the assigned resources may be taken
23444 + * (allocated) from the container's ancestors, if not enough resources are
23445 + * available in the container itself.
23447 + * The type of assignment depends on the dprc_res_req options, as follows:
23448 + * - DPRC_RES_REQ_OPT_EXPLICIT: indicates that assigned resources should have
23449 + * the explicit base ID specified at the id_base_align field of res_req.
23450 + * - DPRC_RES_REQ_OPT_ALIGNED: indicates that the assigned resources should be
23451 + * aligned to the value given at id_base_align field of res_req.
23452 + * - DPRC_RES_REQ_OPT_PLUGGED: Relevant only for object assignment,
23453 + * and indicates that the object must be set to the plugged state.
23455 + * A container may use this function with its own ID in order to change a
23456 + * object state to plugged or unplugged.
23458 + * If IRQ information has been set in the child DPRC, it will signal an
23459 + * interrupt following every change in its object assignment.
23461 + * Return: '0' on Success; Error code otherwise.
23463 +int dprc_assign(struct fsl_mc_io *mc_io,
23464 + uint32_t cmd_flags,
23466 + int container_id,
23467 + struct dprc_res_req *res_req);
23470 + * dprc_unassign() - Un-assigns objects or resources from a child container
23471 + * and moves them into this (parent) DPRC.
23472 + * @mc_io: Pointer to MC portal's I/O object
23473 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23474 + * @token: Token of DPRC object
23475 + * @child_container_id: ID of the child container
23476 + * @res_req: Describes the type and amount of resources to un-assign from
23477 + * the child container
23479 + * Un-assignment of objects can succeed only if the object is not in the
23480 + * plugged or opened state.
23482 + * Return: '0' on Success; Error code otherwise.
23484 +int dprc_unassign(struct fsl_mc_io *mc_io,
23485 + uint32_t cmd_flags,
23487 + int child_container_id,
23488 + struct dprc_res_req *res_req);
23491 + * dprc_get_pool_count() - Get the number of dprc's pools
23492 + * @mc_io: Pointer to MC portal's I/O object
23493 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23494 + * @token: Token of DPRC object
23495 + * @pool_count: Returned number of resource pools in the dprc
23497 + * Return: '0' on Success; Error code otherwise.
23499 +int dprc_get_pool_count(struct fsl_mc_io *mc_io,
23500 + uint32_t cmd_flags,
23502 + int *pool_count);
23505 + * dprc_get_pool() - Get the type (string) of a certain dprc's pool
23506 + * @mc_io: Pointer to MC portal's I/O object
23507 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23508 + * @token: Token of DPRC object
23509 + * @pool_index: Index of the pool to be queried (< pool_count)
23510 + * @type: The type of the pool
23512 + * The pool types retrieved one by one by incrementing
23513 + * pool_index up to (not including) the value of pool_count returned
23514 + * from dprc_get_pool_count(). dprc_get_pool_count() must
23515 + * be called prior to dprc_get_pool().
23517 + * Return: '0' on Success; Error code otherwise.
23519 +int dprc_get_pool(struct fsl_mc_io *mc_io,
23520 + uint32_t cmd_flags,
23526 + * dprc_get_obj_count() - Obtains the number of objects in the DPRC
23527 + * @mc_io: Pointer to MC portal's I/O object
23528 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23529 + * @token: Token of DPRC object
23530 + * @obj_count: Number of objects assigned to the DPRC
23532 + * Return: '0' on Success; Error code otherwise.
23534 +int dprc_get_obj_count(struct fsl_mc_io *mc_io,
23535 + uint32_t cmd_flags,
23540 + * Objects Attributes Flags
23544 + * Opened state - Indicates that an object is open by at least one owner
23546 +#define DPRC_OBJ_STATE_OPEN 0x00000001
23548 + * Plugged state - Indicates that the object is plugged
23550 +#define DPRC_OBJ_STATE_PLUGGED 0x00000002
23553 + * Shareability flag - Object flag indicating no memory shareability.
23554 + * the object generates memory accesses that are non coherent with other
23556 + * user is responsible for proper memory handling through IOMMU configuration.
23558 +#define DPRC_OBJ_FLAG_NO_MEM_SHAREABILITY 0x0001
23561 + * struct dprc_obj_desc - Object descriptor, returned from dprc_get_obj()
23562 + * @type: Type of object: NULL terminated string
23563 + * @id: ID of logical object resource
23564 + * @vendor: Object vendor identifier
23565 + * @ver_major: Major version number
23566 + * @ver_minor: Minor version number
23567 + * @irq_count: Number of interrupts supported by the object
23568 + * @region_count: Number of mappable regions supported by the object
23569 + * @state: Object state: combination of DPRC_OBJ_STATE_ states
23570 + * @label: Object label
23571 + * @flags: Object's flags
23573 +struct dprc_obj_desc {
23577 + uint16_t ver_major;
23578 + uint16_t ver_minor;
23579 + uint8_t irq_count;
23580 + uint8_t region_count;
23587 + * dprc_get_obj() - Get general information on an object
23588 + * @mc_io: Pointer to MC portal's I/O object
23589 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23590 + * @token: Token of DPRC object
23591 + * @obj_index: Index of the object to be queried (< obj_count)
23592 + * @obj_desc: Returns the requested object descriptor
23594 + * The object descriptors are retrieved one by one by incrementing
23595 + * obj_index up to (not including) the value of obj_count returned
23596 + * from dprc_get_obj_count(). dprc_get_obj_count() must
23597 + * be called prior to dprc_get_obj().
23599 + * Return: '0' on Success; Error code otherwise.
23601 +int dprc_get_obj(struct fsl_mc_io *mc_io,
23602 + uint32_t cmd_flags,
23605 + struct dprc_obj_desc *obj_desc);
23608 + * dprc_get_obj_desc() - Get object descriptor.
23610 + * @mc_io: Pointer to MC portal's I/O object
23611 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23612 + * @token: Token of DPRC object
23613 + * @obj_type: The type of the object to get its descriptor.
23614 + * @obj_id: The id of the object to get its descriptor
23615 + * @obj_desc: The returned descriptor to fill and return to the user
23617 + * Return: '0' on Success; Error code otherwise.
23620 +int dprc_get_obj_desc(struct fsl_mc_io *mc_io,
23621 + uint32_t cmd_flags,
23625 + struct dprc_obj_desc *obj_desc);
23628 + * dprc_set_obj_irq() - Set IRQ information for object to trigger an interrupt.
23629 + * @mc_io: Pointer to MC portal's I/O object
23630 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23631 + * @token: Token of DPRC object
23632 + * @obj_type: Type of the object to set its IRQ
23633 + * @obj_id: ID of the object to set its IRQ
23634 + * @irq_index: The interrupt index to configure
23635 + * @irq_cfg: IRQ configuration
23637 + * Return: '0' on Success; Error code otherwise.
23639 +int dprc_set_obj_irq(struct fsl_mc_io *mc_io,
23640 + uint32_t cmd_flags,
23644 + uint8_t irq_index,
23645 + struct dprc_irq_cfg *irq_cfg);
23648 + * dprc_get_obj_irq() - Get IRQ information from object.
23649 + * @mc_io: Pointer to MC portal's I/O object
23650 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23651 + * @token: Token of DPRC object
23652 + * @obj_type: Type od the object to get its IRQ
23653 + * @obj_id: ID of the object to get its IRQ
23654 + * @irq_index: The interrupt index to configure
23655 + * @type: Interrupt type: 0 represents message interrupt
23656 + * type (both irq_addr and irq_val are valid)
23657 + * @irq_cfg: The returned IRQ attributes
23659 + * Return: '0' on Success; Error code otherwise.
23661 +int dprc_get_obj_irq(struct fsl_mc_io *mc_io,
23662 + uint32_t cmd_flags,
23666 + uint8_t irq_index,
23668 + struct dprc_irq_cfg *irq_cfg);
23671 + * dprc_get_res_count() - Obtains the number of free resources that are
23672 + * assigned to this container, by pool type
23673 + * @mc_io: Pointer to MC portal's I/O object
23674 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23675 + * @token: Token of DPRC object
23676 + * @type: pool type
23677 + * @res_count: Returned number of free resources of the given
23678 + * resource type that are assigned to this DPRC
23680 + * Return: '0' on Success; Error code otherwise.
23682 +int dprc_get_res_count(struct fsl_mc_io *mc_io,
23683 + uint32_t cmd_flags,
23689 + * enum dprc_iter_status - Iteration status
23690 + * @DPRC_ITER_STATUS_FIRST: Perform first iteration
23691 + * @DPRC_ITER_STATUS_MORE: Indicates more/next iteration is needed
23692 + * @DPRC_ITER_STATUS_LAST: Indicates last iteration
23694 +enum dprc_iter_status {
23695 + DPRC_ITER_STATUS_FIRST = 0,
23696 + DPRC_ITER_STATUS_MORE = 1,
23697 + DPRC_ITER_STATUS_LAST = 2
23701 + * struct dprc_res_ids_range_desc - Resource ID range descriptor
23702 + * @base_id: Base resource ID of this range
23703 + * @last_id: Last resource ID of this range
23704 + * @iter_status: Iteration status - should be set to DPRC_ITER_STATUS_FIRST at
23705 + * first iteration; while the returned marker is DPRC_ITER_STATUS_MORE,
23706 + * additional iterations are needed, until the returned marker is
23707 + * DPRC_ITER_STATUS_LAST
23709 +struct dprc_res_ids_range_desc {
23712 + enum dprc_iter_status iter_status;
23716 + * dprc_get_res_ids() - Obtains IDs of free resources in the container
23717 + * @mc_io: Pointer to MC portal's I/O object
23718 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23719 + * @token: Token of DPRC object
23720 + * @type: pool type
23721 + * @range_desc: range descriptor
23723 + * Return: '0' on Success; Error code otherwise.
23725 +int dprc_get_res_ids(struct fsl_mc_io *mc_io,
23726 + uint32_t cmd_flags,
23729 + struct dprc_res_ids_range_desc *range_desc);
23735 + * Cacheable - Indicates that region should be mapped as cacheable
23737 +#define DPRC_REGION_CACHEABLE 0x00000001
23740 + * enum dprc_region_type - Region type
23741 + * @DPRC_REGION_TYPE_MC_PORTAL: MC portal region
23742 + * @DPRC_REGION_TYPE_QBMAN_PORTAL: Qbman portal region
23744 +enum dprc_region_type {
23745 + DPRC_REGION_TYPE_MC_PORTAL,
23746 + DPRC_REGION_TYPE_QBMAN_PORTAL
23750 + * struct dprc_region_desc - Mappable region descriptor
23751 + * @base_offset: Region offset from region's base address.
23752 + * For DPMCP and DPRC objects, region base is offset from SoC MC portals
23753 + * base address; For DPIO, region base is offset from SoC QMan portals
23755 + * @size: Region size (in bytes)
23756 + * @flags: Region attributes
23757 + * @type: Portal region type
23759 +struct dprc_region_desc {
23760 + uint32_t base_offset;
23763 + enum dprc_region_type type;
23767 + * dprc_get_obj_region() - Get region information for a specified object.
23768 + * @mc_io: Pointer to MC portal's I/O object
23769 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23770 + * @token: Token of DPRC object
23771 + * @obj_type: Object type as returned in dprc_get_obj()
23772 + * @obj_id: Unique object instance as returned in dprc_get_obj()
23773 + * @region_index: The specific region to query
23774 + * @region_desc: Returns the requested region descriptor
23776 + * Return: '0' on Success; Error code otherwise.
23778 +int dprc_get_obj_region(struct fsl_mc_io *mc_io,
23779 + uint32_t cmd_flags,
23783 + uint8_t region_index,
23784 + struct dprc_region_desc *region_desc);
23787 + * dprc_set_obj_label() - Set object label.
23788 + * @mc_io: Pointer to MC portal's I/O object
23789 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23790 + * @token: Token of DPRC object
23791 + * @obj_type: Object's type
23792 + * @obj_id: Object's ID
23793 + * @label: The required label. The maximum length is 16 chars.
23795 + * Return: '0' on Success; Error code otherwise.
23797 +int dprc_set_obj_label(struct fsl_mc_io *mc_io,
23798 + uint32_t cmd_flags,
23805 + * struct dprc_endpoint - Endpoint description for link connect/disconnect
23807 + * @type: Endpoint object type: NULL terminated string
23808 + * @id: Endpoint object ID
23809 + * @if_id: Interface ID; should be set for endpoints with multiple
23810 + * interfaces ("dpsw", "dpdmux"); for others, always set to 0
23812 +struct dprc_endpoint {
23819 + * struct dprc_connection_cfg - Connection configuration.
23820 + * Used for virtual connections only
23821 + * @committed_rate: Committed rate (Mbits/s)
23822 + * @max_rate: Maximum rate (Mbits/s)
23824 +struct dprc_connection_cfg {
23825 + uint32_t committed_rate;
23826 + uint32_t max_rate;
23830 + * dprc_connect() - Connect two endpoints to create a network link between them
23831 + * @mc_io: Pointer to MC portal's I/O object
23832 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23833 + * @token: Token of DPRC object
23834 + * @endpoint1: Endpoint 1 configuration parameters
23835 + * @endpoint2: Endpoint 2 configuration parameters
23836 + * @cfg: Connection configuration. The connection configuration is ignored for
23837 + * connections made to DPMAC objects, where rate is retrieved from the
23838 + * MAC configuration.
23840 + * Return: '0' on Success; Error code otherwise.
23842 +int dprc_connect(struct fsl_mc_io *mc_io,
23843 + uint32_t cmd_flags,
23845 + const struct dprc_endpoint *endpoint1,
23846 + const struct dprc_endpoint *endpoint2,
23847 + const struct dprc_connection_cfg *cfg);
23850 + * dprc_disconnect() - Disconnect one endpoint to remove its network connection
23851 + * @mc_io: Pointer to MC portal's I/O object
23852 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23853 + * @token: Token of DPRC object
23854 + * @endpoint: Endpoint configuration parameters
23856 + * Return: '0' on Success; Error code otherwise.
23858 +int dprc_disconnect(struct fsl_mc_io *mc_io,
23859 + uint32_t cmd_flags,
23861 + const struct dprc_endpoint *endpoint);
23864 +* dprc_get_connection() - Get connected endpoint and link status if connection
23866 +* @mc_io: Pointer to MC portal's I/O object
23867 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
23868 +* @token: Token of DPRC object
23869 +* @endpoint1: Endpoint 1 configuration parameters
23870 +* @endpoint2: Returned endpoint 2 configuration parameters
23871 +* @state: Returned link state:
23873 +* 0 - link is down;
23874 +* -1 - no connection (endpoint2 information is irrelevant)
23876 +* Return: '0' on Success; -ENAVAIL if connection does not exist.
23878 +int dprc_get_connection(struct fsl_mc_io *mc_io,
23879 + uint32_t cmd_flags,
23881 + const struct dprc_endpoint *endpoint1,
23882 + struct dprc_endpoint *endpoint2,
23885 +#endif /* _FSL_DPRC_H */
23886 diff --git a/drivers/net/dpaa2/mc/fsl_dprc_cmd.h b/drivers/net/dpaa2/mc/fsl_dprc_cmd.h
23887 new file mode 100644
23888 index 0000000..469e286
23890 +++ b/drivers/net/dpaa2/mc/fsl_dprc_cmd.h
23892 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
23894 + * Redistribution and use in source and binary forms, with or without
23895 + * modification, are permitted provided that the following conditions are met:
23896 + * * Redistributions of source code must retain the above copyright
23897 + * notice, this list of conditions and the following disclaimer.
23898 + * * Redistributions in binary form must reproduce the above copyright
23899 + * notice, this list of conditions and the following disclaimer in the
23900 + * documentation and/or other materials provided with the distribution.
23901 + * * Neither the name of the above-listed copyright holders nor the
23902 + * names of any contributors may be used to endorse or promote products
23903 + * derived from this software without specific prior written permission.
23906 + * ALTERNATIVELY, this software may be distributed under the terms of the
23907 + * GNU General Public License ("GPL") as published by the Free Software
23908 + * Foundation, either version 2 of that License or (at your option) any
23911 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23912 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23913 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23914 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
23915 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23916 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23917 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23918 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23919 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23920 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23921 + * POSSIBILITY OF SUCH DAMAGE.
23923 +#ifndef _FSL_DPRC_CMD_H
23924 +#define _FSL_DPRC_CMD_H
23926 +/* DPRC Version */
23927 +#define DPRC_VER_MAJOR 5
23928 +#define DPRC_VER_MINOR 1
23931 +#define DPRC_CMDID_CLOSE 0x800
23932 +#define DPRC_CMDID_OPEN 0x805
23933 +#define DPRC_CMDID_CREATE 0x905
23935 +#define DPRC_CMDID_GET_ATTR 0x004
23936 +#define DPRC_CMDID_RESET_CONT 0x005
23938 +#define DPRC_CMDID_SET_IRQ 0x010
23939 +#define DPRC_CMDID_GET_IRQ 0x011
23940 +#define DPRC_CMDID_SET_IRQ_ENABLE 0x012
23941 +#define DPRC_CMDID_GET_IRQ_ENABLE 0x013
23942 +#define DPRC_CMDID_SET_IRQ_MASK 0x014
23943 +#define DPRC_CMDID_GET_IRQ_MASK 0x015
23944 +#define DPRC_CMDID_GET_IRQ_STATUS 0x016
23945 +#define DPRC_CMDID_CLEAR_IRQ_STATUS 0x017
23947 +#define DPRC_CMDID_CREATE_CONT 0x151
23948 +#define DPRC_CMDID_DESTROY_CONT 0x152
23949 +#define DPRC_CMDID_GET_CONT_ID 0x830
23950 +#define DPRC_CMDID_SET_RES_QUOTA 0x155
23951 +#define DPRC_CMDID_GET_RES_QUOTA 0x156
23952 +#define DPRC_CMDID_ASSIGN 0x157
23953 +#define DPRC_CMDID_UNASSIGN 0x158
23954 +#define DPRC_CMDID_GET_OBJ_COUNT 0x159
23955 +#define DPRC_CMDID_GET_OBJ 0x15A
23956 +#define DPRC_CMDID_GET_RES_COUNT 0x15B
23957 +#define DPRC_CMDID_GET_RES_IDS 0x15C
23958 +#define DPRC_CMDID_GET_OBJ_REG 0x15E
23959 +#define DPRC_CMDID_SET_OBJ_IRQ 0x15F
23960 +#define DPRC_CMDID_GET_OBJ_IRQ 0x160
23961 +#define DPRC_CMDID_SET_OBJ_LABEL 0x161
23962 +#define DPRC_CMDID_GET_OBJ_DESC 0x162
23964 +#define DPRC_CMDID_CONNECT 0x167
23965 +#define DPRC_CMDID_DISCONNECT 0x168
23966 +#define DPRC_CMDID_GET_POOL 0x169
23967 +#define DPRC_CMDID_GET_POOL_COUNT 0x16A
23969 +#define DPRC_CMDID_GET_CONNECTION 0x16C
23971 +/* cmd, param, offset, width, type, arg_name */
23972 +#define DPRC_RSP_GET_CONTAINER_ID(cmd, container_id) \
23973 + MC_RSP_OP(cmd, 0, 0, 32, int, container_id)
23975 +/* cmd, param, offset, width, type, arg_name */
23976 +#define DPRC_CMD_OPEN(cmd, container_id) \
23977 + MC_CMD_OP(cmd, 0, 0, 32, int, container_id)
23979 +/* cmd, param, offset, width, type, arg_name */
23980 +#define DPRC_CMD_CREATE_CONTAINER(cmd, cfg) \
23982 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->icid); \
23983 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, cfg->options); \
23984 + MC_CMD_OP(cmd, 1, 32, 32, int, cfg->portal_id); \
23985 + MC_CMD_OP(cmd, 2, 0, 8, char, cfg->label[0]);\
23986 + MC_CMD_OP(cmd, 2, 8, 8, char, cfg->label[1]);\
23987 + MC_CMD_OP(cmd, 2, 16, 8, char, cfg->label[2]);\
23988 + MC_CMD_OP(cmd, 2, 24, 8, char, cfg->label[3]);\
23989 + MC_CMD_OP(cmd, 2, 32, 8, char, cfg->label[4]);\
23990 + MC_CMD_OP(cmd, 2, 40, 8, char, cfg->label[5]);\
23991 + MC_CMD_OP(cmd, 2, 48, 8, char, cfg->label[6]);\
23992 + MC_CMD_OP(cmd, 2, 56, 8, char, cfg->label[7]);\
23993 + MC_CMD_OP(cmd, 3, 0, 8, char, cfg->label[8]);\
23994 + MC_CMD_OP(cmd, 3, 8, 8, char, cfg->label[9]);\
23995 + MC_CMD_OP(cmd, 3, 16, 8, char, cfg->label[10]);\
23996 + MC_CMD_OP(cmd, 3, 24, 8, char, cfg->label[11]);\
23997 + MC_CMD_OP(cmd, 3, 32, 8, char, cfg->label[12]);\
23998 + MC_CMD_OP(cmd, 3, 40, 8, char, cfg->label[13]);\
23999 + MC_CMD_OP(cmd, 3, 48, 8, char, cfg->label[14]);\
24000 + MC_CMD_OP(cmd, 3, 56, 8, char, cfg->label[15]);\
24003 +/* cmd, param, offset, width, type, arg_name */
24004 +#define DPRC_RSP_CREATE_CONTAINER(cmd, child_container_id, child_portal_offset)\
24006 + MC_RSP_OP(cmd, 1, 0, 32, int, child_container_id); \
24007 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, child_portal_offset);\
24010 +/* cmd, param, offset, width, type, arg_name */
24011 +#define DPRC_CMD_DESTROY_CONTAINER(cmd, child_container_id) \
24012 + MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
24014 +/* cmd, param, offset, width, type, arg_name */
24015 +#define DPRC_CMD_RESET_CONTAINER(cmd, child_container_id) \
24016 + MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id)
24018 +/* cmd, param, offset, width, type, arg_name */
24019 +#define DPRC_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
24021 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
24022 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
24023 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
24024 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
24027 +/* cmd, param, offset, width, type, arg_name */
24028 +#define DPRC_CMD_GET_IRQ(cmd, irq_index) \
24029 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
24031 +/* cmd, param, offset, width, type, arg_name */
24032 +#define DPRC_RSP_GET_IRQ(cmd, type, irq_cfg) \
24034 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
24035 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
24036 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
24037 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
24040 +/* cmd, param, offset, width, type, arg_name */
24041 +#define DPRC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
24043 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
24044 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
24047 +/* cmd, param, offset, width, type, arg_name */
24048 +#define DPRC_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
24049 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
24051 +/* cmd, param, offset, width, type, arg_name */
24052 +#define DPRC_RSP_GET_IRQ_ENABLE(cmd, en) \
24053 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
24055 +/* cmd, param, offset, width, type, arg_name */
24056 +#define DPRC_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
24058 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
24059 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
24062 +/* cmd, param, offset, width, type, arg_name */
24063 +#define DPRC_CMD_GET_IRQ_MASK(cmd, irq_index) \
24064 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
24066 +/* cmd, param, offset, width, type, arg_name */
24067 +#define DPRC_RSP_GET_IRQ_MASK(cmd, mask) \
24068 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
24070 +/* cmd, param, offset, width, type, arg_name */
24071 +#define DPRC_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
24073 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
24074 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
24077 +/* cmd, param, offset, width, type, arg_name */
24078 +#define DPRC_RSP_GET_IRQ_STATUS(cmd, status) \
24079 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
24081 +/* cmd, param, offset, width, type, arg_name */
24082 +#define DPRC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
24084 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
24085 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
24088 +/* cmd, param, offset, width, type, arg_name */
24089 +#define DPRC_RSP_GET_ATTRIBUTES(cmd, attr) \
24091 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->container_id); \
24092 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->icid); \
24093 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
24094 + MC_RSP_OP(cmd, 1, 32, 32, int, attr->portal_id); \
24095 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, attr->version.major);\
24096 + MC_RSP_OP(cmd, 2, 16, 16, uint16_t, attr->version.minor);\
24099 +/* cmd, param, offset, width, type, arg_name */
24100 +#define DPRC_CMD_SET_RES_QUOTA(cmd, child_container_id, type, quota) \
24102 + MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id); \
24103 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, quota);\
24104 + MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
24105 + MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
24106 + MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
24107 + MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
24108 + MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
24109 + MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
24110 + MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
24111 + MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
24112 + MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
24113 + MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
24114 + MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
24115 + MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
24116 + MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
24117 + MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
24118 + MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
24119 + MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
24122 +/* cmd, param, offset, width, type, arg_name */
24123 +#define DPRC_CMD_GET_RES_QUOTA(cmd, child_container_id, type) \
24125 + MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id); \
24126 + MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
24127 + MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
24128 + MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
24129 + MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
24130 + MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
24131 + MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
24132 + MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
24133 + MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
24134 + MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
24135 + MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
24136 + MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
24137 + MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
24138 + MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
24139 + MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
24140 + MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
24141 + MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
24143 +/* cmd, param, offset, width, type, arg_name */
24144 +#define DPRC_RSP_GET_RES_QUOTA(cmd, quota) \
24145 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, quota)
24147 +/* param, offset, width, type, arg_name */
24148 +#define DPRC_CMD_ASSIGN(cmd, container_id, res_req) \
24150 + MC_CMD_OP(cmd, 0, 0, 32, int, container_id); \
24151 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, res_req->options);\
24152 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, res_req->num); \
24153 + MC_CMD_OP(cmd, 1, 32, 32, int, res_req->id_base_align); \
24154 + MC_CMD_OP(cmd, 2, 0, 8, char, res_req->type[0]);\
24155 + MC_CMD_OP(cmd, 2, 8, 8, char, res_req->type[1]);\
24156 + MC_CMD_OP(cmd, 2, 16, 8, char, res_req->type[2]);\
24157 + MC_CMD_OP(cmd, 2, 24, 8, char, res_req->type[3]);\
24158 + MC_CMD_OP(cmd, 2, 32, 8, char, res_req->type[4]);\
24159 + MC_CMD_OP(cmd, 2, 40, 8, char, res_req->type[5]);\
24160 + MC_CMD_OP(cmd, 2, 48, 8, char, res_req->type[6]);\
24161 + MC_CMD_OP(cmd, 2, 56, 8, char, res_req->type[7]);\
24162 + MC_CMD_OP(cmd, 3, 0, 8, char, res_req->type[8]);\
24163 + MC_CMD_OP(cmd, 3, 8, 8, char, res_req->type[9]);\
24164 + MC_CMD_OP(cmd, 3, 16, 8, char, res_req->type[10]);\
24165 + MC_CMD_OP(cmd, 3, 24, 8, char, res_req->type[11]);\
24166 + MC_CMD_OP(cmd, 3, 32, 8, char, res_req->type[12]);\
24167 + MC_CMD_OP(cmd, 3, 40, 8, char, res_req->type[13]);\
24168 + MC_CMD_OP(cmd, 3, 48, 8, char, res_req->type[14]);\
24169 + MC_CMD_OP(cmd, 3, 56, 8, char, res_req->type[15]);\
24172 +/* param, offset, width, type, arg_name */
24173 +#define DPRC_CMD_UNASSIGN(cmd, child_container_id, res_req) \
24175 + MC_CMD_OP(cmd, 0, 0, 32, int, child_container_id); \
24176 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, res_req->options);\
24177 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, res_req->num); \
24178 + MC_CMD_OP(cmd, 1, 32, 32, int, res_req->id_base_align); \
24179 + MC_CMD_OP(cmd, 2, 0, 8, char, res_req->type[0]);\
24180 + MC_CMD_OP(cmd, 2, 8, 8, char, res_req->type[1]);\
24181 + MC_CMD_OP(cmd, 2, 16, 8, char, res_req->type[2]);\
24182 + MC_CMD_OP(cmd, 2, 24, 8, char, res_req->type[3]);\
24183 + MC_CMD_OP(cmd, 2, 32, 8, char, res_req->type[4]);\
24184 + MC_CMD_OP(cmd, 2, 40, 8, char, res_req->type[5]);\
24185 + MC_CMD_OP(cmd, 2, 48, 8, char, res_req->type[6]);\
24186 + MC_CMD_OP(cmd, 2, 56, 8, char, res_req->type[7]);\
24187 + MC_CMD_OP(cmd, 3, 0, 8, char, res_req->type[8]);\
24188 + MC_CMD_OP(cmd, 3, 8, 8, char, res_req->type[9]);\
24189 + MC_CMD_OP(cmd, 3, 16, 8, char, res_req->type[10]);\
24190 + MC_CMD_OP(cmd, 3, 24, 8, char, res_req->type[11]);\
24191 + MC_CMD_OP(cmd, 3, 32, 8, char, res_req->type[12]);\
24192 + MC_CMD_OP(cmd, 3, 40, 8, char, res_req->type[13]);\
24193 + MC_CMD_OP(cmd, 3, 48, 8, char, res_req->type[14]);\
24194 + MC_CMD_OP(cmd, 3, 56, 8, char, res_req->type[15]);\
24197 +/* cmd, param, offset, width, type, arg_name */
24198 +#define DPRC_RSP_GET_POOL_COUNT(cmd, pool_count) \
24199 + MC_RSP_OP(cmd, 0, 0, 32, int, pool_count)
24201 +/* cmd, param, offset, width, type, arg_name */
24202 +#define DPRC_CMD_GET_POOL(cmd, pool_index) \
24203 + MC_CMD_OP(cmd, 0, 0, 32, int, pool_index)
24205 +/* cmd, param, offset, width, type, arg_name */
24206 +#define DPRC_RSP_GET_POOL(cmd, type) \
24208 + MC_RSP_OP(cmd, 1, 0, 8, char, type[0]);\
24209 + MC_RSP_OP(cmd, 1, 8, 8, char, type[1]);\
24210 + MC_RSP_OP(cmd, 1, 16, 8, char, type[2]);\
24211 + MC_RSP_OP(cmd, 1, 24, 8, char, type[3]);\
24212 + MC_RSP_OP(cmd, 1, 32, 8, char, type[4]);\
24213 + MC_RSP_OP(cmd, 1, 40, 8, char, type[5]);\
24214 + MC_RSP_OP(cmd, 1, 48, 8, char, type[6]);\
24215 + MC_RSP_OP(cmd, 1, 56, 8, char, type[7]);\
24216 + MC_RSP_OP(cmd, 2, 0, 8, char, type[8]);\
24217 + MC_RSP_OP(cmd, 2, 8, 8, char, type[9]);\
24218 + MC_RSP_OP(cmd, 2, 16, 8, char, type[10]);\
24219 + MC_RSP_OP(cmd, 2, 24, 8, char, type[11]);\
24220 + MC_RSP_OP(cmd, 2, 32, 8, char, type[12]);\
24221 + MC_RSP_OP(cmd, 2, 40, 8, char, type[13]);\
24222 + MC_RSP_OP(cmd, 2, 48, 8, char, type[14]);\
24223 + MC_RSP_OP(cmd, 2, 56, 8, char, type[15]);\
24226 +/* cmd, param, offset, width, type, arg_name */
24227 +#define DPRC_RSP_GET_OBJ_COUNT(cmd, obj_count) \
24228 + MC_RSP_OP(cmd, 0, 32, 32, int, obj_count)
24230 +/* cmd, param, offset, width, type, arg_name */
24231 +#define DPRC_CMD_GET_OBJ(cmd, obj_index) \
24232 + MC_CMD_OP(cmd, 0, 0, 32, int, obj_index)
24234 +/* cmd, param, offset, width, type, arg_name */
24235 +#define DPRC_RSP_GET_OBJ(cmd, obj_desc) \
24237 + MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
24238 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
24239 + MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
24240 + MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
24241 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
24242 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
24243 + MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
24244 + MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
24245 + MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
24246 + MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
24247 + MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
24248 + MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
24249 + MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
24250 + MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
24251 + MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
24252 + MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
24253 + MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
24254 + MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
24255 + MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
24256 + MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
24257 + MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
24258 + MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
24259 + MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
24260 + MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
24261 + MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
24262 + MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
24263 + MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
24264 + MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
24265 + MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
24266 + MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
24267 + MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
24268 + MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
24269 + MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
24270 + MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
24271 + MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
24272 + MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
24273 + MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
24274 + MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
24275 + MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
24276 + MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
24279 +/* cmd, param, offset, width, type, arg_name */
24280 +#define DPRC_CMD_GET_OBJ_DESC(cmd, obj_type, obj_id) \
24282 + MC_CMD_OP(cmd, 0, 0, 32, int, obj_id);\
24283 + MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\
24284 + MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\
24285 + MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\
24286 + MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\
24287 + MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\
24288 + MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\
24289 + MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\
24290 + MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\
24291 + MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\
24292 + MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\
24293 + MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\
24294 + MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\
24295 + MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\
24296 + MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\
24297 + MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\
24298 + MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\
24301 +/* cmd, param, offset, width, type, arg_name */
24302 +#define DPRC_RSP_GET_OBJ_DESC(cmd, obj_desc) \
24304 + MC_RSP_OP(cmd, 0, 32, 32, int, obj_desc->id); \
24305 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, obj_desc->vendor); \
24306 + MC_RSP_OP(cmd, 1, 16, 8, uint8_t, obj_desc->irq_count); \
24307 + MC_RSP_OP(cmd, 1, 24, 8, uint8_t, obj_desc->region_count); \
24308 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, obj_desc->state);\
24309 + MC_RSP_OP(cmd, 2, 0, 16, uint16_t, obj_desc->ver_major);\
24310 + MC_RSP_OP(cmd, 2, 16, 16, uint16_t, obj_desc->ver_minor);\
24311 + MC_RSP_OP(cmd, 2, 32, 16, uint16_t, obj_desc->flags); \
24312 + MC_RSP_OP(cmd, 3, 0, 8, char, obj_desc->type[0]);\
24313 + MC_RSP_OP(cmd, 3, 8, 8, char, obj_desc->type[1]);\
24314 + MC_RSP_OP(cmd, 3, 16, 8, char, obj_desc->type[2]);\
24315 + MC_RSP_OP(cmd, 3, 24, 8, char, obj_desc->type[3]);\
24316 + MC_RSP_OP(cmd, 3, 32, 8, char, obj_desc->type[4]);\
24317 + MC_RSP_OP(cmd, 3, 40, 8, char, obj_desc->type[5]);\
24318 + MC_RSP_OP(cmd, 3, 48, 8, char, obj_desc->type[6]);\
24319 + MC_RSP_OP(cmd, 3, 56, 8, char, obj_desc->type[7]);\
24320 + MC_RSP_OP(cmd, 4, 0, 8, char, obj_desc->type[8]);\
24321 + MC_RSP_OP(cmd, 4, 8, 8, char, obj_desc->type[9]);\
24322 + MC_RSP_OP(cmd, 4, 16, 8, char, obj_desc->type[10]);\
24323 + MC_RSP_OP(cmd, 4, 24, 8, char, obj_desc->type[11]);\
24324 + MC_RSP_OP(cmd, 4, 32, 8, char, obj_desc->type[12]);\
24325 + MC_RSP_OP(cmd, 4, 40, 8, char, obj_desc->type[13]);\
24326 + MC_RSP_OP(cmd, 4, 48, 8, char, obj_desc->type[14]);\
24327 + MC_RSP_OP(cmd, 4, 56, 8, char, obj_desc->type[15]);\
24328 + MC_RSP_OP(cmd, 5, 0, 8, char, obj_desc->label[0]);\
24329 + MC_RSP_OP(cmd, 5, 8, 8, char, obj_desc->label[1]);\
24330 + MC_RSP_OP(cmd, 5, 16, 8, char, obj_desc->label[2]);\
24331 + MC_RSP_OP(cmd, 5, 24, 8, char, obj_desc->label[3]);\
24332 + MC_RSP_OP(cmd, 5, 32, 8, char, obj_desc->label[4]);\
24333 + MC_RSP_OP(cmd, 5, 40, 8, char, obj_desc->label[5]);\
24334 + MC_RSP_OP(cmd, 5, 48, 8, char, obj_desc->label[6]);\
24335 + MC_RSP_OP(cmd, 5, 56, 8, char, obj_desc->label[7]);\
24336 + MC_RSP_OP(cmd, 6, 0, 8, char, obj_desc->label[8]);\
24337 + MC_RSP_OP(cmd, 6, 8, 8, char, obj_desc->label[9]);\
24338 + MC_RSP_OP(cmd, 6, 16, 8, char, obj_desc->label[10]);\
24339 + MC_RSP_OP(cmd, 6, 24, 8, char, obj_desc->label[11]);\
24340 + MC_RSP_OP(cmd, 6, 32, 8, char, obj_desc->label[12]);\
24341 + MC_RSP_OP(cmd, 6, 40, 8, char, obj_desc->label[13]);\
24342 + MC_RSP_OP(cmd, 6, 48, 8, char, obj_desc->label[14]);\
24343 + MC_RSP_OP(cmd, 6, 56, 8, char, obj_desc->label[15]);\
24346 +/* cmd, param, offset, width, type, arg_name */
24347 +#define DPRC_CMD_GET_RES_COUNT(cmd, type) \
24349 + MC_CMD_OP(cmd, 1, 0, 8, char, type[0]);\
24350 + MC_CMD_OP(cmd, 1, 8, 8, char, type[1]);\
24351 + MC_CMD_OP(cmd, 1, 16, 8, char, type[2]);\
24352 + MC_CMD_OP(cmd, 1, 24, 8, char, type[3]);\
24353 + MC_CMD_OP(cmd, 1, 32, 8, char, type[4]);\
24354 + MC_CMD_OP(cmd, 1, 40, 8, char, type[5]);\
24355 + MC_CMD_OP(cmd, 1, 48, 8, char, type[6]);\
24356 + MC_CMD_OP(cmd, 1, 56, 8, char, type[7]);\
24357 + MC_CMD_OP(cmd, 2, 0, 8, char, type[8]);\
24358 + MC_CMD_OP(cmd, 2, 8, 8, char, type[9]);\
24359 + MC_CMD_OP(cmd, 2, 16, 8, char, type[10]);\
24360 + MC_CMD_OP(cmd, 2, 24, 8, char, type[11]);\
24361 + MC_CMD_OP(cmd, 2, 32, 8, char, type[12]);\
24362 + MC_CMD_OP(cmd, 2, 40, 8, char, type[13]);\
24363 + MC_CMD_OP(cmd, 2, 48, 8, char, type[14]);\
24364 + MC_CMD_OP(cmd, 2, 56, 8, char, type[15]);\
24367 +/* cmd, param, offset, width, type, arg_name */
24368 +#define DPRC_RSP_GET_RES_COUNT(cmd, res_count) \
24369 + MC_RSP_OP(cmd, 0, 0, 32, int, res_count)
24371 +/* cmd, param, offset, width, type, arg_name */
24372 +#define DPRC_CMD_GET_RES_IDS(cmd, range_desc, type) \
24374 + MC_CMD_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
24375 + range_desc->iter_status); \
24376 + MC_CMD_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
24377 + MC_CMD_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
24378 + MC_CMD_OP(cmd, 2, 0, 8, char, type[0]);\
24379 + MC_CMD_OP(cmd, 2, 8, 8, char, type[1]);\
24380 + MC_CMD_OP(cmd, 2, 16, 8, char, type[2]);\
24381 + MC_CMD_OP(cmd, 2, 24, 8, char, type[3]);\
24382 + MC_CMD_OP(cmd, 2, 32, 8, char, type[4]);\
24383 + MC_CMD_OP(cmd, 2, 40, 8, char, type[5]);\
24384 + MC_CMD_OP(cmd, 2, 48, 8, char, type[6]);\
24385 + MC_CMD_OP(cmd, 2, 56, 8, char, type[7]);\
24386 + MC_CMD_OP(cmd, 3, 0, 8, char, type[8]);\
24387 + MC_CMD_OP(cmd, 3, 8, 8, char, type[9]);\
24388 + MC_CMD_OP(cmd, 3, 16, 8, char, type[10]);\
24389 + MC_CMD_OP(cmd, 3, 24, 8, char, type[11]);\
24390 + MC_CMD_OP(cmd, 3, 32, 8, char, type[12]);\
24391 + MC_CMD_OP(cmd, 3, 40, 8, char, type[13]);\
24392 + MC_CMD_OP(cmd, 3, 48, 8, char, type[14]);\
24393 + MC_CMD_OP(cmd, 3, 56, 8, char, type[15]);\
24396 +/* cmd, param, offset, width, type, arg_name */
24397 +#define DPRC_RSP_GET_RES_IDS(cmd, range_desc) \
24399 + MC_RSP_OP(cmd, 0, 42, 7, enum dprc_iter_status, \
24400 + range_desc->iter_status);\
24401 + MC_RSP_OP(cmd, 1, 0, 32, int, range_desc->base_id); \
24402 + MC_RSP_OP(cmd, 1, 32, 32, int, range_desc->last_id);\
24405 +/* cmd, param, offset, width, type, arg_name */
24406 +#define DPRC_CMD_GET_OBJ_REGION(cmd, obj_type, obj_id, region_index) \
24408 + MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
24409 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, region_index);\
24410 + MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
24411 + MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
24412 + MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
24413 + MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
24414 + MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
24415 + MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
24416 + MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
24417 + MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
24418 + MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
24419 + MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
24420 + MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
24421 + MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
24422 + MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
24423 + MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
24424 + MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
24425 + MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
24428 +/* param, offset, width, type, arg_name */
24429 +#define DPRC_RSP_GET_OBJ_REGION(cmd, region_desc) \
24431 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, region_desc->base_offset);\
24432 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, region_desc->size); \
24433 + MC_RSP_OP(cmd, 2, 32, 4, enum dprc_region_type, region_desc->type);\
24434 + MC_RSP_OP(cmd, 3, 0, 32, uint32_t, region_desc->flags);\
24437 +/* cmd, param, offset, width, type, arg_name */
24438 +#define DPRC_CMD_SET_OBJ_LABEL(cmd, obj_type, obj_id, label) \
24440 + MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
24441 + MC_CMD_OP(cmd, 1, 0, 8, char, label[0]);\
24442 + MC_CMD_OP(cmd, 1, 8, 8, char, label[1]);\
24443 + MC_CMD_OP(cmd, 1, 16, 8, char, label[2]);\
24444 + MC_CMD_OP(cmd, 1, 24, 8, char, label[3]);\
24445 + MC_CMD_OP(cmd, 1, 32, 8, char, label[4]);\
24446 + MC_CMD_OP(cmd, 1, 40, 8, char, label[5]);\
24447 + MC_CMD_OP(cmd, 1, 48, 8, char, label[6]);\
24448 + MC_CMD_OP(cmd, 1, 56, 8, char, label[7]);\
24449 + MC_CMD_OP(cmd, 2, 0, 8, char, label[8]);\
24450 + MC_CMD_OP(cmd, 2, 8, 8, char, label[9]);\
24451 + MC_CMD_OP(cmd, 2, 16, 8, char, label[10]);\
24452 + MC_CMD_OP(cmd, 2, 24, 8, char, label[11]);\
24453 + MC_CMD_OP(cmd, 2, 32, 8, char, label[12]);\
24454 + MC_CMD_OP(cmd, 2, 40, 8, char, label[13]);\
24455 + MC_CMD_OP(cmd, 2, 48, 8, char, label[14]);\
24456 + MC_CMD_OP(cmd, 2, 56, 8, char, label[15]);\
24457 + MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
24458 + MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
24459 + MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
24460 + MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
24461 + MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
24462 + MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
24463 + MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
24464 + MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
24465 + MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
24466 + MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
24467 + MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
24468 + MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
24469 + MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
24470 + MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
24471 + MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
24472 + MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
24475 +/* cmd, param, offset, width, type, arg_name */
24476 +#define DPRC_CMD_SET_OBJ_IRQ(cmd, obj_type, obj_id, irq_index, irq_cfg) \
24478 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
24479 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
24480 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
24481 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
24482 + MC_CMD_OP(cmd, 2, 32, 32, int, obj_id); \
24483 + MC_CMD_OP(cmd, 3, 0, 8, char, obj_type[0]);\
24484 + MC_CMD_OP(cmd, 3, 8, 8, char, obj_type[1]);\
24485 + MC_CMD_OP(cmd, 3, 16, 8, char, obj_type[2]);\
24486 + MC_CMD_OP(cmd, 3, 24, 8, char, obj_type[3]);\
24487 + MC_CMD_OP(cmd, 3, 32, 8, char, obj_type[4]);\
24488 + MC_CMD_OP(cmd, 3, 40, 8, char, obj_type[5]);\
24489 + MC_CMD_OP(cmd, 3, 48, 8, char, obj_type[6]);\
24490 + MC_CMD_OP(cmd, 3, 56, 8, char, obj_type[7]);\
24491 + MC_CMD_OP(cmd, 4, 0, 8, char, obj_type[8]);\
24492 + MC_CMD_OP(cmd, 4, 8, 8, char, obj_type[9]);\
24493 + MC_CMD_OP(cmd, 4, 16, 8, char, obj_type[10]);\
24494 + MC_CMD_OP(cmd, 4, 24, 8, char, obj_type[11]);\
24495 + MC_CMD_OP(cmd, 4, 32, 8, char, obj_type[12]);\
24496 + MC_CMD_OP(cmd, 4, 40, 8, char, obj_type[13]);\
24497 + MC_CMD_OP(cmd, 4, 48, 8, char, obj_type[14]);\
24498 + MC_CMD_OP(cmd, 4, 56, 8, char, obj_type[15]);\
24501 +/* cmd, param, offset, width, type, arg_name */
24502 +#define DPRC_CMD_GET_OBJ_IRQ(cmd, obj_type, obj_id, irq_index) \
24504 + MC_CMD_OP(cmd, 0, 0, 32, int, obj_id); \
24505 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
24506 + MC_CMD_OP(cmd, 1, 0, 8, char, obj_type[0]);\
24507 + MC_CMD_OP(cmd, 1, 8, 8, char, obj_type[1]);\
24508 + MC_CMD_OP(cmd, 1, 16, 8, char, obj_type[2]);\
24509 + MC_CMD_OP(cmd, 1, 24, 8, char, obj_type[3]);\
24510 + MC_CMD_OP(cmd, 1, 32, 8, char, obj_type[4]);\
24511 + MC_CMD_OP(cmd, 1, 40, 8, char, obj_type[5]);\
24512 + MC_CMD_OP(cmd, 1, 48, 8, char, obj_type[6]);\
24513 + MC_CMD_OP(cmd, 1, 56, 8, char, obj_type[7]);\
24514 + MC_CMD_OP(cmd, 2, 0, 8, char, obj_type[8]);\
24515 + MC_CMD_OP(cmd, 2, 8, 8, char, obj_type[9]);\
24516 + MC_CMD_OP(cmd, 2, 16, 8, char, obj_type[10]);\
24517 + MC_CMD_OP(cmd, 2, 24, 8, char, obj_type[11]);\
24518 + MC_CMD_OP(cmd, 2, 32, 8, char, obj_type[12]);\
24519 + MC_CMD_OP(cmd, 2, 40, 8, char, obj_type[13]);\
24520 + MC_CMD_OP(cmd, 2, 48, 8, char, obj_type[14]);\
24521 + MC_CMD_OP(cmd, 2, 56, 8, char, obj_type[15]);\
24524 +/* cmd, param, offset, width, type, arg_name */
24525 +#define DPRC_RSP_GET_OBJ_IRQ(cmd, type, irq_cfg) \
24527 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
24528 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
24529 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
24530 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
24533 +/* cmd, param, offset, width, type, arg_name */
24534 +#define DPRC_CMD_CONNECT(cmd, endpoint1, endpoint2, cfg) \
24536 + MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
24537 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
24538 + MC_CMD_OP(cmd, 1, 0, 32, int, endpoint2->id); \
24539 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, endpoint2->if_id); \
24540 + MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[0]); \
24541 + MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[1]); \
24542 + MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[2]); \
24543 + MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[3]); \
24544 + MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[4]); \
24545 + MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[5]); \
24546 + MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[6]); \
24547 + MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[7]); \
24548 + MC_CMD_OP(cmd, 3, 0, 8, char, endpoint1->type[8]); \
24549 + MC_CMD_OP(cmd, 3, 8, 8, char, endpoint1->type[9]); \
24550 + MC_CMD_OP(cmd, 3, 16, 8, char, endpoint1->type[10]); \
24551 + MC_CMD_OP(cmd, 3, 24, 8, char, endpoint1->type[11]); \
24552 + MC_CMD_OP(cmd, 3, 32, 8, char, endpoint1->type[12]); \
24553 + MC_CMD_OP(cmd, 3, 40, 8, char, endpoint1->type[13]); \
24554 + MC_CMD_OP(cmd, 3, 48, 8, char, endpoint1->type[14]); \
24555 + MC_CMD_OP(cmd, 3, 56, 8, char, endpoint1->type[15]); \
24556 + MC_CMD_OP(cmd, 4, 0, 32, uint32_t, cfg->max_rate); \
24557 + MC_CMD_OP(cmd, 4, 32, 32, uint32_t, cfg->committed_rate); \
24558 + MC_CMD_OP(cmd, 5, 0, 8, char, endpoint2->type[0]); \
24559 + MC_CMD_OP(cmd, 5, 8, 8, char, endpoint2->type[1]); \
24560 + MC_CMD_OP(cmd, 5, 16, 8, char, endpoint2->type[2]); \
24561 + MC_CMD_OP(cmd, 5, 24, 8, char, endpoint2->type[3]); \
24562 + MC_CMD_OP(cmd, 5, 32, 8, char, endpoint2->type[4]); \
24563 + MC_CMD_OP(cmd, 5, 40, 8, char, endpoint2->type[5]); \
24564 + MC_CMD_OP(cmd, 5, 48, 8, char, endpoint2->type[6]); \
24565 + MC_CMD_OP(cmd, 5, 56, 8, char, endpoint2->type[7]); \
24566 + MC_CMD_OP(cmd, 6, 0, 8, char, endpoint2->type[8]); \
24567 + MC_CMD_OP(cmd, 6, 8, 8, char, endpoint2->type[9]); \
24568 + MC_CMD_OP(cmd, 6, 16, 8, char, endpoint2->type[10]); \
24569 + MC_CMD_OP(cmd, 6, 24, 8, char, endpoint2->type[11]); \
24570 + MC_CMD_OP(cmd, 6, 32, 8, char, endpoint2->type[12]); \
24571 + MC_CMD_OP(cmd, 6, 40, 8, char, endpoint2->type[13]); \
24572 + MC_CMD_OP(cmd, 6, 48, 8, char, endpoint2->type[14]); \
24573 + MC_CMD_OP(cmd, 6, 56, 8, char, endpoint2->type[15]); \
24576 +/* cmd, param, offset, width, type, arg_name */
24577 +#define DPRC_CMD_DISCONNECT(cmd, endpoint) \
24579 + MC_CMD_OP(cmd, 0, 0, 32, int, endpoint->id); \
24580 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint->if_id); \
24581 + MC_CMD_OP(cmd, 1, 0, 8, char, endpoint->type[0]); \
24582 + MC_CMD_OP(cmd, 1, 8, 8, char, endpoint->type[1]); \
24583 + MC_CMD_OP(cmd, 1, 16, 8, char, endpoint->type[2]); \
24584 + MC_CMD_OP(cmd, 1, 24, 8, char, endpoint->type[3]); \
24585 + MC_CMD_OP(cmd, 1, 32, 8, char, endpoint->type[4]); \
24586 + MC_CMD_OP(cmd, 1, 40, 8, char, endpoint->type[5]); \
24587 + MC_CMD_OP(cmd, 1, 48, 8, char, endpoint->type[6]); \
24588 + MC_CMD_OP(cmd, 1, 56, 8, char, endpoint->type[7]); \
24589 + MC_CMD_OP(cmd, 2, 0, 8, char, endpoint->type[8]); \
24590 + MC_CMD_OP(cmd, 2, 8, 8, char, endpoint->type[9]); \
24591 + MC_CMD_OP(cmd, 2, 16, 8, char, endpoint->type[10]); \
24592 + MC_CMD_OP(cmd, 2, 24, 8, char, endpoint->type[11]); \
24593 + MC_CMD_OP(cmd, 2, 32, 8, char, endpoint->type[12]); \
24594 + MC_CMD_OP(cmd, 2, 40, 8, char, endpoint->type[13]); \
24595 + MC_CMD_OP(cmd, 2, 48, 8, char, endpoint->type[14]); \
24596 + MC_CMD_OP(cmd, 2, 56, 8, char, endpoint->type[15]); \
24599 +/* cmd, param, offset, width, type, arg_name */
24600 +#define DPRC_CMD_GET_CONNECTION(cmd, endpoint1) \
24602 + MC_CMD_OP(cmd, 0, 0, 32, int, endpoint1->id); \
24603 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, endpoint1->if_id); \
24604 + MC_CMD_OP(cmd, 1, 0, 8, char, endpoint1->type[0]); \
24605 + MC_CMD_OP(cmd, 1, 8, 8, char, endpoint1->type[1]); \
24606 + MC_CMD_OP(cmd, 1, 16, 8, char, endpoint1->type[2]); \
24607 + MC_CMD_OP(cmd, 1, 24, 8, char, endpoint1->type[3]); \
24608 + MC_CMD_OP(cmd, 1, 32, 8, char, endpoint1->type[4]); \
24609 + MC_CMD_OP(cmd, 1, 40, 8, char, endpoint1->type[5]); \
24610 + MC_CMD_OP(cmd, 1, 48, 8, char, endpoint1->type[6]); \
24611 + MC_CMD_OP(cmd, 1, 56, 8, char, endpoint1->type[7]); \
24612 + MC_CMD_OP(cmd, 2, 0, 8, char, endpoint1->type[8]); \
24613 + MC_CMD_OP(cmd, 2, 8, 8, char, endpoint1->type[9]); \
24614 + MC_CMD_OP(cmd, 2, 16, 8, char, endpoint1->type[10]); \
24615 + MC_CMD_OP(cmd, 2, 24, 8, char, endpoint1->type[11]); \
24616 + MC_CMD_OP(cmd, 2, 32, 8, char, endpoint1->type[12]); \
24617 + MC_CMD_OP(cmd, 2, 40, 8, char, endpoint1->type[13]); \
24618 + MC_CMD_OP(cmd, 2, 48, 8, char, endpoint1->type[14]); \
24619 + MC_CMD_OP(cmd, 2, 56, 8, char, endpoint1->type[15]); \
24622 +/* cmd, param, offset, width, type, arg_name */
24623 +#define DPRC_RSP_GET_CONNECTION(cmd, endpoint2, state) \
24625 + MC_RSP_OP(cmd, 3, 0, 32, int, endpoint2->id); \
24626 + MC_RSP_OP(cmd, 3, 32, 16, uint16_t, endpoint2->if_id); \
24627 + MC_RSP_OP(cmd, 4, 0, 8, char, endpoint2->type[0]); \
24628 + MC_RSP_OP(cmd, 4, 8, 8, char, endpoint2->type[1]); \
24629 + MC_RSP_OP(cmd, 4, 16, 8, char, endpoint2->type[2]); \
24630 + MC_RSP_OP(cmd, 4, 24, 8, char, endpoint2->type[3]); \
24631 + MC_RSP_OP(cmd, 4, 32, 8, char, endpoint2->type[4]); \
24632 + MC_RSP_OP(cmd, 4, 40, 8, char, endpoint2->type[5]); \
24633 + MC_RSP_OP(cmd, 4, 48, 8, char, endpoint2->type[6]); \
24634 + MC_RSP_OP(cmd, 4, 56, 8, char, endpoint2->type[7]); \
24635 + MC_RSP_OP(cmd, 5, 0, 8, char, endpoint2->type[8]); \
24636 + MC_RSP_OP(cmd, 5, 8, 8, char, endpoint2->type[9]); \
24637 + MC_RSP_OP(cmd, 5, 16, 8, char, endpoint2->type[10]); \
24638 + MC_RSP_OP(cmd, 5, 24, 8, char, endpoint2->type[11]); \
24639 + MC_RSP_OP(cmd, 5, 32, 8, char, endpoint2->type[12]); \
24640 + MC_RSP_OP(cmd, 5, 40, 8, char, endpoint2->type[13]); \
24641 + MC_RSP_OP(cmd, 5, 48, 8, char, endpoint2->type[14]); \
24642 + MC_RSP_OP(cmd, 5, 56, 8, char, endpoint2->type[15]); \
24643 + MC_RSP_OP(cmd, 6, 0, 32, int, state); \
24646 +#endif /* _FSL_DPRC_CMD_H */
24647 diff --git a/drivers/net/dpaa2/mc/fsl_dprtc.h b/drivers/net/dpaa2/mc/fsl_dprtc.h
24648 new file mode 100644
24649 index 0000000..cad0693
24651 +++ b/drivers/net/dpaa2/mc/fsl_dprtc.h
24653 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
24655 + * Redistribution and use in source and binary forms, with or without
24656 + * modification, are permitted provided that the following conditions are met:
24657 + * * Redistributions of source code must retain the above copyright
24658 + * notice, this list of conditions and the following disclaimer.
24659 + * * Redistributions in binary form must reproduce the above copyright
24660 + * notice, this list of conditions and the following disclaimer in the
24661 + * documentation and/or other materials provided with the distribution.
24662 + * * Neither the name of the above-listed copyright holders nor the
24663 + * names of any contributors may be used to endorse or promote products
24664 + * derived from this software without specific prior written permission.
24667 + * ALTERNATIVELY, this software may be distributed under the terms of the
24668 + * GNU General Public License ("GPL") as published by the Free Software
24669 + * Foundation, either version 2 of that License or (at your option) any
24672 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24673 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24674 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24675 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24676 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24677 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24678 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24679 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24680 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24681 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24682 + * POSSIBILITY OF SUCH DAMAGE.
24684 +#ifndef __FSL_DPRTC_H
24685 +#define __FSL_DPRTC_H
24687 +/* Data Path Real Time Counter API
24688 + * Contains initialization APIs and runtime control APIs for RTC
24694 + * Number of irq's
24696 +#define DPRTC_MAX_IRQ_NUM 1
24697 +#define DPRTC_IRQ_INDEX 0
24700 + * Interrupt event masks:
24704 + * Interrupt event mask indicating alarm event had occurred
24706 +#define DPRTC_EVENT_ALARM 0x40000000
24708 + * Interrupt event mask indicating periodic pulse event had occurred
24710 +#define DPRTC_EVENT_PPS 0x08000000
24713 + * dprtc_open() - Open a control session for the specified object.
24714 + * @mc_io: Pointer to MC portal's I/O object
24715 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24716 + * @dprtc_id: DPRTC unique ID
24717 + * @token: Returned token; use in subsequent API calls
24719 + * This function can be used to open a control session for an
24720 + * already created object; an object may have been declared in
24721 + * the DPL or by calling the dprtc_create function.
24722 + * This function returns a unique authentication token,
24723 + * associated with the specific object ID and the specific MC
24724 + * portal; this token must be used in all subsequent commands for
24725 + * this specific object
24727 + * Return: '0' on Success; Error code otherwise.
24729 +int dprtc_open(struct fsl_mc_io *mc_io,
24730 + uint32_t cmd_flags,
24732 + uint16_t *token);
24735 + * dprtc_close() - Close the control session of the object
24736 + * @mc_io: Pointer to MC portal's I/O object
24737 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24738 + * @token: Token of DPRTC object
24740 + * After this function is called, no further operations are
24741 + * allowed on the object without opening a new control session.
24743 + * Return: '0' on Success; Error code otherwise.
24745 +int dprtc_close(struct fsl_mc_io *mc_io,
24746 + uint32_t cmd_flags,
24750 + * struct dprtc_cfg - Structure representing DPRTC configuration
24751 + * @options: place holder
24753 +struct dprtc_cfg {
24754 + uint32_t options;
24758 + * dprtc_create() - Create the DPRTC object.
24759 + * @mc_io: Pointer to MC portal's I/O object
24760 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24761 + * @cfg: Configuration structure
24762 + * @token: Returned token; use in subsequent API calls
24764 + * Create the DPRTC object, allocate required resources and
24765 + * perform required initialization.
24767 + * The object can be created either by declaring it in the
24768 + * DPL file, or by calling this function.
24769 + * This function returns a unique authentication token,
24770 + * associated with the specific object ID and the specific MC
24771 + * portal; this token must be used in all subsequent calls to
24772 + * this specific object. For objects that are created using the
24773 + * DPL file, call dprtc_open function to get an authentication
24776 + * Return: '0' on Success; Error code otherwise.
24778 +int dprtc_create(struct fsl_mc_io *mc_io,
24779 + uint32_t cmd_flags,
24780 + const struct dprtc_cfg *cfg,
24781 + uint16_t *token);
24784 + * dprtc_destroy() - Destroy the DPRTC object and release all its resources.
24785 + * @mc_io: Pointer to MC portal's I/O object
24786 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24787 + * @token: Token of DPRTC object
24789 + * Return: '0' on Success; error code otherwise.
24791 +int dprtc_destroy(struct fsl_mc_io *mc_io,
24792 + uint32_t cmd_flags,
24796 + * dprtc_set_clock_offset() - Sets the clock's offset
24797 + * (usually relative to another clock).
24799 + * @mc_io: Pointer to MC portal's I/O object
24800 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24801 + * @token: Token of DPRTC object
24802 + * @offset: New clock offset (in nanoseconds).
24804 + * Return: '0' on Success; Error code otherwise.
24806 +int dprtc_set_clock_offset(struct fsl_mc_io *mc_io,
24807 + uint32_t cmd_flags,
24812 + * dprtc_set_freq_compensation() - Sets a new frequency compensation value.
24814 + * @mc_io: Pointer to MC portal's I/O object
24815 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24816 + * @token: Token of DPRTC object
24817 + * @freq_compensation:
24818 + * The new frequency compensation value to set.
24820 + * Return: '0' on Success; Error code otherwise.
24822 +int dprtc_set_freq_compensation(struct fsl_mc_io *mc_io,
24823 + uint32_t cmd_flags,
24825 + uint32_t freq_compensation);
24828 + * dprtc_get_freq_compensation() - Retrieves the frequency compensation value
24830 + * @mc_io: Pointer to MC portal's I/O object
24831 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24832 + * @token: Token of DPRTC object
24833 + * @freq_compensation:
24834 + * Frequency compensation value
24836 + * Return: '0' on Success; Error code otherwise.
24838 +int dprtc_get_freq_compensation(struct fsl_mc_io *mc_io,
24839 + uint32_t cmd_flags,
24841 + uint32_t *freq_compensation);
24844 + * dprtc_get_time() - Returns the current RTC time.
24846 + * @mc_io: Pointer to MC portal's I/O object
24847 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24848 + * @token: Token of DPRTC object
24849 + * @time: Current RTC time.
24851 + * Return: '0' on Success; Error code otherwise.
24853 +int dprtc_get_time(struct fsl_mc_io *mc_io,
24854 + uint32_t cmd_flags,
24859 + * dprtc_set_time() - Updates current RTC time.
24861 + * @mc_io: Pointer to MC portal's I/O object
24862 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24863 + * @token: Token of DPRTC object
24864 + * @time: New RTC time.
24866 + * Return: '0' on Success; Error code otherwise.
24868 +int dprtc_set_time(struct fsl_mc_io *mc_io,
24869 + uint32_t cmd_flags,
24874 + * dprtc_set_alarm() - Defines and sets alarm.
24876 + * @mc_io: Pointer to MC portal's I/O object
24877 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24878 + * @token: Token of DPRTC object
24879 + * @time: In nanoseconds, the time when the alarm
24880 + * should go off - must be a multiple of
24883 + * Return: '0' on Success; Error code otherwise.
24885 +int dprtc_set_alarm(struct fsl_mc_io *mc_io,
24886 + uint32_t cmd_flags,
24891 + * struct dprtc_irq_cfg - IRQ configuration
24892 + * @addr: Address that must be written to signal a message-based interrupt
24893 + * @val: Value to write into irq_addr address
24894 + * @irq_num: A user defined number associated with this IRQ
24896 +struct dprtc_irq_cfg {
24903 + * dprtc_set_irq() - Set IRQ information for the DPRTC to trigger an interrupt.
24904 + * @mc_io: Pointer to MC portal's I/O object
24905 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24906 + * @token: Token of DPRTC object
24907 + * @irq_index: Identifies the interrupt index to configure
24908 + * @irq_cfg: IRQ configuration
24910 + * Return: '0' on Success; Error code otherwise.
24912 +int dprtc_set_irq(struct fsl_mc_io *mc_io,
24913 + uint32_t cmd_flags,
24915 + uint8_t irq_index,
24916 + struct dprtc_irq_cfg *irq_cfg);
24919 + * dprtc_get_irq() - Get IRQ information from the DPRTC.
24920 + * @mc_io: Pointer to MC portal's I/O object
24921 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24922 + * @token: Token of DPRTC object
24923 + * @irq_index: The interrupt index to configure
24924 + * @type: Interrupt type: 0 represents message interrupt
24925 + * type (both irq_addr and irq_val are valid)
24926 + * @irq_cfg: IRQ attributes
24928 + * Return: '0' on Success; Error code otherwise.
24930 +int dprtc_get_irq(struct fsl_mc_io *mc_io,
24931 + uint32_t cmd_flags,
24933 + uint8_t irq_index,
24935 + struct dprtc_irq_cfg *irq_cfg);
24938 + * dprtc_set_irq_enable() - Set overall interrupt state.
24939 + * @mc_io: Pointer to MC portal's I/O object
24940 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24941 + * @token: Token of DPRTC object
24942 + * @irq_index: The interrupt index to configure
24943 + * @en: Interrupt state - enable = 1, disable = 0
24945 + * Allows GPP software to control when interrupts are generated.
24946 + * Each interrupt can have up to 32 causes. The enable/disable control's the
24947 + * overall interrupt state. if the interrupt is disabled no causes will cause
24950 + * Return: '0' on Success; Error code otherwise.
24952 +int dprtc_set_irq_enable(struct fsl_mc_io *mc_io,
24953 + uint32_t cmd_flags,
24955 + uint8_t irq_index,
24959 + * dprtc_get_irq_enable() - Get overall interrupt state
24960 + * @mc_io: Pointer to MC portal's I/O object
24961 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24962 + * @token: Token of DPRTC object
24963 + * @irq_index: The interrupt index to configure
24964 + * @en: Returned interrupt state - enable = 1, disable = 0
24966 + * Return: '0' on Success; Error code otherwise.
24968 +int dprtc_get_irq_enable(struct fsl_mc_io *mc_io,
24969 + uint32_t cmd_flags,
24971 + uint8_t irq_index,
24975 + * dprtc_set_irq_mask() - Set interrupt mask.
24976 + * @mc_io: Pointer to MC portal's I/O object
24977 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
24978 + * @token: Token of DPRTC object
24979 + * @irq_index: The interrupt index to configure
24980 + * @mask: Event mask to trigger interrupt;
24982 + * 0 = ignore event
24983 + * 1 = consider event for asserting IRQ
24985 + * Every interrupt can have up to 32 causes and the interrupt model supports
24986 + * masking/unmasking each cause independently
24988 + * Return: '0' on Success; Error code otherwise.
24990 +int dprtc_set_irq_mask(struct fsl_mc_io *mc_io,
24991 + uint32_t cmd_flags,
24993 + uint8_t irq_index,
24997 + * dprtc_get_irq_mask() - Get interrupt mask.
24998 + * @mc_io: Pointer to MC portal's I/O object
24999 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25000 + * @token: Token of DPRTC object
25001 + * @irq_index: The interrupt index to configure
25002 + * @mask: Returned event mask to trigger interrupt
25004 + * Every interrupt can have up to 32 causes and the interrupt model supports
25005 + * masking/unmasking each cause independently
25007 + * Return: '0' on Success; Error code otherwise.
25009 +int dprtc_get_irq_mask(struct fsl_mc_io *mc_io,
25010 + uint32_t cmd_flags,
25012 + uint8_t irq_index,
25016 + * dprtc_get_irq_status() - Get the current status of any pending interrupts.
25018 + * @mc_io: Pointer to MC portal's I/O object
25019 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25020 + * @token: Token of DPRTC object
25021 + * @irq_index: The interrupt index to configure
25022 + * @status: Returned interrupts status - one bit per cause:
25023 + * 0 = no interrupt pending
25024 + * 1 = interrupt pending
25026 + * Return: '0' on Success; Error code otherwise.
25028 +int dprtc_get_irq_status(struct fsl_mc_io *mc_io,
25029 + uint32_t cmd_flags,
25031 + uint8_t irq_index,
25032 + uint32_t *status);
25035 + * dprtc_clear_irq_status() - Clear a pending interrupt's status
25037 + * @mc_io: Pointer to MC portal's I/O object
25038 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25039 + * @token: Token of DPRTC object
25040 + * @irq_index: The interrupt index to configure
25041 + * @status: Bits to clear (W1C) - one bit per cause:
25042 + * 0 = don't change
25043 + * 1 = clear status bit
25045 + * Return: '0' on Success; Error code otherwise.
25047 +int dprtc_clear_irq_status(struct fsl_mc_io *mc_io,
25048 + uint32_t cmd_flags,
25050 + uint8_t irq_index,
25051 + uint32_t status);
25054 + * struct dprtc_attr - Structure representing DPRTC attributes
25055 + * @id: DPRTC object ID
25056 + * @version: DPRTC version
25058 +struct dprtc_attr {
25061 + * struct version - Structure representing DPRTC version
25062 + * @major: DPRTC major version
25063 + * @minor: DPRTC minor version
25072 + * dprtc_get_attributes - Retrieve DPRTC attributes.
25074 + * @mc_io: Pointer to MC portal's I/O object
25075 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25076 + * @token: Token of DPRTC object
25077 + * @attr: Returned object's attributes
25079 + * Return: '0' on Success; Error code otherwise.
25081 +int dprtc_get_attributes(struct fsl_mc_io *mc_io,
25082 + uint32_t cmd_flags,
25084 + struct dprtc_attr *attr);
25086 +#endif /* __FSL_DPRTC_H */
25087 diff --git a/drivers/net/dpaa2/mc/fsl_dprtc_cmd.h b/drivers/net/dpaa2/mc/fsl_dprtc_cmd.h
25088 new file mode 100644
25089 index 0000000..aeccece
25091 +++ b/drivers/net/dpaa2/mc/fsl_dprtc_cmd.h
25093 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
25095 + * Redistribution and use in source and binary forms, with or without
25096 + * modification, are permitted provided that the following conditions are met:
25097 + * * Redistributions of source code must retain the above copyright
25098 + * notice, this list of conditions and the following disclaimer.
25099 + * * Redistributions in binary form must reproduce the above copyright
25100 + * notice, this list of conditions and the following disclaimer in the
25101 + * documentation and/or other materials provided with the distribution.
25102 + * * Neither the name of the above-listed copyright holders nor the
25103 + * names of any contributors may be used to endorse or promote products
25104 + * derived from this software without specific prior written permission.
25107 + * ALTERNATIVELY, this software may be distributed under the terms of the
25108 + * GNU General Public License ("GPL") as published by the Free Software
25109 + * Foundation, either version 2 of that License or (at your option) any
25112 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25113 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25114 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25115 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25116 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25117 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25118 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25119 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25120 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25121 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25122 + * POSSIBILITY OF SUCH DAMAGE.
25124 +#ifndef _FSL_DPRTC_CMD_H
25125 +#define _FSL_DPRTC_CMD_H
25127 +/* DPRTC Version */
25128 +#define DPRTC_VER_MAJOR 1
25129 +#define DPRTC_VER_MINOR 0
25132 +#define DPRTC_CMDID_CLOSE 0x800
25133 +#define DPRTC_CMDID_OPEN 0x810
25134 +#define DPRTC_CMDID_CREATE 0x910
25135 +#define DPRTC_CMDID_DESTROY 0x900
25137 +#define DPRTC_CMDID_ENABLE 0x002
25138 +#define DPRTC_CMDID_DISABLE 0x003
25139 +#define DPRTC_CMDID_GET_ATTR 0x004
25140 +#define DPRTC_CMDID_RESET 0x005
25141 +#define DPRTC_CMDID_IS_ENABLED 0x006
25143 +#define DPRTC_CMDID_SET_IRQ 0x010
25144 +#define DPRTC_CMDID_GET_IRQ 0x011
25145 +#define DPRTC_CMDID_SET_IRQ_ENABLE 0x012
25146 +#define DPRTC_CMDID_GET_IRQ_ENABLE 0x013
25147 +#define DPRTC_CMDID_SET_IRQ_MASK 0x014
25148 +#define DPRTC_CMDID_GET_IRQ_MASK 0x015
25149 +#define DPRTC_CMDID_GET_IRQ_STATUS 0x016
25150 +#define DPRTC_CMDID_CLEAR_IRQ_STATUS 0x017
25152 +#define DPRTC_CMDID_SET_CLOCK_OFFSET 0x1d0
25153 +#define DPRTC_CMDID_SET_FREQ_COMPENSATION 0x1d1
25154 +#define DPRTC_CMDID_GET_FREQ_COMPENSATION 0x1d2
25155 +#define DPRTC_CMDID_GET_TIME 0x1d3
25156 +#define DPRTC_CMDID_SET_TIME 0x1d4
25157 +#define DPRTC_CMDID_SET_ALARM 0x1d5
25158 +#define DPRTC_CMDID_SET_PERIODIC_PULSE 0x1d6
25159 +#define DPRTC_CMDID_CLEAR_PERIODIC_PULSE 0x1d7
25160 +#define DPRTC_CMDID_SET_EXT_TRIGGER 0x1d8
25161 +#define DPRTC_CMDID_CLEAR_EXT_TRIGGER 0x1d9
25162 +#define DPRTC_CMDID_GET_EXT_TRIGGER_TIMESTAMP 0x1dA
25164 +/* cmd, param, offset, width, type, arg_name */
25165 +#define DPRTC_CMD_OPEN(cmd, dpbp_id) \
25166 + MC_CMD_OP(cmd, 0, 0, 32, int, dpbp_id)
25168 +/* cmd, param, offset, width, type, arg_name */
25169 +#define DPRTC_RSP_IS_ENABLED(cmd, en) \
25170 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
25172 +/* cmd, param, offset, width, type, arg_name */
25173 +#define DPRTC_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
25175 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
25176 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
25177 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
25178 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
25181 +/* cmd, param, offset, width, type, arg_name */
25182 +#define DPRTC_CMD_GET_IRQ(cmd, irq_index) \
25183 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
25185 +/* cmd, param, offset, width, type, arg_name */
25186 +#define DPRTC_RSP_GET_IRQ(cmd, type, irq_cfg) \
25188 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
25189 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr); \
25190 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
25191 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
25194 +/* cmd, param, offset, width, type, arg_name */
25195 +#define DPRTC_CMD_SET_IRQ_ENABLE(cmd, irq_index, en) \
25197 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, en); \
25198 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
25201 +/* cmd, param, offset, width, type, arg_name */
25202 +#define DPRTC_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
25203 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
25205 +/* cmd, param, offset, width, type, arg_name */
25206 +#define DPRTC_RSP_GET_IRQ_ENABLE(cmd, en) \
25207 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, en)
25209 +/* cmd, param, offset, width, type, arg_name */
25210 +#define DPRTC_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
25212 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask);\
25213 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
25216 +/* cmd, param, offset, width, type, arg_name */
25217 +#define DPRTC_CMD_GET_IRQ_MASK(cmd, irq_index) \
25218 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
25220 +/* cmd, param, offset, width, type, arg_name */
25221 +#define DPRTC_RSP_GET_IRQ_MASK(cmd, mask) \
25222 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
25224 +/* cmd, param, offset, width, type, arg_name */
25225 +#define DPRTC_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
25227 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
25228 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
25230 +/* cmd, param, offset, width, type, arg_name */
25231 +#define DPRTC_RSP_GET_IRQ_STATUS(cmd, status) \
25232 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
25234 +/* cmd, param, offset, width, type, arg_name */
25235 +#define DPRTC_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
25237 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
25238 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
25241 +/* cmd, param, offset, width, type, arg_name */
25242 +#define DPRTC_RSP_GET_ATTRIBUTES(cmd, attr) \
25244 + MC_RSP_OP(cmd, 0, 32, 32, int, attr->id);\
25245 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
25246 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
25249 +/* cmd, param, offset, width, type, arg_name */
25250 +#define DPRTC_CMD_SET_CLOCK_OFFSET(cmd, offset) \
25251 + MC_CMD_OP(cmd, 0, 0, 64, int64_t, offset)
25253 +/* cmd, param, offset, width, type, arg_name */
25254 +#define DPRTC_CMD_SET_FREQ_COMPENSATION(cmd, freq_compensation) \
25255 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, freq_compensation)
25257 +/* cmd, param, offset, width, type, arg_name */
25258 +#define DPRTC_RSP_GET_FREQ_COMPENSATION(cmd, freq_compensation) \
25259 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, freq_compensation)
25261 +/* cmd, param, offset, width, type, arg_name */
25262 +#define DPRTC_RSP_GET_TIME(cmd, time) \
25263 + MC_RSP_OP(cmd, 0, 0, 64, uint64_t, time)
25265 +/* cmd, param, offset, width, type, arg_name */
25266 +#define DPRTC_CMD_SET_TIME(cmd, time) \
25267 + MC_CMD_OP(cmd, 0, 0, 64, uint64_t, time)
25269 +/* cmd, param, offset, width, type, arg_name */
25270 +#define DPRTC_CMD_SET_ALARM(cmd, time) \
25271 + MC_CMD_OP(cmd, 0, 0, 64, uint64_t, time)
25273 +#endif /* _FSL_DPRTC_CMD_H */
25274 diff --git a/drivers/net/dpaa2/mc/fsl_dpseci.h b/drivers/net/dpaa2/mc/fsl_dpseci.h
25275 new file mode 100644
25276 index 0000000..1dd7215
25278 +++ b/drivers/net/dpaa2/mc/fsl_dpseci.h
25280 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
25282 + * Redistribution and use in source and binary forms, with or without
25283 + * modification, are permitted provided that the following conditions are met:
25284 + * * Redistributions of source code must retain the above copyright
25285 + * notice, this list of conditions and the following disclaimer.
25286 + * * Redistributions in binary form must reproduce the above copyright
25287 + * notice, this list of conditions and the following disclaimer in the
25288 + * documentation and/or other materials provided with the distribution.
25289 + * * Neither the name of the above-listed copyright holders nor the
25290 + * names of any contributors may be used to endorse or promote products
25291 + * derived from this software without specific prior written permission.
25294 + * ALTERNATIVELY, this software may be distributed under the terms of the
25295 + * GNU General Public License ("GPL") as published by the Free Software
25296 + * Foundation, either version 2 of that License or (at your option) any
25299 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25300 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25301 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25302 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25303 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25304 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25305 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25306 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25307 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25308 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25309 + * POSSIBILITY OF SUCH DAMAGE.
25311 +#ifndef __FSL_DPSECI_H
25312 +#define __FSL_DPSECI_H
25314 +/* Data Path SEC Interface API
25315 + * Contains initialization APIs and runtime control APIs for DPSECI
25321 + * General DPSECI macros
25325 + * Maximum number of Tx/Rx priorities per DPSECI object
25327 +#define DPSECI_PRIO_NUM 8
25330 + * All queues considered; see dpseci_set_rx_queue()
25332 +#define DPSECI_ALL_QUEUES (uint8_t)(-1)
25335 + * dpseci_open() - Open a control session for the specified object
25336 + * @mc_io: Pointer to MC portal's I/O object
25337 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25338 + * @dpseci_id: DPSECI unique ID
25339 + * @token: Returned token; use in subsequent API calls
25341 + * This function can be used to open a control session for an
25342 + * already created object; an object may have been declared in
25343 + * the DPL or by calling the dpseci_create() function.
25344 + * This function returns a unique authentication token,
25345 + * associated with the specific object ID and the specific MC
25346 + * portal; this token must be used in all subsequent commands for
25347 + * this specific object.
25349 + * Return: '0' on Success; Error code otherwise.
25351 +int dpseci_open(struct fsl_mc_io *mc_io,
25352 + uint32_t cmd_flags,
25354 + uint16_t *token);
25357 + * dpseci_close() - Close the control session of the object
25358 + * @mc_io: Pointer to MC portal's I/O object
25359 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25360 + * @token: Token of DPSECI object
25362 + * After this function is called, no further operations are
25363 + * allowed on the object without opening a new control session.
25365 + * Return: '0' on Success; Error code otherwise.
25367 +int dpseci_close(struct fsl_mc_io *mc_io,
25368 + uint32_t cmd_flags,
25372 + * struct dpseci_cfg - Structure representing DPSECI configuration
25373 + * @num_tx_queues: num of queues towards the SEC
25374 + * @num_rx_queues: num of queues back from the SEC
25375 + * @priorities: Priorities for the SEC hardware processing;
25376 + * each place in the array is the priority of the tx queue
25377 + * towards the SEC,
25378 + * valid priorities are configured with values 1-8;
25380 +struct dpseci_cfg {
25381 + uint8_t num_tx_queues;
25382 + uint8_t num_rx_queues;
25383 + uint8_t priorities[DPSECI_PRIO_NUM];
25387 + * dpseci_create() - Create the DPSECI object
25388 + * @mc_io: Pointer to MC portal's I/O object
25389 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25390 + * @cfg: Configuration structure
25391 + * @token: Returned token; use in subsequent API calls
25393 + * Create the DPSECI object, allocate required resources and
25394 + * perform required initialization.
25396 + * The object can be created either by declaring it in the
25397 + * DPL file, or by calling this function.
25399 + * This function returns a unique authentication token,
25400 + * associated with the specific object ID and the specific MC
25401 + * portal; this token must be used in all subsequent calls to
25402 + * this specific object. For objects that are created using the
25403 + * DPL file, call dpseci_open() function to get an authentication
25406 + * Return: '0' on Success; Error code otherwise.
25408 +int dpseci_create(struct fsl_mc_io *mc_io,
25409 + uint32_t cmd_flags,
25410 + const struct dpseci_cfg *cfg,
25411 + uint16_t *token);
25414 + * dpseci_destroy() - Destroy the DPSECI object and release all its resources.
25415 + * @mc_io: Pointer to MC portal's I/O object
25416 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25417 + * @token: Token of DPSECI object
25419 + * Return: '0' on Success; error code otherwise.
25421 +int dpseci_destroy(struct fsl_mc_io *mc_io,
25422 + uint32_t cmd_flags,
25426 + * dpseci_enable() - Enable the DPSECI, allow sending and receiving frames.
25427 + * @mc_io: Pointer to MC portal's I/O object
25428 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25429 + * @token: Token of DPSECI object
25431 + * Return: '0' on Success; Error code otherwise.
25433 +int dpseci_enable(struct fsl_mc_io *mc_io,
25434 + uint32_t cmd_flags,
25438 + * dpseci_disable() - Disable the DPSECI, stop sending and receiving frames.
25439 + * @mc_io: Pointer to MC portal's I/O object
25440 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25441 + * @token: Token of DPSECI object
25443 + * Return: '0' on Success; Error code otherwise.
25445 +int dpseci_disable(struct fsl_mc_io *mc_io,
25446 + uint32_t cmd_flags,
25450 + * dpseci_is_enabled() - Check if the DPSECI is enabled.
25451 + * @mc_io: Pointer to MC portal's I/O object
25452 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25453 + * @token: Token of DPSECI object
25454 + * @en: Returns '1' if object is enabled; '0' otherwise
25456 + * Return: '0' on Success; Error code otherwise.
25458 +int dpseci_is_enabled(struct fsl_mc_io *mc_io,
25459 + uint32_t cmd_flags,
25464 + * dpseci_reset() - Reset the DPSECI, returns the object to initial state.
25465 + * @mc_io: Pointer to MC portal's I/O object
25466 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25467 + * @token: Token of DPSECI object
25469 + * Return: '0' on Success; Error code otherwise.
25471 +int dpseci_reset(struct fsl_mc_io *mc_io,
25472 + uint32_t cmd_flags,
25476 + * struct dpseci_irq_cfg - IRQ configuration
25477 + * @addr: Address that must be written to signal a message-based interrupt
25478 + * @val: Value to write into irq_addr address
25479 + * @irq_num: A user defined number associated with this IRQ
25481 +struct dpseci_irq_cfg {
25488 + * dpseci_set_irq() - Set IRQ information for the DPSECI to trigger an interrupt
25489 + * @mc_io: Pointer to MC portal's I/O object
25490 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25491 + * @token: Token of DPSECI object
25492 + * @irq_index: Identifies the interrupt index to configure
25493 + * @irq_cfg: IRQ configuration
25495 + * Return: '0' on Success; Error code otherwise.
25497 +int dpseci_set_irq(struct fsl_mc_io *mc_io,
25498 + uint32_t cmd_flags,
25500 + uint8_t irq_index,
25501 + struct dpseci_irq_cfg *irq_cfg);
25504 + * dpseci_get_irq() - Get IRQ information from the DPSECI
25506 + * @mc_io: Pointer to MC portal's I/O object
25507 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25508 + * @token: Token of DPSECI object
25509 + * @irq_index: The interrupt index to configure
25510 + * @type: Interrupt type: 0 represents message interrupt
25511 + * type (both irq_addr and irq_val are valid)
25512 + * @irq_cfg: IRQ attributes
25514 + * Return: '0' on Success; Error code otherwise.
25516 +int dpseci_get_irq(struct fsl_mc_io *mc_io,
25517 + uint32_t cmd_flags,
25519 + uint8_t irq_index,
25521 + struct dpseci_irq_cfg *irq_cfg);
25524 + * dpseci_set_irq_enable() - Set overall interrupt state.
25525 + * @mc_io: Pointer to MC portal's I/O object
25526 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25527 + * @token: Token of DPSECI object
25528 + * @irq_index: The interrupt index to configure
25529 + * @en: Interrupt state - enable = 1, disable = 0
25531 + * Allows GPP software to control when interrupts are generated.
25532 + * Each interrupt can have up to 32 causes. The enable/disable control's the
25533 + * overall interrupt state. if the interrupt is disabled no causes will cause
25536 + * Return: '0' on Success; Error code otherwise.
25538 +int dpseci_set_irq_enable(struct fsl_mc_io *mc_io,
25539 + uint32_t cmd_flags,
25541 + uint8_t irq_index,
25545 + * dpseci_get_irq_enable() - Get overall interrupt state
25546 + * @mc_io: Pointer to MC portal's I/O object
25547 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25548 + * @token: Token of DPSECI object
25549 + * @irq_index: The interrupt index to configure
25550 + * @en: Returned Interrupt state - enable = 1, disable = 0
25552 + * Return: '0' on Success; Error code otherwise.
25554 +int dpseci_get_irq_enable(struct fsl_mc_io *mc_io,
25555 + uint32_t cmd_flags,
25557 + uint8_t irq_index,
25561 + * dpseci_set_irq_mask() - Set interrupt mask.
25562 + * @mc_io: Pointer to MC portal's I/O object
25563 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25564 + * @token: Token of DPSECI object
25565 + * @irq_index: The interrupt index to configure
25566 + * @mask: event mask to trigger interrupt;
25568 + * 0 = ignore event
25569 + * 1 = consider event for asserting IRQ
25571 + * Every interrupt can have up to 32 causes and the interrupt model supports
25572 + * masking/unmasking each cause independently
25574 + * Return: '0' on Success; Error code otherwise.
25576 +int dpseci_set_irq_mask(struct fsl_mc_io *mc_io,
25577 + uint32_t cmd_flags,
25579 + uint8_t irq_index,
25583 + * dpseci_get_irq_mask() - Get interrupt mask.
25584 + * @mc_io: Pointer to MC portal's I/O object
25585 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25586 + * @token: Token of DPSECI object
25587 + * @irq_index: The interrupt index to configure
25588 + * @mask: Returned event mask to trigger interrupt
25590 + * Every interrupt can have up to 32 causes and the interrupt model supports
25591 + * masking/unmasking each cause independently
25593 + * Return: '0' on Success; Error code otherwise.
25595 +int dpseci_get_irq_mask(struct fsl_mc_io *mc_io,
25596 + uint32_t cmd_flags,
25598 + uint8_t irq_index,
25602 + * dpseci_get_irq_status() - Get the current status of any pending interrupts
25603 + * @mc_io: Pointer to MC portal's I/O object
25604 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25605 + * @token: Token of DPSECI object
25606 + * @irq_index: The interrupt index to configure
25607 + * @status: Returned interrupts status - one bit per cause:
25608 + * 0 = no interrupt pending
25609 + * 1 = interrupt pending
25611 + * Return: '0' on Success; Error code otherwise.
25613 +int dpseci_get_irq_status(struct fsl_mc_io *mc_io,
25614 + uint32_t cmd_flags,
25616 + uint8_t irq_index,
25617 + uint32_t *status);
25620 + * dpseci_clear_irq_status() - Clear a pending interrupt's status
25621 + * @mc_io: Pointer to MC portal's I/O object
25622 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25623 + * @token: Token of DPSECI object
25624 + * @irq_index: The interrupt index to configure
25625 + * @status: bits to clear (W1C) - one bit per cause:
25626 + * 0 = don't change
25627 + * 1 = clear status bit
25629 + * Return: '0' on Success; Error code otherwise.
25631 +int dpseci_clear_irq_status(struct fsl_mc_io *mc_io,
25632 + uint32_t cmd_flags,
25634 + uint8_t irq_index,
25635 + uint32_t status);
25638 + * struct dpseci_attr - Structure representing DPSECI attributes
25639 + * @id: DPSECI object ID
25640 + * @version: DPSECI version
25641 + * @num_tx_queues: number of queues towards the SEC
25642 + * @num_rx_queues: number of queues back from the SEC
25644 +struct dpseci_attr {
25647 + * struct version - DPSECI version
25648 + * @major: DPSECI major version
25649 + * @minor: DPSECI minor version
25655 + uint8_t num_tx_queues;
25656 + uint8_t num_rx_queues;
25660 + * dpseci_get_attributes() - Retrieve DPSECI attributes.
25661 + * @mc_io: Pointer to MC portal's I/O object
25662 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25663 + * @token: Token of DPSECI object
25664 + * @attr: Returned object's attributes
25666 + * Return: '0' on Success; Error code otherwise.
25668 +int dpseci_get_attributes(struct fsl_mc_io *mc_io,
25669 + uint32_t cmd_flags,
25671 + struct dpseci_attr *attr);
25674 + * enum dpseci_dest - DPSECI destination types
25675 + * @DPSECI_DEST_NONE: Unassigned destination; The queue is set in parked mode
25676 + * and does not generate FQDAN notifications; user is expected to
25677 + * dequeue from the queue based on polling or other user-defined
25679 + * @DPSECI_DEST_DPIO: The queue is set in schedule mode and generates FQDAN
25680 + * notifications to the specified DPIO; user is expected to dequeue
25681 + * from the queue only after notification is received
25682 + * @DPSECI_DEST_DPCON: The queue is set in schedule mode and does not generate
25683 + * FQDAN notifications, but is connected to the specified DPCON
25684 + * object; user is expected to dequeue from the DPCON channel
25686 +enum dpseci_dest {
25687 + DPSECI_DEST_NONE = 0,
25688 + DPSECI_DEST_DPIO = 1,
25689 + DPSECI_DEST_DPCON = 2
25693 + * struct dpseci_dest_cfg - Structure representing DPSECI destination parameters
25694 + * @dest_type: Destination type
25695 + * @dest_id: Either DPIO ID or DPCON ID, depending on the destination type
25696 + * @priority: Priority selection within the DPIO or DPCON channel; valid values
25697 + * are 0-1 or 0-7, depending on the number of priorities in that
25698 + * channel; not relevant for 'DPSECI_DEST_NONE' option
25700 +struct dpseci_dest_cfg {
25701 + enum dpseci_dest dest_type;
25703 + uint8_t priority;
25707 + * DPSECI queue modification options
25711 + * Select to modify the user's context associated with the queue
25713 +#define DPSECI_QUEUE_OPT_USER_CTX 0x00000001
25716 + * Select to modify the queue's destination
25718 +#define DPSECI_QUEUE_OPT_DEST 0x00000002
25721 + * Select to modify the queue's order preservation
25723 +#define DPSECI_QUEUE_OPT_ORDER_PRESERVATION 0x00000004
25726 + * struct dpseci_rx_queue_cfg - DPSECI RX queue configuration
25727 + * @options: Flags representing the suggested modifications to the queue;
25728 + * Use any combination of 'DPSECI_QUEUE_OPT_<X>' flags
25729 + * @order_preservation_en: order preservation configuration for the rx queue
25730 + * valid only if 'DPSECI_QUEUE_OPT_ORDER_PRESERVATION' is contained in 'options'
25731 + * @user_ctx: User context value provided in the frame descriptor of each
25732 + * dequeued frame;
25733 + * valid only if 'DPSECI_QUEUE_OPT_USER_CTX' is contained in 'options'
25734 + * @dest_cfg: Queue destination parameters;
25735 + * valid only if 'DPSECI_QUEUE_OPT_DEST' is contained in 'options'
25737 +struct dpseci_rx_queue_cfg {
25738 + uint32_t options;
25739 + int order_preservation_en;
25740 + uint64_t user_ctx;
25741 + struct dpseci_dest_cfg dest_cfg;
25745 + * dpseci_set_rx_queue() - Set Rx queue configuration
25746 + * @mc_io: Pointer to MC portal's I/O object
25747 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25748 + * @token: Token of DPSECI object
25749 + * @queue: Select the queue relative to number of
25750 + * priorities configured at DPSECI creation; use
25751 + * DPSECI_ALL_QUEUES to configure all Rx queues identically.
25752 + * @cfg: Rx queue configuration
25754 + * Return: '0' on Success; Error code otherwise.
25756 +int dpseci_set_rx_queue(struct fsl_mc_io *mc_io,
25757 + uint32_t cmd_flags,
25760 + const struct dpseci_rx_queue_cfg *cfg);
25763 + * struct dpseci_rx_queue_attr - Structure representing attributes of Rx queues
25764 + * @user_ctx: User context value provided in the frame descriptor of each
25766 + * @order_preservation_en: Status of the order preservation configuration
25768 + * @dest_cfg: Queue destination configuration
25769 + * @fqid: Virtual FQID value to be used for dequeue operations
25771 +struct dpseci_rx_queue_attr {
25772 + uint64_t user_ctx;
25773 + int order_preservation_en;
25774 + struct dpseci_dest_cfg dest_cfg;
25779 + * dpseci_get_rx_queue() - Retrieve Rx queue attributes.
25780 + * @mc_io: Pointer to MC portal's I/O object
25781 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25782 + * @token: Token of DPSECI object
25783 + * @queue: Select the queue relative to number of
25784 + * priorities configured at DPSECI creation
25785 + * @attr: Returned Rx queue attributes
25787 + * Return: '0' on Success; Error code otherwise.
25789 +int dpseci_get_rx_queue(struct fsl_mc_io *mc_io,
25790 + uint32_t cmd_flags,
25793 + struct dpseci_rx_queue_attr *attr);
25796 + * struct dpseci_tx_queue_attr - Structure representing attributes of Tx queues
25797 + * @fqid: Virtual FQID to be used for sending frames to SEC hardware
25798 + * @priority: SEC hardware processing priority for the queue
25800 +struct dpseci_tx_queue_attr {
25802 + uint8_t priority;
25806 + * dpseci_get_tx_queue() - Retrieve Tx queue attributes.
25807 + * @mc_io: Pointer to MC portal's I/O object
25808 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25809 + * @token: Token of DPSECI object
25810 + * @queue: Select the queue relative to number of
25811 + * priorities configured at DPSECI creation
25812 + * @attr: Returned Tx queue attributes
25814 + * Return: '0' on Success; Error code otherwise.
25816 +int dpseci_get_tx_queue(struct fsl_mc_io *mc_io,
25817 + uint32_t cmd_flags,
25820 + struct dpseci_tx_queue_attr *attr);
25823 + * struct dpseci_sec_attr - Structure representing attributes of the SEC
25824 + * hardware accelerator
25825 + * @ip_id: ID for SEC.
25826 + * @major_rev: Major revision number for SEC.
25827 + * @minor_rev: Minor revision number for SEC.
25829 + * @deco_num: The number of copies of the DECO that are implemented in
25830 + * this version of SEC.
25831 + * @zuc_auth_acc_num: The number of copies of ZUCA that are implemented
25832 + * in this version of SEC.
25833 + * @zuc_enc_acc_num: The number of copies of ZUCE that are implemented
25834 + * in this version of SEC.
25835 + * @snow_f8_acc_num: The number of copies of the SNOW-f8 module that are
25836 + * implemented in this version of SEC.
25837 + * @snow_f9_acc_num: The number of copies of the SNOW-f9 module that are
25838 + * implemented in this version of SEC.
25839 + * @crc_acc_num: The number of copies of the CRC module that are implemented
25840 + * in this version of SEC.
25841 + * @pk_acc_num: The number of copies of the Public Key module that are
25842 + * implemented in this version of SEC.
25843 + * @kasumi_acc_num: The number of copies of the Kasumi module that are
25844 + * implemented in this version of SEC.
25845 + * @rng_acc_num: The number of copies of the Random Number Generator that are
25846 + * implemented in this version of SEC.
25847 + * @md_acc_num: The number of copies of the MDHA (Hashing module) that are
25848 + * implemented in this version of SEC.
25849 + * @arc4_acc_num: The number of copies of the ARC4 module that are implemented
25850 + * in this version of SEC.
25851 + * @des_acc_num: The number of copies of the DES module that are implemented
25852 + * in this version of SEC.
25853 + * @aes_acc_num: The number of copies of the AES module that are implemented
25854 + * in this version of SEC.
25857 +struct dpseci_sec_attr {
25859 + uint8_t major_rev;
25860 + uint8_t minor_rev;
25862 + uint8_t deco_num;
25863 + uint8_t zuc_auth_acc_num;
25864 + uint8_t zuc_enc_acc_num;
25865 + uint8_t snow_f8_acc_num;
25866 + uint8_t snow_f9_acc_num;
25867 + uint8_t crc_acc_num;
25868 + uint8_t pk_acc_num;
25869 + uint8_t kasumi_acc_num;
25870 + uint8_t rng_acc_num;
25871 + uint8_t md_acc_num;
25872 + uint8_t arc4_acc_num;
25873 + uint8_t des_acc_num;
25874 + uint8_t aes_acc_num;
25878 + * dpseci_get_sec_attr() - Retrieve SEC accelerator attributes.
25879 + * @mc_io: Pointer to MC portal's I/O object
25880 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25881 + * @token: Token of DPSECI object
25882 + * @attr: Returned SEC attributes
25884 + * Return: '0' on Success; Error code otherwise.
25886 +int dpseci_get_sec_attr(struct fsl_mc_io *mc_io,
25887 + uint32_t cmd_flags,
25889 + struct dpseci_sec_attr *attr);
25892 + * struct dpseci_sec_counters - Structure representing global SEC counters and
25893 + * not per dpseci counters
25894 + * @dequeued_requests: Number of Requests Dequeued
25895 + * @ob_enc_requests: Number of Outbound Encrypt Requests
25896 + * @ib_dec_requests: Number of Inbound Decrypt Requests
25897 + * @ob_enc_bytes: Number of Outbound Bytes Encrypted
25898 + * @ob_prot_bytes: Number of Outbound Bytes Protected
25899 + * @ib_dec_bytes: Number of Inbound Bytes Decrypted
25900 + * @ib_valid_bytes: Number of Inbound Bytes Validated
25902 +struct dpseci_sec_counters {
25903 + uint64_t dequeued_requests;
25904 + uint64_t ob_enc_requests;
25905 + uint64_t ib_dec_requests;
25906 + uint64_t ob_enc_bytes;
25907 + uint64_t ob_prot_bytes;
25908 + uint64_t ib_dec_bytes;
25909 + uint64_t ib_valid_bytes;
25913 + * dpseci_get_sec_counters() - Retrieve SEC accelerator counters.
25914 + * @mc_io: Pointer to MC portal's I/O object
25915 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
25916 + * @token: Token of DPSECI object
25917 + * @counters: Returned SEC counters
25919 + * Return: '0' on Success; Error code otherwise.
25921 +int dpseci_get_sec_counters(struct fsl_mc_io *mc_io,
25922 + uint32_t cmd_flags,
25924 + struct dpseci_sec_counters *counters);
25926 +#endif /* __FSL_DPSECI_H */
25927 diff --git a/drivers/net/dpaa2/mc/fsl_dpseci_cmd.h b/drivers/net/dpaa2/mc/fsl_dpseci_cmd.h
25928 new file mode 100644
25929 index 0000000..6c0b96e
25931 +++ b/drivers/net/dpaa2/mc/fsl_dpseci_cmd.h
25933 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
25935 + * Redistribution and use in source and binary forms, with or without
25936 + * modification, are permitted provided that the following conditions are met:
25937 + * * Redistributions of source code must retain the above copyright
25938 + * notice, this list of conditions and the following disclaimer.
25939 + * * Redistributions in binary form must reproduce the above copyright
25940 + * notice, this list of conditions and the following disclaimer in the
25941 + * documentation and/or other materials provided with the distribution.
25942 + * * Neither the name of the above-listed copyright holders nor the
25943 + * names of any contributors may be used to endorse or promote products
25944 + * derived from this software without specific prior written permission.
25947 + * ALTERNATIVELY, this software may be distributed under the terms of the
25948 + * GNU General Public License ("GPL") as published by the Free Software
25949 + * Foundation, either version 2 of that License or (at your option) any
25952 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25953 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25954 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25955 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
25956 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25957 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25958 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25959 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25960 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25961 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25962 + * POSSIBILITY OF SUCH DAMAGE.
25964 +#ifndef _FSL_DPSECI_CMD_H
25965 +#define _FSL_DPSECI_CMD_H
25967 +/* DPSECI Version */
25968 +#define DPSECI_VER_MAJOR 3
25969 +#define DPSECI_VER_MINOR 1
25972 +#define DPSECI_CMDID_CLOSE 0x800
25973 +#define DPSECI_CMDID_OPEN 0x809
25974 +#define DPSECI_CMDID_CREATE 0x909
25975 +#define DPSECI_CMDID_DESTROY 0x900
25977 +#define DPSECI_CMDID_ENABLE 0x002
25978 +#define DPSECI_CMDID_DISABLE 0x003
25979 +#define DPSECI_CMDID_GET_ATTR 0x004
25980 +#define DPSECI_CMDID_RESET 0x005
25981 +#define DPSECI_CMDID_IS_ENABLED 0x006
25983 +#define DPSECI_CMDID_SET_IRQ 0x010
25984 +#define DPSECI_CMDID_GET_IRQ 0x011
25985 +#define DPSECI_CMDID_SET_IRQ_ENABLE 0x012
25986 +#define DPSECI_CMDID_GET_IRQ_ENABLE 0x013
25987 +#define DPSECI_CMDID_SET_IRQ_MASK 0x014
25988 +#define DPSECI_CMDID_GET_IRQ_MASK 0x015
25989 +#define DPSECI_CMDID_GET_IRQ_STATUS 0x016
25990 +#define DPSECI_CMDID_CLEAR_IRQ_STATUS 0x017
25992 +#define DPSECI_CMDID_SET_RX_QUEUE 0x194
25993 +#define DPSECI_CMDID_GET_RX_QUEUE 0x196
25994 +#define DPSECI_CMDID_GET_TX_QUEUE 0x197
25995 +#define DPSECI_CMDID_GET_SEC_ATTR 0x198
25996 +#define DPSECI_CMDID_GET_SEC_COUNTERS 0x199
25998 +/* cmd, param, offset, width, type, arg_name */
25999 +#define DPSECI_CMD_OPEN(cmd, dpseci_id) \
26000 + MC_CMD_OP(cmd, 0, 0, 32, int, dpseci_id)
26002 +/* cmd, param, offset, width, type, arg_name */
26003 +#define DPSECI_CMD_CREATE(cmd, cfg) \
26005 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->priorities[0]);\
26006 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, cfg->priorities[1]);\
26007 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->priorities[2]);\
26008 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->priorities[3]);\
26009 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->priorities[4]);\
26010 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->priorities[5]);\
26011 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->priorities[6]);\
26012 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->priorities[7]);\
26013 + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->num_tx_queues);\
26014 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->num_rx_queues);\
26017 +/* cmd, param, offset, width, type, arg_name */
26018 +#define DPSECI_RSP_IS_ENABLED(cmd, en) \
26019 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
26021 +/* cmd, param, offset, width, type, arg_name */
26022 +#define DPSECI_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
26024 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
26025 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
26026 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
26027 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
26030 +/* cmd, param, offset, width, type, arg_name */
26031 +#define DPSECI_CMD_GET_IRQ(cmd, irq_index) \
26032 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
26034 +/* cmd, param, offset, width, type, arg_name */
26035 +#define DPSECI_RSP_GET_IRQ(cmd, type, irq_cfg) \
26037 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
26038 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
26039 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
26040 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
26043 +/* cmd, param, offset, width, type, arg_name */
26044 +#define DPSECI_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \
26046 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \
26047 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
26050 +/* cmd, param, offset, width, type, arg_name */
26051 +#define DPSECI_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
26052 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
26054 +/* cmd, param, offset, width, type, arg_name */
26055 +#define DPSECI_RSP_GET_IRQ_ENABLE(cmd, enable_state) \
26056 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state)
26058 +/* cmd, param, offset, width, type, arg_name */
26059 +#define DPSECI_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
26061 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
26062 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
26065 +/* cmd, param, offset, width, type, arg_name */
26066 +#define DPSECI_CMD_GET_IRQ_MASK(cmd, irq_index) \
26067 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
26069 +/* cmd, param, offset, width, type, arg_name */
26070 +#define DPSECI_RSP_GET_IRQ_MASK(cmd, mask) \
26071 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
26073 +/* cmd, param, offset, width, type, arg_name */
26074 +#define DPSECI_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
26076 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
26077 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
26080 +/* cmd, param, offset, width, type, arg_name */
26081 +#define DPSECI_RSP_GET_IRQ_STATUS(cmd, status) \
26082 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
26084 +/* cmd, param, offset, width, type, arg_name */
26085 +#define DPSECI_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
26087 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
26088 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index); \
26091 +/* cmd, param, offset, width, type, arg_name */
26092 +#define DPSECI_RSP_GET_ATTR(cmd, attr) \
26094 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->id); \
26095 + MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->num_tx_queues); \
26096 + MC_RSP_OP(cmd, 1, 8, 8, uint8_t, attr->num_rx_queues); \
26097 + MC_RSP_OP(cmd, 5, 0, 16, uint16_t, attr->version.major);\
26098 + MC_RSP_OP(cmd, 5, 16, 16, uint16_t, attr->version.minor);\
26101 +/* cmd, param, offset, width, type, arg_name */
26102 +#define DPSECI_CMD_SET_RX_QUEUE(cmd, queue, cfg) \
26104 + MC_CMD_OP(cmd, 0, 0, 32, int, cfg->dest_cfg.dest_id); \
26105 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->dest_cfg.priority); \
26106 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue); \
26107 + MC_CMD_OP(cmd, 0, 48, 4, enum dpseci_dest, cfg->dest_cfg.dest_type); \
26108 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, cfg->user_ctx); \
26109 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->options);\
26110 + MC_CMD_OP(cmd, 2, 32, 1, int, cfg->order_preservation_en);\
26113 +/* cmd, param, offset, width, type, arg_name */
26114 +#define DPSECI_CMD_GET_RX_QUEUE(cmd, queue) \
26115 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue)
26117 +/* cmd, param, offset, width, type, arg_name */
26118 +#define DPSECI_RSP_GET_RX_QUEUE(cmd, attr) \
26120 + MC_RSP_OP(cmd, 0, 0, 32, int, attr->dest_cfg.dest_id);\
26121 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->dest_cfg.priority);\
26122 + MC_RSP_OP(cmd, 0, 48, 4, enum dpseci_dest, attr->dest_cfg.dest_type);\
26123 + MC_RSP_OP(cmd, 1, 0, 8, uint64_t, attr->user_ctx);\
26124 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->fqid);\
26125 + MC_RSP_OP(cmd, 2, 32, 1, int, attr->order_preservation_en);\
26128 +/* cmd, param, offset, width, type, arg_name */
26129 +#define DPSECI_CMD_GET_TX_QUEUE(cmd, queue) \
26130 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, queue)
26132 +/* cmd, param, offset, width, type, arg_name */
26133 +#define DPSECI_RSP_GET_TX_QUEUE(cmd, attr) \
26135 + MC_RSP_OP(cmd, 0, 32, 32, uint32_t, attr->fqid);\
26136 + MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->priority);\
26139 +/* cmd, param, offset, width, type, arg_name */
26140 +#define DPSECI_RSP_GET_SEC_ATTR(cmd, attr) \
26142 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, attr->ip_id);\
26143 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->major_rev);\
26144 + MC_RSP_OP(cmd, 0, 24, 8, uint8_t, attr->minor_rev);\
26145 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, attr->era);\
26146 + MC_RSP_OP(cmd, 1, 0, 8, uint8_t, attr->deco_num);\
26147 + MC_RSP_OP(cmd, 1, 8, 8, uint8_t, attr->zuc_auth_acc_num);\
26148 + MC_RSP_OP(cmd, 1, 16, 8, uint8_t, attr->zuc_enc_acc_num);\
26149 + MC_RSP_OP(cmd, 1, 32, 8, uint8_t, attr->snow_f8_acc_num);\
26150 + MC_RSP_OP(cmd, 1, 40, 8, uint8_t, attr->snow_f9_acc_num);\
26151 + MC_RSP_OP(cmd, 1, 48, 8, uint8_t, attr->crc_acc_num);\
26152 + MC_RSP_OP(cmd, 2, 0, 8, uint8_t, attr->pk_acc_num);\
26153 + MC_RSP_OP(cmd, 2, 8, 8, uint8_t, attr->kasumi_acc_num);\
26154 + MC_RSP_OP(cmd, 2, 16, 8, uint8_t, attr->rng_acc_num);\
26155 + MC_RSP_OP(cmd, 2, 32, 8, uint8_t, attr->md_acc_num);\
26156 + MC_RSP_OP(cmd, 2, 40, 8, uint8_t, attr->arc4_acc_num);\
26157 + MC_RSP_OP(cmd, 2, 48, 8, uint8_t, attr->des_acc_num);\
26158 + MC_RSP_OP(cmd, 2, 56, 8, uint8_t, attr->aes_acc_num);\
26161 +/* cmd, param, offset, width, type, arg_name */
26162 +#define DPSECI_RSP_GET_SEC_COUNTERS(cmd, counters) \
26164 + MC_RSP_OP(cmd, 0, 0, 64, uint64_t, counters->dequeued_requests);\
26165 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counters->ob_enc_requests);\
26166 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, counters->ib_dec_requests);\
26167 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, counters->ob_enc_bytes);\
26168 + MC_RSP_OP(cmd, 4, 0, 64, uint64_t, counters->ob_prot_bytes);\
26169 + MC_RSP_OP(cmd, 5, 0, 64, uint64_t, counters->ib_dec_bytes);\
26170 + MC_RSP_OP(cmd, 6, 0, 64, uint64_t, counters->ib_valid_bytes);\
26173 +#endif /* _FSL_DPSECI_CMD_H */
26174 diff --git a/drivers/net/dpaa2/mc/fsl_dpsw.h b/drivers/net/dpaa2/mc/fsl_dpsw.h
26175 new file mode 100644
26176 index 0000000..9c1bd9d
26178 +++ b/drivers/net/dpaa2/mc/fsl_dpsw.h
26180 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
26182 + * Redistribution and use in source and binary forms, with or without
26183 + * modification, are permitted provided that the following conditions are met:
26184 + * * Redistributions of source code must retain the above copyright
26185 + * notice, this list of conditions and the following disclaimer.
26186 + * * Redistributions in binary form must reproduce the above copyright
26187 + * notice, this list of conditions and the following disclaimer in the
26188 + * documentation and/or other materials provided with the distribution.
26189 + * * Neither the name of the above-listed copyright holders nor the
26190 + * names of any contributors may be used to endorse or promote products
26191 + * derived from this software without specific prior written permission.
26194 + * ALTERNATIVELY, this software may be distributed under the terms of the
26195 + * GNU General Public License ("GPL") as published by the Free Software
26196 + * Foundation, either version 2 of that License or (at your option) any
26199 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26200 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26201 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26202 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
26203 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26204 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26205 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26206 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26207 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26208 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26209 + * POSSIBILITY OF SUCH DAMAGE.
26211 +#ifndef __FSL_DPSW_H
26212 +#define __FSL_DPSW_H
26214 +#include <fsl_net.h>
26216 +/* Data Path L2-Switch API
26217 + * Contains API for handling DPSW topology and functionality
26223 + * DPSW general definitions
26227 + * Maximum number of traffic class priorities
26229 +#define DPSW_MAX_PRIORITIES 8
26231 + * Maximum number of interfaces
26233 +#define DPSW_MAX_IF 64
26236 + * dpsw_open() - Open a control session for the specified object
26237 + * @mc_io: Pointer to MC portal's I/O object
26238 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26239 + * @dpsw_id: DPSW unique ID
26240 + * @token: Returned token; use in subsequent API calls
26242 + * This function can be used to open a control session for an
26243 + * already created object; an object may have been declared in
26244 + * the DPL or by calling the dpsw_create() function.
26245 + * This function returns a unique authentication token,
26246 + * associated with the specific object ID and the specific MC
26247 + * portal; this token must be used in all subsequent commands for
26248 + * this specific object
26250 + * Return: '0' on Success; Error code otherwise.
26252 +int dpsw_open(struct fsl_mc_io *mc_io,
26253 + uint32_t cmd_flags,
26255 + uint16_t *token);
26258 + * dpsw_close() - Close the control session of the object
26259 + * @mc_io: Pointer to MC portal's I/O object
26260 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26261 + * @token: Token of DPSW object
26263 + * After this function is called, no further operations are
26264 + * allowed on the object without opening a new control session.
26266 + * Return: '0' on Success; Error code otherwise.
26268 +int dpsw_close(struct fsl_mc_io *mc_io,
26269 + uint32_t cmd_flags,
26277 + * Disable flooding
26279 +#define DPSW_OPT_FLOODING_DIS 0x0000000000000001ULL
26281 + * Disable Multicast
26283 +#define DPSW_OPT_MULTICAST_DIS 0x0000000000000004ULL
26285 + * Support control interface
26287 +#define DPSW_OPT_CTRL_IF_DIS 0x0000000000000010ULL
26289 + * Disable flooding metering
26291 +#define DPSW_OPT_FLOODING_METERING_DIS 0x0000000000000020ULL
26293 + * Enable metering
26295 +#define DPSW_OPT_METERING_EN 0x0000000000000040ULL
26298 + * enum dpsw_component_type - component type of a bridge
26299 + * @DPSW_COMPONENT_TYPE_C_VLAN: A C-VLAN component of an
26300 + * enterprise VLAN bridge or of a Provider Bridge used
26301 + * to process C-tagged frames
26302 + * @DPSW_COMPONENT_TYPE_S_VLAN: An S-VLAN component of a
26303 + * Provider Bridge
26306 +enum dpsw_component_type {
26307 + DPSW_COMPONENT_TYPE_C_VLAN = 0,
26308 + DPSW_COMPONENT_TYPE_S_VLAN
26312 + * struct dpsw_cfg - DPSW configuration
26313 + * @num_ifs: Number of external and internal interfaces
26314 + * @adv: Advanced parameters; default is all zeros;
26315 + * use this structure to change default settings
26318 + uint16_t num_ifs;
26320 + * struct adv - Advanced parameters
26321 + * @options: Enable/Disable DPSW features (bitmap)
26322 + * @max_vlans: Maximum Number of VLAN's; 0 - indicates default 16
26323 + * @max_meters_per_if: Number of meters per interface
26324 + * @max_fdbs: Maximum Number of FDB's; 0 - indicates default 16
26325 + * @max_fdb_entries: Number of FDB entries for default FDB table;
26326 + * 0 - indicates default 1024 entries.
26327 + * @fdb_aging_time: Default FDB aging time for default FDB table;
26328 + * 0 - indicates default 300 seconds
26329 + * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
26330 + * 0 - indicates default 32
26331 + * @component_type: Indicates the component type of this bridge
26334 + uint64_t options;
26335 + uint16_t max_vlans;
26336 + uint8_t max_meters_per_if;
26337 + uint8_t max_fdbs;
26338 + uint16_t max_fdb_entries;
26339 + uint16_t fdb_aging_time;
26340 + uint16_t max_fdb_mc_groups;
26341 + enum dpsw_component_type component_type;
26346 + * dpsw_create() - Create the DPSW object.
26347 + * @mc_io: Pointer to MC portal's I/O object
26348 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26349 + * @cfg: Configuration structure
26350 + * @token: Returned token; use in subsequent API calls
26352 + * Create the DPSW object, allocate required resources and
26353 + * perform required initialization.
26355 + * The object can be created either by declaring it in the
26356 + * DPL file, or by calling this function.
26358 + * This function returns a unique authentication token,
26359 + * associated with the specific object ID and the specific MC
26360 + * portal; this token must be used in all subsequent calls to
26361 + * this specific object. For objects that are created using the
26362 + * DPL file, call dpsw_open() function to get an authentication
26365 + * Return: '0' on Success; Error code otherwise.
26367 +int dpsw_create(struct fsl_mc_io *mc_io,
26368 + uint32_t cmd_flags,
26369 + const struct dpsw_cfg *cfg,
26370 + uint16_t *token);
26373 + * dpsw_destroy() - Destroy the DPSW object and release all its resources.
26374 + * @mc_io: Pointer to MC portal's I/O object
26375 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26376 + * @token: Token of DPSW object
26378 + * Return: '0' on Success; error code otherwise.
26380 +int dpsw_destroy(struct fsl_mc_io *mc_io,
26381 + uint32_t cmd_flags,
26385 + * dpsw_enable() - Enable DPSW functionality
26386 + * @mc_io: Pointer to MC portal's I/O object
26387 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26388 + * @token: Token of DPSW object
26390 + * Return: Completion status. '0' on Success; Error code otherwise.
26392 +int dpsw_enable(struct fsl_mc_io *mc_io,
26393 + uint32_t cmd_flags,
26397 + * dpsw_disable() - Disable DPSW functionality
26398 + * @mc_io: Pointer to MC portal's I/O object
26399 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26400 + * @token: Token of DPSW object
26402 + * Return: Completion status. '0' on Success; Error code otherwise.
26404 +int dpsw_disable(struct fsl_mc_io *mc_io,
26405 + uint32_t cmd_flags,
26409 + * dpsw_is_enabled() - Check if the DPSW is enabled
26411 + * @mc_io: Pointer to MC portal's I/O object
26412 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26413 + * @token: Token of DPSW object
26414 + * @en: Returns '1' if object is enabled; '0' otherwise
26416 + * Return: '0' on Success; Error code otherwise
26418 +int dpsw_is_enabled(struct fsl_mc_io *mc_io,
26419 + uint32_t cmd_flags,
26424 + * dpsw_reset() - Reset the DPSW, returns the object to initial state.
26425 + * @mc_io: Pointer to MC portal's I/O object
26426 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26427 + * @token: Token of DPSW object
26429 + * Return: '0' on Success; Error code otherwise.
26431 +int dpsw_reset(struct fsl_mc_io *mc_io,
26432 + uint32_t cmd_flags,
26436 + * DPSW IRQ Index and Events
26439 +#define DPSW_IRQ_INDEX_IF 0x0000
26440 +#define DPSW_IRQ_INDEX_L2SW 0x0001
26443 + * IRQ event - Indicates that the link state changed
26445 +#define DPSW_IRQ_EVENT_LINK_CHANGED 0x0001
26448 + * struct dpsw_irq_cfg - IRQ configuration
26449 + * @addr: Address that must be written to signal a message-based interrupt
26450 + * @val: Value to write into irq_addr address
26451 + * @irq_num: A user defined number associated with this IRQ
26453 +struct dpsw_irq_cfg {
26460 + * dpsw_set_irq() - Set IRQ information for the DPSW to trigger an interrupt.
26461 + * @mc_io: Pointer to MC portal's I/O object
26462 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26463 + * @token: Token of DPSW object
26464 + * @irq_index: Identifies the interrupt index to configure
26465 + * @irq_cfg: IRQ configuration
26467 + * Return: '0' on Success; Error code otherwise.
26469 +int dpsw_set_irq(struct fsl_mc_io *mc_io,
26470 + uint32_t cmd_flags,
26472 + uint8_t irq_index,
26473 + struct dpsw_irq_cfg *irq_cfg);
26476 + * dpsw_get_irq() - Get IRQ information from the DPSW
26478 + * @mc_io: Pointer to MC portal's I/O object
26479 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26480 + * @token: Token of DPSW object
26481 + * @irq_index: The interrupt index to configure
26482 + * @type: Interrupt type: 0 represents message interrupt
26483 + * type (both irq_addr and irq_val are valid)
26484 + * @irq_cfg: IRQ attributes
26486 + * Return: '0' on Success; Error code otherwise.
26488 +int dpsw_get_irq(struct fsl_mc_io *mc_io,
26489 + uint32_t cmd_flags,
26491 + uint8_t irq_index,
26493 + struct dpsw_irq_cfg *irq_cfg);
26496 + * dpsw_set_irq_enable() - Set overall interrupt state.
26497 + * @mc_io: Pointer to MC portal's I/O object
26498 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26499 + * @token: Token of DPCI object
26500 + * @irq_index: The interrupt index to configure
26501 + * @en: Interrupt state - enable = 1, disable = 0
26503 + * Allows GPP software to control when interrupts are generated.
26504 + * Each interrupt can have up to 32 causes. The enable/disable control's the
26505 + * overall interrupt state. if the interrupt is disabled no causes will cause
26508 + * Return: '0' on Success; Error code otherwise.
26510 +int dpsw_set_irq_enable(struct fsl_mc_io *mc_io,
26511 + uint32_t cmd_flags,
26513 + uint8_t irq_index,
26517 + * dpsw_get_irq_enable() - Get overall interrupt state
26518 + * @mc_io: Pointer to MC portal's I/O object
26519 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26520 + * @token: Token of DPSW object
26521 + * @irq_index: The interrupt index to configure
26522 + * @en: Returned Interrupt state - enable = 1, disable = 0
26524 + * Return: '0' on Success; Error code otherwise.
26526 +int dpsw_get_irq_enable(struct fsl_mc_io *mc_io,
26527 + uint32_t cmd_flags,
26529 + uint8_t irq_index,
26533 + * dpsw_set_irq_mask() - Set interrupt mask.
26534 + * @mc_io: Pointer to MC portal's I/O object
26535 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26536 + * @token: Token of DPCI object
26537 + * @irq_index: The interrupt index to configure
26538 + * @mask: event mask to trigger interrupt;
26540 + * 0 = ignore event
26541 + * 1 = consider event for asserting IRQ
26543 + * Every interrupt can have up to 32 causes and the interrupt model supports
26544 + * masking/unmasking each cause independently
26546 + * Return: '0' on Success; Error code otherwise.
26548 +int dpsw_set_irq_mask(struct fsl_mc_io *mc_io,
26549 + uint32_t cmd_flags,
26551 + uint8_t irq_index,
26555 + * dpsw_get_irq_mask() - Get interrupt mask.
26556 + * @mc_io: Pointer to MC portal's I/O object
26557 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26558 + * @token: Token of DPSW object
26559 + * @irq_index: The interrupt index to configure
26560 + * @mask: Returned event mask to trigger interrupt
26562 + * Every interrupt can have up to 32 causes and the interrupt model supports
26563 + * masking/unmasking each cause independently
26565 + * Return: '0' on Success; Error code otherwise.
26567 +int dpsw_get_irq_mask(struct fsl_mc_io *mc_io,
26568 + uint32_t cmd_flags,
26570 + uint8_t irq_index,
26574 + * dpsw_get_irq_status() - Get the current status of any pending interrupts
26575 + * @mc_io: Pointer to MC portal's I/O object
26576 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26577 + * @token: Token of DPSW object
26578 + * @irq_index: The interrupt index to configure
26579 + * @status: Returned interrupts status - one bit per cause:
26580 + * 0 = no interrupt pending
26581 + * 1 = interrupt pending
26583 + * Return: '0' on Success; Error code otherwise.
26585 +int dpsw_get_irq_status(struct fsl_mc_io *mc_io,
26586 + uint32_t cmd_flags,
26588 + uint8_t irq_index,
26589 + uint32_t *status);
26592 + * dpsw_clear_irq_status() - Clear a pending interrupt's status
26593 + * @mc_io: Pointer to MC portal's I/O object
26594 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26595 + * @token: Token of DPCI object
26596 + * @irq_index: The interrupt index to configure
26597 + * @status: bits to clear (W1C) - one bit per cause:
26598 + * 0 = don't change
26599 + * 1 = clear status bit
26601 + * Return: '0' on Success; Error code otherwise.
26603 +int dpsw_clear_irq_status(struct fsl_mc_io *mc_io,
26604 + uint32_t cmd_flags,
26606 + uint8_t irq_index,
26607 + uint32_t status);
26609 + * struct dpsw_attr - Structure representing DPSW attributes
26610 + * @id: DPSW object ID
26611 + * @version: DPSW version
26612 + * @options: Enable/Disable DPSW features
26613 + * @max_vlans: Maximum Number of VLANs
26614 + * @max_meters_per_if: Number of meters per interface
26615 + * @max_fdbs: Maximum Number of FDBs
26616 + * @max_fdb_entries: Number of FDB entries for default FDB table;
26617 + * 0 - indicates default 1024 entries.
26618 + * @fdb_aging_time: Default FDB aging time for default FDB table;
26619 + * 0 - indicates default 300 seconds
26620 + * @max_fdb_mc_groups: Number of multicast groups in each FDB table;
26621 + * 0 - indicates default 32
26622 + * @mem_size: DPSW frame storage memory size
26623 + * @num_ifs: Number of interfaces
26624 + * @num_vlans: Current number of VLANs
26625 + * @num_fdbs: Current number of FDBs
26626 + * @component_type: Component type of this bridge
26628 +struct dpsw_attr {
26631 + * struct version - DPSW version
26632 + * @major: DPSW major version
26633 + * @minor: DPSW minor version
26639 + uint64_t options;
26640 + uint16_t max_vlans;
26641 + uint8_t max_meters_per_if;
26642 + uint8_t max_fdbs;
26643 + uint16_t max_fdb_entries;
26644 + uint16_t fdb_aging_time;
26645 + uint16_t max_fdb_mc_groups;
26646 + uint16_t num_ifs;
26647 + uint16_t mem_size;
26648 + uint16_t num_vlans;
26649 + uint8_t num_fdbs;
26650 + enum dpsw_component_type component_type;
26654 + * dpsw_get_attributes() - Retrieve DPSW attributes
26655 + * @mc_io: Pointer to MC portal's I/O object
26656 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26657 + * @token: Token of DPSW object
26658 + * @attr: Returned DPSW attributes
26660 + * Return: Completion status. '0' on Success; Error code otherwise.
26662 +int dpsw_get_attributes(struct fsl_mc_io *mc_io,
26663 + uint32_t cmd_flags,
26665 + struct dpsw_attr *attr);
26668 + * dpsw_set_reflection_if() - Set target interface for reflected interfaces.
26669 + * @mc_io: Pointer to MC portal's I/O object
26670 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26671 + * @token: Token of DPSW object
26672 + * @if_id: Interface Id
26674 + * Only one reflection receive interface is allowed per switch
26676 + * Return: Completion status. '0' on Success; Error code otherwise.
26678 +int dpsw_set_reflection_if(struct fsl_mc_io *mc_io,
26679 + uint32_t cmd_flags,
26684 + * enum dpsw_action - Action selection for special/control frames
26685 + * @DPSW_ACTION_DROP: Drop frame
26686 + * @DPSW_ACTION_REDIRECT: Redirect frame to control port
26688 +enum dpsw_action {
26689 + DPSW_ACTION_DROP = 0,
26690 + DPSW_ACTION_REDIRECT = 1
26694 + * Enable auto-negotiation
26696 +#define DPSW_LINK_OPT_AUTONEG 0x0000000000000001ULL
26698 + * Enable half-duplex mode
26700 +#define DPSW_LINK_OPT_HALF_DUPLEX 0x0000000000000002ULL
26702 + * Enable pause frames
26704 +#define DPSW_LINK_OPT_PAUSE 0x0000000000000004ULL
26706 + * Enable a-symmetric pause frames
26708 +#define DPSW_LINK_OPT_ASYM_PAUSE 0x0000000000000008ULL
26711 + * struct dpsw_link_cfg - Structure representing DPSW link configuration
26713 + * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
26715 +struct dpsw_link_cfg {
26717 + uint64_t options;
26721 + * dpsw_if_set_link_cfg() - set the link configuration.
26722 + * @mc_io: Pointer to MC portal's I/O object
26723 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26724 + * @token: Token of DPSW object
26725 + * @if_id: interface id
26726 + * @cfg: Link configuration
26728 + * Return: '0' on Success; Error code otherwise.
26730 +int dpsw_if_set_link_cfg(struct fsl_mc_io *mc_io,
26731 + uint32_t cmd_flags,
26734 + struct dpsw_link_cfg *cfg);
26736 + * struct dpsw_link_state - Structure representing DPSW link state
26738 + * @options: Mask of available options; use 'DPSW_LINK_OPT_<X>' values
26739 + * @up: 0 - covers two cases: down and disconnected, 1 - up
26741 +struct dpsw_link_state {
26743 + uint64_t options;
26748 + * dpsw_if_get_link_state - Return the link state
26749 + * @mc_io: Pointer to MC portal's I/O object
26750 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26751 + * @token: Token of DPSW object
26752 + * @if_id: interface id
26753 + * @state: link state 1 - linkup, 0 - link down or disconnected
26755 + * @returns '0' on Success; Error code otherwise.
26757 +int dpsw_if_get_link_state(struct fsl_mc_io *mc_io,
26758 + uint32_t cmd_flags,
26761 + struct dpsw_link_state *state);
26764 + * dpsw_if_set_flooding() - Enable Disable flooding for particular interface
26765 + * @mc_io: Pointer to MC portal's I/O object
26766 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26767 + * @token: Token of DPSW object
26768 + * @if_id: Interface Identifier
26769 + * @en: 1 - enable, 0 - disable
26771 + * Return: Completion status. '0' on Success; Error code otherwise.
26773 +int dpsw_if_set_flooding(struct fsl_mc_io *mc_io,
26774 + uint32_t cmd_flags,
26780 + * dpsw_if_set_broadcast() - Enable/disable broadcast for particular interface
26781 + * @mc_io: Pointer to MC portal's I/O object
26782 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26783 + * @token: Token of DPSW object
26784 + * @if_id: Interface Identifier
26785 + * @en: 1 - enable, 0 - disable
26787 + * Return: Completion status. '0' on Success; Error code otherwise.
26789 +int dpsw_if_set_broadcast(struct fsl_mc_io *mc_io,
26790 + uint32_t cmd_flags,
26796 + * dpsw_if_set_multicast() - Enable/disable multicast for particular interface
26797 + * @mc_io: Pointer to MC portal's I/O object
26798 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26799 + * @token: Token of DPSW object
26800 + * @if_id: Interface Identifier
26801 + * @en: 1 - enable, 0 - disable
26803 + * Return: Completion status. '0' on Success; Error code otherwise.
26805 +int dpsw_if_set_multicast(struct fsl_mc_io *mc_io,
26806 + uint32_t cmd_flags,
26812 + * struct dpsw_tci_cfg - Tag Contorl Information (TCI) configuration
26813 + * @pcp: Priority Code Point (PCP): a 3-bit field which refers
26814 + * to the IEEE 802.1p priority
26815 + * @dei: Drop Eligible Indicator (DEI): a 1-bit field. May be used
26816 + * separately or in conjunction with PCP to indicate frames
26817 + * eligible to be dropped in the presence of congestion
26818 + * @vlan_id: VLAN Identifier (VID): a 12-bit field specifying the VLAN
26819 + * to which the frame belongs. The hexadecimal values
26820 + * of 0x000 and 0xFFF are reserved;
26821 + * all other values may be used as VLAN identifiers,
26822 + * allowing up to 4,094 VLANs
26824 +struct dpsw_tci_cfg {
26827 + uint16_t vlan_id;
26831 + * dpsw_if_set_tci() - Set default VLAN Tag Control Information (TCI)
26832 + * @mc_io: Pointer to MC portal's I/O object
26833 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26834 + * @token: Token of DPSW object
26835 + * @if_id: Interface Identifier
26836 + * @cfg: Tag Control Information Configuration
26838 + * Return: Completion status. '0' on Success; Error code otherwise.
26840 +int dpsw_if_set_tci(struct fsl_mc_io *mc_io,
26841 + uint32_t cmd_flags,
26844 + const struct dpsw_tci_cfg *cfg);
26847 + * dpsw_if_get_tci() - Get default VLAN Tag Control Information (TCI)
26848 + * @mc_io: Pointer to MC portal's I/O object
26849 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26850 + * @token: Token of DPSW object
26851 + * @if_id: Interface Identifier
26852 + * @cfg: Tag Control Information Configuration
26854 + * Return: Completion status. '0' on Success; Error code otherwise.
26856 +int dpsw_if_get_tci(struct fsl_mc_io *mc_io,
26857 + uint32_t cmd_flags,
26860 + struct dpsw_tci_cfg *cfg);
26863 + * enum dpsw_stp_state - Spanning Tree Protocol (STP) states
26864 + * @DPSW_STP_STATE_BLOCKING: Blocking state
26865 + * @DPSW_STP_STATE_LISTENING: Listening state
26866 + * @DPSW_STP_STATE_LEARNING: Learning state
26867 + * @DPSW_STP_STATE_FORWARDING: Forwarding state
26870 +enum dpsw_stp_state {
26871 + DPSW_STP_STATE_BLOCKING = 0,
26872 + DPSW_STP_STATE_LISTENING = 1,
26873 + DPSW_STP_STATE_LEARNING = 2,
26874 + DPSW_STP_STATE_FORWARDING = 3
26878 + * struct dpsw_stp_cfg - Spanning Tree Protocol (STP) Configuration
26879 + * @vlan_id: VLAN ID STP state
26880 + * @state: STP state
26882 +struct dpsw_stp_cfg {
26883 + uint16_t vlan_id;
26884 + enum dpsw_stp_state state;
26888 + * dpsw_if_set_stp() - Function sets Spanning Tree Protocol (STP) state.
26889 + * @mc_io: Pointer to MC portal's I/O object
26890 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26891 + * @token: Token of DPSW object
26892 + * @if_id: Interface Identifier
26893 + * @cfg: STP State configuration parameters
26895 + * The following STP states are supported -
26896 + * blocking, listening, learning, forwarding and disabled.
26898 + * Return: Completion status. '0' on Success; Error code otherwise.
26900 +int dpsw_if_set_stp(struct fsl_mc_io *mc_io,
26901 + uint32_t cmd_flags,
26904 + const struct dpsw_stp_cfg *cfg);
26907 + * enum dpsw_accepted_frames - Types of frames to accept
26908 + * @DPSW_ADMIT_ALL: The device accepts VLAN tagged, untagged and
26909 + * priority tagged frames
26910 + * @DPSW_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
26911 + * Priority-Tagged frames received on this interface.
26914 +enum dpsw_accepted_frames {
26915 + DPSW_ADMIT_ALL = 1,
26916 + DPSW_ADMIT_ONLY_VLAN_TAGGED = 3
26920 + * struct dpsw_accepted_frames_cfg - Types of frames to accept configuration
26921 + * @type: Defines ingress accepted frames
26922 + * @unaccept_act: When a frame is not accepted, it may be discarded or
26923 + * redirected to control interface depending on this mode
26925 +struct dpsw_accepted_frames_cfg {
26926 + enum dpsw_accepted_frames type;
26927 + enum dpsw_action unaccept_act;
26931 + * dpsw_if_set_accepted_frames()
26932 + * @mc_io: Pointer to MC portal's I/O object
26933 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26934 + * @token: Token of DPSW object
26935 + * @if_id: Interface Identifier
26936 + * @cfg: Frame types configuration
26938 + * When is admit_only_vlan_tagged- the device will discard untagged
26939 + * frames or Priority-Tagged frames received on this interface.
26940 + * When admit_only_untagged- untagged frames or Priority-Tagged
26941 + * frames received on this interface will be accepted and assigned
26942 + * to a VID based on the PVID and VID Set for this interface.
26943 + * When admit_all - the device will accept VLAN tagged, untagged
26944 + * and priority tagged frames.
26945 + * The default is admit_all
26947 + * Return: Completion status. '0' on Success; Error code otherwise.
26949 +int dpsw_if_set_accepted_frames(struct fsl_mc_io *mc_io,
26950 + uint32_t cmd_flags,
26953 + const struct dpsw_accepted_frames_cfg *cfg);
26956 + * dpsw_if_set_accept_all_vlan()
26957 + * @mc_io: Pointer to MC portal's I/O object
26958 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
26959 + * @token: Token of DPSW object
26960 + * @if_id: Interface Identifier
26961 + * @accept_all: Accept or drop frames having different VLAN
26963 + * When this is accept (FALSE), the device will discard incoming
26964 + * frames for VLANs that do not include this interface in its
26965 + * Member set. When accept (TRUE), the interface will accept all incoming frames
26967 + * Return: Completion status. '0' on Success; Error code otherwise.
26969 +int dpsw_if_set_accept_all_vlan(struct fsl_mc_io *mc_io,
26970 + uint32_t cmd_flags,
26976 + * enum dpsw_counter - Counters types
26977 + * @DPSW_CNT_ING_FRAME: Counts ingress frames
26978 + * @DPSW_CNT_ING_BYTE: Counts ingress bytes
26979 + * @DPSW_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
26980 + * @DPSW_CNT_ING_FRAME_DISCARD: Counts discarded ingress frame
26981 + * @DPSW_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
26982 + * @DPSW_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
26983 + * @DPSW_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
26984 + * @DPSW_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
26985 + * @DPSW_CNT_EGR_FRAME: Counts egress frames
26986 + * @DPSW_CNT_EGR_BYTE: Counts eEgress bytes
26987 + * @DPSW_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
26988 + * @DPSW_CNT_EGR_STP_FRAME_DISCARD: Counts egress STP discarded frames
26990 +enum dpsw_counter {
26991 + DPSW_CNT_ING_FRAME = 0x0,
26992 + DPSW_CNT_ING_BYTE = 0x1,
26993 + DPSW_CNT_ING_FLTR_FRAME = 0x2,
26994 + DPSW_CNT_ING_FRAME_DISCARD = 0x3,
26995 + DPSW_CNT_ING_MCAST_FRAME = 0x4,
26996 + DPSW_CNT_ING_MCAST_BYTE = 0x5,
26997 + DPSW_CNT_ING_BCAST_FRAME = 0x6,
26998 + DPSW_CNT_ING_BCAST_BYTES = 0x7,
26999 + DPSW_CNT_EGR_FRAME = 0x8,
27000 + DPSW_CNT_EGR_BYTE = 0x9,
27001 + DPSW_CNT_EGR_FRAME_DISCARD = 0xa,
27002 + DPSW_CNT_EGR_STP_FRAME_DISCARD = 0xb
27006 + * dpsw_if_get_counter() - Get specific counter of particular interface
27007 + * @mc_io: Pointer to MC portal's I/O object
27008 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27009 + * @token: Token of DPSW object
27010 + * @if_id: Interface Identifier
27011 + * @type: Counter type
27012 + * @counter: return value
27014 + * Return: Completion status. '0' on Success; Error code otherwise.
27016 +int dpsw_if_get_counter(struct fsl_mc_io *mc_io,
27017 + uint32_t cmd_flags,
27020 + enum dpsw_counter type,
27021 + uint64_t *counter);
27024 + * dpsw_if_set_counter() - Set specific counter of particular interface
27025 + * @mc_io: Pointer to MC portal's I/O object
27026 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27027 + * @token: Token of DPSW object
27028 + * @if_id: Interface Identifier
27029 + * @type: Counter type
27030 + * @counter: New counter value
27032 + * Return: Completion status. '0' on Success; Error code otherwise.
27034 +int dpsw_if_set_counter(struct fsl_mc_io *mc_io,
27035 + uint32_t cmd_flags,
27038 + enum dpsw_counter type,
27039 + uint64_t counter);
27042 + * Maximum number of TC
27044 +#define DPSW_MAX_TC 8
27047 + * enum dpsw_priority_selector - User priority
27048 + * @DPSW_UP_PCP: Priority Code Point (PCP): a 3-bit field which
27049 + * refers to the IEEE 802.1p priority.
27050 + * @DPSW_UP_DSCP: Differentiated services Code Point (DSCP): 6 bit
27051 + * field from IP header
27054 +enum dpsw_priority_selector {
27060 + * enum dpsw_schedule_mode - Traffic classes scheduling
27061 + * @DPSW_SCHED_STRICT_PRIORITY: schedule strict priority
27062 + * @DPSW_SCHED_WEIGHTED: schedule based on token bucket created algorithm
27064 +enum dpsw_schedule_mode {
27065 + DPSW_SCHED_STRICT_PRIORITY,
27066 + DPSW_SCHED_WEIGHTED
27070 + * struct dpsw_tx_schedule_cfg - traffic class configuration
27071 + * @mode: Strict or weight-based scheduling
27072 + * @delta_bandwidth: weighted Bandwidth in range from 100 to 10000
27074 +struct dpsw_tx_schedule_cfg {
27075 + enum dpsw_schedule_mode mode;
27076 + uint16_t delta_bandwidth;
27080 + * struct dpsw_tx_selection_cfg - Mapping user priority into traffic
27081 + * class configuration
27082 + * @priority_selector: Source for user priority regeneration
27083 + * @tc_id: The Regenerated User priority that the incoming
27084 + * User Priority is mapped to for this interface
27085 + * @tc_sched: Traffic classes configuration
27087 +struct dpsw_tx_selection_cfg {
27088 + enum dpsw_priority_selector priority_selector;
27089 + uint8_t tc_id[DPSW_MAX_PRIORITIES];
27090 + struct dpsw_tx_schedule_cfg tc_sched[DPSW_MAX_TC];
27094 + * dpsw_if_set_tx_selection() - Function is used for mapping variety
27095 + * of frame fields
27096 + * @mc_io: Pointer to MC portal's I/O object
27097 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27098 + * @token: Token of DPSW object
27099 + * @if_id: Interface Identifier
27100 + * @cfg: Traffic class mapping configuration
27102 + * Function is used for mapping variety of frame fields (DSCP, PCP)
27103 + * to Traffic Class. Traffic class is a number
27104 + * in the range from 0 to 7
27106 + * Return: Completion status. '0' on Success; Error code otherwise.
27108 +int dpsw_if_set_tx_selection(struct fsl_mc_io *mc_io,
27109 + uint32_t cmd_flags,
27112 + const struct dpsw_tx_selection_cfg *cfg);
27115 + * enum dpsw_reflection_filter - Filter type for frames to reflect
27116 + * @DPSW_REFLECTION_FILTER_INGRESS_ALL: Reflect all frames
27117 + * @DPSW_REFLECTION_FILTER_INGRESS_VLAN: Reflect only frames belong to
27118 + * particular VLAN defined by vid parameter
27121 +enum dpsw_reflection_filter {
27122 + DPSW_REFLECTION_FILTER_INGRESS_ALL = 0,
27123 + DPSW_REFLECTION_FILTER_INGRESS_VLAN = 1
27127 + * struct dpsw_reflection_cfg - Structure representing reflection information
27128 + * @filter: Filter type for frames to reflect
27129 + * @vlan_id: Vlan Id to reflect; valid only when filter type is
27130 + * DPSW_INGRESS_VLAN
27132 +struct dpsw_reflection_cfg {
27133 + enum dpsw_reflection_filter filter;
27134 + uint16_t vlan_id;
27138 + * dpsw_if_add_reflection() - Identify interface to be reflected or mirrored
27139 + * @mc_io: Pointer to MC portal's I/O object
27140 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27141 + * @token: Token of DPSW object
27142 + * @if_id: Interface Identifier
27143 + * @cfg: Reflection configuration
27145 + * Return: Completion status. '0' on Success; Error code otherwise.
27147 +int dpsw_if_add_reflection(struct fsl_mc_io *mc_io,
27148 + uint32_t cmd_flags,
27151 + const struct dpsw_reflection_cfg *cfg);
27154 + * dpsw_if_remove_reflection() - Remove interface to be reflected or mirrored
27155 + * @mc_io: Pointer to MC portal's I/O object
27156 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27157 + * @token: Token of DPSW object
27158 + * @if_id: Interface Identifier
27159 + * @cfg: Reflection configuration
27161 + * Return: Completion status. '0' on Success; Error code otherwise.
27163 +int dpsw_if_remove_reflection(struct fsl_mc_io *mc_io,
27164 + uint32_t cmd_flags,
27167 + const struct dpsw_reflection_cfg *cfg);
27170 + * enum dpsw_metering_mode - Metering modes
27171 + * @DPSW_METERING_MODE_NONE: metering disabled
27172 + * @DPSW_METERING_MODE_RFC2698: RFC 2698
27173 + * @DPSW_METERING_MODE_RFC4115: RFC 4115
27175 +enum dpsw_metering_mode {
27176 + DPSW_METERING_MODE_NONE = 0,
27177 + DPSW_METERING_MODE_RFC2698,
27178 + DPSW_METERING_MODE_RFC4115
27182 + * enum dpsw_metering_unit - Metering count
27183 + * @DPSW_METERING_UNIT_BYTES: count bytes
27184 + * @DPSW_METERING_UNIT_FRAMES: count frames
27186 +enum dpsw_metering_unit {
27187 + DPSW_METERING_UNIT_BYTES = 0,
27188 + DPSW_METERING_UNIT_FRAMES
27192 + * struct dpsw_metering_cfg - Metering configuration
27193 + * @mode: metering modes
27194 + * @units: Bytes or frame units
27195 + * @cir: Committed information rate (CIR) in Kbits/s
27196 + * @eir: Peak information rate (PIR) Kbit/s rfc2698
27197 + * Excess information rate (EIR) Kbit/s rfc4115
27198 + * @cbs: Committed burst size (CBS) in bytes
27199 + * @ebs: Peak burst size (PBS) in bytes for rfc2698
27200 + * Excess bust size (EBS) in bytes rfc4115
27203 +struct dpsw_metering_cfg {
27204 + enum dpsw_metering_mode mode;
27205 + enum dpsw_metering_unit units;
27213 + * dpsw_if_set_flooding_metering() - Set flooding metering
27214 + * @mc_io: Pointer to MC portal's I/O object
27215 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27216 + * @token: Token of DPSW object
27217 + * @if_id: Interface Identifier
27218 + * @cfg: Metering parameters
27220 + * Return: Completion status. '0' on Success; Error code otherwise.
27222 +int dpsw_if_set_flooding_metering(struct fsl_mc_io *mc_io,
27223 + uint32_t cmd_flags,
27226 + const struct dpsw_metering_cfg *cfg);
27229 + * dpsw_if_set_metering() - Set interface metering for flooding
27230 + * @mc_io: Pointer to MC portal's I/O object
27231 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27232 + * @token: Token of DPSW object
27233 + * @if_id: Interface Identifier
27234 + * @tc_id: Traffic class ID
27235 + * @cfg: Metering parameters
27237 + * Return: Completion status. '0' on Success; Error code otherwise.
27239 +int dpsw_if_set_metering(struct fsl_mc_io *mc_io,
27240 + uint32_t cmd_flags,
27244 + const struct dpsw_metering_cfg *cfg);
27247 + * enum dpsw_early_drop_unit - DPSW early drop unit
27248 + * @DPSW_EARLY_DROP_UNIT_BYTE: count bytes
27249 + * @DPSW_EARLY_DROP_UNIT_FRAMES: count frames
27251 +enum dpsw_early_drop_unit {
27252 + DPSW_EARLY_DROP_UNIT_BYTE = 0,
27253 + DPSW_EARLY_DROP_UNIT_FRAMES
27257 + * enum dpsw_early_drop_mode - DPSW early drop mode
27258 + * @DPSW_EARLY_DROP_MODE_NONE: early drop is disabled
27259 + * @DPSW_EARLY_DROP_MODE_TAIL: early drop in taildrop mode
27260 + * @DPSW_EARLY_DROP_MODE_WRED: early drop in WRED mode
27262 +enum dpsw_early_drop_mode {
27263 + DPSW_EARLY_DROP_MODE_NONE = 0,
27264 + DPSW_EARLY_DROP_MODE_TAIL,
27265 + DPSW_EARLY_DROP_MODE_WRED
27269 + * struct dpsw_wred_cfg - WRED configuration
27270 + * @max_threshold: maximum threshold that packets may be discarded. Above this
27271 + * threshold all packets are discarded; must be less than 2^39;
27272 + * approximated to be expressed as (x+256)*2^(y-1) due to HW
27273 + * implementation.
27274 + * @min_threshold: minimum threshold that packets may be discarded at
27275 + * @drop_probability: probability that a packet will be discarded (1-100,
27276 + * associated with the maximum threshold)
27278 +struct dpsw_wred_cfg {
27279 + uint64_t min_threshold;
27280 + uint64_t max_threshold;
27281 + uint8_t drop_probability;
27285 + * struct dpsw_early_drop_cfg - early-drop configuration
27286 + * @drop_mode: drop mode
27287 + * @units: count units
27288 + * @yellow: WRED - 'yellow' configuration
27289 + * @green: WRED - 'green' configuration
27290 + * @tail_drop_threshold: tail drop threshold
27292 +struct dpsw_early_drop_cfg {
27293 + enum dpsw_early_drop_mode drop_mode;
27294 + enum dpsw_early_drop_unit units;
27295 + struct dpsw_wred_cfg yellow;
27296 + struct dpsw_wred_cfg green;
27297 + uint32_t tail_drop_threshold;
27301 + * dpsw_prepare_early_drop() - Prepare an early drop for setting in to interface
27302 + * @cfg: Early-drop configuration
27303 + * @early_drop_buf: Zeroed 256 bytes of memory before mapping it to DMA
27305 + * This function has to be called before dpsw_if_tc_set_early_drop
27308 +void dpsw_prepare_early_drop(const struct dpsw_early_drop_cfg *cfg,
27309 + uint8_t *early_drop_buf);
27312 + * dpsw_if_set_early_drop() - Set interface traffic class early-drop
27314 + * @mc_io: Pointer to MC portal's I/O object
27315 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27316 + * @token: Token of DPSW object
27317 + * @if_id: Interface Identifier
27318 + * @tc_id: Traffic class selection (0-7)
27319 + * @early_drop_iova: I/O virtual address of 64 bytes;
27320 + * Must be cacheline-aligned and DMA-able memory
27322 + * warning: Before calling this function, call dpsw_prepare_if_tc_early_drop()
27323 + * to prepare the early_drop_iova parameter
27325 + * Return: '0' on Success; error code otherwise.
27327 +int dpsw_if_set_early_drop(struct fsl_mc_io *mc_io,
27328 + uint32_t cmd_flags,
27332 + uint64_t early_drop_iova);
27335 + * struct dpsw_custom_tpid_cfg - Structure representing tag Protocol identifier
27336 + * @tpid: An additional tag protocol identifier
27338 +struct dpsw_custom_tpid_cfg {
27343 + * dpsw_add_custom_tpid() - API Configures a distinct Ethernet type value
27344 + * @mc_io: Pointer to MC portal's I/O object
27345 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27346 + * @token: Token of DPSW object
27347 + * @cfg: Tag Protocol identifier
27349 + * API Configures a distinct Ethernet type value (or TPID value)
27350 + * to indicate a VLAN tag in addition to the common
27351 + * TPID values 0x8100 and 0x88A8.
27352 + * Two additional TPID's are supported
27354 + * Return: Completion status. '0' on Success; Error code otherwise.
27356 +int dpsw_add_custom_tpid(struct fsl_mc_io *mc_io,
27357 + uint32_t cmd_flags,
27359 + const struct dpsw_custom_tpid_cfg *cfg);
27362 + * dpsw_remove_custom_tpid - API removes a distinct Ethernet type value
27363 + * @mc_io: Pointer to MC portal's I/O object
27364 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27365 + * @token: Token of DPSW object
27366 + * @cfg: Tag Protocol identifier
27368 + * Return: Completion status. '0' on Success; Error code otherwise.
27370 +int dpsw_remove_custom_tpid(struct fsl_mc_io *mc_io,
27371 + uint32_t cmd_flags,
27373 + const struct dpsw_custom_tpid_cfg *cfg);
27376 + * dpsw_if_enable() - Enable Interface
27377 + * @mc_io: Pointer to MC portal's I/O object
27378 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27379 + * @token: Token of DPSW object
27380 + * @if_id: Interface Identifier
27382 + * Return: Completion status. '0' on Success; Error code otherwise.
27384 +int dpsw_if_enable(struct fsl_mc_io *mc_io,
27385 + uint32_t cmd_flags,
27390 + * dpsw_if_disable() - Disable Interface
27391 + * @mc_io: Pointer to MC portal's I/O object
27392 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27393 + * @token: Token of DPSW object
27394 + * @if_id: Interface Identifier
27396 + * Return: Completion status. '0' on Success; Error code otherwise.
27398 +int dpsw_if_disable(struct fsl_mc_io *mc_io,
27399 + uint32_t cmd_flags,
27404 + * struct dpsw_if_attr - Structure representing DPSW interface attributes
27405 + * @num_tcs: Number of traffic classes
27406 + * @rate: Transmit rate in bits per second
27407 + * @options: Interface configuration options (bitmap)
27408 + * @enabled: Indicates if interface is enabled
27409 + * @accept_all_vlan: The device discards/accepts incoming frames
27410 + * for VLANs that do not include this interface
27411 + * @admit_untagged: When set to 'DPSW_ADMIT_ONLY_VLAN_TAGGED', the device
27412 + * discards untagged frames or priority-tagged frames received on
27413 + * this interface;
27414 + * When set to 'DPSW_ADMIT_ALL', untagged frames or priority-
27415 + * tagged frames received on this interface are accepted
27416 + * @qdid: control frames transmit qdid
27418 +struct dpsw_if_attr {
27421 + uint32_t options;
27423 + int accept_all_vlan;
27424 + enum dpsw_accepted_frames admit_untagged;
27429 + * dpsw_if_get_attributes() - Function obtains attributes of interface
27430 + * @mc_io: Pointer to MC portal's I/O object
27431 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27432 + * @token: Token of DPSW object
27433 + * @if_id: Interface Identifier
27434 + * @attr: Returned interface attributes
27436 + * Return: Completion status. '0' on Success; Error code otherwise.
27438 +int dpsw_if_get_attributes(struct fsl_mc_io *mc_io,
27439 + uint32_t cmd_flags,
27442 + struct dpsw_if_attr *attr);
27445 + * dpsw_if_set_max_frame_length() - Set Maximum Receive frame length.
27446 + * @mc_io: Pointer to MC portal's I/O object
27447 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27448 + * @token: Token of DPSW object
27449 + * @if_id: Interface Identifier
27450 + * @frame_length: Maximum Frame Length
27452 + * Return: Completion status. '0' on Success; Error code otherwise.
27454 +int dpsw_if_set_max_frame_length(struct fsl_mc_io *mc_io,
27455 + uint32_t cmd_flags,
27458 + uint16_t frame_length);
27461 + * dpsw_if_get_max_frame_length() - Get Maximum Receive frame length.
27462 + * @mc_io: Pointer to MC portal's I/O object
27463 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27464 + * @token: Token of DPSW object
27465 + * @if_id: Interface Identifier
27466 + * @frame_length: Returned maximum Frame Length
27468 + * Return: Completion status. '0' on Success; Error code otherwise.
27470 +int dpsw_if_get_max_frame_length(struct fsl_mc_io *mc_io,
27471 + uint32_t cmd_flags,
27474 + uint16_t *frame_length);
27477 + * struct dpsw_vlan_cfg - VLAN Configuration
27478 + * @fdb_id: Forwarding Data Base
27480 +struct dpsw_vlan_cfg {
27485 + * dpsw_vlan_add() - Adding new VLAN to DPSW.
27486 + * @mc_io: Pointer to MC portal's I/O object
27487 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27488 + * @token: Token of DPSW object
27489 + * @vlan_id: VLAN Identifier
27490 + * @cfg: VLAN configuration
27492 + * Only VLAN ID and FDB ID are required parameters here.
27493 + * 12 bit VLAN ID is defined in IEEE802.1Q.
27494 + * Adding a duplicate VLAN ID is not allowed.
27495 + * FDB ID can be shared across multiple VLANs. Shared learning
27496 + * is obtained by calling dpsw_vlan_add for multiple VLAN IDs
27497 + * with same fdb_id
27499 + * Return: Completion status. '0' on Success; Error code otherwise.
27501 +int dpsw_vlan_add(struct fsl_mc_io *mc_io,
27502 + uint32_t cmd_flags,
27504 + uint16_t vlan_id,
27505 + const struct dpsw_vlan_cfg *cfg);
27508 + * struct dpsw_vlan_if_cfg - Set of VLAN Interfaces
27509 + * @num_ifs: The number of interfaces that are assigned to the egress
27510 + * list for this VLAN
27511 + * @if_id: The set of interfaces that are
27512 + * assigned to the egress list for this VLAN
27514 +struct dpsw_vlan_if_cfg {
27515 + uint16_t num_ifs;
27516 + uint16_t if_id[DPSW_MAX_IF];
27520 + * dpsw_vlan_add_if() - Adding a set of interfaces to an existing VLAN.
27521 + * @mc_io: Pointer to MC portal's I/O object
27522 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27523 + * @token: Token of DPSW object
27524 + * @vlan_id: VLAN Identifier
27525 + * @cfg: Set of interfaces to add
27527 + * It adds only interfaces not belonging to this VLAN yet,
27528 + * otherwise an error is generated and an entire command is
27529 + * ignored. This function can be called numerous times always
27530 + * providing required interfaces delta.
27532 + * Return: Completion status. '0' on Success; Error code otherwise.
27534 +int dpsw_vlan_add_if(struct fsl_mc_io *mc_io,
27535 + uint32_t cmd_flags,
27537 + uint16_t vlan_id,
27538 + const struct dpsw_vlan_if_cfg *cfg);
27541 + * dpsw_vlan_add_if_untagged() - Defining a set of interfaces that should be
27542 + * transmitted as untagged.
27543 + * @mc_io: Pointer to MC portal's I/O object
27544 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27545 + * @token: Token of DPSW object
27546 + * @vlan_id: VLAN Identifier
27547 + * @cfg: set of interfaces that should be transmitted as untagged
27549 + * These interfaces should already belong to this VLAN.
27550 + * By default all interfaces are transmitted as tagged.
27551 + * Providing un-existing interface or untagged interface that is
27552 + * configured untagged already generates an error and the entire
27553 + * command is ignored.
27555 + * Return: Completion status. '0' on Success; Error code otherwise.
27557 +int dpsw_vlan_add_if_untagged(struct fsl_mc_io *mc_io,
27558 + uint32_t cmd_flags,
27560 + uint16_t vlan_id,
27561 + const struct dpsw_vlan_if_cfg *cfg);
27564 + * dpsw_vlan_add_if_flooding() - Define a set of interfaces that should be
27565 + * included in flooding when frame with unknown destination
27566 + * unicast MAC arrived.
27567 + * @mc_io: Pointer to MC portal's I/O object
27568 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27569 + * @token: Token of DPSW object
27570 + * @vlan_id: VLAN Identifier
27571 + * @cfg: Set of interfaces that should be used for flooding
27573 + * These interfaces should belong to this VLAN. By default all
27574 + * interfaces are included into flooding list. Providing
27575 + * un-existing interface or an interface that already in the
27576 + * flooding list generates an error and the entire command is
27579 + * Return: Completion status. '0' on Success; Error code otherwise.
27581 +int dpsw_vlan_add_if_flooding(struct fsl_mc_io *mc_io,
27582 + uint32_t cmd_flags,
27584 + uint16_t vlan_id,
27585 + const struct dpsw_vlan_if_cfg *cfg);
27588 + * dpsw_vlan_remove_if() - Remove interfaces from an existing VLAN.
27589 + * @mc_io: Pointer to MC portal's I/O object
27590 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27591 + * @token: Token of DPSW object
27592 + * @vlan_id: VLAN Identifier
27593 + * @cfg: Set of interfaces that should be removed
27595 + * Interfaces must belong to this VLAN, otherwise an error
27596 + * is returned and an the command is ignored
27598 + * Return: Completion status. '0' on Success; Error code otherwise.
27600 +int dpsw_vlan_remove_if(struct fsl_mc_io *mc_io,
27601 + uint32_t cmd_flags,
27603 + uint16_t vlan_id,
27604 + const struct dpsw_vlan_if_cfg *cfg);
27607 + * dpsw_vlan_remove_if_untagged() - Define a set of interfaces that should be
27608 + * converted from transmitted as untagged to transmit as tagged.
27609 + * @mc_io: Pointer to MC portal's I/O object
27610 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27611 + * @token: Token of DPSW object
27612 + * @vlan_id: VLAN Identifier
27613 + * @cfg: set of interfaces that should be removed
27615 + * Interfaces provided by API have to belong to this VLAN and
27616 + * configured untagged, otherwise an error is returned and the
27617 + * command is ignored
27619 + * Return: Completion status. '0' on Success; Error code otherwise.
27621 +int dpsw_vlan_remove_if_untagged(struct fsl_mc_io *mc_io,
27622 + uint32_t cmd_flags,
27624 + uint16_t vlan_id,
27625 + const struct dpsw_vlan_if_cfg *cfg);
27628 + * dpsw_vlan_remove_if_flooding() - Define a set of interfaces that should be
27629 + * removed from the flooding list.
27630 + * @mc_io: Pointer to MC portal's I/O object
27631 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27632 + * @token: Token of DPSW object
27633 + * @vlan_id: VLAN Identifier
27634 + * @cfg: set of interfaces used for flooding
27636 + * Return: Completion status. '0' on Success; Error code otherwise.
27638 +int dpsw_vlan_remove_if_flooding(struct fsl_mc_io *mc_io,
27639 + uint32_t cmd_flags,
27641 + uint16_t vlan_id,
27642 + const struct dpsw_vlan_if_cfg *cfg);
27645 + * dpsw_vlan_remove() - Remove an entire VLAN
27646 + * @mc_io: Pointer to MC portal's I/O object
27647 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27648 + * @token: Token of DPSW object
27649 + * @vlan_id: VLAN Identifier
27651 + * Return: Completion status. '0' on Success; Error code otherwise.
27653 +int dpsw_vlan_remove(struct fsl_mc_io *mc_io,
27654 + uint32_t cmd_flags,
27656 + uint16_t vlan_id);
27659 + * struct dpsw_vlan_attr - VLAN attributes
27660 + * @fdb_id: Associated FDB ID
27661 + * @num_ifs: Number of interfaces
27662 + * @num_untagged_ifs: Number of untagged interfaces
27663 + * @num_flooding_ifs: Number of flooding interfaces
27665 +struct dpsw_vlan_attr {
27667 + uint16_t num_ifs;
27668 + uint16_t num_untagged_ifs;
27669 + uint16_t num_flooding_ifs;
27673 + * dpsw_vlan_get_attributes() - Get VLAN attributes
27674 + * @mc_io: Pointer to MC portal's I/O object
27675 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27676 + * @token: Token of DPSW object
27677 + * @vlan_id: VLAN Identifier
27678 + * @attr: Returned DPSW attributes
27680 + * Return: Completion status. '0' on Success; Error code otherwise.
27682 +int dpsw_vlan_get_attributes(struct fsl_mc_io *mc_io,
27683 + uint32_t cmd_flags,
27685 + uint16_t vlan_id,
27686 + struct dpsw_vlan_attr *attr);
27689 + * dpsw_vlan_get_if() - Get interfaces belong to this VLAN
27690 + * @mc_io: Pointer to MC portal's I/O object
27691 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27692 + * @token: Token of DPSW object
27693 + * @vlan_id: VLAN Identifier
27694 + * @cfg: Returned set of interfaces belong to this VLAN
27696 + * Return: Completion status. '0' on Success; Error code otherwise.
27698 +int dpsw_vlan_get_if(struct fsl_mc_io *mc_io,
27699 + uint32_t cmd_flags,
27701 + uint16_t vlan_id,
27702 + struct dpsw_vlan_if_cfg *cfg);
27705 + * dpsw_vlan_get_if_flooding() - Get interfaces used in flooding for this VLAN
27706 + * @mc_io: Pointer to MC portal's I/O object
27707 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27708 + * @token: Token of DPSW object
27709 + * @vlan_id: VLAN Identifier
27710 + * @cfg: Returned set of flooding interfaces
27712 + * Return: Completion status. '0' on Success; Error code otherwise.
27714 +int dpsw_vlan_get_if_flooding(struct fsl_mc_io *mc_io,
27715 + uint32_t cmd_flags,
27717 + uint16_t vlan_id,
27718 + struct dpsw_vlan_if_cfg *cfg);
27721 + * dpsw_vlan_get_if_untagged() - Get interfaces that should be transmitted as
27723 + * @mc_io: Pointer to MC portal's I/O object
27724 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27725 + * @token: Token of DPSW object
27726 + * @vlan_id: VLAN Identifier
27727 + * @cfg: Returned set of untagged interfaces
27729 + * Return: Completion status. '0' on Success; Error code otherwise.
27731 +int dpsw_vlan_get_if_untagged(struct fsl_mc_io *mc_io,
27732 + uint32_t cmd_flags,
27734 + uint16_t vlan_id,
27735 + struct dpsw_vlan_if_cfg *cfg);
27738 + * struct dpsw_fdb_cfg - FDB Configuration
27739 + * @num_fdb_entries: Number of FDB entries
27740 + * @fdb_aging_time: Aging time in seconds
27742 +struct dpsw_fdb_cfg {
27743 + uint16_t num_fdb_entries;
27744 + uint16_t fdb_aging_time;
27748 + * dpsw_fdb_add() - Add FDB to switch and Returns handle to FDB table for
27750 + * @mc_io: Pointer to MC portal's I/O object
27751 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27752 + * @token: Token of DPSW object
27753 + * @fdb_id: Returned Forwarding Database Identifier
27754 + * @cfg: FDB Configuration
27756 + * Return: Completion status. '0' on Success; Error code otherwise.
27758 +int dpsw_fdb_add(struct fsl_mc_io *mc_io,
27759 + uint32_t cmd_flags,
27761 + uint16_t *fdb_id,
27762 + const struct dpsw_fdb_cfg *cfg);
27765 + * dpsw_fdb_remove() - Remove FDB from switch
27766 + * @mc_io: Pointer to MC portal's I/O object
27767 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27768 + * @token: Token of DPSW object
27769 + * @fdb_id: Forwarding Database Identifier
27771 + * Return: Completion status. '0' on Success; Error code otherwise.
27773 +int dpsw_fdb_remove(struct fsl_mc_io *mc_io,
27774 + uint32_t cmd_flags,
27776 + uint16_t fdb_id);
27779 + * enum dpsw_fdb_entry_type - FDB Entry type - Static/Dynamic
27780 + * @DPSW_FDB_ENTRY_STATIC: Static entry
27781 + * @DPSW_FDB_ENTRY_DINAMIC: Dynamic entry
27783 +enum dpsw_fdb_entry_type {
27784 + DPSW_FDB_ENTRY_STATIC = 0,
27785 + DPSW_FDB_ENTRY_DINAMIC = 1
27789 + * struct dpsw_fdb_unicast_cfg - Unicast entry configuration
27790 + * @type: Select static or dynamic entry
27791 + * @mac_addr: MAC address
27792 + * @if_egress: Egress interface ID
27794 +struct dpsw_fdb_unicast_cfg {
27795 + enum dpsw_fdb_entry_type type;
27796 + uint8_t mac_addr[6];
27797 + uint16_t if_egress;
27801 + * dpsw_fdb_add_unicast() - Function adds an unicast entry into MAC lookup table
27802 + * @mc_io: Pointer to MC portal's I/O object
27803 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27804 + * @token: Token of DPSW object
27805 + * @fdb_id: Forwarding Database Identifier
27806 + * @cfg: Unicast entry configuration
27808 + * Return: Completion status. '0' on Success; Error code otherwise.
27810 +int dpsw_fdb_add_unicast(struct fsl_mc_io *mc_io,
27811 + uint32_t cmd_flags,
27814 + const struct dpsw_fdb_unicast_cfg *cfg);
27817 + * dpsw_fdb_get_unicast() - Get unicast entry from MAC lookup table by
27818 + * unicast Ethernet address
27819 + * @mc_io: Pointer to MC portal's I/O object
27820 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27821 + * @token: Token of DPSW object
27822 + * @fdb_id: Forwarding Database Identifier
27823 + * @cfg: Returned unicast entry configuration
27825 + * Return: Completion status. '0' on Success; Error code otherwise.
27827 +int dpsw_fdb_get_unicast(struct fsl_mc_io *mc_io,
27828 + uint32_t cmd_flags,
27831 + struct dpsw_fdb_unicast_cfg *cfg);
27834 + * dpsw_fdb_remove_unicast() - removes an entry from MAC lookup table
27835 + * @mc_io: Pointer to MC portal's I/O object
27836 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27837 + * @token: Token of DPSW object
27838 + * @fdb_id: Forwarding Database Identifier
27839 + * @cfg: Unicast entry configuration
27841 + * Return: Completion status. '0' on Success; Error code otherwise.
27843 +int dpsw_fdb_remove_unicast(struct fsl_mc_io *mc_io,
27844 + uint32_t cmd_flags,
27847 + const struct dpsw_fdb_unicast_cfg *cfg);
27850 + * struct dpsw_fdb_multicast_cfg - Multi-cast entry configuration
27851 + * @type: Select static or dynamic entry
27852 + * @mac_addr: MAC address
27853 + * @num_ifs: Number of external and internal interfaces
27854 + * @if_id: Egress interface IDs
27856 +struct dpsw_fdb_multicast_cfg {
27857 + enum dpsw_fdb_entry_type type;
27858 + uint8_t mac_addr[6];
27859 + uint16_t num_ifs;
27860 + uint16_t if_id[DPSW_MAX_IF];
27864 + * dpsw_fdb_add_multicast() - Add a set of egress interfaces to multi-cast group
27865 + * @mc_io: Pointer to MC portal's I/O object
27866 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27867 + * @token: Token of DPSW object
27868 + * @fdb_id: Forwarding Database Identifier
27869 + * @cfg: Multicast entry configuration
27871 + * If group doesn't exist, it will be created.
27872 + * It adds only interfaces not belonging to this multicast group
27873 + * yet, otherwise error will be generated and the command is
27875 + * This function may be called numerous times always providing
27876 + * required interfaces delta.
27878 + * Return: Completion status. '0' on Success; Error code otherwise.
27880 +int dpsw_fdb_add_multicast(struct fsl_mc_io *mc_io,
27881 + uint32_t cmd_flags,
27884 + const struct dpsw_fdb_multicast_cfg *cfg);
27887 + * dpsw_fdb_get_multicast() - Reading multi-cast group by multi-cast Ethernet
27889 + * @mc_io: Pointer to MC portal's I/O object
27890 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27891 + * @token: Token of DPSW object
27892 + * @fdb_id: Forwarding Database Identifier
27893 + * @cfg: Returned multicast entry configuration
27895 + * Return: Completion status. '0' on Success; Error code otherwise.
27897 +int dpsw_fdb_get_multicast(struct fsl_mc_io *mc_io,
27898 + uint32_t cmd_flags,
27901 + struct dpsw_fdb_multicast_cfg *cfg);
27904 + * dpsw_fdb_remove_multicast() - Removing interfaces from an existing multicast
27906 + * @mc_io: Pointer to MC portal's I/O object
27907 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27908 + * @token: Token of DPSW object
27909 + * @fdb_id: Forwarding Database Identifier
27910 + * @cfg: Multicast entry configuration
27912 + * Interfaces provided by this API have to exist in the group,
27913 + * otherwise an error will be returned and an entire command
27914 + * ignored. If there is no interface left in the group,
27915 + * an entire group is deleted
27917 + * Return: Completion status. '0' on Success; Error code otherwise.
27919 +int dpsw_fdb_remove_multicast(struct fsl_mc_io *mc_io,
27920 + uint32_t cmd_flags,
27923 + const struct dpsw_fdb_multicast_cfg *cfg);
27926 + * enum dpsw_fdb_learning_mode - Auto-learning modes
27927 + * @DPSW_FDB_LEARNING_MODE_DIS: Disable Auto-learning
27928 + * @DPSW_FDB_LEARNING_MODE_HW: Enable HW auto-Learning
27929 + * @DPSW_FDB_LEARNING_MODE_NON_SECURE: Enable None secure learning by CPU
27930 + * @DPSW_FDB_LEARNING_MODE_SECURE: Enable secure learning by CPU
27932 + * NONE - SECURE LEARNING
27933 + * SMAC found DMAC found CTLU Action
27934 + * v v Forward frame to
27935 + * 1. DMAC destination
27936 + * - v Forward frame to
27937 + * 1. DMAC destination
27938 + * 2. Control interface
27939 + * v - Forward frame to
27940 + * 1. Flooding list of interfaces
27941 + * - - Forward frame to
27942 + * 1. Flooding list of interfaces
27943 + * 2. Control interface
27945 + * SMAC found DMAC found CTLU Action
27946 + * v v Forward frame to
27947 + * 1. DMAC destination
27948 + * - v Forward frame to
27949 + * 1. Control interface
27950 + * v - Forward frame to
27951 + * 1. Flooding list of interfaces
27952 + * - - Forward frame to
27953 + * 1. Control interface
27955 +enum dpsw_fdb_learning_mode {
27956 + DPSW_FDB_LEARNING_MODE_DIS = 0,
27957 + DPSW_FDB_LEARNING_MODE_HW = 1,
27958 + DPSW_FDB_LEARNING_MODE_NON_SECURE = 2,
27959 + DPSW_FDB_LEARNING_MODE_SECURE = 3
27963 + * dpsw_fdb_set_learning_mode() - Define FDB learning mode
27964 + * @mc_io: Pointer to MC portal's I/O object
27965 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27966 + * @token: Token of DPSW object
27967 + * @fdb_id: Forwarding Database Identifier
27968 + * @mode: learning mode
27970 + * Return: Completion status. '0' on Success; Error code otherwise.
27972 +int dpsw_fdb_set_learning_mode(struct fsl_mc_io *mc_io,
27973 + uint32_t cmd_flags,
27976 + enum dpsw_fdb_learning_mode mode);
27979 + * struct dpsw_fdb_attr - FDB Attributes
27980 + * @max_fdb_entries: Number of FDB entries
27981 + * @fdb_aging_time: Aging time in seconds
27982 + * @learning_mode: Learning mode
27983 + * @num_fdb_mc_groups: Current number of multicast groups
27984 + * @max_fdb_mc_groups: Maximum number of multicast groups
27986 +struct dpsw_fdb_attr {
27987 + uint16_t max_fdb_entries;
27988 + uint16_t fdb_aging_time;
27989 + enum dpsw_fdb_learning_mode learning_mode;
27990 + uint16_t num_fdb_mc_groups;
27991 + uint16_t max_fdb_mc_groups;
27995 + * dpsw_fdb_get_attributes() - Get FDB attributes
27996 + * @mc_io: Pointer to MC portal's I/O object
27997 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
27998 + * @token: Token of DPSW object
27999 + * @fdb_id: Forwarding Database Identifier
28000 + * @attr: Returned FDB attributes
28002 + * Return: Completion status. '0' on Success; Error code otherwise.
28004 +int dpsw_fdb_get_attributes(struct fsl_mc_io *mc_io,
28005 + uint32_t cmd_flags,
28008 + struct dpsw_fdb_attr *attr);
28011 + * struct dpsw_acl_cfg - ACL Configuration
28012 + * @max_entries: Number of FDB entries
28014 +struct dpsw_acl_cfg {
28015 + uint16_t max_entries;
28019 + * struct dpsw_acl_fields - ACL fields.
28020 + * @l2_dest_mac: Destination MAC address: BPDU, Multicast, Broadcast, Unicast,
28021 + * slow protocols, MVRP, STP
28022 + * @l2_source_mac: Source MAC address
28023 + * @l2_tpid: Layer 2 (Ethernet) protocol type, used to identify the following
28024 + * protocols: MPLS, PTP, PFC, ARP, Jumbo frames, LLDP, IEEE802.1ae,
28025 + * Q-in-Q, IPv4, IPv6, PPPoE
28026 + * @l2_pcp_dei: indicate which protocol is encapsulated in the payload
28027 + * @l2_vlan_id: layer 2 VLAN ID
28028 + * @l2_ether_type: layer 2 Ethernet type
28029 + * @l3_dscp: Layer 3 differentiated services code point
28030 + * @l3_protocol: Tells the Network layer at the destination host, to which
28031 + * Protocol this packet belongs to. The following protocol are
28032 + * supported: ICMP, IGMP, IPv4 (encapsulation), TCP, IPv6
28033 + * (encapsulation), GRE, PTP
28034 + * @l3_source_ip: Source IPv4 IP
28035 + * @l3_dest_ip: Destination IPv4 IP
28036 + * @l4_source_port: Source TCP/UDP Port
28037 + * @l4_dest_port: Destination TCP/UDP Port
28039 +struct dpsw_acl_fields {
28040 + uint8_t l2_dest_mac[6];
28041 + uint8_t l2_source_mac[6];
28042 + uint16_t l2_tpid;
28043 + uint8_t l2_pcp_dei;
28044 + uint16_t l2_vlan_id;
28045 + uint16_t l2_ether_type;
28047 + uint8_t l3_protocol;
28048 + uint32_t l3_source_ip;
28049 + uint32_t l3_dest_ip;
28050 + uint16_t l4_source_port;
28051 + uint16_t l4_dest_port;
28055 + * struct dpsw_acl_key - ACL key
28056 + * @match: Match fields
28057 + * @mask: Mask: b'1 - valid, b'0 don't care
28059 +struct dpsw_acl_key {
28060 + struct dpsw_acl_fields match;
28061 + struct dpsw_acl_fields mask;
28065 + * enum dpsw_acl_action
28066 + * @DPSW_ACL_ACTION_DROP: Drop frame
28067 + * @DPSW_ACL_ACTION_REDIRECT: Redirect to certain port
28068 + * @DPSW_ACL_ACTION_ACCEPT: Accept frame
28069 + * @DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF: Redirect to control interface
28071 +enum dpsw_acl_action {
28072 + DPSW_ACL_ACTION_DROP,
28073 + DPSW_ACL_ACTION_REDIRECT,
28074 + DPSW_ACL_ACTION_ACCEPT,
28075 + DPSW_ACL_ACTION_REDIRECT_TO_CTRL_IF
28079 + * struct dpsw_acl_result - ACL action
28080 + * @action: Action should be taken when ACL entry hit
28081 + * @if_id: Interface IDs to redirect frame. Valid only if redirect selected for
28084 +struct dpsw_acl_result {
28085 + enum dpsw_acl_action action;
28090 + * struct dpsw_acl_entry_cfg - ACL entry
28091 + * @key_iova: I/O virtual address of DMA-able memory filled with key after call
28092 + * to dpsw_acl_prepare_entry_cfg()
28093 + * @result: Required action when entry hit occurs
28094 + * @precedence: Precedence inside ACL 0 is lowest; This priority can not change
28095 + * during the lifetime of a Policy. It is user responsibility to
28096 + * space the priorities according to consequent rule additions.
28098 +struct dpsw_acl_entry_cfg {
28099 + uint64_t key_iova;
28100 + struct dpsw_acl_result result;
28105 + * dpsw_acl_add() - Adds ACL to L2 switch.
28106 + * @mc_io: Pointer to MC portal's I/O object
28107 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28108 + * @token: Token of DPSW object
28109 + * @acl_id: Returned ACL ID, for the future reference
28110 + * @cfg: ACL configuration
28112 + * Create Access Control List. Multiple ACLs can be created and
28113 + * co-exist in L2 switch
28115 + * Return: '0' on Success; Error code otherwise.
28117 +int dpsw_acl_add(struct fsl_mc_io *mc_io,
28118 + uint32_t cmd_flags,
28120 + uint16_t *acl_id,
28121 + const struct dpsw_acl_cfg *cfg);
28124 + * dpsw_acl_remove() - Removes ACL from L2 switch.
28125 + * @mc_io: Pointer to MC portal's I/O object
28126 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28127 + * @token: Token of DPSW object
28128 + * @acl_id: ACL ID
28130 + * Return: '0' on Success; Error code otherwise.
28132 +int dpsw_acl_remove(struct fsl_mc_io *mc_io,
28133 + uint32_t cmd_flags,
28135 + uint16_t acl_id);
28138 + * dpsw_acl_prepare_entry_cfg() - Set an entry to ACL.
28140 + * @entry_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
28142 + * This function has to be called before adding or removing acl_entry
28145 +void dpsw_acl_prepare_entry_cfg(const struct dpsw_acl_key *key,
28146 + uint8_t *entry_cfg_buf);
28149 + * dpsw_acl_add_entry() - Adds an entry to ACL.
28150 + * @mc_io: Pointer to MC portal's I/O object
28151 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28152 + * @token: Token of DPSW object
28153 + * @acl_id: ACL ID
28154 + * @cfg: entry configuration
28156 + * warning: This function has to be called after dpsw_acl_set_entry_cfg()
28158 + * Return: '0' on Success; Error code otherwise.
28160 +int dpsw_acl_add_entry(struct fsl_mc_io *mc_io,
28161 + uint32_t cmd_flags,
28164 + const struct dpsw_acl_entry_cfg *cfg);
28167 + * dpsw_acl_remove_entry() - Removes an entry from ACL.
28168 + * @mc_io: Pointer to MC portal's I/O object
28169 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28170 + * @token: Token of DPSW object
28171 + * @acl_id: ACL ID
28172 + * @cfg: entry configuration
28174 + * warning: This function has to be called after dpsw_acl_set_entry_cfg()
28176 + * Return: '0' on Success; Error code otherwise.
28178 +int dpsw_acl_remove_entry(struct fsl_mc_io *mc_io,
28179 + uint32_t cmd_flags,
28182 + const struct dpsw_acl_entry_cfg *cfg);
28185 + * struct dpsw_acl_if_cfg - List of interfaces to Associate with ACL
28186 + * @num_ifs: Number of interfaces
28187 + * @if_id: List of interfaces
28189 +struct dpsw_acl_if_cfg {
28190 + uint16_t num_ifs;
28191 + uint16_t if_id[DPSW_MAX_IF];
28195 + * dpsw_acl_add_if() - Associate interface/interfaces with ACL.
28196 + * @mc_io: Pointer to MC portal's I/O object
28197 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28198 + * @token: Token of DPSW object
28199 + * @acl_id: ACL ID
28200 + * @cfg: interfaces list
28202 + * Return: '0' on Success; Error code otherwise.
28204 +int dpsw_acl_add_if(struct fsl_mc_io *mc_io,
28205 + uint32_t cmd_flags,
28208 + const struct dpsw_acl_if_cfg *cfg);
28211 + * dpsw_acl_remove_if() - De-associate interface/interfaces from ACL.
28212 + * @mc_io: Pointer to MC portal's I/O object
28213 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28214 + * @token: Token of DPSW object
28215 + * @acl_id: ACL ID
28216 + * @cfg: interfaces list
28218 + * Return: '0' on Success; Error code otherwise.
28220 +int dpsw_acl_remove_if(struct fsl_mc_io *mc_io,
28221 + uint32_t cmd_flags,
28224 + const struct dpsw_acl_if_cfg *cfg);
28227 + * struct dpsw_acl_attr - ACL Attributes
28228 + * @max_entries: Max number of ACL entries
28229 + * @num_entries: Number of used ACL entries
28230 + * @num_ifs: Number of interfaces associated with ACL
28232 +struct dpsw_acl_attr {
28233 + uint16_t max_entries;
28234 + uint16_t num_entries;
28235 + uint16_t num_ifs;
28239 +* dpsw_acl_get_attributes() - Get specific counter of particular interface
28240 +* @mc_io: Pointer to MC portal's I/O object
28241 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28242 +* @token: Token of DPSW object
28243 +* @acl_id: ACL Identifier
28244 +* @attr: Returned ACL attributes
28246 +* Return: '0' on Success; Error code otherwise.
28248 +int dpsw_acl_get_attributes(struct fsl_mc_io *mc_io,
28249 + uint32_t cmd_flags,
28252 + struct dpsw_acl_attr *attr);
28254 +* struct dpsw_ctrl_if_attr - Control interface attributes
28255 +* @rx_fqid: Receive FQID
28256 +* @rx_err_fqid: Receive error FQID
28257 +* @tx_err_conf_fqid: Transmit error and confirmation FQID
28259 +struct dpsw_ctrl_if_attr {
28260 + uint32_t rx_fqid;
28261 + uint32_t rx_err_fqid;
28262 + uint32_t tx_err_conf_fqid;
28266 +* dpsw_ctrl_if_get_attributes() - Obtain control interface attributes
28267 +* @mc_io: Pointer to MC portal's I/O object
28268 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28269 +* @token: Token of DPSW object
28270 +* @attr: Returned control interface attributes
28272 +* Return: '0' on Success; Error code otherwise.
28274 +int dpsw_ctrl_if_get_attributes(struct fsl_mc_io *mc_io,
28275 + uint32_t cmd_flags,
28277 + struct dpsw_ctrl_if_attr *attr);
28280 + * Maximum number of DPBP
28282 +#define DPSW_MAX_DPBP 8
28285 + * struct dpsw_ctrl_if_pools_cfg - Control interface buffer pools configuration
28286 + * @num_dpbp: Number of DPBPs
28287 + * @pools: Array of buffer pools parameters; The number of valid entries
28288 + * must match 'num_dpbp' value
28290 +struct dpsw_ctrl_if_pools_cfg {
28291 + uint8_t num_dpbp;
28293 + * struct pools - Buffer pools parameters
28294 + * @dpbp_id: DPBP object ID
28295 + * @buffer_size: Buffer size
28296 + * @backup_pool: Backup pool
28300 + uint16_t buffer_size;
28302 + } pools[DPSW_MAX_DPBP];
28306 +* dpsw_ctrl_if_set_pools() - Set control interface buffer pools
28307 +* @mc_io: Pointer to MC portal's I/O object
28308 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28309 +* @token: Token of DPSW object
28310 +* @cfg: buffer pools configuration
28312 +* Return: '0' on Success; Error code otherwise.
28314 +int dpsw_ctrl_if_set_pools(struct fsl_mc_io *mc_io,
28315 + uint32_t cmd_flags,
28317 + const struct dpsw_ctrl_if_pools_cfg *cfg);
28320 +* dpsw_ctrl_if_enable() - Enable control interface
28321 +* @mc_io: Pointer to MC portal's I/O object
28322 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28323 +* @token: Token of DPSW object
28325 +* Return: '0' on Success; Error code otherwise.
28327 +int dpsw_ctrl_if_enable(struct fsl_mc_io *mc_io,
28328 + uint32_t cmd_flags,
28332 +* dpsw_ctrl_if_disable() - Function disables control interface
28333 +* @mc_io: Pointer to MC portal's I/O object
28334 +* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
28335 +* @token: Token of DPSW object
28337 +* Return: '0' on Success; Error code otherwise.
28339 +int dpsw_ctrl_if_disable(struct fsl_mc_io *mc_io,
28340 + uint32_t cmd_flags,
28343 +#endif /* __FSL_DPSW_H */
28344 diff --git a/drivers/net/dpaa2/mc/fsl_dpsw_cmd.h b/drivers/net/dpaa2/mc/fsl_dpsw_cmd.h
28345 new file mode 100644
28346 index 0000000..c65fe38
28348 +++ b/drivers/net/dpaa2/mc/fsl_dpsw_cmd.h
28350 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
28352 + * Redistribution and use in source and binary forms, with or without
28353 + * modification, are permitted provided that the following conditions are met:
28354 + * * Redistributions of source code must retain the above copyright
28355 + * notice, this list of conditions and the following disclaimer.
28356 + * * Redistributions in binary form must reproduce the above copyright
28357 + * notice, this list of conditions and the following disclaimer in the
28358 + * documentation and/or other materials provided with the distribution.
28359 + * * Neither the name of the above-listed copyright holders nor the
28360 + * names of any contributors may be used to endorse or promote products
28361 + * derived from this software without specific prior written permission.
28364 + * ALTERNATIVELY, this software may be distributed under the terms of the
28365 + * GNU General Public License ("GPL") as published by the Free Software
28366 + * Foundation, either version 2 of that License or (at your option) any
28369 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28370 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28371 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28372 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
28373 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28374 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28375 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28376 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28377 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28378 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28379 + * POSSIBILITY OF SUCH DAMAGE.
28381 +#ifndef __FSL_DPSW_CMD_H
28382 +#define __FSL_DPSW_CMD_H
28384 +/* DPSW Version */
28385 +#define DPSW_VER_MAJOR 7
28386 +#define DPSW_VER_MINOR 0
28389 +#define DPSW_CMDID_CLOSE 0x800
28390 +#define DPSW_CMDID_OPEN 0x802
28391 +#define DPSW_CMDID_CREATE 0x902
28392 +#define DPSW_CMDID_DESTROY 0x900
28394 +#define DPSW_CMDID_ENABLE 0x002
28395 +#define DPSW_CMDID_DISABLE 0x003
28396 +#define DPSW_CMDID_GET_ATTR 0x004
28397 +#define DPSW_CMDID_RESET 0x005
28398 +#define DPSW_CMDID_IS_ENABLED 0x006
28400 +#define DPSW_CMDID_SET_IRQ 0x010
28401 +#define DPSW_CMDID_GET_IRQ 0x011
28402 +#define DPSW_CMDID_SET_IRQ_ENABLE 0x012
28403 +#define DPSW_CMDID_GET_IRQ_ENABLE 0x013
28404 +#define DPSW_CMDID_SET_IRQ_MASK 0x014
28405 +#define DPSW_CMDID_GET_IRQ_MASK 0x015
28406 +#define DPSW_CMDID_GET_IRQ_STATUS 0x016
28407 +#define DPSW_CMDID_CLEAR_IRQ_STATUS 0x017
28409 +#define DPSW_CMDID_SET_REFLECTION_IF 0x022
28411 +#define DPSW_CMDID_ADD_CUSTOM_TPID 0x024
28413 +#define DPSW_CMDID_REMOVE_CUSTOM_TPID 0x026
28415 +#define DPSW_CMDID_IF_SET_TCI 0x030
28416 +#define DPSW_CMDID_IF_SET_STP 0x031
28417 +#define DPSW_CMDID_IF_SET_ACCEPTED_FRAMES 0x032
28418 +#define DPSW_CMDID_SET_IF_ACCEPT_ALL_VLAN 0x033
28419 +#define DPSW_CMDID_IF_GET_COUNTER 0x034
28420 +#define DPSW_CMDID_IF_SET_COUNTER 0x035
28421 +#define DPSW_CMDID_IF_SET_TX_SELECTION 0x036
28422 +#define DPSW_CMDID_IF_ADD_REFLECTION 0x037
28423 +#define DPSW_CMDID_IF_REMOVE_REFLECTION 0x038
28424 +#define DPSW_CMDID_IF_SET_FLOODING_METERING 0x039
28425 +#define DPSW_CMDID_IF_SET_METERING 0x03A
28426 +#define DPSW_CMDID_IF_SET_EARLY_DROP 0x03B
28428 +#define DPSW_CMDID_IF_ENABLE 0x03D
28429 +#define DPSW_CMDID_IF_DISABLE 0x03E
28431 +#define DPSW_CMDID_IF_GET_ATTR 0x042
28433 +#define DPSW_CMDID_IF_SET_MAX_FRAME_LENGTH 0x044
28434 +#define DPSW_CMDID_IF_GET_MAX_FRAME_LENGTH 0x045
28435 +#define DPSW_CMDID_IF_GET_LINK_STATE 0x046
28436 +#define DPSW_CMDID_IF_SET_FLOODING 0x047
28437 +#define DPSW_CMDID_IF_SET_BROADCAST 0x048
28438 +#define DPSW_CMDID_IF_SET_MULTICAST 0x049
28439 +#define DPSW_CMDID_IF_GET_TCI 0x04A
28441 +#define DPSW_CMDID_IF_SET_LINK_CFG 0x04C
28443 +#define DPSW_CMDID_VLAN_ADD 0x060
28444 +#define DPSW_CMDID_VLAN_ADD_IF 0x061
28445 +#define DPSW_CMDID_VLAN_ADD_IF_UNTAGGED 0x062
28446 +#define DPSW_CMDID_VLAN_ADD_IF_FLOODING 0x063
28447 +#define DPSW_CMDID_VLAN_REMOVE_IF 0x064
28448 +#define DPSW_CMDID_VLAN_REMOVE_IF_UNTAGGED 0x065
28449 +#define DPSW_CMDID_VLAN_REMOVE_IF_FLOODING 0x066
28450 +#define DPSW_CMDID_VLAN_REMOVE 0x067
28451 +#define DPSW_CMDID_VLAN_GET_IF 0x068
28452 +#define DPSW_CMDID_VLAN_GET_IF_FLOODING 0x069
28453 +#define DPSW_CMDID_VLAN_GET_IF_UNTAGGED 0x06A
28454 +#define DPSW_CMDID_VLAN_GET_ATTRIBUTES 0x06B
28456 +#define DPSW_CMDID_FDB_GET_MULTICAST 0x080
28457 +#define DPSW_CMDID_FDB_GET_UNICAST 0x081
28458 +#define DPSW_CMDID_FDB_ADD 0x082
28459 +#define DPSW_CMDID_FDB_REMOVE 0x083
28460 +#define DPSW_CMDID_FDB_ADD_UNICAST 0x084
28461 +#define DPSW_CMDID_FDB_REMOVE_UNICAST 0x085
28462 +#define DPSW_CMDID_FDB_ADD_MULTICAST 0x086
28463 +#define DPSW_CMDID_FDB_REMOVE_MULTICAST 0x087
28464 +#define DPSW_CMDID_FDB_SET_LEARNING_MODE 0x088
28465 +#define DPSW_CMDID_FDB_GET_ATTR 0x089
28467 +#define DPSW_CMDID_ACL_ADD 0x090
28468 +#define DPSW_CMDID_ACL_REMOVE 0x091
28469 +#define DPSW_CMDID_ACL_ADD_ENTRY 0x092
28470 +#define DPSW_CMDID_ACL_REMOVE_ENTRY 0x093
28471 +#define DPSW_CMDID_ACL_ADD_IF 0x094
28472 +#define DPSW_CMDID_ACL_REMOVE_IF 0x095
28473 +#define DPSW_CMDID_ACL_GET_ATTR 0x096
28475 +#define DPSW_CMDID_CTRL_IF_GET_ATTR 0x0A0
28476 +#define DPSW_CMDID_CTRL_IF_SET_POOLS 0x0A1
28477 +#define DPSW_CMDID_CTRL_IF_ENABLE 0x0A2
28478 +#define DPSW_CMDID_CTRL_IF_DISABLE 0x0A3
28480 +/* cmd, param, offset, width, type, arg_name */
28481 +#define DPSW_CMD_OPEN(cmd, dpsw_id) \
28482 + MC_CMD_OP(cmd, 0, 0, 32, int, dpsw_id)
28484 +/* cmd, param, offset, width, type, arg_name */
28485 +#define DPSW_CMD_CREATE(cmd, cfg) \
28487 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->num_ifs);\
28488 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->adv.max_fdbs);\
28489 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->adv.max_meters_per_if);\
28490 + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_component_type, \
28491 + cfg->adv.component_type);\
28492 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->adv.max_vlans);\
28493 + MC_CMD_OP(cmd, 1, 16, 16, uint16_t, cfg->adv.max_fdb_entries);\
28494 + MC_CMD_OP(cmd, 1, 32, 16, uint16_t, cfg->adv.fdb_aging_time);\
28495 + MC_CMD_OP(cmd, 1, 48, 16, uint16_t, cfg->adv.max_fdb_mc_groups);\
28496 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->adv.options);\
28499 +/* cmd, param, offset, width, type, arg_name */
28500 +#define DPSW_RSP_IS_ENABLED(cmd, en) \
28501 + MC_RSP_OP(cmd, 0, 0, 1, int, en)
28503 +/* cmd, param, offset, width, type, arg_name */
28504 +#define DPSW_CMD_SET_IRQ(cmd, irq_index, irq_cfg) \
28506 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, irq_index);\
28507 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, irq_cfg->val);\
28508 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
28509 + MC_CMD_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
28512 +/* cmd, param, offset, width, type, arg_name */
28513 +#define DPSW_CMD_GET_IRQ(cmd, irq_index) \
28514 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
28516 +/* cmd, param, offset, width, type, arg_name */
28517 +#define DPSW_RSP_GET_IRQ(cmd, type, irq_cfg) \
28519 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, irq_cfg->val); \
28520 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, irq_cfg->addr);\
28521 + MC_RSP_OP(cmd, 2, 0, 32, int, irq_cfg->irq_num); \
28522 + MC_RSP_OP(cmd, 2, 32, 32, int, type); \
28525 +/* cmd, param, offset, width, type, arg_name */
28526 +#define DPSW_CMD_SET_IRQ_ENABLE(cmd, irq_index, enable_state) \
28528 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, enable_state); \
28529 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
28532 +/* cmd, param, offset, width, type, arg_name */
28533 +#define DPSW_CMD_GET_IRQ_ENABLE(cmd, irq_index) \
28534 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
28536 +/* cmd, param, offset, width, type, arg_name */
28537 +#define DPSW_RSP_GET_IRQ_ENABLE(cmd, enable_state) \
28538 + MC_RSP_OP(cmd, 0, 0, 8, uint8_t, enable_state)
28540 +/* cmd, param, offset, width, type, arg_name */
28541 +#define DPSW_CMD_SET_IRQ_MASK(cmd, irq_index, mask) \
28543 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, mask); \
28544 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
28547 +/* cmd, param, offset, width, type, arg_name */
28548 +#define DPSW_CMD_GET_IRQ_MASK(cmd, irq_index) \
28549 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index)
28551 +/* cmd, param, offset, width, type, arg_name */
28552 +#define DPSW_RSP_GET_IRQ_MASK(cmd, mask) \
28553 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, mask)
28555 +/* cmd, param, offset, width, type, arg_name */
28556 +#define DPSW_CMD_GET_IRQ_STATUS(cmd, irq_index, status) \
28558 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status);\
28559 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
28562 +/* cmd, param, offset, width, type, arg_name */
28563 +#define DPSW_RSP_GET_IRQ_STATUS(cmd, status) \
28564 + MC_RSP_OP(cmd, 0, 0, 32, uint32_t, status)
28566 +/* cmd, param, offset, width, type, arg_name */
28567 +#define DPSW_CMD_CLEAR_IRQ_STATUS(cmd, irq_index, status) \
28569 + MC_CMD_OP(cmd, 0, 0, 32, uint32_t, status); \
28570 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, irq_index);\
28573 +/* cmd, param, offset, width, type, arg_name */
28574 +#define DPSW_RSP_GET_ATTR(cmd, attr) \
28576 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, attr->num_ifs);\
28577 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->max_fdbs);\
28578 + MC_RSP_OP(cmd, 0, 24, 8, uint8_t, attr->num_fdbs);\
28579 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->max_vlans);\
28580 + MC_RSP_OP(cmd, 0, 48, 16, uint16_t, attr->num_vlans);\
28581 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->version.major);\
28582 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->version.minor);\
28583 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->max_fdb_entries);\
28584 + MC_RSP_OP(cmd, 1, 48, 16, uint16_t, attr->fdb_aging_time);\
28585 + MC_RSP_OP(cmd, 2, 0, 32, int, attr->id);\
28586 + MC_RSP_OP(cmd, 2, 32, 16, uint16_t, attr->mem_size);\
28587 + MC_RSP_OP(cmd, 2, 48, 16, uint16_t, attr->max_fdb_mc_groups);\
28588 + MC_RSP_OP(cmd, 3, 0, 64, uint64_t, attr->options);\
28589 + MC_RSP_OP(cmd, 4, 0, 8, uint8_t, attr->max_meters_per_if);\
28590 + MC_RSP_OP(cmd, 4, 8, 4, enum dpsw_component_type, \
28591 + attr->component_type);\
28594 +/* cmd, param, offset, width, type, arg_name */
28595 +#define DPSW_CMD_SET_REFLECTION_IF(cmd, if_id) \
28596 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28598 +/* cmd, param, offset, width, type, arg_name */
28599 +#define DPSW_CMD_IF_SET_FLOODING(cmd, if_id, en) \
28601 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28602 + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
28605 +/* cmd, param, offset, width, type, arg_name */
28606 +#define DPSW_CMD_IF_SET_BROADCAST(cmd, if_id, en) \
28608 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28609 + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
28612 +/* cmd, param, offset, width, type, arg_name */
28613 +#define DPSW_CMD_IF_SET_MULTICAST(cmd, if_id, en) \
28615 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28616 + MC_CMD_OP(cmd, 0, 16, 1, int, en);\
28619 +/* cmd, param, offset, width, type, arg_name */
28620 +#define DPSW_CMD_IF_SET_TCI(cmd, if_id, cfg) \
28622 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28623 + MC_CMD_OP(cmd, 0, 16, 12, uint16_t, cfg->vlan_id);\
28624 + MC_CMD_OP(cmd, 0, 28, 1, uint8_t, cfg->dei);\
28625 + MC_CMD_OP(cmd, 0, 29, 3, uint8_t, cfg->pcp);\
28628 +/* cmd, param, offset, width, type, arg_name */
28629 +#define DPSW_CMD_IF_GET_TCI(cmd, if_id) \
28630 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28632 +/* cmd, param, offset, width, type, arg_name */
28633 +#define DPSW_RSP_IF_GET_TCI(cmd, cfg) \
28635 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
28636 + MC_RSP_OP(cmd, 0, 32, 8, uint8_t, cfg->dei);\
28637 + MC_RSP_OP(cmd, 0, 40, 8, uint8_t, cfg->pcp);\
28640 +/* cmd, param, offset, width, type, arg_name */
28641 +#define DPSW_CMD_IF_SET_STP(cmd, if_id, cfg) \
28643 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28644 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
28645 + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_stp_state, cfg->state);\
28648 +/* cmd, param, offset, width, type, arg_name */
28649 +#define DPSW_CMD_IF_SET_ACCEPTED_FRAMES(cmd, if_id, cfg) \
28651 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28652 + MC_CMD_OP(cmd, 0, 16, 4, enum dpsw_accepted_frames, cfg->type);\
28653 + MC_CMD_OP(cmd, 0, 20, 4, enum dpsw_action, cfg->unaccept_act);\
28656 +/* cmd, param, offset, width, type, arg_name */
28657 +#define DPSW_CMD_IF_SET_ACCEPT_ALL_VLAN(cmd, if_id, accept_all) \
28659 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28660 + MC_CMD_OP(cmd, 0, 16, 1, int, accept_all);\
28663 +/* cmd, param, offset, width, type, arg_name */
28664 +#define DPSW_CMD_IF_GET_COUNTER(cmd, if_id, type) \
28666 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28667 + MC_CMD_OP(cmd, 0, 16, 5, enum dpsw_counter, type);\
28670 +/* cmd, param, offset, width, type, arg_name */
28671 +#define DPSW_RSP_IF_GET_COUNTER(cmd, counter) \
28672 + MC_RSP_OP(cmd, 1, 0, 64, uint64_t, counter)
28674 +/* cmd, param, offset, width, type, arg_name */
28675 +#define DPSW_CMD_IF_SET_COUNTER(cmd, if_id, type, counter) \
28677 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28678 + MC_CMD_OP(cmd, 0, 16, 5, enum dpsw_counter, type);\
28679 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, counter);\
28682 +/* cmd, param, offset, width, type, arg_name */
28683 +#define DPSW_CMD_IF_SET_TX_SELECTION(cmd, if_id, cfg) \
28685 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28686 + MC_CMD_OP(cmd, 0, 16, 3, enum dpsw_priority_selector, \
28687 + cfg->priority_selector);\
28688 + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->tc_id[0]);\
28689 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->tc_id[1]);\
28690 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->tc_id[2]);\
28691 + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->tc_id[3]);\
28692 + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->tc_id[4]);\
28693 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->tc_id[5]);\
28694 + MC_CMD_OP(cmd, 1, 48, 8, uint8_t, cfg->tc_id[6]);\
28695 + MC_CMD_OP(cmd, 1, 56, 8, uint8_t, cfg->tc_id[7]);\
28696 + MC_CMD_OP(cmd, 2, 0, 16, uint16_t, cfg->tc_sched[0].delta_bandwidth);\
28697 + MC_CMD_OP(cmd, 2, 16, 4, enum dpsw_schedule_mode, \
28698 + cfg->tc_sched[0].mode);\
28699 + MC_CMD_OP(cmd, 2, 32, 16, uint16_t, cfg->tc_sched[1].delta_bandwidth);\
28700 + MC_CMD_OP(cmd, 2, 48, 4, enum dpsw_schedule_mode, \
28701 + cfg->tc_sched[1].mode);\
28702 + MC_CMD_OP(cmd, 3, 0, 16, uint16_t, cfg->tc_sched[2].delta_bandwidth);\
28703 + MC_CMD_OP(cmd, 3, 16, 4, enum dpsw_schedule_mode, \
28704 + cfg->tc_sched[2].mode);\
28705 + MC_CMD_OP(cmd, 3, 32, 16, uint16_t, cfg->tc_sched[3].delta_bandwidth);\
28706 + MC_CMD_OP(cmd, 3, 48, 4, enum dpsw_schedule_mode, \
28707 + cfg->tc_sched[3].mode);\
28708 + MC_CMD_OP(cmd, 4, 0, 16, uint16_t, cfg->tc_sched[4].delta_bandwidth);\
28709 + MC_CMD_OP(cmd, 4, 16, 4, enum dpsw_schedule_mode, \
28710 + cfg->tc_sched[4].mode);\
28711 + MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->tc_sched[5].delta_bandwidth);\
28712 + MC_CMD_OP(cmd, 4, 48, 4, enum dpsw_schedule_mode, \
28713 + cfg->tc_sched[5].mode);\
28714 + MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->tc_sched[6].delta_bandwidth);\
28715 + MC_CMD_OP(cmd, 5, 16, 4, enum dpsw_schedule_mode, \
28716 + cfg->tc_sched[6].mode);\
28717 + MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->tc_sched[7].delta_bandwidth);\
28718 + MC_CMD_OP(cmd, 5, 48, 4, enum dpsw_schedule_mode, \
28719 + cfg->tc_sched[7].mode);\
28722 +/* cmd, param, offset, width, type, arg_name */
28723 +#define DPSW_CMD_IF_ADD_REFLECTION(cmd, if_id, cfg) \
28725 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28726 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
28727 + MC_CMD_OP(cmd, 0, 32, 2, enum dpsw_reflection_filter, cfg->filter);\
28730 +/* cmd, param, offset, width, type, arg_name */
28731 +#define DPSW_CMD_IF_REMOVE_REFLECTION(cmd, if_id, cfg) \
28733 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28734 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->vlan_id);\
28735 + MC_CMD_OP(cmd, 0, 32, 2, enum dpsw_reflection_filter, cfg->filter);\
28738 +/* cmd, param, offset, width, type, arg_name */
28739 +#define DPSW_CMD_IF_SET_FLOODING_METERING(cmd, if_id, cfg) \
28741 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28742 + MC_CMD_OP(cmd, 0, 24, 4, enum dpsw_metering_mode, cfg->mode);\
28743 + MC_CMD_OP(cmd, 0, 28, 4, enum dpsw_metering_unit, cfg->units);\
28744 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->cir);\
28745 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->eir);\
28746 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs);\
28747 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->ebs);\
28750 +/* cmd, param, offset, width, type, arg_name */
28751 +#define DPSW_CMD_IF_SET_METERING(cmd, if_id, tc_id, cfg) \
28753 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28754 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc_id);\
28755 + MC_CMD_OP(cmd, 0, 24, 4, enum dpsw_metering_mode, cfg->mode);\
28756 + MC_CMD_OP(cmd, 0, 28, 4, enum dpsw_metering_unit, cfg->units);\
28757 + MC_CMD_OP(cmd, 0, 32, 32, uint32_t, cfg->cir);\
28758 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->eir);\
28759 + MC_CMD_OP(cmd, 1, 32, 32, uint32_t, cfg->cbs);\
28760 + MC_CMD_OP(cmd, 2, 0, 32, uint32_t, cfg->ebs);\
28763 +/* cmd, param, offset, width, type, arg_name */
28764 +#define DPSW_PREP_EARLY_DROP(ext, cfg) \
28766 + MC_PREP_OP(ext, 0, 0, 2, enum dpsw_early_drop_mode, cfg->drop_mode); \
28767 + MC_PREP_OP(ext, 0, 2, 2, \
28768 + enum dpsw_early_drop_unit, cfg->units); \
28769 + MC_PREP_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
28770 + MC_PREP_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
28771 + MC_PREP_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
28772 + MC_PREP_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
28773 + MC_PREP_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
28774 + MC_PREP_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
28775 + MC_PREP_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
28778 +/* cmd, param, offset, width, type, arg_name */
28779 +#define DPSW_EXT_EARLY_DROP(ext, cfg) \
28781 + MC_EXT_OP(ext, 0, 0, 2, enum dpsw_early_drop_mode, cfg->drop_mode); \
28782 + MC_EXT_OP(ext, 0, 2, 2, \
28783 + enum dpsw_early_drop_unit, cfg->units); \
28784 + MC_EXT_OP(ext, 0, 32, 32, uint32_t, cfg->tail_drop_threshold); \
28785 + MC_EXT_OP(ext, 1, 0, 8, uint8_t, cfg->green.drop_probability); \
28786 + MC_EXT_OP(ext, 2, 0, 64, uint64_t, cfg->green.max_threshold); \
28787 + MC_EXT_OP(ext, 3, 0, 64, uint64_t, cfg->green.min_threshold); \
28788 + MC_EXT_OP(ext, 5, 0, 8, uint8_t, cfg->yellow.drop_probability);\
28789 + MC_EXT_OP(ext, 6, 0, 64, uint64_t, cfg->yellow.max_threshold); \
28790 + MC_EXT_OP(ext, 7, 0, 64, uint64_t, cfg->yellow.min_threshold); \
28793 +/* cmd, param, offset, width, type, arg_name */
28794 +#define DPSW_CMD_IF_SET_EARLY_DROP(cmd, if_id, tc_id, early_drop_iova) \
28796 + MC_CMD_OP(cmd, 0, 8, 8, uint8_t, tc_id); \
28797 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, if_id); \
28798 + MC_CMD_OP(cmd, 1, 0, 64, uint64_t, early_drop_iova); \
28801 +/* cmd, param, offset, width, type, arg_name */
28802 +#define DPSW_CMD_ADD_CUSTOM_TPID(cmd, cfg) \
28803 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->tpid)
28805 +/* cmd, param, offset, width, type, arg_name */
28806 +#define DPSW_CMD_REMOVE_CUSTOM_TPID(cmd, cfg) \
28807 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->tpid)
28809 +/* cmd, param, offset, width, type, arg_name */
28810 +#define DPSW_CMD_IF_ENABLE(cmd, if_id) \
28811 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28813 +/* cmd, param, offset, width, type, arg_name */
28814 +#define DPSW_CMD_IF_DISABLE(cmd, if_id) \
28815 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28817 +/* cmd, param, offset, width, type, arg_name */
28818 +#define DPSW_CMD_IF_GET_ATTR(cmd, if_id) \
28819 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28821 +/* cmd, param, offset, width, type, arg_name */
28822 +#define DPSW_RSP_IF_GET_ATTR(cmd, attr) \
28824 + MC_RSP_OP(cmd, 0, 0, 4, enum dpsw_accepted_frames, \
28825 + attr->admit_untagged);\
28826 + MC_RSP_OP(cmd, 0, 5, 1, int, attr->enabled);\
28827 + MC_RSP_OP(cmd, 0, 6, 1, int, attr->accept_all_vlan);\
28828 + MC_RSP_OP(cmd, 0, 16, 8, uint8_t, attr->num_tcs);\
28829 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->qdid);\
28830 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->options);\
28831 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->rate);\
28834 +/* cmd, param, offset, width, type, arg_name */
28835 +#define DPSW_CMD_IF_SET_MAX_FRAME_LENGTH(cmd, if_id, frame_length) \
28837 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28838 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, frame_length);\
28841 +/* cmd, param, offset, width, type, arg_name */
28842 +#define DPSW_CMD_IF_GET_MAX_FRAME_LENGTH(cmd, if_id) \
28843 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28845 +/* cmd, param, offset, width, type, arg_name */
28846 +#define DPSW_RSP_IF_GET_MAX_FRAME_LENGTH(cmd, frame_length) \
28847 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, frame_length)
28849 +/* cmd, param, offset, width, type, arg_name */
28850 +#define DPSW_CMD_IF_SET_LINK_CFG(cmd, if_id, cfg) \
28852 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id);\
28853 + MC_CMD_OP(cmd, 1, 0, 32, uint32_t, cfg->rate);\
28854 + MC_CMD_OP(cmd, 2, 0, 64, uint64_t, cfg->options);\
28857 +/* cmd, param, offset, width, type, arg_name */
28858 +#define DPSW_CMD_IF_GET_LINK_STATE(cmd, if_id) \
28859 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, if_id)
28861 +/* cmd, param, offset, width, type, arg_name */
28862 +#define DPSW_RSP_IF_GET_LINK_STATE(cmd, state) \
28864 + MC_RSP_OP(cmd, 0, 32, 1, int, state->up);\
28865 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, state->rate);\
28866 + MC_RSP_OP(cmd, 2, 0, 64, uint64_t, state->options);\
28869 +/* cmd, param, offset, width, type, arg_name */
28870 +#define DPSW_CMD_VLAN_ADD(cmd, vlan_id, cfg) \
28872 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, cfg->fdb_id);\
28873 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id);\
28876 +/* cmd, param, offset, width, type, arg_name */
28877 +#define DPSW_CMD_VLAN_ADD_IF(cmd, vlan_id) \
28878 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28880 +/* cmd, param, offset, width, type, arg_name */
28881 +#define DPSW_CMD_VLAN_ADD_IF_UNTAGGED(cmd, vlan_id) \
28882 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28884 +/* cmd, param, offset, width, type, arg_name */
28885 +#define DPSW_CMD_VLAN_ADD_IF_FLOODING(cmd, vlan_id) \
28886 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28888 +#define DPSW_CMD_VLAN_REMOVE_IF(cmd, vlan_id) \
28889 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28891 +/* cmd, param, offset, width, type, arg_name */
28892 +#define DPSW_CMD_VLAN_REMOVE_IF_UNTAGGED(cmd, vlan_id) \
28893 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28895 +/* cmd, param, offset, width, type, arg_name */
28896 +#define DPSW_CMD_VLAN_REMOVE_IF_FLOODING(cmd, vlan_id) \
28897 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28899 +/* cmd, param, offset, width, type, arg_name */
28900 +#define DPSW_CMD_VLAN_REMOVE(cmd, vlan_id) \
28901 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, vlan_id)
28903 +/* cmd, param, offset, width, type, arg_name */
28904 +#define DPSW_CMD_VLAN_GET_ATTR(cmd, vlan_id) \
28905 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
28907 +/* cmd, param, offset, width, type, arg_name */
28908 +#define DPSW_RSP_VLAN_GET_ATTR(cmd, attr) \
28910 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->fdb_id); \
28911 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->num_ifs); \
28912 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->num_untagged_ifs); \
28913 + MC_RSP_OP(cmd, 1, 48, 16, uint16_t, attr->num_flooding_ifs); \
28916 +/* cmd, param, offset, width, type, arg_name */
28917 +#define DPSW_CMD_VLAN_GET_IF(cmd, vlan_id) \
28918 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
28920 +/* cmd, param, offset, width, type, arg_name */
28921 +#define DPSW_RSP_VLAN_GET_IF(cmd, cfg) \
28922 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
28924 +/* cmd, param, offset, width, type, arg_name */
28925 +#define DPSW_CMD_VLAN_GET_IF_FLOODING(cmd, vlan_id) \
28926 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
28928 +/* cmd, param, offset, width, type, arg_name */
28929 +#define DPSW_RSP_VLAN_GET_IF_FLOODING(cmd, cfg) \
28930 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
28932 +/* cmd, param, offset, width, type, arg_name */
28933 +#define DPSW_CMD_VLAN_GET_IF_UNTAGGED(cmd, vlan_id) \
28934 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, vlan_id)
28936 +/* cmd, param, offset, width, type, arg_name */
28937 +#define DPSW_RSP_VLAN_GET_IF_UNTAGGED(cmd, cfg) \
28938 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs)
28940 +/* param, offset, width, type, arg_name */
28941 +#define DPSW_CMD_FDB_ADD(cmd, cfg) \
28943 + MC_CMD_OP(cmd, 0, 32, 16, uint16_t, cfg->fdb_aging_time);\
28944 + MC_CMD_OP(cmd, 0, 48, 16, uint16_t, cfg->num_fdb_entries);\
28947 +/* cmd, param, offset, width, type, arg_name */
28948 +#define DPSW_RSP_FDB_ADD(cmd, fdb_id) \
28949 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
28951 +/* cmd, param, offset, width, type, arg_name */
28952 +#define DPSW_CMD_FDB_REMOVE(cmd, fdb_id) \
28953 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
28955 +/* cmd, param, offset, width, type, arg_name */
28956 +#define DPSW_CMD_FDB_ADD_UNICAST(cmd, fdb_id, cfg) \
28958 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
28959 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
28960 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
28961 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
28962 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
28963 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
28964 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
28965 + MC_CMD_OP(cmd, 1, 0, 8, uint16_t, cfg->if_egress);\
28966 + MC_CMD_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
28969 +/* cmd, param, offset, width, type, arg_name */
28970 +#define DPSW_CMD_FDB_GET_UNICAST(cmd, fdb_id) \
28972 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
28973 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
28974 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
28975 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
28976 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
28977 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
28978 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
28981 +/* cmd, param, offset, width, type, arg_name */
28982 +#define DPSW_RSP_FDB_GET_UNICAST(cmd, cfg) \
28984 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, cfg->if_egress);\
28985 + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
28988 +/* cmd, param, offset, width, type, arg_name */
28989 +#define DPSW_CMD_FDB_REMOVE_UNICAST(cmd, fdb_id, cfg) \
28991 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
28992 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
28993 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
28994 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
28995 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
28996 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
28997 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
28998 + MC_CMD_OP(cmd, 1, 0, 16, uint16_t, cfg->if_egress);\
28999 + MC_CMD_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
29002 +/* cmd, param, offset, width, type, arg_name */
29003 +#define DPSW_CMD_FDB_ADD_MULTICAST(cmd, fdb_id, cfg) \
29005 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
29006 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs);\
29007 + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_fdb_entry_type, cfg->type);\
29008 + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->mac_addr[5]);\
29009 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->mac_addr[4]);\
29010 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->mac_addr[3]);\
29011 + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->mac_addr[2]);\
29012 + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->mac_addr[1]);\
29013 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->mac_addr[0]);\
29016 +/* cmd, param, offset, width, type, arg_name */
29017 +#define DPSW_CMD_FDB_GET_MULTICAST(cmd, fdb_id) \
29019 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
29020 + MC_CMD_OP(cmd, 0, 16, 8, uint8_t, cfg->mac_addr[5]);\
29021 + MC_CMD_OP(cmd, 0, 24, 8, uint8_t, cfg->mac_addr[4]);\
29022 + MC_CMD_OP(cmd, 0, 32, 8, uint8_t, cfg->mac_addr[3]);\
29023 + MC_CMD_OP(cmd, 0, 40, 8, uint8_t, cfg->mac_addr[2]);\
29024 + MC_CMD_OP(cmd, 0, 48, 8, uint8_t, cfg->mac_addr[1]);\
29025 + MC_CMD_OP(cmd, 0, 56, 8, uint8_t, cfg->mac_addr[0]);\
29028 +/* cmd, param, offset, width, type, arg_name */
29029 +#define DPSW_RSP_FDB_GET_MULTICAST(cmd, cfg) \
29031 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, cfg->num_ifs);\
29032 + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_entry_type, cfg->type);\
29035 +/* cmd, param, offset, width, type, arg_name */
29036 +#define DPSW_CMD_FDB_REMOVE_MULTICAST(cmd, fdb_id, cfg) \
29038 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
29039 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs);\
29040 + MC_CMD_OP(cmd, 0, 32, 4, enum dpsw_fdb_entry_type, cfg->type);\
29041 + MC_CMD_OP(cmd, 1, 0, 8, uint8_t, cfg->mac_addr[5]);\
29042 + MC_CMD_OP(cmd, 1, 8, 8, uint8_t, cfg->mac_addr[4]);\
29043 + MC_CMD_OP(cmd, 1, 16, 8, uint8_t, cfg->mac_addr[3]);\
29044 + MC_CMD_OP(cmd, 1, 24, 8, uint8_t, cfg->mac_addr[2]);\
29045 + MC_CMD_OP(cmd, 1, 32, 8, uint8_t, cfg->mac_addr[1]);\
29046 + MC_CMD_OP(cmd, 1, 40, 8, uint8_t, cfg->mac_addr[0]);\
29049 +/* cmd, param, offset, width, type, arg_name */
29050 +#define DPSW_CMD_FDB_SET_LEARNING_MODE(cmd, fdb_id, mode) \
29052 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id);\
29053 + MC_CMD_OP(cmd, 0, 16, 4, enum dpsw_fdb_learning_mode, mode);\
29056 +/* cmd, param, offset, width, type, arg_name */
29057 +#define DPSW_CMD_FDB_GET_ATTR(cmd, fdb_id) \
29058 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, fdb_id)
29060 +/* cmd, param, offset, width, type, arg_name */
29061 +#define DPSW_RSP_FDB_GET_ATTR(cmd, attr) \
29063 + MC_RSP_OP(cmd, 0, 16, 16, uint16_t, attr->max_fdb_entries);\
29064 + MC_RSP_OP(cmd, 0, 32, 16, uint16_t, attr->fdb_aging_time);\
29065 + MC_RSP_OP(cmd, 0, 48, 16, uint16_t, attr->num_fdb_mc_groups);\
29066 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->max_fdb_mc_groups);\
29067 + MC_RSP_OP(cmd, 1, 16, 4, enum dpsw_fdb_learning_mode, \
29068 + attr->learning_mode);\
29071 +/* cmd, param, offset, width, type, arg_name */
29072 +#define DPSW_CMD_ACL_ADD(cmd, cfg) \
29073 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->max_entries)
29075 +/* cmd, param, offset, width, type, arg_name */
29076 +#define DPSW_RSP_ACL_ADD(cmd, acl_id) \
29077 + MC_RSP_OP(cmd, 0, 0, 16, uint16_t, acl_id)
29079 +/* cmd, param, offset, width, type, arg_name */
29080 +#define DPSW_CMD_ACL_REMOVE(cmd, acl_id) \
29081 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id)
29083 +/* cmd, param, offset, width, type, arg_name */
29084 +#define DPSW_PREP_ACL_ENTRY(ext, key) \
29086 + MC_PREP_OP(ext, 0, 0, 8, uint8_t, key->match.l2_dest_mac[5]);\
29087 + MC_PREP_OP(ext, 0, 8, 8, uint8_t, key->match.l2_dest_mac[4]);\
29088 + MC_PREP_OP(ext, 0, 16, 8, uint8_t, key->match.l2_dest_mac[3]);\
29089 + MC_PREP_OP(ext, 0, 24, 8, uint8_t, key->match.l2_dest_mac[2]);\
29090 + MC_PREP_OP(ext, 0, 32, 8, uint8_t, key->match.l2_dest_mac[1]);\
29091 + MC_PREP_OP(ext, 0, 40, 8, uint8_t, key->match.l2_dest_mac[0]);\
29092 + MC_PREP_OP(ext, 0, 48, 16, uint16_t, key->match.l2_tpid);\
29093 + MC_PREP_OP(ext, 1, 0, 8, uint8_t, key->match.l2_source_mac[5]);\
29094 + MC_PREP_OP(ext, 1, 8, 8, uint8_t, key->match.l2_source_mac[4]);\
29095 + MC_PREP_OP(ext, 1, 16, 8, uint8_t, key->match.l2_source_mac[3]);\
29096 + MC_PREP_OP(ext, 1, 24, 8, uint8_t, key->match.l2_source_mac[2]);\
29097 + MC_PREP_OP(ext, 1, 32, 8, uint8_t, key->match.l2_source_mac[1]);\
29098 + MC_PREP_OP(ext, 1, 40, 8, uint8_t, key->match.l2_source_mac[0]);\
29099 + MC_PREP_OP(ext, 1, 48, 16, uint16_t, key->match.l2_vlan_id);\
29100 + MC_PREP_OP(ext, 2, 0, 32, uint32_t, key->match.l3_dest_ip);\
29101 + MC_PREP_OP(ext, 2, 32, 32, uint32_t, key->match.l3_source_ip);\
29102 + MC_PREP_OP(ext, 3, 0, 16, uint16_t, key->match.l4_dest_port);\
29103 + MC_PREP_OP(ext, 3, 16, 16, uint16_t, key->match.l4_source_port);\
29104 + MC_PREP_OP(ext, 3, 32, 16, uint16_t, key->match.l2_ether_type);\
29105 + MC_PREP_OP(ext, 3, 48, 8, uint8_t, key->match.l2_pcp_dei);\
29106 + MC_PREP_OP(ext, 3, 56, 8, uint8_t, key->match.l3_dscp);\
29107 + MC_PREP_OP(ext, 4, 0, 8, uint8_t, key->mask.l2_dest_mac[5]);\
29108 + MC_PREP_OP(ext, 4, 8, 8, uint8_t, key->mask.l2_dest_mac[4]);\
29109 + MC_PREP_OP(ext, 4, 16, 8, uint8_t, key->mask.l2_dest_mac[3]);\
29110 + MC_PREP_OP(ext, 4, 24, 8, uint8_t, key->mask.l2_dest_mac[2]);\
29111 + MC_PREP_OP(ext, 4, 32, 8, uint8_t, key->mask.l2_dest_mac[1]);\
29112 + MC_PREP_OP(ext, 4, 40, 8, uint8_t, key->mask.l2_dest_mac[0]);\
29113 + MC_PREP_OP(ext, 4, 48, 16, uint16_t, key->mask.l2_tpid);\
29114 + MC_PREP_OP(ext, 5, 0, 8, uint8_t, key->mask.l2_source_mac[5]);\
29115 + MC_PREP_OP(ext, 5, 8, 8, uint8_t, key->mask.l2_source_mac[4]);\
29116 + MC_PREP_OP(ext, 5, 16, 8, uint8_t, key->mask.l2_source_mac[3]);\
29117 + MC_PREP_OP(ext, 5, 24, 8, uint8_t, key->mask.l2_source_mac[2]);\
29118 + MC_PREP_OP(ext, 5, 32, 8, uint8_t, key->mask.l2_source_mac[1]);\
29119 + MC_PREP_OP(ext, 5, 40, 8, uint8_t, key->mask.l2_source_mac[0]);\
29120 + MC_PREP_OP(ext, 5, 48, 16, uint16_t, key->mask.l2_vlan_id);\
29121 + MC_PREP_OP(ext, 6, 0, 32, uint32_t, key->mask.l3_dest_ip);\
29122 + MC_PREP_OP(ext, 6, 32, 32, uint32_t, key->mask.l3_source_ip);\
29123 + MC_PREP_OP(ext, 7, 0, 16, uint16_t, key->mask.l4_dest_port);\
29124 + MC_PREP_OP(ext, 7, 16, 16, uint16_t, key->mask.l4_source_port);\
29125 + MC_PREP_OP(ext, 7, 32, 16, uint16_t, key->mask.l2_ether_type);\
29126 + MC_PREP_OP(ext, 7, 48, 8, uint8_t, key->mask.l2_pcp_dei);\
29127 + MC_PREP_OP(ext, 7, 56, 8, uint8_t, key->mask.l3_dscp);\
29128 + MC_PREP_OP(ext, 8, 0, 8, uint8_t, key->match.l3_protocol);\
29129 + MC_PREP_OP(ext, 8, 8, 8, uint8_t, key->mask.l3_protocol);\
29132 +/* cmd, param, offset, width, type, arg_name */
29133 +#define DPSW_EXT_ACL_ENTRY(ext, key) \
29135 + MC_EXT_OP(ext, 0, 0, 8, uint8_t, key->match.l2_dest_mac[5]);\
29136 + MC_EXT_OP(ext, 0, 8, 8, uint8_t, key->match.l2_dest_mac[4]);\
29137 + MC_EXT_OP(ext, 0, 16, 8, uint8_t, key->match.l2_dest_mac[3]);\
29138 + MC_EXT_OP(ext, 0, 24, 8, uint8_t, key->match.l2_dest_mac[2]);\
29139 + MC_EXT_OP(ext, 0, 32, 8, uint8_t, key->match.l2_dest_mac[1]);\
29140 + MC_EXT_OP(ext, 0, 40, 8, uint8_t, key->match.l2_dest_mac[0]);\
29141 + MC_EXT_OP(ext, 0, 48, 16, uint16_t, key->match.l2_tpid);\
29142 + MC_EXT_OP(ext, 1, 0, 8, uint8_t, key->match.l2_source_mac[5]);\
29143 + MC_EXT_OP(ext, 1, 8, 8, uint8_t, key->match.l2_source_mac[4]);\
29144 + MC_EXT_OP(ext, 1, 16, 8, uint8_t, key->match.l2_source_mac[3]);\
29145 + MC_EXT_OP(ext, 1, 24, 8, uint8_t, key->match.l2_source_mac[2]);\
29146 + MC_EXT_OP(ext, 1, 32, 8, uint8_t, key->match.l2_source_mac[1]);\
29147 + MC_EXT_OP(ext, 1, 40, 8, uint8_t, key->match.l2_source_mac[0]);\
29148 + MC_EXT_OP(ext, 1, 48, 16, uint16_t, key->match.l2_vlan_id);\
29149 + MC_EXT_OP(ext, 2, 0, 32, uint32_t, key->match.l3_dest_ip);\
29150 + MC_EXT_OP(ext, 2, 32, 32, uint32_t, key->match.l3_source_ip);\
29151 + MC_EXT_OP(ext, 3, 0, 16, uint16_t, key->match.l4_dest_port);\
29152 + MC_EXT_OP(ext, 3, 16, 16, uint16_t, key->match.l4_source_port);\
29153 + MC_EXT_OP(ext, 3, 32, 16, uint16_t, key->match.l2_ether_type);\
29154 + MC_EXT_OP(ext, 3, 48, 8, uint8_t, key->match.l2_pcp_dei);\
29155 + MC_EXT_OP(ext, 3, 56, 8, uint8_t, key->match.l3_dscp);\
29156 + MC_EXT_OP(ext, 4, 0, 8, uint8_t, key->mask.l2_dest_mac[5]);\
29157 + MC_EXT_OP(ext, 4, 8, 8, uint8_t, key->mask.l2_dest_mac[4]);\
29158 + MC_EXT_OP(ext, 4, 16, 8, uint8_t, key->mask.l2_dest_mac[3]);\
29159 + MC_EXT_OP(ext, 4, 24, 8, uint8_t, key->mask.l2_dest_mac[2]);\
29160 + MC_EXT_OP(ext, 4, 32, 8, uint8_t, key->mask.l2_dest_mac[1]);\
29161 + MC_EXT_OP(ext, 4, 40, 8, uint8_t, key->mask.l2_dest_mac[0]);\
29162 + MC_EXT_OP(ext, 4, 48, 16, uint16_t, key->mask.l2_tpid);\
29163 + MC_EXT_OP(ext, 5, 0, 8, uint8_t, key->mask.l2_source_mac[5]);\
29164 + MC_EXT_OP(ext, 5, 8, 8, uint8_t, key->mask.l2_source_mac[4]);\
29165 + MC_EXT_OP(ext, 5, 16, 8, uint8_t, key->mask.l2_source_mac[3]);\
29166 + MC_EXT_OP(ext, 5, 24, 8, uint8_t, key->mask.l2_source_mac[2]);\
29167 + MC_EXT_OP(ext, 5, 32, 8, uint8_t, key->mask.l2_source_mac[1]);\
29168 + MC_EXT_OP(ext, 5, 40, 8, uint8_t, key->mask.l2_source_mac[0]);\
29169 + MC_EXT_OP(ext, 5, 48, 16, uint16_t, key->mask.l2_vlan_id);\
29170 + MC_EXT_OP(ext, 6, 0, 32, uint32_t, key->mask.l3_dest_ip);\
29171 + MC_EXT_OP(ext, 6, 32, 32, uint32_t, key->mask.l3_source_ip);\
29172 + MC_EXT_OP(ext, 7, 0, 16, uint16_t, key->mask.l4_dest_port);\
29173 + MC_EXT_OP(ext, 7, 16, 16, uint16_t, key->mask.l4_source_port);\
29174 + MC_EXT_OP(ext, 7, 32, 16, uint16_t, key->mask.l2_ether_type);\
29175 + MC_EXT_OP(ext, 7, 48, 8, uint8_t, key->mask.l2_pcp_dei);\
29176 + MC_EXT_OP(ext, 7, 56, 8, uint8_t, key->mask.l3_dscp);\
29177 + MC_EXT_OP(ext, 8, 0, 8, uint8_t, key->match.l3_protocol);\
29178 + MC_EXT_OP(ext, 8, 8, 8, uint8_t, key->mask.l3_protocol);\
29181 +/* cmd, param, offset, width, type, arg_name */
29182 +#define DPSW_CMD_ACL_ADD_ENTRY(cmd, acl_id, cfg) \
29184 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
29185 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->result.if_id);\
29186 + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->precedence);\
29187 + MC_CMD_OP(cmd, 1, 0, 4, enum dpsw_acl_action, cfg->result.action);\
29188 + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_iova); \
29191 +/* cmd, param, offset, width, type, arg_name */
29192 +#define DPSW_CMD_ACL_REMOVE_ENTRY(cmd, acl_id, cfg) \
29194 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
29195 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->result.if_id);\
29196 + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->precedence);\
29197 + MC_CMD_OP(cmd, 1, 0, 4, enum dpsw_acl_action, cfg->result.action);\
29198 + MC_CMD_OP(cmd, 6, 0, 64, uint64_t, cfg->key_iova); \
29201 +/* cmd, param, offset, width, type, arg_name */
29202 +#define DPSW_CMD_ACL_ADD_IF(cmd, acl_id, cfg) \
29204 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
29205 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs); \
29208 +/* cmd, param, offset, width, type, arg_name */
29209 +#define DPSW_CMD_ACL_REMOVE_IF(cmd, acl_id, cfg) \
29211 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id);\
29212 + MC_CMD_OP(cmd, 0, 16, 16, uint16_t, cfg->num_ifs); \
29215 +/* cmd, param, offset, width, type, arg_name */
29216 +#define DPSW_CMD_ACL_GET_ATTR(cmd, acl_id) \
29217 + MC_CMD_OP(cmd, 0, 0, 16, uint16_t, acl_id)
29219 +/* cmd, param, offset, width, type, arg_name */
29220 +#define DPSW_RSP_ACL_GET_ATTR(cmd, attr) \
29222 + MC_RSP_OP(cmd, 1, 0, 16, uint16_t, attr->max_entries);\
29223 + MC_RSP_OP(cmd, 1, 16, 16, uint16_t, attr->num_entries);\
29224 + MC_RSP_OP(cmd, 1, 32, 16, uint16_t, attr->num_ifs);\
29227 +/* cmd, param, offset, width, type, arg_name */
29228 +#define DPSW_RSP_CTRL_IF_GET_ATTR(cmd, attr) \
29230 + MC_RSP_OP(cmd, 1, 0, 32, uint32_t, attr->rx_fqid);\
29231 + MC_RSP_OP(cmd, 1, 32, 32, uint32_t, attr->rx_err_fqid);\
29232 + MC_RSP_OP(cmd, 2, 0, 32, uint32_t, attr->tx_err_conf_fqid);\
29235 +/* cmd, param, offset, width, type, arg_name */
29236 +#define DPSW_CMD_CTRL_IF_SET_POOLS(cmd, cfg) \
29238 + MC_CMD_OP(cmd, 0, 0, 8, uint8_t, cfg->num_dpbp); \
29239 + MC_CMD_OP(cmd, 0, 8, 1, int, cfg->pools[0].backup_pool); \
29240 + MC_CMD_OP(cmd, 0, 9, 1, int, cfg->pools[1].backup_pool); \
29241 + MC_CMD_OP(cmd, 0, 10, 1, int, cfg->pools[2].backup_pool); \
29242 + MC_CMD_OP(cmd, 0, 11, 1, int, cfg->pools[3].backup_pool); \
29243 + MC_CMD_OP(cmd, 0, 12, 1, int, cfg->pools[4].backup_pool); \
29244 + MC_CMD_OP(cmd, 0, 13, 1, int, cfg->pools[5].backup_pool); \
29245 + MC_CMD_OP(cmd, 0, 14, 1, int, cfg->pools[6].backup_pool); \
29246 + MC_CMD_OP(cmd, 0, 15, 1, int, cfg->pools[7].backup_pool); \
29247 + MC_CMD_OP(cmd, 0, 32, 32, int, cfg->pools[0].dpbp_id); \
29248 + MC_CMD_OP(cmd, 4, 32, 16, uint16_t, cfg->pools[0].buffer_size);\
29249 + MC_CMD_OP(cmd, 1, 0, 32, int, cfg->pools[1].dpbp_id); \
29250 + MC_CMD_OP(cmd, 4, 48, 16, uint16_t, cfg->pools[1].buffer_size);\
29251 + MC_CMD_OP(cmd, 1, 32, 32, int, cfg->pools[2].dpbp_id); \
29252 + MC_CMD_OP(cmd, 5, 0, 16, uint16_t, cfg->pools[2].buffer_size);\
29253 + MC_CMD_OP(cmd, 2, 0, 32, int, cfg->pools[3].dpbp_id); \
29254 + MC_CMD_OP(cmd, 5, 16, 16, uint16_t, cfg->pools[3].buffer_size);\
29255 + MC_CMD_OP(cmd, 2, 32, 32, int, cfg->pools[4].dpbp_id); \
29256 + MC_CMD_OP(cmd, 5, 32, 16, uint16_t, cfg->pools[4].buffer_size);\
29257 + MC_CMD_OP(cmd, 3, 0, 32, int, cfg->pools[5].dpbp_id); \
29258 + MC_CMD_OP(cmd, 5, 48, 16, uint16_t, cfg->pools[5].buffer_size);\
29259 + MC_CMD_OP(cmd, 3, 32, 32, int, cfg->pools[6].dpbp_id); \
29260 + MC_CMD_OP(cmd, 6, 0, 16, uint16_t, cfg->pools[6].buffer_size);\
29261 + MC_CMD_OP(cmd, 4, 0, 32, int, cfg->pools[7].dpbp_id); \
29262 + MC_CMD_OP(cmd, 6, 16, 16, uint16_t, cfg->pools[7].buffer_size);\
29265 +#endif /* __FSL_DPSW_CMD_H */
29266 diff --git a/drivers/net/dpaa2/mc/fsl_mc_cmd.h b/drivers/net/dpaa2/mc/fsl_mc_cmd.h
29267 new file mode 100644
29268 index 0000000..ca4fb64
29270 +++ b/drivers/net/dpaa2/mc/fsl_mc_cmd.h
29272 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
29274 + * Redistribution and use in source and binary forms, with or without
29275 + * modification, are permitted provided that the following conditions are met:
29276 + * * Redistributions of source code must retain the above copyright
29277 + * notice, this list of conditions and the following disclaimer.
29278 + * * Redistributions in binary form must reproduce the above copyright
29279 + * notice, this list of conditions and the following disclaimer in the
29280 + * documentation and/or other materials provided with the distribution.
29281 + * * Neither the name of the above-listed copyright holders nor the
29282 + * names of any contributors may be used to endorse or promote products
29283 + * derived from this software without specific prior written permission.
29286 + * ALTERNATIVELY, this software may be distributed under the terms of the
29287 + * GNU General Public License ("GPL") as published by the Free Software
29288 + * Foundation, either version 2 of that License or (at your option) any
29291 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29292 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29293 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29294 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
29295 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29296 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29297 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29298 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29299 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29300 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29301 + * POSSIBILITY OF SUCH DAMAGE.
29303 +#ifndef __FSL_MC_CMD_H
29304 +#define __FSL_MC_CMD_H
29306 +#define MC_CMD_NUM_OF_PARAMS 7
29308 +#define MAKE_UMASK64(_width) \
29309 + ((uint64_t)((_width) < 64 ? ((uint64_t)1 << (_width)) - 1 :\
29311 +static inline uint64_t mc_enc(int lsoffset, int width, uint64_t val)
29313 + return (uint64_t)(((uint64_t)val & MAKE_UMASK64(width)) << lsoffset);
29316 +static inline uint64_t mc_dec(uint64_t val, int lsoffset, int width)
29318 + return (uint64_t)((val >> lsoffset) & MAKE_UMASK64(width));
29321 +struct mc_command {
29323 + uint64_t params[MC_CMD_NUM_OF_PARAMS];
29327 + * enum mc_cmd_status - indicates MC status at command response
29328 + * @MC_CMD_STATUS_OK: Completed successfully
29329 + * @MC_CMD_STATUS_READY: Ready to be processed
29330 + * @MC_CMD_STATUS_AUTH_ERR: Authentication error
29331 + * @MC_CMD_STATUS_NO_PRIVILEGE: No privilege
29332 + * @MC_CMD_STATUS_DMA_ERR: DMA or I/O error
29333 + * @MC_CMD_STATUS_CONFIG_ERR: Configuration error
29334 + * @MC_CMD_STATUS_TIMEOUT: Operation timed out
29335 + * @MC_CMD_STATUS_NO_RESOURCE: No resources
29336 + * @MC_CMD_STATUS_NO_MEMORY: No memory available
29337 + * @MC_CMD_STATUS_BUSY: Device is busy
29338 + * @MC_CMD_STATUS_UNSUPPORTED_OP: Unsupported operation
29339 + * @MC_CMD_STATUS_INVALID_STATE: Invalid state
29341 +enum mc_cmd_status {
29342 + MC_CMD_STATUS_OK = 0x0,
29343 + MC_CMD_STATUS_READY = 0x1,
29344 + MC_CMD_STATUS_AUTH_ERR = 0x3,
29345 + MC_CMD_STATUS_NO_PRIVILEGE = 0x4,
29346 + MC_CMD_STATUS_DMA_ERR = 0x5,
29347 + MC_CMD_STATUS_CONFIG_ERR = 0x6,
29348 + MC_CMD_STATUS_TIMEOUT = 0x7,
29349 + MC_CMD_STATUS_NO_RESOURCE = 0x8,
29350 + MC_CMD_STATUS_NO_MEMORY = 0x9,
29351 + MC_CMD_STATUS_BUSY = 0xA,
29352 + MC_CMD_STATUS_UNSUPPORTED_OP = 0xB,
29353 + MC_CMD_STATUS_INVALID_STATE = 0xC
29356 +/* MC command flags */
29359 + * High priority flag
29361 +#define MC_CMD_FLAG_PRI 0x00008000
29363 + * Command completion flag
29365 +#define MC_CMD_FLAG_INTR_DIS 0x01000000
29368 + * Command ID field offset
29370 +#define MC_CMD_HDR_CMDID_O 52
29372 + * Command ID field size
29374 +#define MC_CMD_HDR_CMDID_S 12
29376 + * Token field offset
29378 +#define MC_CMD_HDR_TOKEN_O 38
29380 + * Token field size
29382 +#define MC_CMD_HDR_TOKEN_S 10
29384 + * Status field offset
29386 +#define MC_CMD_HDR_STATUS_O 16
29388 + * Status field size
29390 +#define MC_CMD_HDR_STATUS_S 8
29392 + * Flags field offset
29394 +#define MC_CMD_HDR_FLAGS_O 0
29396 + * Flags field size
29398 +#define MC_CMD_HDR_FLAGS_S 32
29400 + * Command flags mask
29402 +#define MC_CMD_HDR_FLAGS_MASK 0xFF00FF00
29404 +#define MC_CMD_HDR_READ_STATUS(_hdr) \
29405 + ((enum mc_cmd_status)mc_dec((_hdr), \
29406 + MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S))
29408 +#define MC_CMD_HDR_READ_TOKEN(_hdr) \
29409 + ((uint16_t)mc_dec((_hdr), MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S))
29411 +#define MC_PREP_OP(_ext, _param, _offset, _width, _type, _arg) \
29412 + ((_ext)[_param] |= cpu_to_le64(mc_enc((_offset), (_width), _arg)))
29414 +#define MC_EXT_OP(_ext, _param, _offset, _width, _type, _arg) \
29415 + (_arg = (_type)mc_dec(cpu_to_le64(_ext[_param]), (_offset), (_width)))
29417 +#define MC_CMD_OP(_cmd, _param, _offset, _width, _type, _arg) \
29418 + ((_cmd).params[_param] |= mc_enc((_offset), (_width), _arg))
29420 +#define MC_RSP_OP(_cmd, _param, _offset, _width, _type, _arg) \
29421 + (_arg = (_type)mc_dec(_cmd.params[_param], (_offset), (_width)))
29423 +static inline uint64_t mc_encode_cmd_header(uint16_t cmd_id,
29424 + uint32_t cmd_flags,
29429 + hdr = mc_enc(MC_CMD_HDR_CMDID_O, MC_CMD_HDR_CMDID_S, cmd_id);
29430 + hdr |= mc_enc(MC_CMD_HDR_FLAGS_O, MC_CMD_HDR_FLAGS_S,
29431 + (cmd_flags & MC_CMD_HDR_FLAGS_MASK));
29432 + hdr |= mc_enc(MC_CMD_HDR_TOKEN_O, MC_CMD_HDR_TOKEN_S, token);
29433 + hdr |= mc_enc(MC_CMD_HDR_STATUS_O, MC_CMD_HDR_STATUS_S,
29434 + MC_CMD_STATUS_READY);
29440 + * mc_write_command - writes a command to a Management Complex (MC) portal
29442 + * @portal: pointer to an MC portal
29443 + * @cmd: pointer to a filled command
29445 +static inline void mc_write_command(struct mc_command __iomem *portal,
29446 + struct mc_command *cmd)
29451 + /* copy command parameters into the portal */
29452 + for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
29453 + iowrite64(cmd->params[i], &portal->params[i]);
29455 + /* submit the command by writing the header */
29456 + word = (uint32_t)mc_dec(cmd->header, 32, 32);
29457 + iowrite32(word, (((uint32_t *)&portal->header) + 1));
29459 + word = (uint32_t)mc_dec(cmd->header, 0, 32);
29460 + iowrite32(word, (uint32_t *)&portal->header);
29464 + * mc_read_response - reads the response for the last MC command from a
29465 + * Management Complex (MC) portal
29467 + * @portal: pointer to an MC portal
29468 + * @resp: pointer to command response buffer
29470 + * Returns MC_CMD_STATUS_OK on Success; Error code otherwise.
29472 +static inline enum mc_cmd_status mc_read_response(
29473 + struct mc_command __iomem *portal,
29474 + struct mc_command *resp)
29477 + enum mc_cmd_status status;
29479 + /* Copy command response header from MC portal: */
29480 + resp->header = ioread64(&portal->header);
29481 + status = MC_CMD_HDR_READ_STATUS(resp->header);
29482 + if (status != MC_CMD_STATUS_OK)
29485 + /* Copy command response data from MC portal: */
29486 + for (i = 0; i < MC_CMD_NUM_OF_PARAMS; i++)
29487 + resp->params[i] = ioread64(&portal->params[i]);
29492 +#endif /* __FSL_MC_CMD_H */
29493 diff --git a/drivers/net/dpaa2/mc/fsl_mc_sys.h b/drivers/net/dpaa2/mc/fsl_mc_sys.h
29494 new file mode 100644
29495 index 0000000..b9f4244
29497 +++ b/drivers/net/dpaa2/mc/fsl_mc_sys.h
29499 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
29501 + * Redistribution and use in source and binary forms, with or without
29502 + * modification, are permitted provided that the following conditions are met:
29503 + * * Redistributions of source code must retain the above copyright
29504 + * notice, this list of conditions and the following disclaimer.
29505 + * * Redistributions in binary form must reproduce the above copyright
29506 + * notice, this list of conditions and the following disclaimer in the
29507 + * documentation and/or other materials provided with the distribution.
29508 + * * Neither the name of the above-listed copyright holders nor the
29509 + * names of any contributors may be used to endorse or promote products
29510 + * derived from this software without specific prior written permission.
29513 + * ALTERNATIVELY, this software may be distributed under the terms of the
29514 + * GNU General Public License ("GPL") as published by the Free Software
29515 + * Foundation, either version 2 of that License or (at your option) any
29518 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29519 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29520 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29521 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
29522 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29523 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29524 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29525 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29526 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29527 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29528 + * POSSIBILITY OF SUCH DAMAGE.
29530 +#ifndef _FSL_MC_SYS_H
29531 +#define _FSL_MC_SYS_H
29533 +#ifdef __linux_driver__
29535 +#include <linux/errno.h>
29536 +#include <asm/io.h>
29537 +#include <linux/slab.h>
29539 +struct fsl_mc_io {
29544 +#define ENOTSUP 95
29547 +#define ioread64(_p) readq(_p)
29548 +#define iowrite64(_v, _p) writeq(_v, _p)
29550 +#else /* __linux_driver__ */
29552 +#include <stdio.h>
29553 +#include <libio.h>
29554 +#include <stdint.h>
29555 +#include <errno.h>
29556 +#include <sys/uio.h>
29557 +#include <linux/byteorder/little_endian.h>
29559 +#define cpu_to_le64(x) __cpu_to_le64(x)
29561 +#define dmb() do {\
29562 + __asm__ __volatile__ ("" : : : "memory");\
29566 +#define __iormb() dmb()
29567 +#define __iowmb() dmb()
29568 +#define __arch_getq(a) (*(volatile unsigned long *)(a))
29569 +#define __arch_putq(v, a) (*(volatile unsigned long *)(a) = (v))
29570 +#define __arch_putq32(v, a) (*(volatile unsigned int *)(a) = (v))
29571 +#define readq(c) ({ uint64_t __v = __arch_getq(c); __iormb(); __v; })
29572 +#define writeq(v, c) ({ uint64_t __v = v; __iowmb(); __arch_putq(__v, c); __v; })
29573 +#define writeq32(v, c) ({ uint32_t __v = v; __iowmb(); __arch_putq32(__v, c); __v; })
29574 +#define ioread64(_p) readq(_p)
29575 +#define iowrite64(_v, _p) writeq(_v, _p)
29576 +#define iowrite32(_v, _p) writeq32(_v, _p)
29579 +struct fsl_mc_io {
29584 +#define ENOTSUP 95
29587 +/*GPP is supposed to use MC commands with low priority*/
29588 +#define CMD_PRI_LOW 0 /*!< Low Priority command indication */
29590 +struct mc_command;
29592 +int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd);
29594 +#endif /* __linux_driver__ */
29596 +#endif /* _FSL_MC_SYS_H */
29597 diff --git a/drivers/net/dpaa2/mc/fsl_net.h b/drivers/net/dpaa2/mc/fsl_net.h
29598 new file mode 100644
29599 index 0000000..43825b8
29601 +++ b/drivers/net/dpaa2/mc/fsl_net.h
29603 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
29605 + * Redistribution and use in source and binary forms, with or without
29606 + * modification, are permitted provided that the following conditions are met:
29607 + * * Redistributions of source code must retain the above copyright
29608 + * notice, this list of conditions and the following disclaimer.
29609 + * * Redistributions in binary form must reproduce the above copyright
29610 + * notice, this list of conditions and the following disclaimer in the
29611 + * documentation and/or other materials provided with the distribution.
29612 + * * Neither the name of the above-listed copyright holders nor the
29613 + * names of any contributors may be used to endorse or promote products
29614 + * derived from this software without specific prior written permission.
29617 + * ALTERNATIVELY, this software may be distributed under the terms of the
29618 + * GNU General Public License ("GPL") as published by the Free Software
29619 + * Foundation, either version 2 of that License or (at your option) any
29622 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29623 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29624 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29625 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
29626 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29627 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29628 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29629 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29630 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29631 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29632 + * POSSIBILITY OF SUCH DAMAGE.
29634 +#ifndef __FSL_NET_H
29635 +#define __FSL_NET_H
29637 +#define LAST_HDR_INDEX 0xFFFFFFFF
29639 +/*****************************************************************************/
29640 +/* Protocol fields */
29641 +/*****************************************************************************/
29643 +/************************* Ethernet fields *********************************/
29644 +#define NH_FLD_ETH_DA (1)
29645 +#define NH_FLD_ETH_SA (NH_FLD_ETH_DA << 1)
29646 +#define NH_FLD_ETH_LENGTH (NH_FLD_ETH_DA << 2)
29647 +#define NH_FLD_ETH_TYPE (NH_FLD_ETH_DA << 3)
29648 +#define NH_FLD_ETH_FINAL_CKSUM (NH_FLD_ETH_DA << 4)
29649 +#define NH_FLD_ETH_PADDING (NH_FLD_ETH_DA << 5)
29650 +#define NH_FLD_ETH_ALL_FIELDS ((NH_FLD_ETH_DA << 6) - 1)
29652 +#define NH_FLD_ETH_ADDR_SIZE 6
29654 +/*************************** VLAN fields ***********************************/
29655 +#define NH_FLD_VLAN_VPRI (1)
29656 +#define NH_FLD_VLAN_CFI (NH_FLD_VLAN_VPRI << 1)
29657 +#define NH_FLD_VLAN_VID (NH_FLD_VLAN_VPRI << 2)
29658 +#define NH_FLD_VLAN_LENGTH (NH_FLD_VLAN_VPRI << 3)
29659 +#define NH_FLD_VLAN_TYPE (NH_FLD_VLAN_VPRI << 4)
29660 +#define NH_FLD_VLAN_ALL_FIELDS ((NH_FLD_VLAN_VPRI << 5) - 1)
29662 +#define NH_FLD_VLAN_TCI (NH_FLD_VLAN_VPRI | \
29663 + NH_FLD_VLAN_CFI | \
29666 +/************************ IP (generic) fields ******************************/
29667 +#define NH_FLD_IP_VER (1)
29668 +#define NH_FLD_IP_DSCP (NH_FLD_IP_VER << 2)
29669 +#define NH_FLD_IP_ECN (NH_FLD_IP_VER << 3)
29670 +#define NH_FLD_IP_PROTO (NH_FLD_IP_VER << 4)
29671 +#define NH_FLD_IP_SRC (NH_FLD_IP_VER << 5)
29672 +#define NH_FLD_IP_DST (NH_FLD_IP_VER << 6)
29673 +#define NH_FLD_IP_TOS_TC (NH_FLD_IP_VER << 7)
29674 +#define NH_FLD_IP_ID (NH_FLD_IP_VER << 8)
29675 +#define NH_FLD_IP_ALL_FIELDS ((NH_FLD_IP_VER << 9) - 1)
29677 +#define NH_FLD_IP_PROTO_SIZE 1
29679 +/***************************** IPV4 fields *********************************/
29680 +#define NH_FLD_IPV4_VER (1)
29681 +#define NH_FLD_IPV4_HDR_LEN (NH_FLD_IPV4_VER << 1)
29682 +#define NH_FLD_IPV4_TOS (NH_FLD_IPV4_VER << 2)
29683 +#define NH_FLD_IPV4_TOTAL_LEN (NH_FLD_IPV4_VER << 3)
29684 +#define NH_FLD_IPV4_ID (NH_FLD_IPV4_VER << 4)
29685 +#define NH_FLD_IPV4_FLAG_D (NH_FLD_IPV4_VER << 5)
29686 +#define NH_FLD_IPV4_FLAG_M (NH_FLD_IPV4_VER << 6)
29687 +#define NH_FLD_IPV4_OFFSET (NH_FLD_IPV4_VER << 7)
29688 +#define NH_FLD_IPV4_TTL (NH_FLD_IPV4_VER << 8)
29689 +#define NH_FLD_IPV4_PROTO (NH_FLD_IPV4_VER << 9)
29690 +#define NH_FLD_IPV4_CKSUM (NH_FLD_IPV4_VER << 10)
29691 +#define NH_FLD_IPV4_SRC_IP (NH_FLD_IPV4_VER << 11)
29692 +#define NH_FLD_IPV4_DST_IP (NH_FLD_IPV4_VER << 12)
29693 +#define NH_FLD_IPV4_OPTS (NH_FLD_IPV4_VER << 13)
29694 +#define NH_FLD_IPV4_OPTS_COUNT (NH_FLD_IPV4_VER << 14)
29695 +#define NH_FLD_IPV4_ALL_FIELDS ((NH_FLD_IPV4_VER << 15) - 1)
29697 +#define NH_FLD_IPV4_ADDR_SIZE 4
29698 +#define NH_FLD_IPV4_PROTO_SIZE 1
29700 +/***************************** IPV6 fields *********************************/
29701 +#define NH_FLD_IPV6_VER (1)
29702 +#define NH_FLD_IPV6_TC (NH_FLD_IPV6_VER << 1)
29703 +#define NH_FLD_IPV6_SRC_IP (NH_FLD_IPV6_VER << 2)
29704 +#define NH_FLD_IPV6_DST_IP (NH_FLD_IPV6_VER << 3)
29705 +#define NH_FLD_IPV6_NEXT_HDR (NH_FLD_IPV6_VER << 4)
29706 +#define NH_FLD_IPV6_FL (NH_FLD_IPV6_VER << 5)
29707 +#define NH_FLD_IPV6_HOP_LIMIT (NH_FLD_IPV6_VER << 6)
29708 +#define NH_FLD_IPV6_ID (NH_FLD_IPV6_VER << 7)
29709 +#define NH_FLD_IPV6_ALL_FIELDS ((NH_FLD_IPV6_VER << 8) - 1)
29711 +#define NH_FLD_IPV6_ADDR_SIZE 16
29712 +#define NH_FLD_IPV6_NEXT_HDR_SIZE 1
29714 +/***************************** ICMP fields *********************************/
29715 +#define NH_FLD_ICMP_TYPE (1)
29716 +#define NH_FLD_ICMP_CODE (NH_FLD_ICMP_TYPE << 1)
29717 +#define NH_FLD_ICMP_CKSUM (NH_FLD_ICMP_TYPE << 2)
29718 +#define NH_FLD_ICMP_ID (NH_FLD_ICMP_TYPE << 3)
29719 +#define NH_FLD_ICMP_SQ_NUM (NH_FLD_ICMP_TYPE << 4)
29720 +#define NH_FLD_ICMP_ALL_FIELDS ((NH_FLD_ICMP_TYPE << 5) - 1)
29722 +#define NH_FLD_ICMP_CODE_SIZE 1
29723 +#define NH_FLD_ICMP_TYPE_SIZE 1
29725 +/***************************** IGMP fields *********************************/
29726 +#define NH_FLD_IGMP_VERSION (1)
29727 +#define NH_FLD_IGMP_TYPE (NH_FLD_IGMP_VERSION << 1)
29728 +#define NH_FLD_IGMP_CKSUM (NH_FLD_IGMP_VERSION << 2)
29729 +#define NH_FLD_IGMP_DATA (NH_FLD_IGMP_VERSION << 3)
29730 +#define NH_FLD_IGMP_ALL_FIELDS ((NH_FLD_IGMP_VERSION << 4) - 1)
29732 +/***************************** TCP fields **********************************/
29733 +#define NH_FLD_TCP_PORT_SRC (1)
29734 +#define NH_FLD_TCP_PORT_DST (NH_FLD_TCP_PORT_SRC << 1)
29735 +#define NH_FLD_TCP_SEQ (NH_FLD_TCP_PORT_SRC << 2)
29736 +#define NH_FLD_TCP_ACK (NH_FLD_TCP_PORT_SRC << 3)
29737 +#define NH_FLD_TCP_OFFSET (NH_FLD_TCP_PORT_SRC << 4)
29738 +#define NH_FLD_TCP_FLAGS (NH_FLD_TCP_PORT_SRC << 5)
29739 +#define NH_FLD_TCP_WINDOW (NH_FLD_TCP_PORT_SRC << 6)
29740 +#define NH_FLD_TCP_CKSUM (NH_FLD_TCP_PORT_SRC << 7)
29741 +#define NH_FLD_TCP_URGPTR (NH_FLD_TCP_PORT_SRC << 8)
29742 +#define NH_FLD_TCP_OPTS (NH_FLD_TCP_PORT_SRC << 9)
29743 +#define NH_FLD_TCP_OPTS_COUNT (NH_FLD_TCP_PORT_SRC << 10)
29744 +#define NH_FLD_TCP_ALL_FIELDS ((NH_FLD_TCP_PORT_SRC << 11) - 1)
29746 +#define NH_FLD_TCP_PORT_SIZE 2
29748 +/***************************** UDP fields **********************************/
29749 +#define NH_FLD_UDP_PORT_SRC (1)
29750 +#define NH_FLD_UDP_PORT_DST (NH_FLD_UDP_PORT_SRC << 1)
29751 +#define NH_FLD_UDP_LEN (NH_FLD_UDP_PORT_SRC << 2)
29752 +#define NH_FLD_UDP_CKSUM (NH_FLD_UDP_PORT_SRC << 3)
29753 +#define NH_FLD_UDP_ALL_FIELDS ((NH_FLD_UDP_PORT_SRC << 4) - 1)
29755 +#define NH_FLD_UDP_PORT_SIZE 2
29757 +/*************************** UDP-lite fields *******************************/
29758 +#define NH_FLD_UDP_LITE_PORT_SRC (1)
29759 +#define NH_FLD_UDP_LITE_PORT_DST (NH_FLD_UDP_LITE_PORT_SRC << 1)
29760 +#define NH_FLD_UDP_LITE_ALL_FIELDS \
29761 + ((NH_FLD_UDP_LITE_PORT_SRC << 2) - 1)
29763 +#define NH_FLD_UDP_LITE_PORT_SIZE 2
29765 +/*************************** UDP-encap-ESP fields **************************/
29766 +#define NH_FLD_UDP_ENC_ESP_PORT_SRC (1)
29767 +#define NH_FLD_UDP_ENC_ESP_PORT_DST (NH_FLD_UDP_ENC_ESP_PORT_SRC << 1)
29768 +#define NH_FLD_UDP_ENC_ESP_LEN (NH_FLD_UDP_ENC_ESP_PORT_SRC << 2)
29769 +#define NH_FLD_UDP_ENC_ESP_CKSUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 3)
29770 +#define NH_FLD_UDP_ENC_ESP_SPI (NH_FLD_UDP_ENC_ESP_PORT_SRC << 4)
29771 +#define NH_FLD_UDP_ENC_ESP_SEQUENCE_NUM (NH_FLD_UDP_ENC_ESP_PORT_SRC << 5)
29772 +#define NH_FLD_UDP_ENC_ESP_ALL_FIELDS \
29773 + ((NH_FLD_UDP_ENC_ESP_PORT_SRC << 6) - 1)
29775 +#define NH_FLD_UDP_ENC_ESP_PORT_SIZE 2
29776 +#define NH_FLD_UDP_ENC_ESP_SPI_SIZE 4
29778 +/***************************** SCTP fields *********************************/
29779 +#define NH_FLD_SCTP_PORT_SRC (1)
29780 +#define NH_FLD_SCTP_PORT_DST (NH_FLD_SCTP_PORT_SRC << 1)
29781 +#define NH_FLD_SCTP_VER_TAG (NH_FLD_SCTP_PORT_SRC << 2)
29782 +#define NH_FLD_SCTP_CKSUM (NH_FLD_SCTP_PORT_SRC << 3)
29783 +#define NH_FLD_SCTP_ALL_FIELDS ((NH_FLD_SCTP_PORT_SRC << 4) - 1)
29785 +#define NH_FLD_SCTP_PORT_SIZE 2
29787 +/***************************** DCCP fields *********************************/
29788 +#define NH_FLD_DCCP_PORT_SRC (1)
29789 +#define NH_FLD_DCCP_PORT_DST (NH_FLD_DCCP_PORT_SRC << 1)
29790 +#define NH_FLD_DCCP_ALL_FIELDS ((NH_FLD_DCCP_PORT_SRC << 2) - 1)
29792 +#define NH_FLD_DCCP_PORT_SIZE 2
29794 +/***************************** IPHC fields *********************************/
29795 +#define NH_FLD_IPHC_CID (1)
29796 +#define NH_FLD_IPHC_CID_TYPE (NH_FLD_IPHC_CID << 1)
29797 +#define NH_FLD_IPHC_HCINDEX (NH_FLD_IPHC_CID << 2)
29798 +#define NH_FLD_IPHC_GEN (NH_FLD_IPHC_CID << 3)
29799 +#define NH_FLD_IPHC_D_BIT (NH_FLD_IPHC_CID << 4)
29800 +#define NH_FLD_IPHC_ALL_FIELDS ((NH_FLD_IPHC_CID << 5) - 1)
29802 +/***************************** SCTP fields *********************************/
29803 +#define NH_FLD_SCTP_CHUNK_DATA_TYPE (1)
29804 +#define NH_FLD_SCTP_CHUNK_DATA_FLAGS (NH_FLD_SCTP_CHUNK_DATA_TYPE << 1)
29805 +#define NH_FLD_SCTP_CHUNK_DATA_LENGTH (NH_FLD_SCTP_CHUNK_DATA_TYPE << 2)
29806 +#define NH_FLD_SCTP_CHUNK_DATA_TSN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 3)
29807 +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_ID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 4)
29808 +#define NH_FLD_SCTP_CHUNK_DATA_STREAM_SQN (NH_FLD_SCTP_CHUNK_DATA_TYPE << 5)
29809 +#define NH_FLD_SCTP_CHUNK_DATA_PAYLOAD_PID (NH_FLD_SCTP_CHUNK_DATA_TYPE << 6)
29810 +#define NH_FLD_SCTP_CHUNK_DATA_UNORDERED (NH_FLD_SCTP_CHUNK_DATA_TYPE << 7)
29811 +#define NH_FLD_SCTP_CHUNK_DATA_BEGGINING (NH_FLD_SCTP_CHUNK_DATA_TYPE << 8)
29812 +#define NH_FLD_SCTP_CHUNK_DATA_END (NH_FLD_SCTP_CHUNK_DATA_TYPE << 9)
29813 +#define NH_FLD_SCTP_CHUNK_DATA_ALL_FIELDS \
29814 + ((NH_FLD_SCTP_CHUNK_DATA_TYPE << 10) - 1)
29816 +/*************************** L2TPV2 fields *********************************/
29817 +#define NH_FLD_L2TPV2_TYPE_BIT (1)
29818 +#define NH_FLD_L2TPV2_LENGTH_BIT (NH_FLD_L2TPV2_TYPE_BIT << 1)
29819 +#define NH_FLD_L2TPV2_SEQUENCE_BIT (NH_FLD_L2TPV2_TYPE_BIT << 2)
29820 +#define NH_FLD_L2TPV2_OFFSET_BIT (NH_FLD_L2TPV2_TYPE_BIT << 3)
29821 +#define NH_FLD_L2TPV2_PRIORITY_BIT (NH_FLD_L2TPV2_TYPE_BIT << 4)
29822 +#define NH_FLD_L2TPV2_VERSION (NH_FLD_L2TPV2_TYPE_BIT << 5)
29823 +#define NH_FLD_L2TPV2_LEN (NH_FLD_L2TPV2_TYPE_BIT << 6)
29824 +#define NH_FLD_L2TPV2_TUNNEL_ID (NH_FLD_L2TPV2_TYPE_BIT << 7)
29825 +#define NH_FLD_L2TPV2_SESSION_ID (NH_FLD_L2TPV2_TYPE_BIT << 8)
29826 +#define NH_FLD_L2TPV2_NS (NH_FLD_L2TPV2_TYPE_BIT << 9)
29827 +#define NH_FLD_L2TPV2_NR (NH_FLD_L2TPV2_TYPE_BIT << 10)
29828 +#define NH_FLD_L2TPV2_OFFSET_SIZE (NH_FLD_L2TPV2_TYPE_BIT << 11)
29829 +#define NH_FLD_L2TPV2_FIRST_BYTE (NH_FLD_L2TPV2_TYPE_BIT << 12)
29830 +#define NH_FLD_L2TPV2_ALL_FIELDS \
29831 + ((NH_FLD_L2TPV2_TYPE_BIT << 13) - 1)
29833 +/*************************** L2TPV3 fields *********************************/
29834 +#define NH_FLD_L2TPV3_CTRL_TYPE_BIT (1)
29835 +#define NH_FLD_L2TPV3_CTRL_LENGTH_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 1)
29836 +#define NH_FLD_L2TPV3_CTRL_SEQUENCE_BIT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 2)
29837 +#define NH_FLD_L2TPV3_CTRL_VERSION (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 3)
29838 +#define NH_FLD_L2TPV3_CTRL_LENGTH (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 4)
29839 +#define NH_FLD_L2TPV3_CTRL_CONTROL (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 5)
29840 +#define NH_FLD_L2TPV3_CTRL_SENT (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 6)
29841 +#define NH_FLD_L2TPV3_CTRL_RECV (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 7)
29842 +#define NH_FLD_L2TPV3_CTRL_FIRST_BYTE (NH_FLD_L2TPV3_CTRL_TYPE_BIT << 8)
29843 +#define NH_FLD_L2TPV3_CTRL_ALL_FIELDS \
29844 + ((NH_FLD_L2TPV3_CTRL_TYPE_BIT << 9) - 1)
29846 +#define NH_FLD_L2TPV3_SESS_TYPE_BIT (1)
29847 +#define NH_FLD_L2TPV3_SESS_VERSION (NH_FLD_L2TPV3_SESS_TYPE_BIT << 1)
29848 +#define NH_FLD_L2TPV3_SESS_ID (NH_FLD_L2TPV3_SESS_TYPE_BIT << 2)
29849 +#define NH_FLD_L2TPV3_SESS_COOKIE (NH_FLD_L2TPV3_SESS_TYPE_BIT << 3)
29850 +#define NH_FLD_L2TPV3_SESS_ALL_FIELDS \
29851 + ((NH_FLD_L2TPV3_SESS_TYPE_BIT << 4) - 1)
29853 +/**************************** PPP fields ***********************************/
29854 +#define NH_FLD_PPP_PID (1)
29855 +#define NH_FLD_PPP_COMPRESSED (NH_FLD_PPP_PID << 1)
29856 +#define NH_FLD_PPP_ALL_FIELDS ((NH_FLD_PPP_PID << 2) - 1)
29858 +/************************** PPPoE fields ***********************************/
29859 +#define NH_FLD_PPPOE_VER (1)
29860 +#define NH_FLD_PPPOE_TYPE (NH_FLD_PPPOE_VER << 1)
29861 +#define NH_FLD_PPPOE_CODE (NH_FLD_PPPOE_VER << 2)
29862 +#define NH_FLD_PPPOE_SID (NH_FLD_PPPOE_VER << 3)
29863 +#define NH_FLD_PPPOE_LEN (NH_FLD_PPPOE_VER << 4)
29864 +#define NH_FLD_PPPOE_SESSION (NH_FLD_PPPOE_VER << 5)
29865 +#define NH_FLD_PPPOE_PID (NH_FLD_PPPOE_VER << 6)
29866 +#define NH_FLD_PPPOE_ALL_FIELDS ((NH_FLD_PPPOE_VER << 7) - 1)
29868 +/************************* PPP-Mux fields **********************************/
29869 +#define NH_FLD_PPPMUX_PID (1)
29870 +#define NH_FLD_PPPMUX_CKSUM (NH_FLD_PPPMUX_PID << 1)
29871 +#define NH_FLD_PPPMUX_COMPRESSED (NH_FLD_PPPMUX_PID << 2)
29872 +#define NH_FLD_PPPMUX_ALL_FIELDS ((NH_FLD_PPPMUX_PID << 3) - 1)
29874 +/*********************** PPP-Mux sub-frame fields **************************/
29875 +#define NH_FLD_PPPMUX_SUBFRM_PFF (1)
29876 +#define NH_FLD_PPPMUX_SUBFRM_LXT (NH_FLD_PPPMUX_SUBFRM_PFF << 1)
29877 +#define NH_FLD_PPPMUX_SUBFRM_LEN (NH_FLD_PPPMUX_SUBFRM_PFF << 2)
29878 +#define NH_FLD_PPPMUX_SUBFRM_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 3)
29879 +#define NH_FLD_PPPMUX_SUBFRM_USE_PID (NH_FLD_PPPMUX_SUBFRM_PFF << 4)
29880 +#define NH_FLD_PPPMUX_SUBFRM_ALL_FIELDS \
29881 + ((NH_FLD_PPPMUX_SUBFRM_PFF << 5) - 1)
29883 +/*************************** LLC fields ************************************/
29884 +#define NH_FLD_LLC_DSAP (1)
29885 +#define NH_FLD_LLC_SSAP (NH_FLD_LLC_DSAP << 1)
29886 +#define NH_FLD_LLC_CTRL (NH_FLD_LLC_DSAP << 2)
29887 +#define NH_FLD_LLC_ALL_FIELDS ((NH_FLD_LLC_DSAP << 3) - 1)
29889 +/*************************** NLPID fields **********************************/
29890 +#define NH_FLD_NLPID_NLPID (1)
29891 +#define NH_FLD_NLPID_ALL_FIELDS ((NH_FLD_NLPID_NLPID << 1) - 1)
29893 +/*************************** SNAP fields ***********************************/
29894 +#define NH_FLD_SNAP_OUI (1)
29895 +#define NH_FLD_SNAP_PID (NH_FLD_SNAP_OUI << 1)
29896 +#define NH_FLD_SNAP_ALL_FIELDS ((NH_FLD_SNAP_OUI << 2) - 1)
29898 +/*************************** LLC SNAP fields *******************************/
29899 +#define NH_FLD_LLC_SNAP_TYPE (1)
29900 +#define NH_FLD_LLC_SNAP_ALL_FIELDS ((NH_FLD_LLC_SNAP_TYPE << 1) - 1)
29902 +#define NH_FLD_ARP_HTYPE (1)
29903 +#define NH_FLD_ARP_PTYPE (NH_FLD_ARP_HTYPE << 1)
29904 +#define NH_FLD_ARP_HLEN (NH_FLD_ARP_HTYPE << 2)
29905 +#define NH_FLD_ARP_PLEN (NH_FLD_ARP_HTYPE << 3)
29906 +#define NH_FLD_ARP_OPER (NH_FLD_ARP_HTYPE << 4)
29907 +#define NH_FLD_ARP_SHA (NH_FLD_ARP_HTYPE << 5)
29908 +#define NH_FLD_ARP_SPA (NH_FLD_ARP_HTYPE << 6)
29909 +#define NH_FLD_ARP_THA (NH_FLD_ARP_HTYPE << 7)
29910 +#define NH_FLD_ARP_TPA (NH_FLD_ARP_HTYPE << 8)
29911 +#define NH_FLD_ARP_ALL_FIELDS ((NH_FLD_ARP_HTYPE << 9) - 1)
29913 +/*************************** RFC2684 fields ********************************/
29914 +#define NH_FLD_RFC2684_LLC (1)
29915 +#define NH_FLD_RFC2684_NLPID (NH_FLD_RFC2684_LLC << 1)
29916 +#define NH_FLD_RFC2684_OUI (NH_FLD_RFC2684_LLC << 2)
29917 +#define NH_FLD_RFC2684_PID (NH_FLD_RFC2684_LLC << 3)
29918 +#define NH_FLD_RFC2684_VPN_OUI (NH_FLD_RFC2684_LLC << 4)
29919 +#define NH_FLD_RFC2684_VPN_IDX (NH_FLD_RFC2684_LLC << 5)
29920 +#define NH_FLD_RFC2684_ALL_FIELDS ((NH_FLD_RFC2684_LLC << 6) - 1)
29922 +/*************************** User defined fields ***************************/
29923 +#define NH_FLD_USER_DEFINED_SRCPORT (1)
29924 +#define NH_FLD_USER_DEFINED_PCDID (NH_FLD_USER_DEFINED_SRCPORT << 1)
29925 +#define NH_FLD_USER_DEFINED_ALL_FIELDS \
29926 + ((NH_FLD_USER_DEFINED_SRCPORT << 2) - 1)
29928 +/*************************** Payload fields ********************************/
29929 +#define NH_FLD_PAYLOAD_BUFFER (1)
29930 +#define NH_FLD_PAYLOAD_SIZE (NH_FLD_PAYLOAD_BUFFER << 1)
29931 +#define NH_FLD_MAX_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 2)
29932 +#define NH_FLD_MIN_FRM_SIZE (NH_FLD_PAYLOAD_BUFFER << 3)
29933 +#define NH_FLD_PAYLOAD_TYPE (NH_FLD_PAYLOAD_BUFFER << 4)
29934 +#define NH_FLD_FRAME_SIZE (NH_FLD_PAYLOAD_BUFFER << 5)
29935 +#define NH_FLD_PAYLOAD_ALL_FIELDS ((NH_FLD_PAYLOAD_BUFFER << 6) - 1)
29937 +/*************************** GRE fields ************************************/
29938 +#define NH_FLD_GRE_TYPE (1)
29939 +#define NH_FLD_GRE_ALL_FIELDS ((NH_FLD_GRE_TYPE << 1) - 1)
29941 +/*************************** MINENCAP fields *******************************/
29942 +#define NH_FLD_MINENCAP_SRC_IP (1)
29943 +#define NH_FLD_MINENCAP_DST_IP (NH_FLD_MINENCAP_SRC_IP << 1)
29944 +#define NH_FLD_MINENCAP_TYPE (NH_FLD_MINENCAP_SRC_IP << 2)
29945 +#define NH_FLD_MINENCAP_ALL_FIELDS \
29946 + ((NH_FLD_MINENCAP_SRC_IP << 3) - 1)
29948 +/*************************** IPSEC AH fields *******************************/
29949 +#define NH_FLD_IPSEC_AH_SPI (1)
29950 +#define NH_FLD_IPSEC_AH_NH (NH_FLD_IPSEC_AH_SPI << 1)
29951 +#define NH_FLD_IPSEC_AH_ALL_FIELDS ((NH_FLD_IPSEC_AH_SPI << 2) - 1)
29953 +/*************************** IPSEC ESP fields ******************************/
29954 +#define NH_FLD_IPSEC_ESP_SPI (1)
29955 +#define NH_FLD_IPSEC_ESP_SEQUENCE_NUM (NH_FLD_IPSEC_ESP_SPI << 1)
29956 +#define NH_FLD_IPSEC_ESP_ALL_FIELDS ((NH_FLD_IPSEC_ESP_SPI << 2) - 1)
29958 +#define NH_FLD_IPSEC_ESP_SPI_SIZE 4
29960 +/*************************** MPLS fields ***********************************/
29961 +#define NH_FLD_MPLS_LABEL_STACK (1)
29962 +#define NH_FLD_MPLS_LABEL_STACK_ALL_FIELDS \
29963 + ((NH_FLD_MPLS_LABEL_STACK << 1) - 1)
29965 +/*************************** MACSEC fields *********************************/
29966 +#define NH_FLD_MACSEC_SECTAG (1)
29967 +#define NH_FLD_MACSEC_ALL_FIELDS ((NH_FLD_MACSEC_SECTAG << 1) - 1)
29969 +/*************************** GTP fields ************************************/
29970 +#define NH_FLD_GTP_TEID (1)
29972 +/* Protocol options */
29974 +/* Ethernet options */
29975 +#define NH_OPT_ETH_BROADCAST 1
29976 +#define NH_OPT_ETH_MULTICAST 2
29977 +#define NH_OPT_ETH_UNICAST 3
29978 +#define NH_OPT_ETH_BPDU 4
29980 +#define NH_ETH_IS_MULTICAST_ADDR(addr) (addr[0] & 0x01)
29981 +/* also applicable for broadcast */
29983 +/* VLAN options */
29984 +#define NH_OPT_VLAN_CFI 1
29986 +/* IPV4 options */
29987 +#define NH_OPT_IPV4_UNICAST 1
29988 +#define NH_OPT_IPV4_MULTICAST 2
29989 +#define NH_OPT_IPV4_BROADCAST 3
29990 +#define NH_OPT_IPV4_OPTION 4
29991 +#define NH_OPT_IPV4_FRAG 5
29992 +#define NH_OPT_IPV4_INITIAL_FRAG 6
29994 +/* IPV6 options */
29995 +#define NH_OPT_IPV6_UNICAST 1
29996 +#define NH_OPT_IPV6_MULTICAST 2
29997 +#define NH_OPT_IPV6_OPTION 3
29998 +#define NH_OPT_IPV6_FRAG 4
29999 +#define NH_OPT_IPV6_INITIAL_FRAG 5
30001 +/* General IP options (may be used for any version) */
30002 +#define NH_OPT_IP_FRAG 1
30003 +#define NH_OPT_IP_INITIAL_FRAG 2
30004 +#define NH_OPT_IP_OPTION 3
30006 +/* Minenc. options */
30007 +#define NH_OPT_MINENCAP_SRC_ADDR_PRESENT 1
30009 +/* GRE. options */
30010 +#define NH_OPT_GRE_ROUTING_PRESENT 1
30013 +#define NH_OPT_TCP_OPTIONS 1
30014 +#define NH_OPT_TCP_CONTROL_HIGH_BITS 2
30015 +#define NH_OPT_TCP_CONTROL_LOW_BITS 3
30017 +/* CAPWAP options */
30018 +#define NH_OPT_CAPWAP_DTLS 1
30021 + NET_PROT_NONE = 0,
30022 + NET_PROT_PAYLOAD,
30030 + NET_PROT_UDP_LITE,
30033 + NET_PROT_SCTP_CHUNK_DATA,
30037 + NET_PROT_PPPMUX_SUBFRM,
30039 + NET_PROT_L2TPV3_CTRL,
30040 + NET_PROT_L2TPV3_SESS,
30042 + NET_PROT_LLC_SNAP,
30046 + NET_PROT_IPSEC_AH,
30047 + NET_PROT_IPSEC_ESP,
30048 + NET_PROT_UDP_ENC_ESP, /* RFC 3948 */
30051 + NET_PROT_MINENCAP,
30056 + NET_PROT_CAPWAP_DATA,
30057 + NET_PROT_CAPWAP_CTRL,
30058 + NET_PROT_RFC2684,
30064 + NET_PROT_USER_DEFINED_L2,
30065 + NET_PROT_USER_DEFINED_L3,
30066 + NET_PROT_USER_DEFINED_L4,
30067 + NET_PROT_USER_DEFINED_L5,
30068 + NET_PROT_USER_DEFINED_SHIM1,
30069 + NET_PROT_USER_DEFINED_SHIM2,
30071 + NET_PROT_DUMMY_LAST
30075 +#define NH_IEEE8021Q_ETYPE 0x8100
30076 +#define NH_IEEE8021Q_HDR(etype, pcp, dei, vlan_id) \
30077 + ((((uint32_t)(etype & 0xFFFF)) << 16) | \
30078 + (((uint32_t)(pcp & 0x07)) << 13) | \
30079 + (((uint32_t)(dei & 0x01)) << 12) | \
30080 + (((uint32_t)(vlan_id & 0xFFF))))
30082 +#endif /* __FSL_NET_H */
30083 diff --git a/drivers/net/dpaa2/mc/mc_sys.c b/drivers/net/dpaa2/mc/mc_sys.c
30084 new file mode 100644
30085 index 0000000..fcbed28
30087 +++ b/drivers/net/dpaa2/mc/mc_sys.c
30089 +/* Copyright 2013-2015 Freescale Semiconductor Inc.
30091 + * Redistribution and use in source and binary forms, with or without
30092 + * modification, are permitted provided that the following conditions are met:
30093 + * * Redistributions of source code must retain the above copyright
30094 + * notice, this list of conditions and the following disclaimer.
30095 + * * Redistributions in binary form must reproduce the above copyright
30096 + * notice, this list of conditions and the following disclaimer in the
30097 + * documentation and/or other materials provided with the distribution.
30098 + * * Neither the name of the above-listed copyright holders nor the
30099 + * names of any contributors may be used to endorse or promote products
30100 + * derived from this software without specific prior written permission.
30103 + * ALTERNATIVELY, this software may be distributed under the terms of the
30104 + * GNU General Public License ("GPL") as published by the Free Software
30105 + * Foundation, either version 2 of that License or (at your option) any
30108 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
30109 + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30110 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30111 + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
30112 + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30113 + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30114 + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30115 + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30116 + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30117 + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30118 + * POSSIBILITY OF SUCH DAMAGE.
30120 +#include <fsl_mc_sys.h>
30121 +#include <fsl_mc_cmd.h>
30123 +/* ODP framework using MC poratl in shared mode. Following
30124 + changes to introduce Locks must be maintained while
30125 + merging the FLIB.
30129 +* The mc_spinlock_t type.
30132 + volatile int locked; /**< lock status 0 = unlocked, 1 = locked */
30136 +* A static spinlock initializer.
30138 +static mc_spinlock_t mc_portal_lock = { 0 };
30140 +static inline void mc_pause(void) {}
30142 +static inline void mc_spinlock_lock(mc_spinlock_t *sl)
30144 + while (__sync_lock_test_and_set(&sl->locked, 1))
30145 + while (sl->locked)
30149 +static inline void mc_spinlock_unlock(mc_spinlock_t *sl)
30151 + __sync_lock_release(&sl->locked);
30154 +static int mc_status_to_error(enum mc_cmd_status status)
30156 + switch (status) {
30157 + case MC_CMD_STATUS_OK:
30159 + case MC_CMD_STATUS_AUTH_ERR:
30160 + return -EACCES; /* Token error */
30161 + case MC_CMD_STATUS_NO_PRIVILEGE:
30162 + return -EPERM; /* Permission denied */
30163 + case MC_CMD_STATUS_DMA_ERR:
30164 + return -EIO; /* Input/Output error */
30165 + case MC_CMD_STATUS_CONFIG_ERR:
30166 + return -EINVAL; /* Device not configured */
30167 + case MC_CMD_STATUS_TIMEOUT:
30168 + return -ETIMEDOUT; /* Operation timed out */
30169 + case MC_CMD_STATUS_NO_RESOURCE:
30170 + return -ENAVAIL; /* Resource temporarily unavailable */
30171 + case MC_CMD_STATUS_NO_MEMORY:
30172 + return -ENOMEM; /* Cannot allocate memory */
30173 + case MC_CMD_STATUS_BUSY:
30174 + return -EBUSY; /* Device busy */
30175 + case MC_CMD_STATUS_UNSUPPORTED_OP:
30176 + return -ENOTSUP; /* Operation not supported by device */
30177 + case MC_CMD_STATUS_INVALID_STATE:
30178 + return -ENODEV; /* Invalid device state */
30183 + /* Not expected to reach here */
30187 +int mc_send_command(struct fsl_mc_io *mc_io, struct mc_command *cmd)
30189 + enum mc_cmd_status status;
30191 + if (!mc_io || !mc_io->regs)
30194 + /* --- Call lock function here in case portal is shared --- */
30195 + mc_spinlock_lock(&mc_portal_lock);
30197 + mc_write_command(mc_io->regs, cmd);
30199 + /* Spin until status changes */
30201 + status = MC_CMD_HDR_READ_STATUS(ioread64(mc_io->regs));
30203 + /* --- Call wait function here to prevent blocking ---
30204 + * Change the loop condition accordingly to exit on timeout.
30206 + } while (status == MC_CMD_STATUS_READY);
30208 + /* Read the response back into the command buffer */
30209 + mc_read_response(mc_io->regs, cmd);
30211 + /* --- Call unlock function here in case portal is shared --- */
30212 + mc_spinlock_unlock(&mc_portal_lock);
30214 + return mc_status_to_error(status);
30216 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_debug.c b/drivers/net/dpaa2/qbman/driver/qbman_debug.c
30217 new file mode 100644
30218 index 0000000..ef6c257
30220 +++ b/drivers/net/dpaa2/qbman/driver/qbman_debug.c
30222 +/* Copyright (C) 2015 Freescale Semiconductor, Inc.
30224 + * Redistribution and use in source and binary forms, with or without
30225 + * modification, are permitted provided that the following conditions are met:
30226 + * * Redistributions of source code must retain the above copyright
30227 + * notice, this list of conditions and the following disclaimer.
30228 + * * Redistributions in binary form must reproduce the above copyright
30229 + * notice, this list of conditions and the following disclaimer in the
30230 + * documentation and/or other materials provided with the distribution.
30231 + * * Neither the name of Freescale Semiconductor nor the
30232 + * names of its contributors may be used to endorse or promote products
30233 + * derived from this software without specific prior written permission.
30235 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
30236 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
30237 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
30238 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
30239 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30240 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30241 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
30242 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30243 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30244 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30247 +#include "qbman_portal.h"
30248 +#include "qbman_debug.h"
30249 +#include <drivers/fsl_qbman_portal.h>
30251 +/* QBMan portal management command code */
30252 +#define QBMAN_BP_QUERY 0x32
30253 +#define QBMAN_FQ_QUERY 0x44
30254 +#define QBMAN_FQ_QUERY_NP 0x45
30255 +#define QBMAN_WQ_QUERY 0x47
30256 +#define QBMAN_CGR_QUERY 0x51
30257 +#define QBMAN_WRED_QUERY 0x54
30258 +#define QBMAN_CGR_STAT_QUERY 0x55
30259 +#define QBMAN_CGR_STAT_QUERY_CLR 0x56
30261 +enum qbman_attr_usage_e {
30262 + qbman_attr_usage_fq,
30263 + qbman_attr_usage_bpool,
30264 + qbman_attr_usage_cgr,
30265 + qbman_attr_usage_wqchan
30268 +struct int_qbman_attr {
30269 + uint32_t words[32];
30270 + enum qbman_attr_usage_e usage;
30273 +#define attr_type_set(a, e) \
30275 + struct qbman_attr *__attr = a; \
30276 + enum qbman_attr_usage_e __usage = e; \
30277 + ((struct int_qbman_attr *)__attr)->usage = __usage; \
30280 +#define ATTR32(d) (&(d)->dont_manipulate_directly[0])
30281 +#define ATTR32_1(d) (&(d)->dont_manipulate_directly[16])
30283 +static struct qb_attr_code code_bp_bpid = QB_CODE(0, 16, 16);
30284 +static struct qb_attr_code code_bp_bdi = QB_CODE(1, 16, 1);
30285 +static struct qb_attr_code code_bp_va = QB_CODE(1, 17, 1);
30286 +static struct qb_attr_code code_bp_wae = QB_CODE(1, 18, 1);
30287 +static struct qb_attr_code code_bp_swdet = QB_CODE(4, 0, 16);
30288 +static struct qb_attr_code code_bp_swdxt = QB_CODE(4, 16, 16);
30289 +static struct qb_attr_code code_bp_hwdet = QB_CODE(5, 0, 16);
30290 +static struct qb_attr_code code_bp_hwdxt = QB_CODE(5, 16, 16);
30291 +static struct qb_attr_code code_bp_swset = QB_CODE(6, 0, 16);
30292 +static struct qb_attr_code code_bp_swsxt = QB_CODE(6, 16, 16);
30293 +static struct qb_attr_code code_bp_vbpid = QB_CODE(7, 0, 14);
30294 +static struct qb_attr_code code_bp_icid = QB_CODE(7, 16, 15);
30295 +static struct qb_attr_code code_bp_pl = QB_CODE(7, 31, 1);
30296 +static struct qb_attr_code code_bp_bpscn_addr_lo = QB_CODE(8, 0, 32);
30297 +static struct qb_attr_code code_bp_bpscn_addr_hi = QB_CODE(9, 0, 32);
30298 +static struct qb_attr_code code_bp_bpscn_ctx_lo = QB_CODE(10, 0, 32);
30299 +static struct qb_attr_code code_bp_bpscn_ctx_hi = QB_CODE(11, 0, 32);
30300 +static struct qb_attr_code code_bp_hw_targ = QB_CODE(12, 0, 16);
30301 +static struct qb_attr_code code_bp_state = QB_CODE(1, 24, 3);
30302 +static struct qb_attr_code code_bp_fill = QB_CODE(2, 0, 32);
30303 +static struct qb_attr_code code_bp_hdptr = QB_CODE(3, 0, 32);
30304 +static struct qb_attr_code code_bp_sdcnt = QB_CODE(13, 0, 8);
30305 +static struct qb_attr_code code_bp_hdcnt = QB_CODE(13, 8, 8);
30306 +static struct qb_attr_code code_bp_sscnt = QB_CODE(13, 16, 8);
30308 +static void qbman_bp_attr_clear(struct qbman_attr *a)
30310 + memset(a, 0, sizeof(*a));
30311 + attr_type_set(a, qbman_attr_usage_bpool);
30314 +int qbman_bp_query(struct qbman_swp *s, uint32_t bpid,
30315 + struct qbman_attr *a)
30319 + uint32_t *attr = ATTR32(a);
30321 + qbman_bp_attr_clear(a);
30323 + /* Start the management command */
30324 + p = qbman_swp_mc_start(s);
30328 + /* Encode the caller-provided attributes */
30329 + qb_attr_code_encode(&code_bp_bpid, p, bpid);
30331 + /* Complete the management command */
30332 + p = qbman_swp_mc_complete(s, p, p[0] | QBMAN_BP_QUERY);
30334 + /* Decode the outcome */
30335 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
30336 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p) != QBMAN_BP_QUERY);
30338 + /* Determine success or failure */
30339 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
30340 + pr_err("Query of BPID 0x%x failed, code=0x%02x\n", bpid, rslt);
30344 + /* For the query, word[0] of the result contains only the
30345 + * verb/rslt fields, so skip word[0].
30347 + word_copy(&attr[1], &p[1], 15);
30351 +void qbman_bp_attr_get_bdi(struct qbman_attr *a, int *bdi, int *va, int *wae)
30353 + uint32_t *p = ATTR32(a);
30355 + *bdi = !!qb_attr_code_decode(&code_bp_bdi, p);
30356 + *va = !!qb_attr_code_decode(&code_bp_va, p);
30357 + *wae = !!qb_attr_code_decode(&code_bp_wae, p);
30360 +static uint32_t qbman_bp_thresh_to_value(uint32_t val)
30362 + return (val & 0xff) << ((val & 0xf00) >> 8);
30365 +void qbman_bp_attr_get_swdet(struct qbman_attr *a, uint32_t *swdet)
30367 + uint32_t *p = ATTR32(a);
30369 + *swdet = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_swdet,
30373 +void qbman_bp_attr_get_swdxt(struct qbman_attr *a, uint32_t *swdxt)
30375 + uint32_t *p = ATTR32(a);
30377 + *swdxt = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_swdxt,
30381 +void qbman_bp_attr_get_hwdet(struct qbman_attr *a, uint32_t *hwdet)
30383 + uint32_t *p = ATTR32(a);
30385 + *hwdet = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_hwdet,
30389 +void qbman_bp_attr_get_hwdxt(struct qbman_attr *a, uint32_t *hwdxt)
30391 + uint32_t *p = ATTR32(a);
30393 + *hwdxt = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_hwdxt,
30397 +void qbman_bp_attr_get_swset(struct qbman_attr *a, uint32_t *swset)
30399 + uint32_t *p = ATTR32(a);
30401 + *swset = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_swset,
30405 +void qbman_bp_attr_get_swsxt(struct qbman_attr *a, uint32_t *swsxt)
30407 + uint32_t *p = ATTR32(a);
30409 + *swsxt = qbman_bp_thresh_to_value(qb_attr_code_decode(&code_bp_swsxt,
30413 +void qbman_bp_attr_get_vbpid(struct qbman_attr *a, uint32_t *vbpid)
30415 + uint32_t *p = ATTR32(a);
30417 + *vbpid = qb_attr_code_decode(&code_bp_vbpid, p);
30420 +void qbman_bp_attr_get_icid(struct qbman_attr *a, uint32_t *icid, int *pl)
30422 + uint32_t *p = ATTR32(a);
30424 + *icid = qb_attr_code_decode(&code_bp_icid, p);
30425 + *pl = !!qb_attr_code_decode(&code_bp_pl, p);
30428 +void qbman_bp_attr_get_bpscn_addr(struct qbman_attr *a, uint64_t *bpscn_addr)
30430 + uint32_t *p = ATTR32(a);
30432 + *bpscn_addr = ((uint64_t)qb_attr_code_decode(&code_bp_bpscn_addr_hi,
30434 + (uint64_t)qb_attr_code_decode(&code_bp_bpscn_addr_lo,
30438 +void qbman_bp_attr_get_bpscn_ctx(struct qbman_attr *a, uint64_t *bpscn_ctx)
30440 + uint32_t *p = ATTR32(a);
30442 + *bpscn_ctx = ((uint64_t)qb_attr_code_decode(&code_bp_bpscn_ctx_hi, p)
30444 + (uint64_t)qb_attr_code_decode(&code_bp_bpscn_ctx_lo,
30448 +void qbman_bp_attr_get_hw_targ(struct qbman_attr *a, uint32_t *hw_targ)
30450 + uint32_t *p = ATTR32(a);
30452 + *hw_targ = qb_attr_code_decode(&code_bp_hw_targ, p);
30455 +int qbman_bp_info_has_free_bufs(struct qbman_attr *a)
30457 + uint32_t *p = ATTR32(a);
30459 + return !(int)(qb_attr_code_decode(&code_bp_state, p) & 0x1);
30462 +int qbman_bp_info_is_depleted(struct qbman_attr *a)
30464 + uint32_t *p = ATTR32(a);
30466 + return (int)(qb_attr_code_decode(&code_bp_state, p) & 0x2);
30469 +int qbman_bp_info_is_surplus(struct qbman_attr *a)
30471 + uint32_t *p = ATTR32(a);
30473 + return (int)(qb_attr_code_decode(&code_bp_state, p) & 0x4);
30476 +uint32_t qbman_bp_info_num_free_bufs(struct qbman_attr *a)
30478 + uint32_t *p = ATTR32(a);
30480 + return qb_attr_code_decode(&code_bp_fill, p);
30483 +uint32_t qbman_bp_info_hdptr(struct qbman_attr *a)
30485 + uint32_t *p = ATTR32(a);
30487 + return qb_attr_code_decode(&code_bp_hdptr, p);
30490 +uint32_t qbman_bp_info_sdcnt(struct qbman_attr *a)
30492 + uint32_t *p = ATTR32(a);
30494 + return qb_attr_code_decode(&code_bp_sdcnt, p);
30497 +uint32_t qbman_bp_info_hdcnt(struct qbman_attr *a)
30499 + uint32_t *p = ATTR32(a);
30501 + return qb_attr_code_decode(&code_bp_hdcnt, p);
30504 +uint32_t qbman_bp_info_sscnt(struct qbman_attr *a)
30506 + uint32_t *p = ATTR32(a);
30508 + return qb_attr_code_decode(&code_bp_sscnt, p);
30511 +static struct qb_attr_code code_fq_fqid = QB_CODE(1, 0, 24);
30512 +static struct qb_attr_code code_fq_cgrid = QB_CODE(2, 16, 16);
30513 +static struct qb_attr_code code_fq_destwq = QB_CODE(3, 0, 15);
30514 +static struct qb_attr_code code_fq_fqctrl = QB_CODE(3, 24, 8);
30515 +static struct qb_attr_code code_fq_icscred = QB_CODE(4, 0, 15);
30516 +static struct qb_attr_code code_fq_tdthresh = QB_CODE(4, 16, 13);
30517 +static struct qb_attr_code code_fq_oa_len = QB_CODE(5, 0, 12);
30518 +static struct qb_attr_code code_fq_oa_ics = QB_CODE(5, 14, 1);
30519 +static struct qb_attr_code code_fq_oa_cgr = QB_CODE(5, 15, 1);
30520 +static struct qb_attr_code code_fq_mctl_bdi = QB_CODE(5, 24, 1);
30521 +static struct qb_attr_code code_fq_mctl_ff = QB_CODE(5, 25, 1);
30522 +static struct qb_attr_code code_fq_mctl_va = QB_CODE(5, 26, 1);
30523 +static struct qb_attr_code code_fq_mctl_ps = QB_CODE(5, 27, 1);
30524 +static struct qb_attr_code code_fq_ctx_lower32 = QB_CODE(6, 0, 32);
30525 +static struct qb_attr_code code_fq_ctx_upper32 = QB_CODE(7, 0, 32);
30526 +static struct qb_attr_code code_fq_icid = QB_CODE(8, 0, 15);
30527 +static struct qb_attr_code code_fq_pl = QB_CODE(8, 15, 1);
30528 +static struct qb_attr_code code_fq_vfqid = QB_CODE(9, 0, 24);
30529 +static struct qb_attr_code code_fq_erfqid = QB_CODE(10, 0, 24);
30531 +static void qbman_fq_attr_clear(struct qbman_attr *a)
30533 + memset(a, 0, sizeof(*a));
30534 + attr_type_set(a, qbman_attr_usage_fq);
30537 +/* FQ query function for programmable fields */
30538 +int qbman_fq_query(struct qbman_swp *s, uint32_t fqid, struct qbman_attr *desc)
30542 + uint32_t *d = ATTR32(desc);
30544 + qbman_fq_attr_clear(desc);
30546 + p = qbman_swp_mc_start(s);
30549 + qb_attr_code_encode(&code_fq_fqid, p, fqid);
30550 + p = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY);
30552 + /* Decode the outcome */
30553 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
30554 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p) != QBMAN_FQ_QUERY);
30556 + /* Determine success or failure */
30557 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
30558 + pr_err("Query of FQID 0x%x failed, code=0x%02x\n",
30562 + /* For the configure, word[0] of the command contains only the WE-mask.
30563 + * For the query, word[0] of the result contains only the verb/rslt
30564 + * fields. Skip word[0] in the latter case. */
30565 + word_copy(&d[1], &p[1], 15);
30569 +void qbman_fq_attr_get_fqctrl(struct qbman_attr *d, uint32_t *fqctrl)
30571 + uint32_t *p = ATTR32(d);
30573 + *fqctrl = qb_attr_code_decode(&code_fq_fqctrl, p);
30576 +void qbman_fq_attr_get_cgrid(struct qbman_attr *d, uint32_t *cgrid)
30578 + uint32_t *p = ATTR32(d);
30580 + *cgrid = qb_attr_code_decode(&code_fq_cgrid, p);
30583 +void qbman_fq_attr_get_destwq(struct qbman_attr *d, uint32_t *destwq)
30585 + uint32_t *p = ATTR32(d);
30587 + *destwq = qb_attr_code_decode(&code_fq_destwq, p);
30590 +void qbman_fq_attr_get_icscred(struct qbman_attr *d, uint32_t *icscred)
30592 + uint32_t *p = ATTR32(d);
30594 + *icscred = qb_attr_code_decode(&code_fq_icscred, p);
30597 +static struct qb_attr_code code_tdthresh_exp = QB_CODE(0, 0, 5);
30598 +static struct qb_attr_code code_tdthresh_mant = QB_CODE(0, 5, 8);
30599 +static uint32_t qbman_thresh_to_value(uint32_t val)
30603 + m = qb_attr_code_decode(&code_tdthresh_mant, &val);
30604 + e = qb_attr_code_decode(&code_tdthresh_exp, &val);
30608 +void qbman_fq_attr_get_tdthresh(struct qbman_attr *d, uint32_t *tdthresh)
30610 + uint32_t *p = ATTR32(d);
30612 + *tdthresh = qbman_thresh_to_value(qb_attr_code_decode(&code_fq_tdthresh,
30616 +void qbman_fq_attr_get_oa(struct qbman_attr *d,
30617 + int *oa_ics, int *oa_cgr, int32_t *oa_len)
30619 + uint32_t *p = ATTR32(d);
30621 + *oa_ics = !!qb_attr_code_decode(&code_fq_oa_ics, p);
30622 + *oa_cgr = !!qb_attr_code_decode(&code_fq_oa_cgr, p);
30623 + *oa_len = qb_attr_code_makesigned(&code_fq_oa_len,
30624 + qb_attr_code_decode(&code_fq_oa_len, p));
30627 +void qbman_fq_attr_get_mctl(struct qbman_attr *d,
30628 + int *bdi, int *ff, int *va, int *ps)
30630 + uint32_t *p = ATTR32(d);
30632 + *bdi = !!qb_attr_code_decode(&code_fq_mctl_bdi, p);
30633 + *ff = !!qb_attr_code_decode(&code_fq_mctl_ff, p);
30634 + *va = !!qb_attr_code_decode(&code_fq_mctl_va, p);
30635 + *ps = !!qb_attr_code_decode(&code_fq_mctl_ps, p);
30638 +void qbman_fq_attr_get_ctx(struct qbman_attr *d, uint32_t *hi, uint32_t *lo)
30640 + uint32_t *p = ATTR32(d);
30642 + *hi = qb_attr_code_decode(&code_fq_ctx_upper32, p);
30643 + *lo = qb_attr_code_decode(&code_fq_ctx_lower32, p);
30646 +void qbman_fq_attr_get_icid(struct qbman_attr *d, uint32_t *icid, int *pl)
30648 + uint32_t *p = ATTR32(d);
30650 + *icid = qb_attr_code_decode(&code_fq_icid, p);
30651 + *pl = !!qb_attr_code_decode(&code_fq_pl, p);
30654 +void qbman_fq_attr_get_vfqid(struct qbman_attr *d, uint32_t *vfqid)
30656 + uint32_t *p = ATTR32(d);
30658 + *vfqid = qb_attr_code_decode(&code_fq_vfqid, p);
30661 +void qbman_fq_attr_get_erfqid(struct qbman_attr *d, uint32_t *erfqid)
30663 + uint32_t *p = ATTR32(d);
30665 + *erfqid = qb_attr_code_decode(&code_fq_erfqid, p);
30668 +/* Query FQ Non-Programmalbe Fields */
30669 +static struct qb_attr_code code_fq_np_state = QB_CODE(0, 16, 3);
30670 +static struct qb_attr_code code_fq_np_fe = QB_CODE(0, 19, 1);
30671 +static struct qb_attr_code code_fq_np_x = QB_CODE(0, 20, 1);
30672 +static struct qb_attr_code code_fq_np_r = QB_CODE(0, 21, 1);
30673 +static struct qb_attr_code code_fq_np_oe = QB_CODE(0, 22, 1);
30674 +static struct qb_attr_code code_fq_np_frm_cnt = QB_CODE(6, 0, 24);
30675 +static struct qb_attr_code code_fq_np_byte_cnt = QB_CODE(7, 0, 32);
30677 +int qbman_fq_query_state(struct qbman_swp *s, uint32_t fqid,
30678 + struct qbman_attr *state)
30682 + uint32_t *d = ATTR32(state);
30684 + qbman_fq_attr_clear(state);
30686 + p = qbman_swp_mc_start(s);
30689 + qb_attr_code_encode(&code_fq_fqid, p, fqid);
30690 + p = qbman_swp_mc_complete(s, p, QBMAN_FQ_QUERY_NP);
30692 + /* Decode the outcome */
30693 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
30694 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p) != QBMAN_FQ_QUERY_NP);
30696 + /* Determine success or failure */
30697 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
30698 + pr_err("Query NP fields of FQID 0x%x failed, code=0x%02x\n",
30702 + word_copy(&d[0], &p[0], 16);
30706 +uint32_t qbman_fq_state_schedstate(const struct qbman_attr *state)
30708 + const uint32_t *p = ATTR32(state);
30710 + return qb_attr_code_decode(&code_fq_np_state, p);
30713 +int qbman_fq_state_force_eligible(const struct qbman_attr *state)
30715 + const uint32_t *p = ATTR32(state);
30717 + return !!qb_attr_code_decode(&code_fq_np_fe, p);
30720 +int qbman_fq_state_xoff(const struct qbman_attr *state)
30722 + const uint32_t *p = ATTR32(state);
30724 + return !!qb_attr_code_decode(&code_fq_np_x, p);
30727 +int qbman_fq_state_retirement_pending(const struct qbman_attr *state)
30729 + const uint32_t *p = ATTR32(state);
30731 + return !!qb_attr_code_decode(&code_fq_np_r, p);
30734 +int qbman_fq_state_overflow_error(const struct qbman_attr *state)
30736 + const uint32_t *p = ATTR32(state);
30738 + return !!qb_attr_code_decode(&code_fq_np_oe, p);
30741 +uint32_t qbman_fq_state_frame_count(const struct qbman_attr *state)
30743 + const uint32_t *p = ATTR32(state);
30745 + return qb_attr_code_decode(&code_fq_np_frm_cnt, p);
30748 +uint32_t qbman_fq_state_byte_count(const struct qbman_attr *state)
30750 + const uint32_t *p = ATTR32(state);
30752 + return qb_attr_code_decode(&code_fq_np_byte_cnt, p);
30756 +static struct qb_attr_code code_cgr_cgid = QB_CODE(0, 16, 16);
30757 +static struct qb_attr_code code_cgr_cscn_wq_en_enter = QB_CODE(2, 0, 1);
30758 +static struct qb_attr_code code_cgr_cscn_wq_en_exit = QB_CODE(2, 1, 1);
30759 +static struct qb_attr_code code_cgr_cscn_wq_icd = QB_CODE(2, 2, 1);
30760 +static struct qb_attr_code code_cgr_mode = QB_CODE(3, 16, 2);
30761 +static struct qb_attr_code code_cgr_rej_cnt_mode = QB_CODE(3, 18, 1);
30762 +static struct qb_attr_code code_cgr_cscn_bdi = QB_CODE(3, 19, 1);
30763 +static struct qb_attr_code code_cgr_cscn_wr_en_enter = QB_CODE(3, 24, 1);
30764 +static struct qb_attr_code code_cgr_cscn_wr_en_exit = QB_CODE(3, 25, 1);
30765 +static struct qb_attr_code code_cgr_cg_wr_ae = QB_CODE(3, 26, 1);
30766 +static struct qb_attr_code code_cgr_cscn_dcp_en = QB_CODE(3, 27, 1);
30767 +static struct qb_attr_code code_cgr_cg_wr_va = QB_CODE(3, 28, 1);
30768 +static struct qb_attr_code code_cgr_i_cnt_wr_en = QB_CODE(4, 0, 1);
30769 +static struct qb_attr_code code_cgr_i_cnt_wr_bnd = QB_CODE(4, 1, 5);
30770 +static struct qb_attr_code code_cgr_td_en = QB_CODE(4, 8, 1);
30771 +static struct qb_attr_code code_cgr_cs_thres = QB_CODE(4, 16, 13);
30772 +static struct qb_attr_code code_cgr_cs_thres_x = QB_CODE(5, 0, 13);
30773 +static struct qb_attr_code code_cgr_td_thres = QB_CODE(5, 16, 13);
30774 +static struct qb_attr_code code_cgr_cscn_tdcp = QB_CODE(6, 0, 16);
30775 +static struct qb_attr_code code_cgr_cscn_wqid = QB_CODE(6, 16, 16);
30776 +static struct qb_attr_code code_cgr_cscn_vcgid = QB_CODE(7, 0, 16);
30777 +static struct qb_attr_code code_cgr_cg_icid = QB_CODE(7, 16, 15);
30778 +static struct qb_attr_code code_cgr_cg_pl = QB_CODE(7, 31, 1);
30779 +static struct qb_attr_code code_cgr_cg_wr_addr_lo = QB_CODE(8, 0, 32);
30780 +static struct qb_attr_code code_cgr_cg_wr_addr_hi = QB_CODE(9, 0, 32);
30781 +static struct qb_attr_code code_cgr_cscn_ctx_lo = QB_CODE(10, 0, 32);
30782 +static struct qb_attr_code code_cgr_cscn_ctx_hi = QB_CODE(11, 0, 32);
30784 +static void qbman_cgr_attr_clear(struct qbman_attr *a)
30786 + memset(a, 0, sizeof(*a));
30787 + attr_type_set(a, qbman_attr_usage_cgr);
30790 +int qbman_cgr_query(struct qbman_swp *s, uint32_t cgid, struct qbman_attr *attr)
30793 + uint32_t verb, rslt;
30796 + uint32_t query_verb;
30798 + d[0] = ATTR32(attr);
30799 + d[1] = ATTR32_1(attr);
30801 + qbman_cgr_attr_clear(attr);
30803 + for (i = 0; i < 2; i++) {
30804 + p = qbman_swp_mc_start(s);
30807 + query_verb = i ? QBMAN_WRED_QUERY : QBMAN_CGR_QUERY;
30809 + qb_attr_code_encode(&code_cgr_cgid, p, cgid);
30810 + p = qbman_swp_mc_complete(s, p, p[0] | query_verb);
30812 + /* Decode the outcome */
30813 + verb = qb_attr_code_decode(&code_generic_verb, p);
30814 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
30815 + BUG_ON(verb != query_verb);
30817 + /* Determine success or failure */
30818 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
30819 + pr_err("Query CGID 0x%x failed,", cgid);
30820 + pr_err(" verb=0x%02x, code=0x%02x\n", verb, rslt);
30823 + /* For the configure, word[0] of the command contains only the
30824 + * verb/cgid. For the query, word[0] of the result contains
30825 + * only the verb/rslt fields. Skip word[0] in the latter case.
30827 + word_copy(&d[i][1], &p[1], 15);
30832 +void qbman_cgr_attr_get_ctl1(struct qbman_attr *d, int *cscn_wq_en_enter,
30833 + int *cscn_wq_en_exit, int *cscn_wq_icd)
30835 + uint32_t *p = ATTR32(d);
30836 + *cscn_wq_en_enter = !!qb_attr_code_decode(&code_cgr_cscn_wq_en_enter,
30838 + *cscn_wq_en_exit = !!qb_attr_code_decode(&code_cgr_cscn_wq_en_exit, p);
30839 + *cscn_wq_icd = !!qb_attr_code_decode(&code_cgr_cscn_wq_icd, p);
30842 +void qbman_cgr_attr_get_mode(struct qbman_attr *d, uint32_t *mode,
30843 + int *rej_cnt_mode, int *cscn_bdi)
30845 + uint32_t *p = ATTR32(d);
30846 + *mode = qb_attr_code_decode(&code_cgr_mode, p);
30847 + *rej_cnt_mode = !!qb_attr_code_decode(&code_cgr_rej_cnt_mode, p);
30848 + *cscn_bdi = !!qb_attr_code_decode(&code_cgr_cscn_bdi, p);
30851 +void qbman_cgr_attr_get_ctl2(struct qbman_attr *d, int *cscn_wr_en_enter,
30852 + int *cscn_wr_en_exit, int *cg_wr_ae,
30853 + int *cscn_dcp_en, int *cg_wr_va)
30855 + uint32_t *p = ATTR32(d);
30856 + *cscn_wr_en_enter = !!qb_attr_code_decode(&code_cgr_cscn_wr_en_enter,
30858 + *cscn_wr_en_exit = !!qb_attr_code_decode(&code_cgr_cscn_wr_en_exit, p);
30859 + *cg_wr_ae = !!qb_attr_code_decode(&code_cgr_cg_wr_ae, p);
30860 + *cscn_dcp_en = !!qb_attr_code_decode(&code_cgr_cscn_dcp_en, p);
30861 + *cg_wr_va = !!qb_attr_code_decode(&code_cgr_cg_wr_va, p);
30864 +void qbman_cgr_attr_get_iwc(struct qbman_attr *d, int *i_cnt_wr_en,
30865 + uint32_t *i_cnt_wr_bnd)
30867 + uint32_t *p = ATTR32(d);
30868 + *i_cnt_wr_en = !!qb_attr_code_decode(&code_cgr_i_cnt_wr_en, p);
30869 + *i_cnt_wr_bnd = qb_attr_code_decode(&code_cgr_i_cnt_wr_bnd, p);
30872 +void qbman_cgr_attr_get_tdc(struct qbman_attr *d, int *td_en)
30874 + uint32_t *p = ATTR32(d);
30875 + *td_en = !!qb_attr_code_decode(&code_cgr_td_en, p);
30878 +void qbman_cgr_attr_get_cs_thres(struct qbman_attr *d, uint32_t *cs_thres)
30880 + uint32_t *p = ATTR32(d);
30881 + *cs_thres = qbman_thresh_to_value(qb_attr_code_decode(
30882 + &code_cgr_cs_thres, p));
30885 +void qbman_cgr_attr_get_cs_thres_x(struct qbman_attr *d,
30886 + uint32_t *cs_thres_x)
30888 + uint32_t *p = ATTR32(d);
30889 + *cs_thres_x = qbman_thresh_to_value(qb_attr_code_decode(
30890 + &code_cgr_cs_thres_x, p));
30893 +void qbman_cgr_attr_get_td_thres(struct qbman_attr *d, uint32_t *td_thres)
30895 + uint32_t *p = ATTR32(d);
30896 + *td_thres = qbman_thresh_to_value(qb_attr_code_decode(
30897 + &code_cgr_td_thres, p));
30900 +void qbman_cgr_attr_get_cscn_tdcp(struct qbman_attr *d, uint32_t *cscn_tdcp)
30902 + uint32_t *p = ATTR32(d);
30903 + *cscn_tdcp = qb_attr_code_decode(&code_cgr_cscn_tdcp, p);
30906 +void qbman_cgr_attr_get_cscn_wqid(struct qbman_attr *d, uint32_t *cscn_wqid)
30908 + uint32_t *p = ATTR32(d);
30909 + *cscn_wqid = qb_attr_code_decode(&code_cgr_cscn_wqid, p);
30912 +void qbman_cgr_attr_get_cscn_vcgid(struct qbman_attr *d,
30913 + uint32_t *cscn_vcgid)
30915 + uint32_t *p = ATTR32(d);
30916 + *cscn_vcgid = qb_attr_code_decode(&code_cgr_cscn_vcgid, p);
30919 +void qbman_cgr_attr_get_cg_icid(struct qbman_attr *d, uint32_t *icid,
30922 + uint32_t *p = ATTR32(d);
30923 + *icid = qb_attr_code_decode(&code_cgr_cg_icid, p);
30924 + *pl = !!qb_attr_code_decode(&code_cgr_cg_pl, p);
30927 +void qbman_cgr_attr_get_cg_wr_addr(struct qbman_attr *d,
30928 + uint64_t *cg_wr_addr)
30930 + uint32_t *p = ATTR32(d);
30931 + *cg_wr_addr = ((uint64_t)qb_attr_code_decode(&code_cgr_cg_wr_addr_hi,
30933 + (uint64_t)qb_attr_code_decode(&code_cgr_cg_wr_addr_lo,
30937 +void qbman_cgr_attr_get_cscn_ctx(struct qbman_attr *d, uint64_t *cscn_ctx)
30939 + uint32_t *p = ATTR32(d);
30940 + *cscn_ctx = ((uint64_t)qb_attr_code_decode(&code_cgr_cscn_ctx_hi, p)
30942 + (uint64_t)qb_attr_code_decode(&code_cgr_cscn_ctx_lo, p);
30945 +#define WRED_EDP_WORD(n) (18 + n / 4)
30946 +#define WRED_EDP_OFFSET(n) (8 * (n % 4))
30947 +#define WRED_PARM_DP_WORD(n) (n + 20)
30948 +#define WRED_WE_EDP(n) (16 + n * 2)
30949 +#define WRED_WE_PARM_DP(n) (17 + n * 2)
30950 +void qbman_cgr_attr_wred_get_edp(struct qbman_attr *d, uint32_t idx,
30953 + uint32_t *p = ATTR32(d);
30954 + struct qb_attr_code code_wred_edp = QB_CODE(WRED_EDP_WORD(idx),
30955 + WRED_EDP_OFFSET(idx), 8);
30956 + *edp = (int)qb_attr_code_decode(&code_wred_edp, p);
30959 +void qbman_cgr_attr_wred_dp_decompose(uint32_t dp, uint64_t *minth,
30960 + uint64_t *maxth, uint8_t *maxp)
30962 + uint8_t ma, mn, step_i, step_s, pn;
30964 + ma = (uint8_t)(dp >> 24);
30965 + mn = (uint8_t)(dp >> 19) & 0x1f;
30966 + step_i = (uint8_t)(dp >> 11);
30967 + step_s = (uint8_t)(dp >> 6) & 0x1f;
30968 + pn = (uint8_t)dp & 0x3f;
30970 + *maxp = (uint8_t)(((pn << 2) * 100) / 256);
30975 + *maxth = ((ma + 256) * (1 << (mn - 1)));
30978 + *minth = *maxth - step_i;
30980 + *minth = *maxth - (256 + step_i) * (1 << (step_s - 1));
30983 +void qbman_cgr_attr_wred_get_parm_dp(struct qbman_attr *d, uint32_t idx,
30986 + uint32_t *p = ATTR32(d);
30987 + struct qb_attr_code code_wred_parm_dp = QB_CODE(WRED_PARM_DP_WORD(idx),
30989 + *dp = qb_attr_code_decode(&code_wred_parm_dp, p);
30992 +/* Query CGR/CCGR/CQ statistics */
30993 +static struct qb_attr_code code_cgr_stat_ct = QB_CODE(4, 0, 32);
30994 +static struct qb_attr_code code_cgr_stat_frame_cnt_lo = QB_CODE(4, 0, 32);
30995 +static struct qb_attr_code code_cgr_stat_frame_cnt_hi = QB_CODE(5, 0, 8);
30996 +static struct qb_attr_code code_cgr_stat_byte_cnt_lo = QB_CODE(6, 0, 32);
30997 +static struct qb_attr_code code_cgr_stat_byte_cnt_hi = QB_CODE(7, 0, 16);
30998 +static int qbman_cgr_statistics_query(struct qbman_swp *s, uint32_t cgid,
30999 + int clear, uint32_t command_type,
31000 + uint64_t *frame_cnt, uint64_t *byte_cnt)
31003 + uint32_t verb, rslt;
31004 + uint32_t query_verb;
31007 + p = qbman_swp_mc_start(s);
31011 + qb_attr_code_encode(&code_cgr_cgid, p, cgid);
31012 + if (command_type < 2)
31013 + qb_attr_code_encode(&code_cgr_stat_ct, p, command_type);
31014 + query_verb = clear ?
31015 + QBMAN_CGR_STAT_QUERY_CLR : QBMAN_CGR_STAT_QUERY;
31016 + p = qbman_swp_mc_complete(s, p, p[0] | query_verb);
31018 + /* Decode the outcome */
31019 + verb = qb_attr_code_decode(&code_generic_verb, p);
31020 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
31021 + BUG_ON(verb != query_verb);
31023 + /* Determine success or failure */
31024 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
31025 + pr_err("Query statistics of CGID 0x%x failed,", cgid);
31026 + pr_err(" verb=0x%02x code=0x%02x\n", verb, rslt);
31030 + if (*frame_cnt) {
31031 + hi = qb_attr_code_decode(&code_cgr_stat_frame_cnt_hi, p);
31032 + lo = qb_attr_code_decode(&code_cgr_stat_frame_cnt_lo, p);
31033 + *frame_cnt = ((uint64_t)hi << 32) | (uint64_t)lo;
31036 + hi = qb_attr_code_decode(&code_cgr_stat_byte_cnt_hi, p);
31037 + lo = qb_attr_code_decode(&code_cgr_stat_byte_cnt_lo, p);
31038 + *byte_cnt = ((uint64_t)hi << 32) | (uint64_t)lo;
31044 +int qbman_cgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31045 + uint64_t *frame_cnt, uint64_t *byte_cnt)
31047 + return qbman_cgr_statistics_query(s, cgid, clear, 0xff,
31048 + frame_cnt, byte_cnt);
31051 +int qbman_ccgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31052 + uint64_t *frame_cnt, uint64_t *byte_cnt)
31054 + return qbman_cgr_statistics_query(s, cgid, clear, 1,
31055 + frame_cnt, byte_cnt);
31058 +int qbman_cq_dequeue_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31059 + uint64_t *frame_cnt, uint64_t *byte_cnt)
31061 + return qbman_cgr_statistics_query(s, cgid, clear, 0,
31062 + frame_cnt, byte_cnt);
31065 +/* WQ Chan Query */
31066 +static struct qb_attr_code code_wqchan_chanid = QB_CODE(0, 16, 16);
31067 +static struct qb_attr_code code_wqchan_cdan_ctx_lo = QB_CODE(2, 0, 32);
31068 +static struct qb_attr_code code_wqchan_cdan_ctx_hi = QB_CODE(3, 0, 32);
31069 +static struct qb_attr_code code_wqchan_cdan_wqid = QB_CODE(1, 16, 16);
31070 +static struct qb_attr_code code_wqchan_ctrl = QB_CODE(1, 8, 8);
31072 +static void qbman_wqchan_attr_clear(struct qbman_attr *a)
31074 + memset(a, 0, sizeof(*a));
31075 + attr_type_set(a, qbman_attr_usage_wqchan);
31078 +int qbman_wqchan_query(struct qbman_swp *s, uint16_t chanid,
31079 + struct qbman_attr *a)
31083 + uint32_t *attr = ATTR32(a);
31085 + qbman_wqchan_attr_clear(a);
31087 + /* Start the management command */
31088 + p = qbman_swp_mc_start(s);
31092 + /* Encode the caller-provided attributes */
31093 + qb_attr_code_encode(&code_wqchan_chanid, p, chanid);
31095 + /* Complete the management command */
31096 + p = qbman_swp_mc_complete(s, p, p[0] | QBMAN_WQ_QUERY);
31098 + /* Decode the outcome */
31099 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
31100 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p); != QBMAN_WQ_QUERY);
31102 + /* Determine success or failure */
31103 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
31104 + pr_err("Query of WQCHAN 0x%x failed, code=0x%02x\n",
31109 + /* For the query, word[0] of the result contains only the
31110 + * verb/rslt fields, so skip word[0].
31112 + word_copy(&attr[1], &p[1], 15);
31116 +void qbman_wqchan_attr_get_wqlen(struct qbman_attr *attr, int wq, uint32_t *len)
31118 + uint32_t *p = ATTR32(attr);
31119 + struct qb_attr_code code_wqchan_len = QB_CODE(wq + 8, 0, 24);
31120 + *len = qb_attr_code_decode(&code_wqchan_len, p);
31123 +void qbman_wqchan_attr_get_cdan_ctx(struct qbman_attr *attr, uint64_t *cdan_ctx)
31126 + uint32_t *p = ATTR32(attr);
31128 + lo = qb_attr_code_decode(&code_wqchan_cdan_ctx_lo, p);
31129 + hi = qb_attr_code_decode(&code_wqchan_cdan_ctx_hi, p);
31130 + *cdan_ctx = ((uint64_t)hi << 32) | (uint64_t)lo;
31133 +void qbman_wqchan_attr_get_cdan_wqid(struct qbman_attr *attr,
31134 + uint16_t *cdan_wqid)
31136 + uint32_t *p = ATTR32(attr);
31137 + *cdan_wqid = (uint16_t)qb_attr_code_decode(&code_wqchan_cdan_wqid, p);
31140 +void qbman_wqchan_attr_get_ctrl(struct qbman_attr *attr, uint8_t *ctrl)
31142 + uint32_t *p = ATTR32(attr);
31143 + *ctrl = (uint8_t)qb_attr_code_decode(&code_wqchan_ctrl, p);
31146 +void qbman_wqchan_attr_get_chanid(struct qbman_attr *attr, uint16_t *chanid)
31148 + uint32_t *p = ATTR32(attr);
31149 + *chanid = (uint16_t)qb_attr_code_decode(&code_wqchan_chanid, p);
31151 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_debug.h b/drivers/net/dpaa2/qbman/driver/qbman_debug.h
31152 new file mode 100644
31153 index 0000000..4d586a6
31155 +++ b/drivers/net/dpaa2/qbman/driver/qbman_debug.h
31157 +/* Copyright (C) 2015 Freescale Semiconductor, Inc.
31159 + * Redistribution and use in source and binary forms, with or without
31160 + * modification, are permitted provided that the following conditions are met:
31161 + * * Redistributions of source code must retain the above copyright
31162 + * notice, this list of conditions and the following disclaimer.
31163 + * * Redistributions in binary form must reproduce the above copyright
31164 + * notice, this list of conditions and the following disclaimer in the
31165 + * documentation and/or other materials provided with the distribution.
31166 + * * Neither the name of Freescale Semiconductor nor the
31167 + * names of its contributors may be used to endorse or promote products
31168 + * derived from this software without specific prior written permission.
31170 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
31171 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31172 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31173 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
31174 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31175 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31176 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31177 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31178 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31179 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31182 +struct qbman_attr {
31183 + uint32_t dont_manipulate_directly[40];
31186 +/* Buffer pool query commands */
31187 +int qbman_bp_query(struct qbman_swp *s, uint32_t bpid,
31188 + struct qbman_attr *a);
31189 +void qbman_bp_attr_get_bdi(struct qbman_attr *a, int *bdi, int *va, int *wae);
31190 +void qbman_bp_attr_get_swdet(struct qbman_attr *a, uint32_t *swdet);
31191 +void qbman_bp_attr_get_swdxt(struct qbman_attr *a, uint32_t *swdxt);
31192 +void qbman_bp_attr_get_hwdet(struct qbman_attr *a, uint32_t *hwdet);
31193 +void qbman_bp_attr_get_hwdxt(struct qbman_attr *a, uint32_t *hwdxt);
31194 +void qbman_bp_attr_get_swset(struct qbman_attr *a, uint32_t *swset);
31195 +void qbman_bp_attr_get_swsxt(struct qbman_attr *a, uint32_t *swsxt);
31196 +void qbman_bp_attr_get_vbpid(struct qbman_attr *a, uint32_t *vbpid);
31197 +void qbman_bp_attr_get_icid(struct qbman_attr *a, uint32_t *icid, int *pl);
31198 +void qbman_bp_attr_get_bpscn_addr(struct qbman_attr *a, uint64_t *bpscn_addr);
31199 +void qbman_bp_attr_get_bpscn_ctx(struct qbman_attr *a, uint64_t *bpscn_ctx);
31200 +void qbman_bp_attr_get_hw_targ(struct qbman_attr *a, uint32_t *hw_targ);
31201 +int qbman_bp_info_has_free_bufs(struct qbman_attr *a);
31202 +int qbman_bp_info_is_depleted(struct qbman_attr *a);
31203 +int qbman_bp_info_is_surplus(struct qbman_attr *a);
31204 +uint32_t qbman_bp_info_num_free_bufs(struct qbman_attr *a);
31205 +uint32_t qbman_bp_info_hdptr(struct qbman_attr *a);
31206 +uint32_t qbman_bp_info_sdcnt(struct qbman_attr *a);
31207 +uint32_t qbman_bp_info_hdcnt(struct qbman_attr *a);
31208 +uint32_t qbman_bp_info_sscnt(struct qbman_attr *a);
31210 +/* FQ query function for programmable fields */
31211 +int qbman_fq_query(struct qbman_swp *s, uint32_t fqid,
31212 + struct qbman_attr *desc);
31213 +void qbman_fq_attr_get_fqctrl(struct qbman_attr *d, uint32_t *fqctrl);
31214 +void qbman_fq_attr_get_cgrid(struct qbman_attr *d, uint32_t *cgrid);
31215 +void qbman_fq_attr_get_destwq(struct qbman_attr *d, uint32_t *destwq);
31216 +void qbman_fq_attr_get_icscred(struct qbman_attr *d, uint32_t *icscred);
31217 +void qbman_fq_attr_get_tdthresh(struct qbman_attr *d, uint32_t *tdthresh);
31218 +void qbman_fq_attr_get_oa(struct qbman_attr *d,
31219 + int *oa_ics, int *oa_cgr, int32_t *oa_len);
31220 +void qbman_fq_attr_get_mctl(struct qbman_attr *d,
31221 + int *bdi, int *ff, int *va, int *ps);
31222 +void qbman_fq_attr_get_ctx(struct qbman_attr *d, uint32_t *hi, uint32_t *lo);
31223 +void qbman_fq_attr_get_icid(struct qbman_attr *d, uint32_t *icid, int *pl);
31224 +void qbman_fq_attr_get_vfqid(struct qbman_attr *d, uint32_t *vfqid);
31225 +void qbman_fq_attr_get_erfqid(struct qbman_attr *d, uint32_t *erfqid);
31227 +/* FQ query command for non-programmable fields*/
31228 +enum qbman_fq_schedstate_e {
31229 + qbman_fq_schedstate_oos = 0,
31230 + qbman_fq_schedstate_retired,
31231 + qbman_fq_schedstate_tentatively_scheduled,
31232 + qbman_fq_schedstate_truly_scheduled,
31233 + qbman_fq_schedstate_parked,
31234 + qbman_fq_schedstate_held_active,
31237 +int qbman_fq_query_state(struct qbman_swp *s, uint32_t fqid,
31238 + struct qbman_attr *state);
31239 +uint32_t qbman_fq_state_schedstate(const struct qbman_attr *state);
31240 +int qbman_fq_state_force_eligible(const struct qbman_attr *state);
31241 +int qbman_fq_state_xoff(const struct qbman_attr *state);
31242 +int qbman_fq_state_retirement_pending(const struct qbman_attr *state);
31243 +int qbman_fq_state_overflow_error(const struct qbman_attr *state);
31244 +uint32_t qbman_fq_state_frame_count(const struct qbman_attr *state);
31245 +uint32_t qbman_fq_state_byte_count(const struct qbman_attr *state);
31248 +int qbman_cgr_query(struct qbman_swp *s, uint32_t cgid,
31249 + struct qbman_attr *attr);
31250 +void qbman_cgr_attr_get_ctl1(struct qbman_attr *d, int *cscn_wq_en_enter,
31251 + int *cscn_wq_en_exit, int *cscn_wq_icd);
31252 +void qbman_cgr_attr_get_mode(struct qbman_attr *d, uint32_t *mode,
31253 + int *rej_cnt_mode, int *cscn_bdi);
31254 +void qbman_cgr_attr_get_ctl2(struct qbman_attr *d, int *cscn_wr_en_enter,
31255 + int *cscn_wr_en_exit, int *cg_wr_ae,
31256 + int *cscn_dcp_en, int *cg_wr_va);
31257 +void qbman_cgr_attr_get_iwc(struct qbman_attr *d, int *i_cnt_wr_en,
31258 + uint32_t *i_cnt_wr_bnd);
31259 +void qbman_cgr_attr_get_tdc(struct qbman_attr *d, int *td_en);
31260 +void qbman_cgr_attr_get_cs_thres(struct qbman_attr *d, uint32_t *cs_thres);
31261 +void qbman_cgr_attr_get_cs_thres_x(struct qbman_attr *d,
31262 + uint32_t *cs_thres_x);
31263 +void qbman_cgr_attr_get_td_thres(struct qbman_attr *d, uint32_t *td_thres);
31264 +void qbman_cgr_attr_get_cscn_tdcp(struct qbman_attr *d, uint32_t *cscn_tdcp);
31265 +void qbman_cgr_attr_get_cscn_wqid(struct qbman_attr *d, uint32_t *cscn_wqid);
31266 +void qbman_cgr_attr_get_cscn_vcgid(struct qbman_attr *d,
31267 + uint32_t *cscn_vcgid);
31268 +void qbman_cgr_attr_get_cg_icid(struct qbman_attr *d, uint32_t *icid,
31270 +void qbman_cgr_attr_get_cg_wr_addr(struct qbman_attr *d,
31271 + uint64_t *cg_wr_addr);
31272 +void qbman_cgr_attr_get_cscn_ctx(struct qbman_attr *d, uint64_t *cscn_ctx);
31273 +void qbman_cgr_attr_wred_get_edp(struct qbman_attr *d, uint32_t idx,
31275 +void qbman_cgr_attr_wred_dp_decompose(uint32_t dp, uint64_t *minth,
31276 + uint64_t *maxth, uint8_t *maxp);
31277 +void qbman_cgr_attr_wred_get_parm_dp(struct qbman_attr *d, uint32_t idx,
31280 +/* CGR/CCGR/CQ statistics query */
31281 +int qbman_cgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31282 + uint64_t *frame_cnt, uint64_t *byte_cnt);
31283 +int qbman_ccgr_reject_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31284 + uint64_t *frame_cnt, uint64_t *byte_cnt);
31285 +int qbman_cq_dequeue_statistics(struct qbman_swp *s, uint32_t cgid, int clear,
31286 + uint64_t *frame_cnt, uint64_t *byte_cnt);
31288 +/* Query Work Queue Channel */
31289 +int qbman_wqchan_query(struct qbman_swp *s, uint16_t chanid,
31290 + struct qbman_attr *attr);
31291 +void qbman_wqchan_attr_get_wqlen(struct qbman_attr *attr, int wq, uint32_t *len);
31292 +void qbman_wqchan_attr_get_cdan_ctx(struct qbman_attr *attr, uint64_t *cdan_ctx);
31293 +void qbman_wqchan_attr_get_cdan_wqid(struct qbman_attr *attr,
31294 + uint16_t *cdan_wqid);
31295 +void qbman_wqchan_attr_get_ctrl(struct qbman_attr *attr, uint8_t *ctrl);
31296 +void qbman_wqchan_attr_get_chanid(struct qbman_attr *attr, uint16_t *chanid);
31297 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_portal.c b/drivers/net/dpaa2/qbman/driver/qbman_portal.c
31298 new file mode 100644
31299 index 0000000..52e1f64
31301 +++ b/drivers/net/dpaa2/qbman/driver/qbman_portal.c
31303 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
31305 + * Redistribution and use in source and binary forms, with or without
31306 + * modification, are permitted provided that the following conditions are met:
31307 + * * Redistributions of source code must retain the above copyright
31308 + * notice, this list of conditions and the following disclaimer.
31309 + * * Redistributions in binary form must reproduce the above copyright
31310 + * notice, this list of conditions and the following disclaimer in the
31311 + * documentation and/or other materials provided with the distribution.
31312 + * * Neither the name of Freescale Semiconductor nor the
31313 + * names of its contributors may be used to endorse or promote products
31314 + * derived from this software without specific prior written permission.
31316 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
31317 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31318 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
31319 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
31320 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31321 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31322 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31323 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31324 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31325 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31328 +#include "qbman_portal.h"
31330 +/* QBMan portal management command codes */
31331 +#define QBMAN_MC_ACQUIRE 0x30
31332 +#define QBMAN_WQCHAN_CONFIGURE 0x46
31334 +/* CINH register offsets */
31335 +#define QBMAN_CINH_SWP_EQCR_PI 0x800
31336 +#define QBMAN_CINH_SWP_EQCR_CI 0x840
31337 +#define QBMAN_CINH_SWP_EQAR 0x8c0
31338 +#define QBMAN_CINH_SWP_DQPI 0xa00
31339 +#define QBMAN_CINH_SWP_DCAP 0xac0
31340 +#define QBMAN_CINH_SWP_SDQCR 0xb00
31341 +#define QBMAN_CINH_SWP_RAR 0xcc0
31342 +#define QBMAN_CINH_SWP_ISR 0xe00
31343 +#define QBMAN_CINH_SWP_IER 0xe40
31344 +#define QBMAN_CINH_SWP_ISDR 0xe80
31345 +#define QBMAN_CINH_SWP_IIR 0xec0
31347 +/* CENA register offsets */
31348 +#define QBMAN_CENA_SWP_EQCR(n) (0x000 + ((uint32_t)(n) << 6))
31349 +#define QBMAN_CENA_SWP_DQRR(n) (0x200 + ((uint32_t)(n) << 6))
31350 +#define QBMAN_CENA_SWP_RCR(n) (0x400 + ((uint32_t)(n) << 6))
31351 +#define QBMAN_CENA_SWP_CR 0x600
31352 +#define QBMAN_CENA_SWP_RR(vb) (0x700 + ((uint32_t)(vb) >> 1))
31353 +#define QBMAN_CENA_SWP_VDQCR 0x780
31354 +#define QBMAN_CENA_SWP_EQCR_CI 0x840
31356 +/* Reverse mapping of QBMAN_CENA_SWP_DQRR() */
31357 +#define QBMAN_IDX_FROM_DQRR(p) (((unsigned long)p & 0x1ff) >> 6)
31359 +/* QBMan FQ management command codes */
31360 +#define QBMAN_FQ_SCHEDULE 0x48
31361 +#define QBMAN_FQ_FORCE 0x49
31362 +#define QBMAN_FQ_XON 0x4d
31363 +#define QBMAN_FQ_XOFF 0x4e
31365 +/*******************************/
31366 +/* Pre-defined attribute codes */
31367 +/*******************************/
31369 +struct qb_attr_code code_generic_verb = QB_CODE(0, 0, 7);
31370 +struct qb_attr_code code_generic_rslt = QB_CODE(0, 8, 8);
31372 +/*************************/
31373 +/* SDQCR attribute codes */
31374 +/*************************/
31376 +/* we put these here because at least some of them are required by
31377 + * qbman_swp_init() */
31378 +struct qb_attr_code code_sdqcr_dct = QB_CODE(0, 24, 2);
31379 +struct qb_attr_code code_sdqcr_fc = QB_CODE(0, 29, 1);
31380 +struct qb_attr_code code_sdqcr_tok = QB_CODE(0, 16, 8);
31381 +static struct qb_attr_code code_eq_dca_idx;
31382 +#define CODE_SDQCR_DQSRC(n) QB_CODE(0, n, 1)
31383 +enum qbman_sdqcr_dct {
31384 + qbman_sdqcr_dct_null = 0,
31385 + qbman_sdqcr_dct_prio_ics,
31386 + qbman_sdqcr_dct_active_ics,
31387 + qbman_sdqcr_dct_active
31390 +enum qbman_sdqcr_fc {
31391 + qbman_sdqcr_fc_one = 0,
31392 + qbman_sdqcr_fc_up_to_3 = 1
31395 +struct qb_attr_code code_sdqcr_dqsrc = QB_CODE(0, 0, 16);
31397 +/*********************************/
31398 +/* Portal constructor/destructor */
31399 +/*********************************/
31401 +/* Software portals should always be in the power-on state when we initialise,
31402 + * due to the CCSR-based portal reset functionality that MC has.
31404 + * Erk! Turns out that QMan versions prior to 4.1 do not correctly reset DQRR
31405 + * valid-bits, so we need to support a workaround where we don't trust
31406 + * valid-bits when detecting new entries until any stale ring entries have been
31407 + * overwritten at least once. The idea is that we read PI for the first few
31408 + * entries, then switch to valid-bit after that. The trick is to clear the
31409 + * bug-work-around boolean once the PI wraps around the ring for the first time.
31411 + * Note: this still carries a slight additional cost once the decrementer hits
31414 +struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
31417 + uint32_t eqcr_pi;
31418 + struct qbman_swp *p = kmalloc(sizeof(*p), GFP_KERNEL);
31423 +#ifdef QBMAN_CHECKING
31424 + p->mc.check = swp_mc_can_start;
31426 + p->mc.valid_bit = QB_VALID_BIT;
31428 + qb_attr_code_encode(&code_sdqcr_dct, &p->sdq, qbman_sdqcr_dct_prio_ics);
31429 + qb_attr_code_encode(&code_sdqcr_fc, &p->sdq, qbman_sdqcr_fc_up_to_3);
31430 + qb_attr_code_encode(&code_sdqcr_tok, &p->sdq, 0xbb);
31431 + atomic_set(&p->vdq.busy, 1);
31432 + p->vdq.valid_bit = QB_VALID_BIT;
31433 + p->dqrr.next_idx = 0;
31434 + p->dqrr.valid_bit = QB_VALID_BIT;
31435 + qman_version = p->desc->qman_version;
31436 + if ((qman_version & 0xFFFF0000) < QMAN_REV_4100) {
31437 + p->dqrr.dqrr_size = 4;
31438 + p->dqrr.reset_bug = 1;
31439 + /* Set size of DQRR to 4, encoded in 2 bits */
31440 + code_eq_dca_idx = (struct qb_attr_code)QB_CODE(0, 8, 2);
31442 + p->dqrr.dqrr_size = 8;
31443 + p->dqrr.reset_bug = 0;
31444 + /* Set size of DQRR to 8, encoded in 3 bits */
31445 + code_eq_dca_idx = (struct qb_attr_code)QB_CODE(0, 8, 3);
31448 + ret = qbman_swp_sys_init(&p->sys, d, p->dqrr.dqrr_size);
31451 + pr_err("qbman_swp_sys_init() failed %d\n", ret);
31454 + /* SDQCR needs to be initialized to 0 when no channels are
31455 + being dequeued from or else the QMan HW will indicate an
31456 + error. The values that were calculated above will be
31457 + applied when dequeues from a specific channel are enabled */
31458 + qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_SDQCR, 0);
31459 + eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
31460 + p->eqcr.pi = eqcr_pi & 0xF;
31461 + p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
31462 + p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_CI) & 0xF;
31463 + p->eqcr.available = QBMAN_EQCR_SIZE - qm_cyc_diff(QBMAN_EQCR_SIZE,
31464 + p->eqcr.ci, p->eqcr.pi);
31469 +void qbman_swp_finish(struct qbman_swp *p)
31471 +#ifdef QBMAN_CHECKING
31472 + BUG_ON(p->mc.check != swp_mc_can_start);
31474 + qbman_swp_sys_finish(&p->sys);
31478 +const struct qbman_swp_desc *qbman_swp_get_desc(struct qbman_swp *p)
31487 +uint32_t qbman_swp_interrupt_get_vanish(struct qbman_swp *p)
31489 + return qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_ISDR);
31492 +void qbman_swp_interrupt_set_vanish(struct qbman_swp *p, uint32_t mask)
31494 + qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_ISDR, mask);
31497 +uint32_t qbman_swp_interrupt_read_status(struct qbman_swp *p)
31499 + return qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_ISR);
31502 +void qbman_swp_interrupt_clear_status(struct qbman_swp *p, uint32_t mask)
31504 + qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_ISR, mask);
31507 +uint32_t qbman_swp_interrupt_get_trigger(struct qbman_swp *p)
31509 + return qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_IER);
31512 +void qbman_swp_interrupt_set_trigger(struct qbman_swp *p, uint32_t mask)
31514 + qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_IER, mask);
31517 +int qbman_swp_interrupt_get_inhibit(struct qbman_swp *p)
31519 + return qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_IIR);
31522 +void qbman_swp_interrupt_set_inhibit(struct qbman_swp *p, int inhibit)
31524 + qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_IIR, inhibit ? 0xffffffff : 0);
31527 +/***********************/
31528 +/* Management commands */
31529 +/***********************/
31532 + * Internal code common to all types of management commands.
31535 +void *qbman_swp_mc_start(struct qbman_swp *p)
31538 +#ifdef QBMAN_CHECKING
31539 + BUG_ON(p->mc.check != swp_mc_can_start);
31541 + ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
31542 +#ifdef QBMAN_CHECKING
31544 + p->mc.check = swp_mc_can_submit;
31549 +void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb)
31551 + uint32_t *v = cmd;
31552 +#ifdef QBMAN_CHECKING
31553 + BUG_ON(!p->mc.check != swp_mc_can_submit);
31555 + /* TBD: "|=" is going to hurt performance. Need to move as many fields
31556 + * out of word zero, and for those that remain, the "OR" needs to occur
31557 + * at the caller side. This debug check helps to catch cases where the
31558 + * caller wants to OR but has forgotten to do so. */
31559 + BUG_ON((*v & cmd_verb) != *v);
31560 + *v = cmd_verb | p->mc.valid_bit;
31561 + qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
31562 +#ifdef QBMAN_CHECKING
31563 + p->mc.check = swp_mc_can_poll;
31567 +void *qbman_swp_mc_result(struct qbman_swp *p)
31569 + uint32_t *ret, verb;
31570 +#ifdef QBMAN_CHECKING
31571 + BUG_ON(p->mc.check != swp_mc_can_poll);
31573 + qbman_cena_invalidate_prefetch(&p->sys,
31574 + QBMAN_CENA_SWP_RR(p->mc.valid_bit));
31575 + ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR(p->mc.valid_bit));
31576 + /* Remove the valid-bit - command completed iff the rest is non-zero */
31577 + verb = ret[0] & ~QB_VALID_BIT;
31580 +#ifdef QBMAN_CHECKING
31581 + p->mc.check = swp_mc_can_start;
31583 + p->mc.valid_bit ^= QB_VALID_BIT;
31591 +/* These should be const, eventually */
31592 +static struct qb_attr_code code_eq_cmd = QB_CODE(0, 0, 2);
31593 +static struct qb_attr_code code_eq_eqdi = QB_CODE(0, 3, 1);
31594 +static struct qb_attr_code code_eq_dca_en = QB_CODE(0, 15, 1);
31595 +static struct qb_attr_code code_eq_dca_pk = QB_CODE(0, 14, 1);
31596 +/* Can't set code_eq_dca_idx width. Need qman version. Read at runtime */
31597 +static struct qb_attr_code code_eq_orp_en = QB_CODE(0, 2, 1);
31598 +static struct qb_attr_code code_eq_orp_is_nesn = QB_CODE(0, 31, 1);
31599 +static struct qb_attr_code code_eq_orp_nlis = QB_CODE(0, 30, 1);
31600 +static struct qb_attr_code code_eq_orp_seqnum = QB_CODE(0, 16, 14);
31601 +static struct qb_attr_code code_eq_opr_id = QB_CODE(1, 0, 16);
31602 +static struct qb_attr_code code_eq_tgt_id = QB_CODE(2, 0, 24);
31603 +/* static struct qb_attr_code code_eq_tag = QB_CODE(3, 0, 32); */
31604 +static struct qb_attr_code code_eq_qd_en = QB_CODE(0, 4, 1);
31605 +static struct qb_attr_code code_eq_qd_bin = QB_CODE(4, 0, 16);
31606 +static struct qb_attr_code code_eq_qd_pri = QB_CODE(4, 16, 4);
31607 +static struct qb_attr_code code_eq_rsp_stash = QB_CODE(5, 16, 1);
31608 +static struct qb_attr_code code_eq_rsp_id = QB_CODE(5, 24, 8);
31609 +static struct qb_attr_code code_eq_rsp_lo = QB_CODE(6, 0, 32);
31611 +enum qbman_eq_cmd_e {
31612 + /* No enqueue, primarily for plugging ORP gaps for dropped frames */
31613 + qbman_eq_cmd_empty,
31614 + /* DMA an enqueue response once complete */
31615 + qbman_eq_cmd_respond,
31616 + /* DMA an enqueue response only if the enqueue fails */
31617 + qbman_eq_cmd_respond_reject
31620 +void qbman_eq_desc_clear(struct qbman_eq_desc *d)
31622 + memset(d, 0, sizeof(*d));
31625 +void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success)
31627 + uint32_t *cl = qb_cl(d);
31629 + qb_attr_code_encode(&code_eq_orp_en, cl, 0);
31630 + qb_attr_code_encode(&code_eq_cmd, cl,
31631 + respond_success ? qbman_eq_cmd_respond :
31632 + qbman_eq_cmd_respond_reject);
31635 +void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
31636 + uint32_t opr_id, uint32_t seqnum, int incomplete)
31638 + uint32_t *cl = qb_cl(d);
31640 + qb_attr_code_encode(&code_eq_orp_en, cl, 1);
31641 + qb_attr_code_encode(&code_eq_cmd, cl,
31642 + respond_success ? qbman_eq_cmd_respond :
31643 + qbman_eq_cmd_respond_reject);
31644 + qb_attr_code_encode(&code_eq_opr_id, cl, opr_id);
31645 + qb_attr_code_encode(&code_eq_orp_seqnum, cl, seqnum);
31646 + qb_attr_code_encode(&code_eq_orp_nlis, cl, !!incomplete);
31649 +void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, uint32_t opr_id,
31652 + uint32_t *cl = qb_cl(d);
31654 + qb_attr_code_encode(&code_eq_orp_en, cl, 1);
31655 + qb_attr_code_encode(&code_eq_cmd, cl, qbman_eq_cmd_empty);
31656 + qb_attr_code_encode(&code_eq_opr_id, cl, opr_id);
31657 + qb_attr_code_encode(&code_eq_orp_seqnum, cl, seqnum);
31658 + qb_attr_code_encode(&code_eq_orp_nlis, cl, 0);
31659 + qb_attr_code_encode(&code_eq_orp_is_nesn, cl, 0);
31662 +void qbman_eq_desc_set_orp_nesn(struct qbman_eq_desc *d, uint32_t opr_id,
31665 + uint32_t *cl = qb_cl(d);
31667 + qb_attr_code_encode(&code_eq_orp_en, cl, 1);
31668 + qb_attr_code_encode(&code_eq_cmd, cl, qbman_eq_cmd_empty);
31669 + qb_attr_code_encode(&code_eq_opr_id, cl, opr_id);
31670 + qb_attr_code_encode(&code_eq_orp_seqnum, cl, seqnum);
31671 + qb_attr_code_encode(&code_eq_orp_nlis, cl, 0);
31672 + qb_attr_code_encode(&code_eq_orp_is_nesn, cl, 1);
31675 +void qbman_eq_desc_set_response(struct qbman_eq_desc *d,
31676 + dma_addr_t storage_phys,
31679 + uint32_t *cl = qb_cl(d);
31681 + qb_attr_code_encode_64(&code_eq_rsp_lo, (uint64_t *)cl, storage_phys);
31682 + qb_attr_code_encode(&code_eq_rsp_stash, cl, !!stash);
31685 +void qbman_eq_desc_set_token(struct qbman_eq_desc *d, uint8_t token)
31687 + uint32_t *cl = qb_cl(d);
31689 + qb_attr_code_encode(&code_eq_rsp_id, cl, (uint32_t)token);
31692 +void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, uint32_t fqid)
31694 + uint32_t *cl = qb_cl(d);
31696 + qb_attr_code_encode(&code_eq_qd_en, cl, 0);
31697 + qb_attr_code_encode(&code_eq_tgt_id, cl, fqid);
31700 +void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, uint32_t qdid,
31701 + uint32_t qd_bin, uint32_t qd_prio)
31703 + uint32_t *cl = qb_cl(d);
31705 + qb_attr_code_encode(&code_eq_qd_en, cl, 1);
31706 + qb_attr_code_encode(&code_eq_tgt_id, cl, qdid);
31707 + qb_attr_code_encode(&code_eq_qd_bin, cl, qd_bin);
31708 + qb_attr_code_encode(&code_eq_qd_pri, cl, qd_prio);
31711 +void qbman_eq_desc_set_eqdi(struct qbman_eq_desc *d, int enable)
31713 + uint32_t *cl = qb_cl(d);
31715 + qb_attr_code_encode(&code_eq_eqdi, cl, !!enable);
31718 +void qbman_eq_desc_set_dca(struct qbman_eq_desc *d, int enable,
31719 + uint32_t dqrr_idx, int park)
31721 + uint32_t *cl = qb_cl(d);
31723 + qb_attr_code_encode(&code_eq_dca_en, cl, !!enable);
31725 + qb_attr_code_encode(&code_eq_dca_pk, cl, !!park);
31726 + qb_attr_code_encode(&code_eq_dca_idx, cl, dqrr_idx);
31730 +#define EQAR_IDX(eqar) ((eqar) & 0x7)
31731 +#define EQAR_VB(eqar) ((eqar) & 0x80)
31732 +#define EQAR_SUCCESS(eqar) ((eqar) & 0x100)
31733 +static int qbman_swp_enqueue_array_mode(struct qbman_swp *s,
31734 + const struct qbman_eq_desc *d,
31735 + const struct qbman_fd *fd)
31738 + const uint32_t *cl = qb_cl(d);
31739 + uint32_t eqar = qbman_cinh_read(&s->sys, QBMAN_CINH_SWP_EQAR);
31741 + pr_debug("EQAR=%08x\n", eqar);
31742 + if (!EQAR_SUCCESS(eqar))
31744 + p = qbman_cena_write_start_wo_shadow(&s->sys,
31745 + QBMAN_CENA_SWP_EQCR(EQAR_IDX(eqar)));
31746 + word_copy(&p[1], &cl[1], 7);
31747 + word_copy(&p[8], fd, sizeof(*fd) >> 2);
31748 + /* Set the verb byte, have to substitute in the valid-bit */
31750 + p[0] = cl[0] | EQAR_VB(eqar);
31751 + qbman_cena_write_complete_wo_shadow(&s->sys,
31752 + QBMAN_CENA_SWP_EQCR(EQAR_IDX(eqar)));
31756 +static int qbman_swp_enqueue_ring_mode(struct qbman_swp *s,
31757 + const struct qbman_eq_desc *d,
31758 + const struct qbman_fd *fd)
31761 + const uint32_t *cl = qb_cl(d);
31762 + uint32_t eqcr_ci;
31765 + if (!s->eqcr.available) {
31766 + eqcr_ci = s->eqcr.ci;
31767 + s->eqcr.ci = qbman_cena_read_reg(&s->sys,
31768 + QBMAN_CENA_SWP_EQCR_CI) & 0xF;
31769 + diff = qm_cyc_diff(QBMAN_EQCR_SIZE,
31770 + eqcr_ci, s->eqcr.ci);
31771 + s->eqcr.available += diff;
31776 + p = qbman_cena_write_start_wo_shadow(&s->sys,
31777 + QBMAN_CENA_SWP_EQCR(s->eqcr.pi & 7));
31778 + word_copy(&p[1], &cl[1], 7);
31779 + word_copy(&p[8], fd, sizeof(*fd) >> 2);
31781 + /* Set the verb byte, have to substitute in the valid-bit */
31782 + p[0] = cl[0] | s->eqcr.pi_vb;
31783 + qbman_cena_write_complete_wo_shadow(&s->sys,
31784 + QBMAN_CENA_SWP_EQCR(s->eqcr.pi & 7));
31786 + s->eqcr.pi &= 0xF;
31787 + s->eqcr.available--;
31788 + if (!(s->eqcr.pi & 7))
31789 + s->eqcr.pi_vb ^= QB_VALID_BIT;
31793 +int qbman_swp_fill_ring(struct qbman_swp *s,
31794 + const struct qbman_eq_desc *d,
31795 + const struct qbman_fd *fd,
31796 + __attribute__((unused)) uint8_t burst_index)
31799 + const uint32_t *cl = qb_cl(d);
31800 + uint32_t eqcr_ci;
31803 + if (!s->eqcr.available) {
31804 + eqcr_ci = s->eqcr.ci;
31805 + s->eqcr.ci = qbman_cena_read_reg(&s->sys,
31806 + QBMAN_CENA_SWP_EQCR_CI) & 0xF;
31807 + diff = qm_cyc_diff(QBMAN_EQCR_SIZE,
31808 + eqcr_ci, s->eqcr.ci);
31809 + s->eqcr.available += diff;
31814 + p = qbman_cena_write_start_wo_shadow(&s->sys,
31815 + QBMAN_CENA_SWP_EQCR((s->eqcr.pi/* +burst_index */) & 7));
31816 + /* word_copy(&p[1], &cl[1], 7); */
31817 + memcpy(&p[1], &cl[1], 7*4);
31818 + /* word_copy(&p[8], fd, sizeof(*fd) >> 2); */
31819 + memcpy(&p[8], fd, sizeof(struct qbman_fd));
31822 + p[0] = cl[0] | s->eqcr.pi_vb;
31825 + s->eqcr.pi &= 0xF;
31826 + s->eqcr.available--;
31827 + if (!(s->eqcr.pi & 7))
31828 + s->eqcr.pi_vb ^= QB_VALID_BIT;
31833 +int qbman_swp_flush_ring(struct qbman_swp *s)
31835 + void *ptr = s->sys.addr_cena;
31837 + dcbf((uint64_t)ptr);
31838 + dcbf((uint64_t)ptr + 0x40);
31839 + dcbf((uint64_t)ptr + 0x80);
31840 + dcbf((uint64_t)ptr + 0xc0);
31841 + dcbf((uint64_t)ptr + 0x100);
31842 + dcbf((uint64_t)ptr + 0x140);
31843 + dcbf((uint64_t)ptr + 0x180);
31844 + dcbf((uint64_t)ptr + 0x1c0);
31849 +void qbman_sync(void)
31854 +int qbman_swp_enqueue(struct qbman_swp *s, const struct qbman_eq_desc *d,
31855 + const struct qbman_fd *fd)
31857 + if (s->sys.eqcr_mode == qman_eqcr_vb_array)
31858 + return qbman_swp_enqueue_array_mode(s, d, fd);
31859 + else /* Use ring mode by default */
31860 + return qbman_swp_enqueue_ring_mode(s, d, fd);
31863 +/*************************/
31864 +/* Static (push) dequeue */
31865 +/*************************/
31867 +void qbman_swp_push_get(struct qbman_swp *s, uint8_t channel_idx, int *enabled)
31869 + struct qb_attr_code code = CODE_SDQCR_DQSRC(channel_idx);
31871 + BUG_ON(channel_idx > 15);
31872 + *enabled = (int)qb_attr_code_decode(&code, &s->sdq);
31875 +void qbman_swp_push_set(struct qbman_swp *s, uint8_t channel_idx, int enable)
31878 + struct qb_attr_code code = CODE_SDQCR_DQSRC(channel_idx);
31880 + BUG_ON(channel_idx > 15);
31881 + qb_attr_code_encode(&code, &s->sdq, !!enable);
31882 + /* Read make the complete src map. If no channels are enabled
31883 + the SDQCR must be 0 or else QMan will assert errors */
31884 + dqsrc = (uint16_t)qb_attr_code_decode(&code_sdqcr_dqsrc, &s->sdq);
31886 + qbman_cinh_write(&s->sys, QBMAN_CINH_SWP_SDQCR, s->sdq);
31888 + qbman_cinh_write(&s->sys, QBMAN_CINH_SWP_SDQCR, 0);
31891 +/***************************/
31892 +/* Volatile (pull) dequeue */
31893 +/***************************/
31895 +/* These should be const, eventually */
31896 +static struct qb_attr_code code_pull_dct = QB_CODE(0, 0, 2);
31897 +static struct qb_attr_code code_pull_dt = QB_CODE(0, 2, 2);
31898 +static struct qb_attr_code code_pull_rls = QB_CODE(0, 4, 1);
31899 +static struct qb_attr_code code_pull_stash = QB_CODE(0, 5, 1);
31900 +static struct qb_attr_code code_pull_numframes = QB_CODE(0, 8, 4);
31901 +static struct qb_attr_code code_pull_token = QB_CODE(0, 16, 8);
31902 +static struct qb_attr_code code_pull_dqsource = QB_CODE(1, 0, 24);
31903 +static struct qb_attr_code code_pull_rsp_lo = QB_CODE(2, 0, 32);
31905 +enum qb_pull_dt_e {
31906 + qb_pull_dt_channel,
31907 + qb_pull_dt_workqueue,
31908 + qb_pull_dt_framequeue
31911 +void qbman_pull_desc_clear(struct qbman_pull_desc *d)
31913 + memset(d, 0, sizeof(*d));
31916 +void qbman_pull_desc_set_storage(struct qbman_pull_desc *d,
31917 + struct qbman_result *storage,
31918 + dma_addr_t storage_phys,
31921 + uint32_t *cl = qb_cl(d);
31922 + /* Squiggle the pointer 'storage' into the extra 2 words of the
31923 + * descriptor (which aren't copied to the hw command) */
31924 + *(void **)&cl[4] = storage;
31926 + qb_attr_code_encode(&code_pull_rls, cl, 0);
31929 + qb_attr_code_encode(&code_pull_rls, cl, 1);
31930 + qb_attr_code_encode(&code_pull_stash, cl, !!stash);
31931 + qb_attr_code_encode_64(&code_pull_rsp_lo, (uint64_t *)cl, storage_phys);
31934 +void qbman_pull_desc_set_numframes(struct qbman_pull_desc *d, uint8_t numframes)
31936 + uint32_t *cl = qb_cl(d);
31938 + BUG_ON(!numframes || (numframes > 16));
31939 + qb_attr_code_encode(&code_pull_numframes, cl,
31940 + (uint32_t)(numframes - 1));
31943 +void qbman_pull_desc_set_token(struct qbman_pull_desc *d, uint8_t token)
31945 + uint32_t *cl = qb_cl(d);
31947 + qb_attr_code_encode(&code_pull_token, cl, token);
31950 +void qbman_pull_desc_set_fq(struct qbman_pull_desc *d, uint32_t fqid)
31952 + uint32_t *cl = qb_cl(d);
31954 + qb_attr_code_encode(&code_pull_dct, cl, 1);
31955 + qb_attr_code_encode(&code_pull_dt, cl, qb_pull_dt_framequeue);
31956 + qb_attr_code_encode(&code_pull_dqsource, cl, fqid);
31959 +void qbman_pull_desc_set_wq(struct qbman_pull_desc *d, uint32_t wqid,
31960 + enum qbman_pull_type_e dct)
31962 + uint32_t *cl = qb_cl(d);
31964 + qb_attr_code_encode(&code_pull_dct, cl, dct);
31965 + qb_attr_code_encode(&code_pull_dt, cl, qb_pull_dt_workqueue);
31966 + qb_attr_code_encode(&code_pull_dqsource, cl, wqid);
31969 +void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, uint32_t chid,
31970 + enum qbman_pull_type_e dct)
31972 + uint32_t *cl = qb_cl(d);
31974 + qb_attr_code_encode(&code_pull_dct, cl, dct);
31975 + qb_attr_code_encode(&code_pull_dt, cl, qb_pull_dt_channel);
31976 + qb_attr_code_encode(&code_pull_dqsource, cl, chid);
31979 +int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d)
31982 + uint32_t *cl = qb_cl(d);
31984 + if (!atomic_dec_and_test(&s->vdq.busy)) {
31985 + atomic_inc(&s->vdq.busy);
31988 + s->vdq.storage = *(void **)&cl[4];
31989 + qb_attr_code_encode(&code_pull_token, cl, 1);
31990 + p = qbman_cena_write_start_wo_shadow(&s->sys, QBMAN_CENA_SWP_VDQCR);
31991 + word_copy(&p[1], &cl[1], 3);
31992 + /* Set the verb byte, have to substitute in the valid-bit */
31994 + p[0] = cl[0] | s->vdq.valid_bit;
31995 + s->vdq.valid_bit ^= QB_VALID_BIT;
31996 + qbman_cena_write_complete_wo_shadow(&s->sys, QBMAN_CENA_SWP_VDQCR);
32000 +/****************/
32001 +/* Polling DQRR */
32002 +/****************/
32004 +static struct qb_attr_code code_dqrr_verb = QB_CODE(0, 0, 8);
32005 +static struct qb_attr_code code_dqrr_response = QB_CODE(0, 0, 7);
32006 +static struct qb_attr_code code_dqrr_stat = QB_CODE(0, 8, 8);
32007 +static struct qb_attr_code code_dqrr_seqnum = QB_CODE(0, 16, 14);
32008 +static struct qb_attr_code code_dqrr_odpid = QB_CODE(1, 0, 16);
32009 +/* static struct qb_attr_code code_dqrr_tok = QB_CODE(1, 24, 8); */
32010 +static struct qb_attr_code code_dqrr_fqid = QB_CODE(2, 0, 24);
32011 +static struct qb_attr_code code_dqrr_byte_count = QB_CODE(4, 0, 32);
32012 +static struct qb_attr_code code_dqrr_frame_count = QB_CODE(5, 0, 24);
32013 +static struct qb_attr_code code_dqrr_ctx_lo = QB_CODE(6, 0, 32);
32015 +#define QBMAN_RESULT_DQ 0x60
32016 +#define QBMAN_RESULT_FQRN 0x21
32017 +#define QBMAN_RESULT_FQRNI 0x22
32018 +#define QBMAN_RESULT_FQPN 0x24
32019 +#define QBMAN_RESULT_FQDAN 0x25
32020 +#define QBMAN_RESULT_CDAN 0x26
32021 +#define QBMAN_RESULT_CSCN_MEM 0x27
32022 +#define QBMAN_RESULT_CGCU 0x28
32023 +#define QBMAN_RESULT_BPSCN 0x29
32024 +#define QBMAN_RESULT_CSCN_WQ 0x2a
32026 +static struct qb_attr_code code_dqpi_pi = QB_CODE(0, 0, 4);
32028 +/* NULL return if there are no unconsumed DQRR entries. Returns a DQRR entry
32029 + * only once, so repeated calls can return a sequence of DQRR entries, without
32030 + * requiring they be consumed immediately or in any particular order. */
32031 +const struct qbman_result *qbman_swp_dqrr_next(struct qbman_swp *s)
32034 + uint32_t response_verb;
32036 + const struct qbman_result *dq;
32037 + const uint32_t *p;
32039 + /* Before using valid-bit to detect if something is there, we have to
32040 + * handle the case of the DQRR reset bug... */
32041 + if (unlikely(s->dqrr.reset_bug)) {
32042 + /* We pick up new entries by cache-inhibited producer index,
32043 + * which means that a non-coherent mapping would require us to
32044 + * invalidate and read *only* once that PI has indicated that
32045 + * there's an entry here. The first trip around the DQRR ring
32046 + * will be much less efficient than all subsequent trips around
32049 + uint32_t dqpi = qbman_cinh_read(&s->sys, QBMAN_CINH_SWP_DQPI);
32050 + uint32_t pi = qb_attr_code_decode(&code_dqpi_pi, &dqpi);
32051 + /* there are new entries iff pi != next_idx */
32052 + if (pi == s->dqrr.next_idx)
32054 + /* if next_idx is/was the last ring index, and 'pi' is
32055 + * different, we can disable the workaround as all the ring
32056 + * entries have now been DMA'd to so valid-bit checking is
32057 + * repaired. Note: this logic needs to be based on next_idx
32058 + * (which increments one at a time), rather than on pi (which
32059 + * can burst and wrap-around between our snapshots of it).
32061 + BUG_ON((s->dqrr.dqrr_size - 1) < 0);
32062 + if (s->dqrr.next_idx == (s->dqrr.dqrr_size - 1u)) {
32063 + pr_debug("DEBUG: next_idx=%d, pi=%d, clear reset bug\n",
32064 + s->dqrr.next_idx, pi);
32065 + s->dqrr.reset_bug = 0;
32067 + qbman_cena_invalidate_prefetch(&s->sys,
32068 + QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
32070 + dq = qbman_cena_read_wo_shadow(&s->sys,
32071 + QBMAN_CENA_SWP_DQRR(s->dqrr.next_idx));
32073 + verb = qb_attr_code_decode(&code_dqrr_verb, p);
32074 + /* If the valid-bit isn't of the expected polarity, nothing there. Note,
32075 + * in the DQRR reset bug workaround, we shouldn't need to skip these
32076 + * check, because we've already determined that a new entry is available
32077 + * and we've invalidated the cacheline before reading it, so the
32078 + * valid-bit behaviour is repaired and should tell us what we already
32079 + * knew from reading PI.
32081 + if ((verb & QB_VALID_BIT) != s->dqrr.valid_bit)
32084 + /* There's something there. Move "next_idx" attention to the next ring
32085 + * entry (and prefetch it) before returning what we found. */
32086 + s->dqrr.next_idx++;
32087 + if (s->dqrr.next_idx == s->dqrr.dqrr_size) {
32088 + s->dqrr.next_idx = 0;
32089 + s->dqrr.valid_bit ^= QB_VALID_BIT;
32091 + /* If this is the final response to a volatile dequeue command
32092 + indicate that the vdq is no longer busy */
32093 + flags = qbman_result_DQ_flags(dq);
32094 + response_verb = qb_attr_code_decode(&code_dqrr_response, &verb);
32095 + if ((response_verb == QBMAN_RESULT_DQ) &&
32096 + (flags & QBMAN_DQ_STAT_VOLATILE) &&
32097 + (flags & QBMAN_DQ_STAT_EXPIRED))
32098 + atomic_inc(&s->vdq.busy);
32103 +/* Consume DQRR entries previously returned from qbman_swp_dqrr_next(). */
32104 +void qbman_swp_dqrr_consume(struct qbman_swp *s,
32105 + const struct qbman_result *dq)
32107 + qbman_cinh_write(&s->sys, QBMAN_CINH_SWP_DCAP, QBMAN_IDX_FROM_DQRR(dq));
32110 +/*********************************/
32111 +/* Polling user-provided storage */
32112 +/*********************************/
32114 +int qbman_result_has_new_result(__attribute__((unused)) struct qbman_swp *s,
32115 + const struct qbman_result *dq)
32117 + /* To avoid converting the little-endian DQ entry to host-endian prior
32118 + * to us knowing whether there is a valid entry or not (and run the
32119 + * risk of corrupting the incoming hardware LE write), we detect in
32120 + * hardware endianness rather than host. This means we need a different
32121 + * "code" depending on whether we are BE or LE in software, which is
32122 + * where DQRR_TOK_OFFSET comes in... */
32123 + static struct qb_attr_code code_dqrr_tok_detect =
32124 + QB_CODE(0, DQRR_TOK_OFFSET, 8);
32125 + /* The user trying to poll for a result treats "dq" as const. It is
32126 + * however the same address that was provided to us non-const in the
32127 + * first place, for directing hardware DMA to. So we can cast away the
32128 + * const because it is mutable from our perspective. */
32129 + uint32_t *p = (uint32_t *)(unsigned long)qb_cl(dq);
32132 + token = qb_attr_code_decode(&code_dqrr_tok_detect, &p[1]);
32135 + qb_attr_code_encode(&code_dqrr_tok_detect, &p[1], 0);
32137 + /* Only now do we convert from hardware to host endianness. Also, as we
32138 + * are returning success, the user has promised not to call us again, so
32139 + * there's no risk of us converting the endianness twice... */
32140 + make_le32_n(p, 16);
32144 +int qbman_check_command_complete(struct qbman_swp *s,
32145 + const struct qbman_result *dq)
32147 + /* To avoid converting the little-endian DQ entry to host-endian prior
32148 + * to us knowing whether there is a valid entry or not (and run the
32149 + * risk of corrupting the incoming hardware LE write), we detect in
32150 + * hardware endianness rather than host. This means we need a different
32151 + * "code" depending on whether we are BE or LE in software, which is
32152 + * where DQRR_TOK_OFFSET comes in... */
32153 + static struct qb_attr_code code_dqrr_tok_detect =
32154 + QB_CODE(0, DQRR_TOK_OFFSET, 8);
32155 + /* The user trying to poll for a result treats "dq" as const. It is
32156 + * however the same address that was provided to us non-const in the
32157 + * first place, for directing hardware DMA to. So we can cast away the
32158 + * const because it is mutable from our perspective. */
32159 + uint32_t *p = (uint32_t *)(unsigned long)qb_cl(dq);
32162 + token = qb_attr_code_decode(&code_dqrr_tok_detect, &p[1]);
32165 + /*When token is set it indicates that VDQ command has been fetched by qbman and
32166 + *is working on it. It is safe for software to issue another VDQ command, so
32167 + *incrementing the busy variable.*/
32168 + if (s->vdq.storage == dq) {
32169 + s->vdq.storage = NULL;
32170 + atomic_inc(&s->vdq.busy);
32175 +/********************************/
32176 +/* Categorising qbman results */
32177 +/********************************/
32179 +static struct qb_attr_code code_result_in_mem =
32180 + QB_CODE(0, QBMAN_RESULT_VERB_OFFSET_IN_MEM, 7);
32182 +static inline int __qbman_result_is_x(const struct qbman_result *dq,
32185 + const uint32_t *p = qb_cl(dq);
32186 + uint32_t response_verb = qb_attr_code_decode(&code_dqrr_response, p);
32188 + return (response_verb == x);
32191 +static inline int __qbman_result_is_x_in_mem(const struct qbman_result *dq,
32194 + const uint32_t *p = qb_cl(dq);
32195 + uint32_t response_verb = qb_attr_code_decode(&code_result_in_mem, p);
32197 + return (response_verb == x);
32200 +int qbman_result_is_DQ(const struct qbman_result *dq)
32202 + return __qbman_result_is_x(dq, QBMAN_RESULT_DQ);
32205 +int qbman_result_is_FQDAN(const struct qbman_result *dq)
32207 + return __qbman_result_is_x(dq, QBMAN_RESULT_FQDAN);
32210 +int qbman_result_is_CDAN(const struct qbman_result *dq)
32212 + return __qbman_result_is_x(dq, QBMAN_RESULT_CDAN);
32215 +int qbman_result_is_CSCN(const struct qbman_result *dq)
32217 + return __qbman_result_is_x_in_mem(dq, QBMAN_RESULT_CSCN_MEM) ||
32218 + __qbman_result_is_x(dq, QBMAN_RESULT_CSCN_WQ);
32221 +int qbman_result_is_BPSCN(const struct qbman_result *dq)
32223 + return __qbman_result_is_x_in_mem(dq, QBMAN_RESULT_BPSCN);
32226 +int qbman_result_is_CGCU(const struct qbman_result *dq)
32228 + return __qbman_result_is_x_in_mem(dq, QBMAN_RESULT_CGCU);
32231 +int qbman_result_is_FQRN(const struct qbman_result *dq)
32233 + return __qbman_result_is_x_in_mem(dq, QBMAN_RESULT_FQRN);
32236 +int qbman_result_is_FQRNI(const struct qbman_result *dq)
32238 + return __qbman_result_is_x_in_mem(dq, QBMAN_RESULT_FQRNI);
32241 +int qbman_result_is_FQPN(const struct qbman_result *dq)
32243 + return __qbman_result_is_x(dq, QBMAN_RESULT_FQPN);
32246 +/*********************************/
32247 +/* Parsing frame dequeue results */
32248 +/*********************************/
32250 +/* These APIs assume qbman_result_is_DQ() is TRUE */
32252 +uint32_t qbman_result_DQ_flags(const struct qbman_result *dq)
32254 + const uint32_t *p = qb_cl(dq);
32256 + return qb_attr_code_decode(&code_dqrr_stat, p);
32259 +uint16_t qbman_result_DQ_seqnum(const struct qbman_result *dq)
32261 + const uint32_t *p = qb_cl(dq);
32263 + return (uint16_t)qb_attr_code_decode(&code_dqrr_seqnum, p);
32266 +uint16_t qbman_result_DQ_odpid(const struct qbman_result *dq)
32268 + const uint32_t *p = qb_cl(dq);
32270 + return (uint16_t)qb_attr_code_decode(&code_dqrr_odpid, p);
32273 +uint32_t qbman_result_DQ_fqid(const struct qbman_result *dq)
32275 + const uint32_t *p = qb_cl(dq);
32277 + return qb_attr_code_decode(&code_dqrr_fqid, p);
32280 +uint32_t qbman_result_DQ_byte_count(const struct qbman_result *dq)
32282 + const uint32_t *p = qb_cl(dq);
32284 + return qb_attr_code_decode(&code_dqrr_byte_count, p);
32287 +uint32_t qbman_result_DQ_frame_count(const struct qbman_result *dq)
32289 + const uint32_t *p = qb_cl(dq);
32291 + return qb_attr_code_decode(&code_dqrr_frame_count, p);
32294 +uint64_t qbman_result_DQ_fqd_ctx(const struct qbman_result *dq)
32296 + const uint64_t *p = (const uint64_t *)qb_cl(dq);
32298 + return qb_attr_code_decode_64(&code_dqrr_ctx_lo, p);
32301 +const struct qbman_fd *qbman_result_DQ_fd(const struct qbman_result *dq)
32303 + const uint32_t *p = qb_cl(dq);
32305 + return (const struct qbman_fd *)&p[8];
32308 +/**************************************/
32309 +/* Parsing state-change notifications */
32310 +/**************************************/
32312 +static struct qb_attr_code code_scn_state = QB_CODE(0, 16, 8);
32313 +static struct qb_attr_code code_scn_rid = QB_CODE(1, 0, 24);
32314 +static struct qb_attr_code code_scn_state_in_mem =
32315 + QB_CODE(0, SCN_STATE_OFFSET_IN_MEM, 8);
32316 +static struct qb_attr_code code_scn_rid_in_mem =
32317 + QB_CODE(1, SCN_RID_OFFSET_IN_MEM, 24);
32318 +static struct qb_attr_code code_scn_ctx_lo = QB_CODE(2, 0, 32);
32320 +uint8_t qbman_result_SCN_state(const struct qbman_result *scn)
32322 + const uint32_t *p = qb_cl(scn);
32324 + return (uint8_t)qb_attr_code_decode(&code_scn_state, p);
32327 +uint32_t qbman_result_SCN_rid(const struct qbman_result *scn)
32329 + const uint32_t *p = qb_cl(scn);
32331 + return qb_attr_code_decode(&code_scn_rid, p);
32334 +uint64_t qbman_result_SCN_ctx(const struct qbman_result *scn)
32336 + const uint64_t *p = (const uint64_t *)qb_cl(scn);
32338 + return qb_attr_code_decode_64(&code_scn_ctx_lo, p);
32341 +uint8_t qbman_result_SCN_state_in_mem(const struct qbman_result *scn)
32343 + const uint32_t *p = qb_cl(scn);
32345 + return (uint8_t)qb_attr_code_decode(&code_scn_state_in_mem, p);
32348 +uint32_t qbman_result_SCN_rid_in_mem(const struct qbman_result *scn)
32350 + const uint32_t *p = qb_cl(scn);
32351 + uint32_t result_rid;
32353 + result_rid = qb_attr_code_decode(&code_scn_rid_in_mem, p);
32354 + return make_le24(result_rid);
32357 +/*****************/
32358 +/* Parsing BPSCN */
32359 +/*****************/
32360 +uint16_t qbman_result_bpscn_bpid(const struct qbman_result *scn)
32362 + return (uint16_t)qbman_result_SCN_rid_in_mem(scn) & 0x3FFF;
32365 +int qbman_result_bpscn_has_free_bufs(const struct qbman_result *scn)
32367 + return !(int)(qbman_result_SCN_state_in_mem(scn) & 0x1);
32370 +int qbman_result_bpscn_is_depleted(const struct qbman_result *scn)
32372 + return (int)(qbman_result_SCN_state_in_mem(scn) & 0x2);
32375 +int qbman_result_bpscn_is_surplus(const struct qbman_result *scn)
32377 + return (int)(qbman_result_SCN_state_in_mem(scn) & 0x4);
32380 +uint64_t qbman_result_bpscn_ctx(const struct qbman_result *scn)
32383 + uint32_t ctx_hi, ctx_lo;
32385 + ctx = qbman_result_SCN_ctx(scn);
32386 + ctx_hi = upper32(ctx);
32387 + ctx_lo = lower32(ctx);
32388 + return ((uint64_t)make_le32(ctx_hi) << 32 |
32389 + (uint64_t)make_le32(ctx_lo));
32392 +/*****************/
32393 +/* Parsing CGCU */
32394 +/*****************/
32395 +uint16_t qbman_result_cgcu_cgid(const struct qbman_result *scn)
32397 + return (uint16_t)qbman_result_SCN_rid_in_mem(scn) & 0xFFFF;
32400 +uint64_t qbman_result_cgcu_icnt(const struct qbman_result *scn)
32403 + uint32_t ctx_hi, ctx_lo;
32405 + ctx = qbman_result_SCN_ctx(scn);
32406 + ctx_hi = upper32(ctx);
32407 + ctx_lo = lower32(ctx);
32408 + return ((uint64_t)(make_le32(ctx_hi) & 0xFF) << 32) |
32409 + (uint64_t)make_le32(ctx_lo);
32412 +/******************/
32413 +/* Buffer release */
32414 +/******************/
32416 +/* These should be const, eventually */
32417 +/* static struct qb_attr_code code_release_num = QB_CODE(0, 0, 3); */
32418 +static struct qb_attr_code code_release_set_me = QB_CODE(0, 5, 1);
32419 +static struct qb_attr_code code_release_rcdi = QB_CODE(0, 6, 1);
32420 +static struct qb_attr_code code_release_bpid = QB_CODE(0, 16, 16);
32422 +void qbman_release_desc_clear(struct qbman_release_desc *d)
32426 + memset(d, 0, sizeof(*d));
32428 + qb_attr_code_encode(&code_release_set_me, cl, 1);
32431 +void qbman_release_desc_set_bpid(struct qbman_release_desc *d, uint32_t bpid)
32433 + uint32_t *cl = qb_cl(d);
32435 + qb_attr_code_encode(&code_release_bpid, cl, bpid);
32438 +void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable)
32440 + uint32_t *cl = qb_cl(d);
32442 + qb_attr_code_encode(&code_release_rcdi, cl, !!enable);
32445 +#define RAR_IDX(rar) ((rar) & 0x7)
32446 +#define RAR_VB(rar) ((rar) & 0x80)
32447 +#define RAR_SUCCESS(rar) ((rar) & 0x100)
32449 +int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d,
32450 + const uint64_t *buffers, unsigned int num_buffers)
32453 + const uint32_t *cl = qb_cl(d);
32454 + uint32_t rar = qbman_cinh_read(&s->sys, QBMAN_CINH_SWP_RAR);
32456 + pr_debug("RAR=%08x\n", rar);
32457 + if (!RAR_SUCCESS(rar))
32459 + BUG_ON(!num_buffers || (num_buffers > 7));
32460 + /* Start the release command */
32461 + p = qbman_cena_write_start_wo_shadow(&s->sys,
32462 + QBMAN_CENA_SWP_RCR(RAR_IDX(rar)));
32463 + /* Copy the caller's buffer pointers to the command */
32464 + u64_to_le32_copy(&p[2], buffers, num_buffers);
32465 + /* Set the verb byte, have to substitute in the valid-bit and the number
32468 + p[0] = cl[0] | RAR_VB(rar) | num_buffers;
32469 + qbman_cena_write_complete_wo_shadow(&s->sys,
32470 + QBMAN_CENA_SWP_RCR(RAR_IDX(rar)));
32474 +/*******************/
32475 +/* Buffer acquires */
32476 +/*******************/
32478 +/* These should be const, eventually */
32479 +static struct qb_attr_code code_acquire_bpid = QB_CODE(0, 16, 16);
32480 +static struct qb_attr_code code_acquire_num = QB_CODE(1, 0, 3);
32481 +static struct qb_attr_code code_acquire_r_num = QB_CODE(1, 0, 3);
32483 +int qbman_swp_acquire(struct qbman_swp *s, uint32_t bpid, uint64_t *buffers,
32484 + unsigned int num_buffers)
32487 + uint32_t rslt, num;
32489 + BUG_ON(!num_buffers || (num_buffers > 7));
32491 + /* Start the management command */
32492 + p = qbman_swp_mc_start(s);
32497 + /* Encode the caller-provided attributes */
32498 + qb_attr_code_encode(&code_acquire_bpid, p, bpid);
32499 + qb_attr_code_encode(&code_acquire_num, p, num_buffers);
32501 + /* Complete the management command */
32502 + p = qbman_swp_mc_complete(s, p, p[0] | QBMAN_MC_ACQUIRE);
32504 + /* Decode the outcome */
32505 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
32506 + num = qb_attr_code_decode(&code_acquire_r_num, p);
32507 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p) != QBMAN_MC_ACQUIRE);
32509 + /* Determine success or failure */
32510 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
32511 + pr_err("Acquire buffers from BPID 0x%x failed, code=0x%02x\n",
32515 + BUG_ON(num > num_buffers);
32516 + /* Copy the acquired buffers to the caller's array */
32517 + u64_from_le32_copy(buffers, &p[2], num);
32521 +/*****************/
32522 +/* FQ management */
32523 +/*****************/
32525 +static struct qb_attr_code code_fqalt_fqid = QB_CODE(1, 0, 32);
32527 +static int qbman_swp_alt_fq_state(struct qbman_swp *s, uint32_t fqid,
32528 + uint8_t alt_fq_verb)
32533 + /* Start the management command */
32534 + p = qbman_swp_mc_start(s);
32538 + qb_attr_code_encode(&code_fqalt_fqid, p, fqid);
32539 + /* Complete the management command */
32540 + p = qbman_swp_mc_complete(s, p, p[0] | alt_fq_verb);
32542 + /* Decode the outcome */
32543 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
32544 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p) != alt_fq_verb);
32546 + /* Determine success or failure */
32547 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
32548 + pr_err("ALT FQID %d failed: verb = 0x%08x, code = 0x%02x\n",
32549 + fqid, alt_fq_verb, rslt);
32556 +int qbman_swp_fq_schedule(struct qbman_swp *s, uint32_t fqid)
32558 + return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_SCHEDULE);
32561 +int qbman_swp_fq_force(struct qbman_swp *s, uint32_t fqid)
32563 + return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_FORCE);
32566 +int qbman_swp_fq_xon(struct qbman_swp *s, uint32_t fqid)
32568 + return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_XON);
32571 +int qbman_swp_fq_xoff(struct qbman_swp *s, uint32_t fqid)
32573 + return qbman_swp_alt_fq_state(s, fqid, QBMAN_FQ_XOFF);
32576 +/**********************/
32577 +/* Channel management */
32578 +/**********************/
32580 +static struct qb_attr_code code_cdan_cid = QB_CODE(0, 16, 12);
32581 +static struct qb_attr_code code_cdan_we = QB_CODE(1, 0, 8);
32582 +static struct qb_attr_code code_cdan_en = QB_CODE(1, 8, 1);
32583 +static struct qb_attr_code code_cdan_ctx_lo = QB_CODE(2, 0, 32);
32585 +/* Hide "ICD" for now as we don't use it, don't set it, and don't test it, so it
32586 + * would be irresponsible to expose it. */
32587 +#define CODE_CDAN_WE_EN 0x1
32588 +#define CODE_CDAN_WE_CTX 0x4
32590 +static int qbman_swp_CDAN_set(struct qbman_swp *s, uint16_t channelid,
32591 + uint8_t we_mask, uint8_t cdan_en,
32597 + /* Start the management command */
32598 + p = qbman_swp_mc_start(s);
32602 + /* Encode the caller-provided attributes */
32603 + qb_attr_code_encode(&code_cdan_cid, p, channelid);
32604 + qb_attr_code_encode(&code_cdan_we, p, we_mask);
32605 + qb_attr_code_encode(&code_cdan_en, p, cdan_en);
32606 + qb_attr_code_encode_64(&code_cdan_ctx_lo, (uint64_t *)p, ctx);
32607 + /* Complete the management command */
32608 + p = qbman_swp_mc_complete(s, p, p[0] | QBMAN_WQCHAN_CONFIGURE);
32610 + /* Decode the outcome */
32611 + rslt = qb_attr_code_decode(&code_generic_rslt, p);
32612 + BUG_ON(qb_attr_code_decode(&code_generic_verb, p)
32613 + != QBMAN_WQCHAN_CONFIGURE);
32615 + /* Determine success or failure */
32616 + if (unlikely(rslt != QBMAN_MC_RSLT_OK)) {
32617 + pr_err("CDAN cQID %d failed: code = 0x%02x\n",
32618 + channelid, rslt);
32625 +int qbman_swp_CDAN_set_context(struct qbman_swp *s, uint16_t channelid,
32628 + return qbman_swp_CDAN_set(s, channelid,
32629 + CODE_CDAN_WE_CTX,
32633 +int qbman_swp_CDAN_enable(struct qbman_swp *s, uint16_t channelid)
32635 + return qbman_swp_CDAN_set(s, channelid,
32640 +int qbman_swp_CDAN_disable(struct qbman_swp *s, uint16_t channelid)
32642 + return qbman_swp_CDAN_set(s, channelid,
32647 +int qbman_swp_CDAN_set_context_enable(struct qbman_swp *s, uint16_t channelid,
32650 + return qbman_swp_CDAN_set(s, channelid,
32651 + CODE_CDAN_WE_EN | CODE_CDAN_WE_CTX,
32655 +uint8_t qbman_get_dqrr_idx(struct qbman_result *dqrr)
32657 + return QBMAN_IDX_FROM_DQRR(dqrr);
32660 +struct qbman_result *qbman_get_dqrr_from_idx(struct qbman_swp *s, uint8_t idx)
32662 + struct qbman_result *dq;
32664 + dq = qbman_cena_read(&s->sys, QBMAN_CENA_SWP_DQRR(idx));
32668 +int qbman_swp_send_multiple(struct qbman_swp *s,
32669 + const struct qbman_eq_desc *d,
32670 + const struct qbman_fd *fd,
32671 + int frames_to_send)
32674 + const uint32_t *cl = qb_cl(d);
32675 + uint32_t eqcr_ci;
32679 + int initial_pi = s->eqcr.pi;
32680 + uint64_t start_pointer;
32682 + if (!s->eqcr.available) {
32683 + eqcr_ci = s->eqcr.ci;
32684 + s->eqcr.ci = qbman_cena_read_reg(&s->sys,
32685 + QBMAN_CENA_SWP_EQCR_CI) & 0xF;
32686 + diff = qm_cyc_diff(QBMAN_EQCR_SIZE,
32687 + eqcr_ci, s->eqcr.ci);
32690 + s->eqcr.available += diff;
32693 + /* we are trying to send frames_to_send if we have enough space in the ring */
32694 + while (s->eqcr.available && frames_to_send--) {
32695 + p = qbman_cena_write_start_wo_shadow_fast(&s->sys,
32696 + QBMAN_CENA_SWP_EQCR((initial_pi) & 7));
32697 + /* Write command (except of first byte) and FD */
32698 + memcpy(&p[1], &cl[1], 7*4);
32699 + memcpy(&p[8], &fd[sent], sizeof(struct qbman_fd));
32702 + initial_pi &= 0xF;
32703 + s->eqcr.available--;
32708 + initial_pi = s->eqcr.pi;
32711 + /* in order for flushes to complete faster */
32712 + /*For that we use a following trick: we record all lines in 32 bit word */
32714 + initial_pi = s->eqcr.pi;
32715 + for (i = 0; i < sent; i++) {
32716 + p = qbman_cena_write_start_wo_shadow_fast(&s->sys,
32717 + QBMAN_CENA_SWP_EQCR((initial_pi) & 7));
32719 + p[0] = cl[0] | s->eqcr.pi_vb;
32721 + initial_pi &= 0xF;
32723 + if (!(initial_pi & 7))
32724 + s->eqcr.pi_vb ^= QB_VALID_BIT;
32727 + initial_pi = s->eqcr.pi;
32729 + /* We need to flush all the lines but without load/store operations between them */
32730 + /* We assign start_pointer before we start loop so that in loop we do not read it from memory */
32731 + start_pointer = (uint64_t)s->sys.addr_cena;
32732 + for (i = 0; i < sent; i++) {
32733 + p = (uint32_t *)(start_pointer + QBMAN_CENA_SWP_EQCR(initial_pi & 7));
32734 + dcbf((uint64_t)p);
32736 + initial_pi &= 0xF;
32739 + /* Update producer index for the next call */
32740 + s->eqcr.pi = initial_pi;
32744 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_portal.h b/drivers/net/dpaa2/qbman/driver/qbman_portal.h
32745 new file mode 100644
32746 index 0000000..17f1c53
32748 +++ b/drivers/net/dpaa2/qbman/driver/qbman_portal.h
32750 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
32752 + * Redistribution and use in source and binary forms, with or without
32753 + * modification, are permitted provided that the following conditions are met:
32754 + * * Redistributions of source code must retain the above copyright
32755 + * notice, this list of conditions and the following disclaimer.
32756 + * * Redistributions in binary form must reproduce the above copyright
32757 + * notice, this list of conditions and the following disclaimer in the
32758 + * documentation and/or other materials provided with the distribution.
32759 + * * Neither the name of Freescale Semiconductor nor the
32760 + * names of its contributors may be used to endorse or promote products
32761 + * derived from this software without specific prior written permission.
32763 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
32764 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32765 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32766 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
32767 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
32768 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32769 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32770 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32771 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
32772 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32775 +#include "qbman_private.h"
32776 +#include <drivers/fsl_qbman_portal.h>
32778 +uint32_t qman_version;
32779 +/* All QBMan command and result structures use this "valid bit" encoding */
32780 +#define QB_VALID_BIT ((uint32_t)0x80)
32782 +/* Management command result codes */
32783 +#define QBMAN_MC_RSLT_OK 0xf0
32785 +/* QBMan DQRR size is set at runtime in qbman_portal.c */
32787 +#define QBMAN_EQCR_SIZE 8
32789 +static inline u8 qm_cyc_diff(u8 ringsize, u8 first, u8 last)
32791 + /* 'first' is included, 'last' is excluded */
32792 + if (first <= last)
32793 + return last - first;
32794 + return (2 * ringsize) + last - first;
32797 +/* --------------------- */
32798 +/* portal data structure */
32799 +/* --------------------- */
32801 +struct qbman_swp {
32802 + const struct qbman_swp_desc *desc;
32803 + /* The qbman_sys (ie. arch/OS-specific) support code can put anything it
32804 + * needs in here. */
32805 + struct qbman_swp_sys sys;
32806 + /* Management commands */
32808 +#ifdef QBMAN_CHECKING
32809 + enum swp_mc_check {
32810 + swp_mc_can_start, /* call __qbman_swp_mc_start() */
32811 + swp_mc_can_submit, /* call __qbman_swp_mc_submit() */
32812 + swp_mc_can_poll, /* call __qbman_swp_mc_result() */
32815 + uint32_t valid_bit; /* 0x00 or 0x80 */
32817 + /* Push dequeues */
32819 + /* Volatile dequeues */
32821 + /* VDQCR supports a "1 deep pipeline", meaning that if you know
32822 + * the last-submitted command is already executing in the
32823 + * hardware (as evidenced by at least 1 valid dequeue result),
32824 + * you can write another dequeue command to the register, the
32825 + * hardware will start executing it as soon as the
32826 + * already-executing command terminates. (This minimises latency
32827 + * and stalls.) With that in mind, this "busy" variable refers
32828 + * to whether or not a command can be submitted, not whether or
32829 + * not a previously-submitted command is still executing. In
32830 + * other words, once proof is seen that the previously-submitted
32831 + * command is executing, "vdq" is no longer "busy". */
32833 + uint32_t valid_bit; /* 0x00 or 0x80 */
32834 + /* We need to determine when vdq is no longer busy. This depends
32835 + * on whether the "busy" (last-submitted) dequeue command is
32836 + * targeting DQRR or main-memory, and detected is based on the
32837 + * presence of the dequeue command's "token" showing up in
32838 + * dequeue entries in DQRR or main-memory (respectively). */
32839 + struct qbman_result *storage; /* NULL if DQRR */
32843 + uint32_t next_idx;
32844 + uint32_t valid_bit;
32845 + uint8_t dqrr_size;
32856 +/* -------------------------- */
32857 +/* portal management commands */
32858 +/* -------------------------- */
32860 +/* Different management commands all use this common base layer of code to issue
32861 + * commands and poll for results. The first function returns a pointer to where
32862 + * the caller should fill in their MC command (though they should ignore the
32863 + * verb byte), the second function commits merges in the caller-supplied command
32864 + * verb (which should not include the valid-bit) and submits the command to
32865 + * hardware, and the third function checks for a completed response (returns
32866 + * non-NULL if only if the response is complete). */
32867 +void *qbman_swp_mc_start(struct qbman_swp *p);
32868 +void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint32_t cmd_verb);
32869 +void *qbman_swp_mc_result(struct qbman_swp *p);
32871 +/* Wraps up submit + poll-for-result */
32872 +static inline void *qbman_swp_mc_complete(struct qbman_swp *swp, void *cmd,
32873 + uint32_t cmd_verb)
32877 + qbman_swp_mc_submit(swp, cmd, cmd_verb);
32878 + DBG_POLL_START(loopvar);
32880 + DBG_POLL_CHECK(loopvar);
32881 + cmd = qbman_swp_mc_result(swp);
32886 +/* ------------ */
32887 +/* qb_attr_code */
32888 +/* ------------ */
32890 +/* This struct locates a sub-field within a QBMan portal (CENA) cacheline which
32891 + * is either serving as a configuration command or a query result. The
32892 + * representation is inherently little-endian, as the indexing of the words is
32893 + * itself little-endian in nature and DPAA2 QBMan is little endian for anything
32894 + * that crosses a word boundary too (64-bit fields are the obvious examples).
32896 +struct qb_attr_code {
32897 + unsigned int word; /* which uint32_t[] array member encodes the field */
32898 + unsigned int lsoffset; /* encoding offset from ls-bit */
32899 + unsigned int width; /* encoding width. (bool must be 1.) */
32902 +/* Some pre-defined codes */
32903 +extern struct qb_attr_code code_generic_verb;
32904 +extern struct qb_attr_code code_generic_rslt;
32906 +/* Macros to define codes */
32907 +#define QB_CODE(a, b, c) { a, b, c}
32908 +#define QB_CODE_NULL \
32909 + QB_CODE((unsigned int)-1, (unsigned int)-1, (unsigned int)-1)
32911 +/* Rotate a code "ms", meaning that it moves from less-significant bytes to
32912 + * more-significant, from less-significant words to more-significant, etc. The
32913 + * "ls" version does the inverse, from more-significant towards
32914 + * less-significant.
32916 +static inline void qb_attr_code_rotate_ms(struct qb_attr_code *code,
32917 + unsigned int bits)
32919 + code->lsoffset += bits;
32920 + while (code->lsoffset > 31) {
32922 + code->lsoffset -= 32;
32926 +static inline void qb_attr_code_rotate_ls(struct qb_attr_code *code,
32927 + unsigned int bits)
32929 + /* Don't be fooled, this trick should work because the types are
32930 + * unsigned. So the case that interests the while loop (the rotate has
32931 + * gone too far and the word count needs to compensate for it), is
32932 + * manifested when lsoffset is negative. But that equates to a really
32933 + * large unsigned value, starting with lots of "F"s. As such, we can
32934 + * continue adding 32 back to it until it wraps back round above zero,
32935 + * to a value of 31 or less...
32937 + code->lsoffset -= bits;
32938 + while (code->lsoffset > 31) {
32940 + code->lsoffset += 32;
32944 +/* Implement a loop of code rotations until 'expr' evaluates to FALSE (0). */
32945 +#define qb_attr_code_for_ms(code, bits, expr) \
32946 + for (; expr; qb_attr_code_rotate_ms(code, bits))
32947 +#define qb_attr_code_for_ls(code, bits, expr) \
32948 + for (; expr; qb_attr_code_rotate_ls(code, bits))
32950 +/* decode a field from a cacheline */
32951 +static inline uint32_t qb_attr_code_decode(const struct qb_attr_code *code,
32952 + const uint32_t *cacheline)
32954 + return d32_uint32_t(code->lsoffset, code->width, cacheline[code->word]);
32957 +static inline uint64_t qb_attr_code_decode_64(const struct qb_attr_code *code,
32958 + const uint64_t *cacheline)
32960 + return cacheline[code->word / 2];
32963 +/* encode a field to a cacheline */
32964 +static inline void qb_attr_code_encode(const struct qb_attr_code *code,
32965 + uint32_t *cacheline, uint32_t val)
32967 + cacheline[code->word] =
32968 + r32_uint32_t(code->lsoffset, code->width, cacheline[code->word])
32969 + | e32_uint32_t(code->lsoffset, code->width, val);
32972 +static inline void qb_attr_code_encode_64(const struct qb_attr_code *code,
32973 + uint64_t *cacheline, uint64_t val)
32975 + cacheline[code->word / 2] = val;
32978 +/* Small-width signed values (two's-complement) will decode into medium-width
32979 + * positives. (Eg. for an 8-bit signed field, which stores values from -128 to
32980 + * +127, a setting of -7 would appear to decode to the 32-bit unsigned value
32981 + * 249. Likewise -120 would decode as 136.) This function allows the caller to
32982 + * "re-sign" such fields to 32-bit signed. (Eg. -7, which was 249 with an 8-bit
32983 + * encoding, will become 0xfffffff9 if you cast the return value to uint32_t).
32985 +static inline int32_t qb_attr_code_makesigned(const struct qb_attr_code *code,
32988 + BUG_ON(val >= (1u << code->width));
32989 + /* code->width should never exceed the width of val. If it does then a
32990 + * different function with larger val size must be used to translate
32991 + * from unsigned to signed */
32992 + BUG_ON(code->width > sizeof(val) * CHAR_BIT);
32993 + /* If the high bit was set, it was encoding a negative */
32994 + if (val >= 1u << (code->width - 1))
32995 + return (int32_t)0 - (int32_t)(((uint32_t)1 << code->width) -
32997 + /* Otherwise, it was encoding a positive */
32998 + return (int32_t)val;
33001 +/* ---------------------- */
33002 +/* Descriptors/cachelines */
33003 +/* ---------------------- */
33005 +/* To avoid needless dynamic allocation, the driver API often gives the caller
33006 + * a "descriptor" type that the caller can instantiate however they like.
33007 + * Ultimately though, it is just a cacheline of binary storage (or something
33008 + * smaller when it is known that the descriptor doesn't need all 64 bytes) for
33009 + * holding pre-formatted pieces of hardware commands. The performance-critical
33010 + * code can then copy these descriptors directly into hardware command
33011 + * registers more efficiently than trying to construct/format commands
33012 + * on-the-fly. The API user sees the descriptor as an array of 32-bit words in
33013 + * order for the compiler to know its size, but the internal details are not
33014 + * exposed. The following macro is used within the driver for converting *any*
33015 + * descriptor pointer to a usable array pointer. The use of a macro (instead of
33016 + * an inline) is necessary to work with different descriptor types and to work
33017 + * correctly with const and non-const inputs (and similarly-qualified outputs).
33019 +#define qb_cl(d) (&(d)->dont_manipulate_directly[0])
33020 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_private.h b/drivers/net/dpaa2/qbman/driver/qbman_private.h
33021 new file mode 100644
33022 index 0000000..624ede1
33024 +++ b/drivers/net/dpaa2/qbman/driver/qbman_private.h
33026 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
33028 + * Redistribution and use in source and binary forms, with or without
33029 + * modification, are permitted provided that the following conditions are met:
33030 + * * Redistributions of source code must retain the above copyright
33031 + * notice, this list of conditions and the following disclaimer.
33032 + * * Redistributions in binary form must reproduce the above copyright
33033 + * notice, this list of conditions and the following disclaimer in the
33034 + * documentation and/or other materials provided with the distribution.
33035 + * * Neither the name of Freescale Semiconductor nor the
33036 + * names of its contributors may be used to endorse or promote products
33037 + * derived from this software without specific prior written permission.
33039 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33040 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33041 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33042 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33043 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33044 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33045 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33046 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33047 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33048 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33051 +/* Perform extra checking */
33052 +#define QBMAN_CHECKING
33054 +/* To maximise the amount of logic that is common between the Linux driver and
33055 + * other targets (such as the embedded MC firmware), we pivot here between the
33056 + * inclusion of two platform-specific headers.
33058 + * The first, qbman_sys_decl.h, includes any and all required system headers as
33059 + * well as providing any definitions for the purposes of compatibility. The
33060 + * second, qbman_sys.h, is where platform-specific routines go.
33062 + * The point of the split is that the platform-independent code (including this
33063 + * header) may depend on platform-specific declarations, yet other
33064 + * platform-specific routines may depend on platform-independent definitions.
33067 +#include "qbman_sys_decl.h"
33069 +/* When things go wrong, it is a convenient trick to insert a few FOO()
33070 + * statements in the code to trace progress. TODO: remove this once we are
33071 + * hacking the code less actively.
33073 +#define FOO() fsl_os_print("FOO: %s:%d\n", __FILE__, __LINE__)
33075 +/* Any time there is a register interface which we poll on, this provides a
33076 + * "break after x iterations" scheme for it. It's handy for debugging, eg.
33077 + * where you don't want millions of lines of log output from a polling loop
33078 + * that won't, because such things tend to drown out the earlier log output
33079 + * that might explain what caused the problem. (NB: put ";" after each macro!)
33080 + * TODO: we should probably remove this once we're done sanitising the
33083 +#define DBG_POLL_START(loopvar) (loopvar = 10)
33084 +#define DBG_POLL_CHECK(loopvar) \
33085 + do {if (!(loopvar--)) BUG_ON(NULL == "DBG_POLL_CHECK"); } while (0)
33087 +/* For CCSR or portal-CINH registers that contain fields at arbitrary offsets
33088 + * and widths, these macro-generated encode/decode/isolate/remove inlines can
33091 + * Eg. to "d"ecode a 14-bit field out of a register (into a "uint16_t" type),
33092 + * where the field is located 3 bits "up" from the least-significant bit of the
33093 + * register (ie. the field location within the 32-bit register corresponds to a
33094 + * mask of 0x0001fff8), you would do;
33095 + * uint16_t field = d32_uint16_t(3, 14, reg_value);
33097 + * Or to "e"ncode a 1-bit boolean value (input type is "int", zero is FALSE,
33098 + * non-zero is TRUE, so must convert all non-zero inputs to 1, hence the "!!"
33099 + * operator) into a register at bit location 0x00080000 (19 bits "in" from the
33101 + * reg_value |= e32_int(19, 1, !!field);
33103 + * If you wish to read-modify-write a register, such that you leave the 14-bit
33104 + * field as-is but have all other fields set to zero, then "i"solate the 14-bit
33106 + * reg_value = i32_uint16_t(3, 14, reg_value);
33108 + * Alternatively, you could "r"emove the 1-bit boolean field (setting it to
33109 + * zero) but leaving all other fields as-is;
33110 + * reg_val = r32_int(19, 1, reg_value);
33113 +#define MAKE_MASK32(width) (width == 32 ? 0xffffffff : \
33114 + (uint32_t)((1 << width) - 1))
33115 +#define DECLARE_CODEC32(t) \
33116 +static inline uint32_t e32_##t(uint32_t lsoffset, uint32_t width, t val) \
33118 + BUG_ON(width > (sizeof(t) * 8)); \
33119 + return ((uint32_t)val & MAKE_MASK32(width)) << lsoffset; \
33121 +static inline t d32_##t(uint32_t lsoffset, uint32_t width, uint32_t val) \
33123 + BUG_ON(width > (sizeof(t) * 8)); \
33124 + return (t)((val >> lsoffset) & MAKE_MASK32(width)); \
33126 +static inline uint32_t i32_##t(uint32_t lsoffset, uint32_t width, \
33129 + BUG_ON(width > (sizeof(t) * 8)); \
33130 + return e32_##t(lsoffset, width, d32_##t(lsoffset, width, val)); \
33132 +static inline uint32_t r32_##t(uint32_t lsoffset, uint32_t width, \
33135 + BUG_ON(width > (sizeof(t) * 8)); \
33136 + return ~(MAKE_MASK32(width) << lsoffset) & val; \
33138 +DECLARE_CODEC32(uint32_t)
33139 +DECLARE_CODEC32(uint16_t)
33140 +DECLARE_CODEC32(uint8_t)
33141 +DECLARE_CODEC32(int)
33143 + /*********************/
33144 + /* Debugging assists */
33145 + /*********************/
33147 +static inline void __hexdump(unsigned long start, unsigned long end,
33148 + unsigned long p, size_t sz, const unsigned char *c)
33150 + while (start < end) {
33151 + unsigned int pos = 0;
33155 + pos += sprintf(buf + pos, "%08lx: ", start);
33157 + if ((start < p) || (start >= (p + sz)))
33158 + pos += sprintf(buf + pos, "..");
33160 + pos += sprintf(buf + pos, "%02x", *(c++));
33161 + if (!(++start & 15)) {
33162 + buf[pos++] = '\n';
33166 + if (!(start & 1))
33167 + buf[pos++] = ' ';
33168 + if (!(start & 3))
33169 + buf[pos++] = ' ';
33171 + } while (start & 15);
33173 + buf[pos++] = '\n';
33175 + pr_info("%s", buf);
33179 +static inline void hexdump(const void *ptr, size_t sz)
33181 + unsigned long p = (unsigned long)ptr;
33182 + unsigned long start = p & ~(unsigned long)15;
33183 + unsigned long end = (p + sz + 15) & ~(unsigned long)15;
33184 + const unsigned char *c = ptr;
33186 + __hexdump(start, end, p, sz, c);
33189 +#define QMAN_REV_4000 0x04000000
33190 +#define QMAN_REV_4100 0x04010000
33191 +#define QMAN_REV_4101 0x04010001
33193 +#include "qbman_sys.h"
33194 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_sys.h b/drivers/net/dpaa2/qbman/driver/qbman_sys.h
33195 new file mode 100644
33196 index 0000000..a39fa71
33198 +++ b/drivers/net/dpaa2/qbman/driver/qbman_sys.h
33200 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
33202 + * Redistribution and use in source and binary forms, with or without
33203 + * modification, are permitted provided that the following conditions are met:
33204 + * * Redistributions of source code must retain the above copyright
33205 + * notice, this list of conditions and the following disclaimer.
33206 + * * Redistributions in binary form must reproduce the above copyright
33207 + * notice, this list of conditions and the following disclaimer in the
33208 + * documentation and/or other materials provided with the distribution.
33209 + * * Neither the name of Freescale Semiconductor nor the
33210 + * names of its contributors may be used to endorse or promote products
33211 + * derived from this software without specific prior written permission.
33213 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33214 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33215 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33216 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33217 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33218 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33219 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33220 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33221 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33222 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33224 +/* qbman_sys_decl.h and qbman_sys.h are the two platform-specific files in the
33225 + * driver. They are only included via qbman_private.h, which is itself a
33226 + * platform-independent file and is included by all the other driver source.
33228 + * qbman_sys_decl.h is included prior to all other declarations and logic, and
33229 + * it exists to provide compatibility with any linux interfaces our
33230 + * single-source driver code is dependent on (eg. kmalloc). Ie. this file
33231 + * provides linux compatibility.
33233 + * This qbman_sys.h header, on the other hand, is included *after* any common
33234 + * and platform-neutral declarations and logic in qbman_private.h, and exists to
33235 + * implement any platform-specific logic of the qbman driver itself. Ie. it is
33236 + * *not* to provide linux compatibility.
33239 +/* Trace the 3 different classes of read/write access to QBMan. #undef as
33241 +#undef QBMAN_CCSR_TRACE
33242 +#undef QBMAN_CINH_TRACE
33243 +#undef QBMAN_CENA_TRACE
33245 +static inline void word_copy(void *d, const void *s, unsigned int cnt)
33247 + uint32_t *dd = d;
33248 + const uint32_t *ss = s;
33251 + *(dd++) = *(ss++);
33254 +/* Currently, the CENA support code expects each 32-bit word to be written in
33255 + * host order, and these are converted to hardware (little-endian) order on
33256 + * command submission. However, 64-bit quantities are must be written (and read)
33257 + * as two 32-bit words with the least-significant word first, irrespective of
33258 + * host endianness. */
33259 +static inline void u64_to_le32_copy(void *d, const uint64_t *s,
33260 + unsigned int cnt)
33262 + uint32_t *dd = d;
33263 + const uint32_t *ss = (const uint32_t *)s;
33266 + /* TBD: the toolchain was choking on the use of 64-bit types up
33267 + * until recently so this works entirely with 32-bit variables.
33268 + * When 64-bit types become usable again, investigate better
33269 + * ways of doing this. */
33270 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33275 + *(dd++) = *(ss++);
33276 + *(dd++) = *(ss++);
33281 +static inline void u64_from_le32_copy(uint64_t *d, const void *s,
33282 + unsigned int cnt)
33284 + const uint32_t *ss = s;
33285 + uint32_t *dd = (uint32_t *)d;
33288 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33293 + *(dd++) = *(ss++);
33294 + *(dd++) = *(ss++);
33299 +/* Convert a host-native 32bit value into little endian */
33300 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33301 +static inline uint32_t make_le32(uint32_t val)
33303 + return ((val & 0xff) << 24) | ((val & 0xff00) << 8) |
33304 + ((val & 0xff0000) >> 8) | ((val & 0xff000000) >> 24);
33307 +static inline uint32_t make_le24(uint32_t val)
33309 + return (((val & 0xff) << 16) | (val & 0xff00) |
33310 + ((val & 0xff0000) >> 16));
33313 +#define make_le32(val) (val)
33314 +#define make_le24(val) (val)
33316 +static inline void make_le32_n(uint32_t *val, unsigned int num)
33319 + *val = make_le32(*val);
33324 + /******************/
33325 + /* Portal access */
33326 + /******************/
33327 +struct qbman_swp_sys {
33328 + /* On GPP, the sys support for qbman_swp is here. The CENA region isi
33329 + * not an mmap() of the real portal registers, but an allocated
33330 + * place-holder, because the actual writes/reads to/from the portal are
33331 + * marshalled from these allocated areas using QBMan's "MC access
33332 + * registers". CINH accesses are atomic so there's no need for a
33333 + * place-holder. */
33335 + uint8_t __iomem *addr_cena;
33336 + uint8_t __iomem *addr_cinh;
33338 + enum qbman_eqcr_mode eqcr_mode;
33341 +/* P_OFFSET is (ACCESS_CMD,0,12) - offset within the portal
33342 + * C is (ACCESS_CMD,12,1) - is inhibited? (0==CENA, 1==CINH)
33343 + * SWP_IDX is (ACCESS_CMD,16,10) - Software portal index
33344 + * P is (ACCESS_CMD,28,1) - (0==special portal, 1==any portal)
33345 + * T is (ACCESS_CMD,29,1) - Command type (0==READ, 1==WRITE)
33346 + * E is (ACCESS_CMD,31,1) - Command execute (1 to issue, poll for 0==complete)
33349 +static inline void qbman_cinh_write(struct qbman_swp_sys *s, uint32_t offset,
33352 + __raw_writel(val, s->addr_cinh + offset);
33353 +#ifdef QBMAN_CINH_TRACE
33354 + pr_info("qbman_cinh_write(%p:%d:0x%03x) 0x%08x\n",
33355 + s->addr_cinh, s->idx, offset, val);
33359 +static inline uint32_t qbman_cinh_read(struct qbman_swp_sys *s, uint32_t offset)
33361 + uint32_t reg = __raw_readl(s->addr_cinh + offset);
33362 +#ifdef QBMAN_CINH_TRACE
33363 + pr_info("qbman_cinh_read(%p:%d:0x%03x) 0x%08x\n",
33364 + s->addr_cinh, s->idx, offset, reg);
33369 +static inline void *qbman_cena_write_start(struct qbman_swp_sys *s,
33372 + void *shadow = s->cena + offset;
33374 +#ifdef QBMAN_CENA_TRACE
33375 + pr_info("qbman_cena_write_start(%p:%d:0x%03x) %p\n",
33376 + s->addr_cena, s->idx, offset, shadow);
33378 + BUG_ON(offset & 63);
33383 +static inline void *qbman_cena_write_start_wo_shadow(struct qbman_swp_sys *s,
33386 +#ifdef QBMAN_CENA_TRACE
33387 + pr_info("qbman_cena_write_start(%p:%d:0x%03x)\n",
33388 + s->addr_cena, s->idx, offset);
33390 + BUG_ON(offset & 63);
33391 + return (s->addr_cena + offset);
33394 +static inline void qbman_cena_write_complete(struct qbman_swp_sys *s,
33395 + uint32_t offset, void *cmd)
33397 + const uint32_t *shadow = cmd;
33399 +#ifdef QBMAN_CENA_TRACE
33400 + pr_info("qbman_cena_write_complete(%p:%d:0x%03x) %p\n",
33401 + s->addr_cena, s->idx, offset, shadow);
33402 + hexdump(cmd, 64);
33404 + for (loop = 15; loop >= 1; loop--)
33405 + __raw_writel(shadow[loop], s->addr_cena +
33406 + offset + loop * 4);
33408 + __raw_writel(shadow[0], s->addr_cena + offset);
33409 + dcbf(s->addr_cena + offset);
33412 +static inline void qbman_cena_write_complete_wo_shadow(struct qbman_swp_sys *s,
33415 +#ifdef QBMAN_CENA_TRACE
33416 + pr_info("qbman_cena_write_complete(%p:%d:0x%03x)\n",
33417 + s->addr_cena, s->idx, offset);
33418 + hexdump(cmd, 64);
33420 + dcbf(s->addr_cena + offset);
33423 +static inline uint32_t qbman_cena_read_reg(struct qbman_swp_sys *s,
33426 + return __raw_readl(s->addr_cena + offset);
33429 +static inline void *qbman_cena_read(struct qbman_swp_sys *s, uint32_t offset)
33431 + uint32_t *shadow = (uint32_t *)(s->cena + offset);
33432 + unsigned int loop;
33433 +#ifdef QBMAN_CENA_TRACE
33434 + pr_info("qbman_cena_read(%p:%d:0x%03x) %p\n",
33435 + s->addr_cena, s->idx, offset, shadow);
33438 + for (loop = 0; loop < 16; loop++)
33439 + shadow[loop] = __raw_readl(s->addr_cena + offset
33441 +#ifdef QBMAN_CENA_TRACE
33442 + hexdump(shadow, 64);
33447 +static inline void *qbman_cena_read_wo_shadow(struct qbman_swp_sys *s,
33450 +#ifdef QBMAN_CENA_TRACE
33451 + pr_info("qbman_cena_read(%p:%d:0x%03x) %p\n",
33452 + s->addr_cena, s->idx, offset, shadow);
33455 +#ifdef QBMAN_CENA_TRACE
33456 + hexdump(shadow, 64);
33458 + return s->addr_cena + offset;
33461 +static inline void qbman_cena_invalidate(struct qbman_swp_sys *s,
33464 + dccivac(s->addr_cena + offset);
33467 +static inline void qbman_cena_invalidate_prefetch(struct qbman_swp_sys *s,
33470 + dccivac(s->addr_cena + offset);
33471 + prefetch_for_load(s->addr_cena + offset);
33474 +static inline void qbman_cena_prefetch(struct qbman_swp_sys *s,
33477 + prefetch_for_load(s->addr_cena + offset);
33480 + /******************/
33481 + /* Portal support */
33482 + /******************/
33484 +/* The SWP_CFG portal register is special, in that it is used by the
33485 + * platform-specific code rather than the platform-independent code in
33486 + * qbman_portal.c. So use of it is declared locally here. */
33487 +#define QBMAN_CINH_SWP_CFG 0xd00
33489 +/* For MC portal use, we always configure with
33490 + * DQRR_MF is (SWP_CFG,20,3) - DQRR max fill (<- 0x4)
33491 + * EST is (SWP_CFG,16,3) - EQCR_CI stashing threshold (<- 0x2)
33492 + * RPM is (SWP_CFG,12,2) - RCR production notification mode (<- 0x3)
33493 + * DCM is (SWP_CFG,10,2) - DQRR consumption notification mode (<- 0x2)
33494 + * EPM is (SWP_CFG,8,2) - EQCR production notification mode (<- 0x2)
33495 + * SD is (SWP_CFG,5,1) - memory stashing drop enable (<- TRUE)
33496 + * SP is (SWP_CFG,4,1) - memory stashing priority (<- TRUE)
33497 + * SE is (SWP_CFG,3,1) - memory stashing enable (<- TRUE)
33498 + * DP is (SWP_CFG,2,1) - dequeue stashing priority (<- TRUE)
33499 + * DE is (SWP_CFG,1,1) - dequeue stashing enable (<- TRUE)
33500 + * EP is (SWP_CFG,0,1) - EQCR_CI stashing priority (<- TRUE)
33502 +static inline uint32_t qbman_set_swp_cfg(uint8_t max_fill, uint8_t wn,
33503 + uint8_t est, uint8_t rpm, uint8_t dcm,
33504 + uint8_t epm, int sd, int sp, int se,
33505 + int dp, int de, int ep)
33509 + reg = e32_uint8_t(20, (uint32_t)(3 + (max_fill >> 3)), max_fill) |
33510 + e32_uint8_t(16, 3, est) |
33511 + e32_uint8_t(12, 2, rpm) | e32_uint8_t(10, 2, dcm) |
33512 + e32_uint8_t(8, 2, epm) | e32_int(5, 1, sd) |
33513 + e32_int(4, 1, sp) | e32_int(3, 1, se) | e32_int(2, 1, dp) |
33514 + e32_int(1, 1, de) | e32_int(0, 1, ep) | e32_uint8_t(14, 1, wn);
33518 +static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
33519 + const struct qbman_swp_desc *d,
33520 + uint8_t dqrr_size)
33524 + s->addr_cena = d->cena_bar;
33525 + s->addr_cinh = d->cinh_bar;
33526 + s->idx = (uint32_t)d->idx;
33527 + s->cena = (void *)get_zeroed_page(GFP_KERNEL);
33529 + pr_err("Could not allocate page for cena shadow\n");
33532 + s->eqcr_mode = d->eqcr_mode;
33533 + BUG_ON(d->idx < 0);
33534 +#ifdef QBMAN_CHECKING
33535 + /* We should never be asked to initialise for a portal that isn't in
33536 + * the power-on state. (Ie. don't forget to reset portals when they are
33537 + * decommissioned!)
33539 + reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
33542 + if (s->eqcr_mode == qman_eqcr_vb_array)
33543 + reg = qbman_set_swp_cfg(dqrr_size, 0, 0, 3, 2, 3, 1, 1, 1, 1,
33546 + reg = qbman_set_swp_cfg(dqrr_size, 0, 2, 3, 2, 2, 1, 1, 1, 1,
33548 + qbman_cinh_write(s, QBMAN_CINH_SWP_CFG, reg);
33549 + reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
33551 + pr_err("The portal %d is not enabled!\n", s->idx);
33558 +static inline void qbman_swp_sys_finish(struct qbman_swp_sys *s)
33560 + free_page((unsigned long)s->cena);
33563 +static inline void *qbman_cena_write_start_wo_shadow_fast(struct qbman_swp_sys *s,
33566 +#ifdef QBMAN_CENA_TRACE
33567 + pr_info("qbman_cena_write_start(%p:%d:0x%03x)\n",
33568 + s->addr_cena, s->idx, offset);
33570 + BUG_ON(offset & 63);
33571 + return (s->addr_cena + offset);
33573 diff --git a/drivers/net/dpaa2/qbman/driver/qbman_sys_decl.h b/drivers/net/dpaa2/qbman/driver/qbman_sys_decl.h
33574 new file mode 100644
33575 index 0000000..bbf3627
33577 +++ b/drivers/net/dpaa2/qbman/driver/qbman_sys_decl.h
33579 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
33581 + * Redistribution and use in source and binary forms, with or without
33582 + * modification, are permitted provided that the following conditions are met:
33583 + * * Redistributions of source code must retain the above copyright
33584 + * notice, this list of conditions and the following disclaimer.
33585 + * * Redistributions in binary form must reproduce the above copyright
33586 + * notice, this list of conditions and the following disclaimer in the
33587 + * documentation and/or other materials provided with the distribution.
33588 + * * Neither the name of Freescale Semiconductor nor the
33589 + * names of its contributors may be used to endorse or promote products
33590 + * derived from this software without specific prior written permission.
33592 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33593 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33594 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33595 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33596 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33597 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33598 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33599 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33600 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33601 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33603 +#include <compat.h>
33604 +#include <drivers/fsl_qbman_base.h>
33606 +/* Sanity check */
33607 +#if (__BYTE_ORDER__ != __ORDER_BIG_ENDIAN__) && \
33608 + (__BYTE_ORDER__ != __ORDER_LITTLE_ENDIAN__)
33609 +#error "Unknown endianness!"
33612 +/* The platform-independent code shouldn't need endianness, except for
33613 + * weird/fast-path cases like qbman_result_has_token(), which needs to
33614 + * perform a passive and endianness-specific test on a read-only data structure
33615 + * very quickly. It's an exception, and this symbol is used for that case. */
33616 +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
33617 +#define DQRR_TOK_OFFSET 0
33618 +#define QBMAN_RESULT_VERB_OFFSET_IN_MEM 24
33619 +#define SCN_STATE_OFFSET_IN_MEM 8
33620 +#define SCN_RID_OFFSET_IN_MEM 8
33622 +#define DQRR_TOK_OFFSET 24
33623 +#define QBMAN_RESULT_VERB_OFFSET_IN_MEM 0
33624 +#define SCN_STATE_OFFSET_IN_MEM 16
33625 +#define SCN_RID_OFFSET_IN_MEM 0
33628 +/* Similarly-named functions */
33629 +#define upper32(a) upper_32_bits(a)
33630 +#define lower32(a) lower_32_bits(a)
33632 + /****************/
33633 + /* arch assists */
33634 + /****************/
33635 +#define dcbz(p) { asm volatile("dc zva, %0" : : "r" (p) : "memory"); }
33636 +#define lwsync() { asm volatile("dmb st" : : : "memory"); }
33637 +#define dcbf(p) { asm volatile("dc cvac, %0" : : "r"(p) : "memory"); }
33638 +#define dccivac(p) { asm volatile("dc civac, %0" : : "r"(p) : "memory"); }
33639 +static inline void prefetch_for_load(void *p)
33641 + asm volatile("prfm pldl1keep, [%0, #64]" : : "r" (p));
33644 +static inline void prefetch_for_store(void *p)
33646 + asm volatile("prfm pstl1keep, [%0, #64]" : : "r" (p));
33648 diff --git a/drivers/net/dpaa2/qbman/include/compat.h b/drivers/net/dpaa2/qbman/include/compat.h
33649 new file mode 100644
33650 index 0000000..456f938
33652 +++ b/drivers/net/dpaa2/qbman/include/compat.h
33654 +/* Copyright (c) 2008-2011 Freescale Semiconductor, Inc.
33655 + * All rights reserved.
33657 + * Redistribution and use in source and binary forms, with or without
33658 + * modification, are permitted provided that the following conditions are met:
33659 + * * Redistributions of source code must retain the above copyright
33660 + * notice, this list of conditions and the following disclaimer.
33661 + * * Redistributions in binary form must reproduce the above copyright
33662 + * notice, this list of conditions and the following disclaimer in the
33663 + * documentation and/or other materials provided with the distribution.
33664 + * * Neither the name of Freescale Semiconductor nor the
33665 + * names of its contributors may be used to endorse or promote products
33666 + * derived from this software without specific prior written permission.
33668 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
33669 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
33670 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33671 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
33672 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
33673 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33674 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33675 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33676 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33677 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33680 +#ifndef HEADER_COMPAT_H
33681 +#define HEADER_COMPAT_H
33683 +#include <sched.h>
33685 +#ifndef _GNU_SOURCE
33686 +#define _GNU_SOURCE
33688 +#include <stdint.h>
33689 +#include <stdlib.h>
33690 +#include <stddef.h>
33691 +#include <errno.h>
33692 +#include <string.h>
33693 +#include <pthread.h>
33694 +#include <net/ethernet.h>
33695 +#include <stdio.h>
33696 +#include <stdbool.h>
33697 +#include <ctype.h>
33698 +#include <malloc.h>
33699 +#include <sys/types.h>
33700 +#include <sys/stat.h>
33701 +#include <fcntl.h>
33702 +#include <unistd.h>
33703 +#include <sys/mman.h>
33704 +#include <limits.h>
33705 +#include <assert.h>
33706 +#include <dirent.h>
33707 +#include <inttypes.h>
33708 +#include <error.h>
33710 +/* The following definitions are primarily to allow the single-source driver
33711 + * interfaces to be included by arbitrary program code. Ie. for interfaces that
33712 + * are also available in kernel-space, these definitions provide compatibility
33713 + * with certain attributes and types used in those interfaces. */
33715 +/* Required compiler attributes */
33716 +#define __maybe_unused __attribute__((unused))
33717 +#define __always_unused __attribute__((unused))
33718 +#define __packed __attribute__((__packed__))
33720 +#define likely(x) __builtin_expect(!!(x), 1)
33721 +#define unlikely(x) __builtin_expect(!!(x), 0)
33722 +#define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
33723 +#undef container_of
33724 +#define container_of(ptr, type, member) ({ \
33725 + typeof(((type *)0)->member)(*__mptr) = (ptr); \
33726 + (type *)((char *)__mptr - offsetof(type, member)); })
33727 +#define __stringify_1(x) #x
33728 +#define __stringify(x) __stringify_1(x)
33729 +#define panic(x) \
33731 + printf("panic: %s", x); \
33738 +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
33740 +/* Required types */
33741 +typedef uint8_t u8;
33742 +typedef uint16_t u16;
33743 +typedef uint32_t u32;
33744 +typedef uint64_t u64;
33745 +typedef uint64_t dma_addr_t;
33746 +typedef cpu_set_t cpumask_t;
33747 +#define spinlock_t pthread_mutex_t
33748 +typedef u32 compat_uptr_t;
33749 +static inline void __user *compat_ptr(compat_uptr_t uptr)
33751 + return (void __user *)(unsigned long)uptr;
33754 +static inline compat_uptr_t ptr_to_compat(void __user *uptr)
33756 + return (u32)(unsigned long)uptr;
33759 +/* I/O operations */
33760 +static inline u32 in_be32(volatile void *__p)
33762 + volatile u32 *p = __p;
33766 +static inline void out_be32(volatile void *__p, u32 val)
33768 + volatile u32 *p = __p;
33773 +#define prflush(fmt, args...) \
33775 + printf(fmt, ##args); \
33776 + fflush(stdout); \
33778 +#define pr_crit(fmt, args...) prflush("CRIT:" fmt, ##args)
33779 +#define pr_err(fmt, args...) prflush("ERR:" fmt, ##args)
33780 +#define pr_warn(fmt, args...) prflush("WARN:" fmt, ##args)
33781 +#define pr_info(fmt, args...) prflush(fmt, ##args)
33783 +#define BUG() abort()
33784 +#ifdef CONFIG_BUGON
33788 +#define pr_debug(fmt, args...) printf(fmt, ##args)
33789 +#define BUG_ON(c) \
33792 + pr_crit("BUG: %s:%d\n", __FILE__, __LINE__); \
33796 +#define might_sleep_if(c) BUG_ON(c)
33797 +#define msleep(x) \
33799 + pr_crit("BUG: illegal call %s:%d\n", __FILE__, __LINE__); \
33800 + exit(EXIT_FAILURE); \
33806 +#define pr_debug(fmt, args...) do { ; } while (0)
33807 +#define BUG_ON(c) do { ; } while (0)
33808 +#define might_sleep_if(c) do { ; } while (0)
33809 +#define msleep(x) do { ; } while (0)
33811 +#define WARN_ON(c, str) \
33813 + static int warned_##__LINE__; \
33814 + if ((c) && !warned_##__LINE__) { \
33815 + pr_warn("%s\n", str); \
33816 + pr_warn("(%s:%d)\n", __FILE__, __LINE__); \
33817 + warned_##__LINE__ = 1; \
33821 +#define ALIGN(x, a) (((x) + ((typeof(x))(a) - 1)) & ~((typeof(x))(a) - 1))
33823 +/****************/
33824 +/* Linked-lists */
33825 +/****************/
33827 +struct list_head {
33828 + struct list_head *prev;
33829 + struct list_head *next;
33832 +#define LIST_HEAD(n) \
33833 +struct list_head n = { \
33838 +#define INIT_LIST_HEAD(p) \
33840 + struct list_head *__p298 = (p); \
33841 + __p298->prev = __p298->next = __p298; \
33843 +#define list_entry(node, type, member) \
33844 + (type *)((void *)node - offsetof(type, member))
33845 +#define list_empty(p) \
33847 + const struct list_head *__p298 = (p); \
33848 + ((__p298->next == __p298) && (__p298->prev == __p298)); \
33850 +#define list_add(p, l) \
33852 + struct list_head *__p298 = (p); \
33853 + struct list_head *__l298 = (l); \
33854 + __p298->next = __l298->next; \
33855 + __p298->prev = __l298; \
33856 + __l298->next->prev = __p298; \
33857 + __l298->next = __p298; \
33859 +#define list_add_tail(p, l) \
33861 + struct list_head *__p298 = (p); \
33862 + struct list_head *__l298 = (l); \
33863 + __p298->prev = __l298->prev; \
33864 + __p298->next = __l298; \
33865 + __l298->prev->next = __p298; \
33866 + __l298->prev = __p298; \
33868 +#define list_for_each(i, l) \
33869 + for (i = (l)->next; i != (l); i = i->next)
33870 +#define list_for_each_safe(i, j, l) \
33871 + for (i = (l)->next, j = i->next; i != (l); \
33872 + i = j, j = i->next)
33873 +#define list_for_each_entry(i, l, name) \
33874 + for (i = list_entry((l)->next, typeof(*i), name); &i->name != (l); \
33875 + i = list_entry(i->name.next, typeof(*i), name))
33876 +#define list_for_each_entry_safe(i, j, l, name) \
33877 + for (i = list_entry((l)->next, typeof(*i), name), \
33878 + j = list_entry(i->name.next, typeof(*j), name); \
33879 + &i->name != (l); \
33880 + i = j, j = list_entry(j->name.next, typeof(*j), name))
33881 +#define list_del(i) \
33883 + (i)->next->prev = (i)->prev; \
33884 + (i)->prev->next = (i)->next; \
33887 +/* Other miscellaneous interfaces our APIs depend on; */
33889 +#define lower_32_bits(x) ((u32)(x))
33890 +#define upper_32_bits(x) ((u32)(((x) >> 16) >> 16))
33892 +/* Compiler/type stuff */
33893 +typedef unsigned int gfp_t;
33894 +typedef uint32_t phandle;
33896 +#define noinline __attribute__((noinline))
33900 +#define MODULE_AUTHOR(s)
33901 +#define MODULE_LICENSE(s)
33902 +#define MODULE_DESCRIPTION(s)
33903 +#define MODULE_PARM_DESC(x, y)
33904 +#define EXPORT_SYMBOL(x)
33905 +#define module_init(fn) int m_##fn(void) { return fn(); }
33906 +#define module_exit(fn) void m_##fn(void) { fn(); }
33907 +#define module_param(x, y, z)
33908 +#define module_param_string(w, x, y, z)
33909 +#define GFP_KERNEL 0
33910 +#define __KERNEL__
33912 +#define __raw_readb(p) *(const volatile unsigned char *)(p)
33913 +#define __raw_readl(p) *(const volatile unsigned int *)(p)
33914 +#define __raw_writel(v, p) \
33916 + *(volatile unsigned int *)(p) = (v); \
33919 +/* printk() stuff */
33920 +#define printk(fmt, args...) do_not_use_printk
33921 +#define nada(fmt, args...) do { ; } while (0)
33923 +/* Interrupt stuff */
33924 +typedef uint32_t irqreturn_t;
33925 +#define IRQ_HANDLED 0
33927 +/* memcpy() stuff - when you know alignments in advance */
33928 +#ifdef CONFIG_TRY_BETTER_MEMCPY
33929 +static inline void copy_words(void *dest, const void *src, size_t sz)
33931 + u32 *__dest = dest;
33932 + const u32 *__src = src;
33933 + size_t __sz = sz >> 2;
33935 + BUG_ON((unsigned long)dest & 0x3);
33936 + BUG_ON((unsigned long)src & 0x3);
33937 + BUG_ON(sz & 0x3);
33939 + *(__dest++) = *(__src++);
33942 +static inline void copy_shorts(void *dest, const void *src, size_t sz)
33944 + u16 *__dest = dest;
33945 + const u16 *__src = src;
33946 + size_t __sz = sz >> 1;
33948 + BUG_ON((unsigned long)dest & 0x1);
33949 + BUG_ON((unsigned long)src & 0x1);
33950 + BUG_ON(sz & 0x1);
33952 + *(__dest++) = *(__src++);
33955 +static inline void copy_bytes(void *dest, const void *src, size_t sz)
33957 + u8 *__dest = dest;
33958 + const u8 *__src = src;
33961 + *(__dest++) = *(__src++);
33964 +#define copy_words memcpy
33965 +#define copy_shorts memcpy
33966 +#define copy_bytes memcpy
33969 +/* Spinlock stuff */
33970 +#define spinlock_t pthread_mutex_t
33971 +#define __SPIN_LOCK_UNLOCKED(x) PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP
33972 +#define DEFINE_SPINLOCK(x) spinlock_t x = __SPIN_LOCK_UNLOCKED(x)
33973 +#define spin_lock_init(x) \
33975 + __maybe_unused int __foo; \
33976 + pthread_mutexattr_t __foo_attr; \
33977 + __foo = pthread_mutexattr_init(&__foo_attr); \
33979 + __foo = pthread_mutexattr_settype(&__foo_attr, \
33980 + PTHREAD_MUTEX_ADAPTIVE_NP); \
33982 + __foo = pthread_mutex_init(x, &__foo_attr); \
33985 +#define spin_lock(x) \
33987 + __maybe_unused int __foo = pthread_mutex_lock(x); \
33990 +#define spin_unlock(x) \
33992 + __maybe_unused int __foo = pthread_mutex_unlock(x); \
33995 +#define spin_lock_irq(x) do { \
33996 + local_irq_disable(); \
33999 +#define spin_unlock_irq(x) do { \
34000 + spin_unlock(x); \
34001 + local_irq_enable(); \
34003 +#define spin_lock_irqsave(x, f) do { spin_lock_irq(x); } while (0)
34004 +#define spin_unlock_irqrestore(x, f) do { spin_unlock_irq(x); } while (0)
34006 +#define raw_spinlock_t spinlock_t
34007 +#define raw_spin_lock_init(x) spin_lock_init(x)
34008 +#define raw_spin_lock_irqsave(x, f) spin_lock(x)
34009 +#define raw_spin_unlock_irqrestore(x, f) spin_unlock(x)
34011 +/* Completion stuff */
34012 +#define DECLARE_COMPLETION(n) int n = 0;
34013 +#define complete(n) \
34017 +#define wait_for_completion(n) \
34026 +/* Platform device stuff */
34027 +struct platform_device { void *dev; };
34028 +static inline struct
34029 +platform_device *platform_device_alloc(const char *name __always_unused,
34030 + int id __always_unused)
34032 + struct platform_device *ret = malloc(sizeof(*ret));
34039 +#define platform_device_add(pdev) 0
34040 +#define platform_device_del(pdev) do { ; } while (0)
34041 +static inline void platform_device_put(struct platform_device *pdev)
34050 +/* Allocator stuff */
34051 +#define kmalloc(sz, t) malloc(sz)
34052 +#define vmalloc(sz) malloc(sz)
34053 +#define kfree(p) do { if (p) free(p); } while (0)
34054 +static inline void *kzalloc(size_t sz, gfp_t __foo __always_unused)
34056 + void *ptr = malloc(sz);
34059 + memset(ptr, 0, sz);
34063 +static inline unsigned long get_zeroed_page(gfp_t __foo __always_unused)
34067 + if (posix_memalign(&p, 4096, 4096))
34069 + memset(p, 0, 4096);
34070 + return (unsigned long)p;
34073 +static inline void free_page(unsigned long p)
34078 +struct kmem_cache {
34083 +#define SLAB_HWCACHE_ALIGN 0
34084 +static inline struct kmem_cache *kmem_cache_create(const char *n __always_unused,
34085 + size_t sz, size_t align, unsigned long flags __always_unused,
34086 + void (*c)(void *) __always_unused)
34088 + struct kmem_cache *ret = malloc(sizeof(*ret));
34092 + ret->align = align;
34097 +static inline void kmem_cache_destroy(struct kmem_cache *c)
34102 +static inline void *kmem_cache_alloc(struct kmem_cache *c, gfp_t f __always_unused)
34106 + if (posix_memalign(&p, c->align, c->sz))
34111 +static inline void kmem_cache_free(struct kmem_cache *c __always_unused, void *p)
34116 +static inline void *kmem_cache_zalloc(struct kmem_cache *c, gfp_t f)
34118 + void *ret = kmem_cache_alloc(c, f);
34121 + memset(ret, 0, c->sz);
34125 +/* Bitfield stuff. */
34126 +#define BITS_PER_ULONG (sizeof(unsigned long) << 3)
34127 +#define SHIFT_PER_ULONG (((1 << 5) == BITS_PER_ULONG) ? 5 : 6)
34128 +#define BITS_MASK(idx) ((unsigned long)1 << ((idx) & (BITS_PER_ULONG - 1)))
34129 +#define BITS_IDX(idx) ((idx) >> SHIFT_PER_ULONG)
34130 +static inline unsigned long test_bits(unsigned long mask,
34131 + volatile unsigned long *p)
34133 + return *p & mask;
34136 +static inline int test_bit(int idx, volatile unsigned long *bits)
34138 + return test_bits(BITS_MASK(idx), bits + BITS_IDX(idx));
34141 +static inline void set_bits(unsigned long mask, volatile unsigned long *p)
34146 +static inline void set_bit(int idx, volatile unsigned long *bits)
34148 + set_bits(BITS_MASK(idx), bits + BITS_IDX(idx));
34151 +static inline void clear_bits(unsigned long mask, volatile unsigned long *p)
34156 +static inline void clear_bit(int idx, volatile unsigned long *bits)
34158 + clear_bits(BITS_MASK(idx), bits + BITS_IDX(idx));
34161 +static inline unsigned long test_and_set_bits(unsigned long mask,
34162 + volatile unsigned long *p)
34164 + unsigned long ret = test_bits(mask, p);
34166 + set_bits(mask, p);
34170 +static inline int test_and_set_bit(int idx, volatile unsigned long *bits)
34172 + int ret = test_bit(idx, bits);
34174 + set_bit(idx, bits);
34178 +static inline int test_and_clear_bit(int idx, volatile unsigned long *bits)
34180 + int ret = test_bit(idx, bits);
34182 + clear_bit(idx, bits);
34186 +static inline int find_next_zero_bit(unsigned long *bits, int limit, int idx)
34188 + while ((++idx < limit) && test_bit(idx, bits))
34193 +static inline int find_first_zero_bit(unsigned long *bits, int limit)
34197 + while (test_bit(idx, bits) && (++idx < limit))
34202 +static inline u64 div64_u64(u64 n, u64 d)
34207 +#define dmb(opt) { asm volatile("dmb " #opt : : : "memory"); }
34208 +#define smp_mb() dmb(ish)
34210 +/* Atomic stuff */
34215 +#define atomic_read(v) (*(volatile int *)&(v)->counter)
34216 +#define atomic_set(v, i) (((v)->counter) = (i))
34217 +static inline void atomic_add(int i, atomic_t *v)
34219 + unsigned long tmp;
34222 + asm volatile("// atomic_add\n"
34223 + "1: ldxr %w0, %2\n"
34224 + " add %w0, %w0, %w3\n"
34225 + " stxr %w1, %w0, %2\n"
34227 + : "=&r" (result), "=&r" (tmp), "+Q" (v->counter)
34231 +static inline int atomic_add_return(int i, atomic_t *v)
34233 + unsigned long tmp;
34236 + asm volatile("// atomic_add_return\n"
34237 + "1: ldxr %w0, %2\n"
34238 + " add %w0, %w0, %w3\n"
34239 + " stlxr %w1, %w0, %2\n"
34241 + : "=&r" (result), "=&r" (tmp), "+Q" (v->counter)
34249 +static inline void atomic_sub(int i, atomic_t *v)
34251 + unsigned long tmp;
34254 + asm volatile("// atomic_sub\n"
34255 + "1: ldxr %w0, %2\n"
34256 + " sub %w0, %w0, %w3\n"
34257 + " stxr %w1, %w0, %2\n"
34259 + : "=&r" (result), "=&r" (tmp), "+Q" (v->counter)
34263 +static inline int atomic_sub_return(int i, atomic_t *v)
34265 + unsigned long tmp;
34268 + asm volatile("// atomic_sub_return\n"
34269 + "1: ldxr %w0, %2\n"
34270 + " sub %w0, %w0, %w3\n"
34271 + " stlxr %w1, %w0, %2\n"
34273 + : "=&r" (result), "=&r" (tmp), "+Q" (v->counter)
34281 +#define atomic_inc(v) atomic_add(1, v)
34282 +#define atomic_dec(v) atomic_sub(1, v)
34284 +#define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
34285 +#define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
34286 +#define atomic_inc_return(v) (atomic_add_return(1, v))
34287 +#define atomic_dec_return(v) (atomic_sub_return(1, v))
34288 +#define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
34290 +#endif /* HEADER_COMPAT_H */
34291 diff --git a/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_base.h b/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_base.h
34292 new file mode 100644
34293 index 0000000..4cb784c
34295 +++ b/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_base.h
34297 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
34299 + * Redistribution and use in source and binary forms, with or without
34300 + * modification, are permitted provided that the following conditions are met:
34301 + * * Redistributions of source code must retain the above copyright
34302 + * notice, this list of conditions and the following disclaimer.
34303 + * * Redistributions in binary form must reproduce the above copyright
34304 + * notice, this list of conditions and the following disclaimer in the
34305 + * documentation and/or other materials provided with the distribution.
34306 + * * Neither the name of Freescale Semiconductor nor the
34307 + * names of its contributors may be used to endorse or promote products
34308 + * derived from this software without specific prior written permission.
34310 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
34311 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34312 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34313 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
34314 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34315 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34316 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34317 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34318 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34319 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34321 +#ifndef _FSL_QBMAN_BASE_H
34322 +#define _FSL_QBMAN_BASE_H
34325 + * DOC: QBMan basic structures
34327 + * The QBMan block descriptor, software portal descriptor and Frame descriptor
34328 + * are defined here.
34333 + * struct qbman_block_desc - qbman block descriptor structure
34334 + * @ccsr_reg_bar: CCSR register map.
34335 + * @irq_rerr: Recoverable error interrupt line.
34336 + * @irq_nrerr: Non-recoverable error interrupt line
34338 + * Descriptor for a QBMan instance on the SoC. On partitions/targets that do not
34339 + * control this QBMan instance, these values may simply be place-holders. The
34340 + * idea is simply that we be able to distinguish between them, eg. so that SWP
34341 + * descriptors can identify which QBMan instance they belong to.
34343 +struct qbman_block_desc {
34344 + void *ccsr_reg_bar;
34349 +enum qbman_eqcr_mode {
34350 + qman_eqcr_vb_ring = 2, /* Valid bit, with eqcr in ring mode */
34351 + qman_eqcr_vb_array, /* Valid bit, with eqcr in array mode */
34355 + * struct qbman_swp_desc - qbman software portal descriptor structure
34356 + * @block: The QBMan instance.
34357 + * @cena_bar: Cache-enabled portal register map.
34358 + * @cinh_bar: Cache-inhibited portal register map.
34359 + * @irq: -1 if unused (or unassigned)
34360 + * @idx: SWPs within a QBMan are indexed. -1 if opaque to the user.
34361 + * @qman_version: the qman version.
34362 + * @eqcr_mode: Select the eqcr mode, currently only valid bit ring mode and
34363 + * valid bit array mode are supported.
34365 + * Descriptor for a QBMan software portal, expressed in terms that make sense to
34366 + * the user context. Ie. on MC, this information is likely to be true-physical,
34367 + * and instantiated statically at compile-time. On GPP, this information is
34368 + * likely to be obtained via "discovery" over a partition's "MC bus"
34369 + * (ie. in response to a MC portal command), and would take into account any
34370 + * virtualisation of the GPP user's address space and/or interrupt numbering.
34372 +struct qbman_swp_desc {
34373 + const struct qbman_block_desc *block;
34374 + uint8_t *cena_bar;
34375 + uint8_t *cinh_bar;
34378 + uint32_t qman_version;
34379 + enum qbman_eqcr_mode eqcr_mode;
34382 +/* Driver object for managing a QBMan portal */
34386 + * struct qbman_fd - basci structure for qbman frame descriptor
34387 + * @words: for easier/faster copying the whole FD structure.
34388 + * @addr_lo: the lower 32 bits of the address in FD.
34389 + * @addr_hi: the upper 32 bits of the address in FD.
34390 + * @len: the length field in FD.
34391 + * @bpid_offset: represent the bpid and offset fields in FD. offset in
34392 + * the MS 16 bits, BPID in the LS 16 bits.
34393 + * @frc: frame context
34394 + * @ctrl: the 32bit control bits including dd, sc,... va, err.
34395 + * @flc_lo: the lower 32bit of flow context.
34396 + * @flc_hi: the upper 32bits of flow context.
34398 + * Place-holder for FDs, we represent it via the simplest form that we need for
34399 + * now. Different overlays may be needed to support different options, etc. (It
34400 + * is impractical to define One True Struct, because the resulting encoding
34401 + * routines (lots of read-modify-writes) would be worst-case performance whether
34402 + * or not circumstances required them.)
34404 + * Note, as with all data-structures exchanged between software and hardware (be
34405 + * they located in the portal register map or DMA'd to and from main-memory),
34406 + * the driver ensures that the caller of the driver API sees the data-structures
34407 + * in host-endianness. "struct qbman_fd" is no exception. The 32-bit words
34408 + * contained within this structure are represented in host-endianness, even if
34409 + * hardware always treats them as little-endian. As such, if any of these fields
34410 + * are interpreted in a binary (rather than numerical) fashion by hardware
34411 + * blocks (eg. accelerators), then the user should be careful. We illustrate
34412 + * with an example;
34414 + * Suppose the desired behaviour of an accelerator is controlled by the "frc"
34415 + * field of the FDs that are sent to it. Suppose also that the behaviour desired
34416 + * by the user corresponds to an "frc" value which is expressed as the literal
34417 + * sequence of bytes 0xfe, 0xed, 0xab, and 0xba. So "frc" should be the 32-bit
34418 + * value in which 0xfe is the first byte and 0xba is the last byte, and as
34419 + * hardware is little-endian, this amounts to a 32-bit "value" of 0xbaabedfe. If
34420 + * the software is little-endian also, this can simply be achieved by setting
34421 + * frc=0xbaabedfe. On the other hand, if software is big-endian, it should set
34422 + * frc=0xfeedabba! The best away of avoiding trouble with this sort of thing is
34423 + * to treat the 32-bit words as numerical values, in which the offset of a field
34424 + * from the beginning of the first byte (as required or generated by hardware)
34425 + * is numerically encoded by a left-shift (ie. by raising the field to a
34426 + * corresponding power of 2). Ie. in the current example, software could set
34427 + * "frc" in the following way, and it would work correctly on both little-endian
34428 + * and big-endian operation;
34429 + * fd.frc = (0xfe << 0) | (0xed << 8) | (0xab << 16) | (0xba << 24);
34433 + uint32_t words[8];
34434 + struct qbman_fd_simple {
34435 + uint32_t addr_lo;
34436 + uint32_t addr_hi;
34438 + uint32_t bpid_offset;
34447 +#endif /* !_FSL_QBMAN_BASE_H */
34448 diff --git a/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_portal.h b/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_portal.h
34449 new file mode 100644
34450 index 0000000..9e8e5f2
34452 +++ b/drivers/net/dpaa2/qbman/include/drivers/fsl_qbman_portal.h
34454 +/* Copyright (C) 2014 Freescale Semiconductor, Inc.
34456 + * Redistribution and use in source and binary forms, with or without
34457 + * modification, are permitted provided that the following conditions are met:
34458 + * * Redistributions of source code must retain the above copyright
34459 + * notice, this list of conditions and the following disclaimer.
34460 + * * Redistributions in binary form must reproduce the above copyright
34461 + * notice, this list of conditions and the following disclaimer in the
34462 + * documentation and/or other materials provided with the distribution.
34463 + * * Neither the name of Freescale Semiconductor nor the
34464 + * names of its contributors may be used to endorse or promote products
34465 + * derived from this software without specific prior written permission.
34467 + * THIS SOFTWARE IS PROVIDED BY Freescale Semiconductor ``AS IS'' AND ANY
34468 + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
34469 + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
34470 + * DISCLAIMED. IN NO EVENT SHALL Freescale Semiconductor BE LIABLE FOR ANY
34471 + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34472 + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34473 + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
34474 + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34475 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34476 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34478 +#ifndef _FSL_QBMAN_PORTAL_H
34479 +#define _FSL_QBMAN_PORTAL_H
34481 +#include <drivers/fsl_qbman_base.h>
34484 + * DOC - QBMan portal APIs to implement the following functions:
34485 + * - Initialize and destroy Software portal object.
34486 + * - Read and write Software portal interrupt registers.
34487 + * - Enqueue, including setting the enqueue descriptor, and issuing enqueue
34489 + * - Dequeue, including setting the dequeue descriptor, issuing dequeue command,
34490 + * parsing the dequeue response in DQRR and memeory, parsing the state change
34491 + * notifications etc.
34492 + * - Release, including setting the release descriptor, and issuing the buffer
34493 + * release command.
34494 + * - Acquire, acquire the buffer from the given buffer pool.
34495 + * - FQ management.
34496 + * - Channel management, enable/disable CDAN with or without context.
34500 + * qbman_swp_init() - Create a functional object representing the given
34501 + * QBMan portal descriptor.
34502 + * @d: the given qbman swp descriptor
34504 + * Return qbman_swp portal object for success, NULL if the object cannot
34507 +struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d);
34510 + * qbman_swp_finish() - Create and destroy a functional object representing
34511 + * the given QBMan portal descriptor.
34512 + * @p: the qbman_swp object to be destroyed.
34515 +void qbman_swp_finish(struct qbman_swp *p);
34518 + * qbman_swp_get_desc() - Get the descriptor of the given portal object.
34519 + * @p: the given portal object.
34521 + * Return the descriptor for this portal.
34523 +const struct qbman_swp_desc *qbman_swp_get_desc(struct qbman_swp *);
34529 +/* EQCR ring interrupt */
34530 +#define QBMAN_SWP_INTERRUPT_EQRI ((uint32_t)0x00000001)
34531 +/* Enqueue command dispatched interrupt */
34532 +#define QBMAN_SWP_INTERRUPT_EQDI ((uint32_t)0x00000002)
34533 +/* DQRR non-empty interrupt */
34534 +#define QBMAN_SWP_INTERRUPT_DQRI ((uint32_t)0x00000004)
34535 +/* RCR ring interrupt */
34536 +#define QBMAN_SWP_INTERRUPT_RCRI ((uint32_t)0x00000008)
34537 +/* Release command dispatched interrupt */
34538 +#define QBMAN_SWP_INTERRUPT_RCDI ((uint32_t)0x00000010)
34539 +/* Volatile dequeue command interrupt */
34540 +#define QBMAN_SWP_INTERRUPT_VDCI ((uint32_t)0x00000020)
34543 + * qbman_swp_interrupt_get_vanish() - Get the data in software portal
34544 + * interrupt status disable register.
34545 + * @p: the given software portal object.
34547 + * Return the settings in SWP_ISDR register.
34549 +uint32_t qbman_swp_interrupt_get_vanish(struct qbman_swp *p);
34552 + * qbman_swp_interrupt_set_vanish() - Set the data in software portal
34553 + * interrupt status disable register.
34554 + * @p: the given software portal object.
34555 + * @mask: The value to set in SWP_IDSR register.
34557 +void qbman_swp_interrupt_set_vanish(struct qbman_swp *p, uint32_t mask);
34560 + * qbman_swp_interrupt_read_status() - Get the data in software portal
34561 + * interrupt status register.
34562 + * @p: the given software portal object.
34564 + * Return the settings in SWP_ISR register.
34566 +uint32_t qbman_swp_interrupt_read_status(struct qbman_swp *p);
34569 + * qbman_swp_interrupt_clear_status() - Set the data in software portal
34570 + * interrupt status register.
34571 + * @p: the given software portal object.
34572 + * @mask: The value to set in SWP_ISR register.
34574 +void qbman_swp_interrupt_clear_status(struct qbman_swp *p, uint32_t mask);
34577 + * qbman_swp_interrupt_get_trigger() - Get the data in software portal
34578 + * interrupt enable register.
34579 + * @p: the given software portal object.
34581 + * Return the settings in SWP_IER register.
34583 +uint32_t qbman_swp_interrupt_get_trigger(struct qbman_swp *p);
34586 + * qbman_swp_interrupt_set_trigger() - Set the data in software portal
34587 + * interrupt enable register.
34588 + * @p: the given software portal object.
34589 + * @mask: The value to set in SWP_IER register.
34591 +void qbman_swp_interrupt_set_trigger(struct qbman_swp *p, uint32_t mask);
34594 + * qbman_swp_interrupt_get_inhibit() - Get the data in software portal
34595 + * interrupt inhibit register.
34596 + * @p: the given software portal object.
34598 + * Return the settings in SWP_IIR register.
34600 +int qbman_swp_interrupt_get_inhibit(struct qbman_swp *p);
34603 + * qbman_swp_interrupt_set_inhibit() - Set the data in software portal
34604 + * interrupt inhibit register.
34605 + * @p: the given software portal object.
34606 + * @mask: The value to set in SWP_IIR register.
34608 +void qbman_swp_interrupt_set_inhibit(struct qbman_swp *p, int inhibit);
34615 + * struct qbman_result - structure for qbman dequeue response and/or
34617 + * @dont_manipulate_directly: the 16 32bit data to represent the whole
34618 + * possible qbman dequeue result.
34620 +struct qbman_result {
34621 + uint32_t dont_manipulate_directly[16];
34625 + *A DQRI interrupt can be generated when there are dequeue results on the
34626 + * portal's DQRR (this mechanism does not deal with "pull" dequeues to
34627 + * user-supplied 'storage' addresses). There are two parameters to this
34628 + * interrupt source, one is a threshold and the other is a timeout. The
34629 + * interrupt will fire if either the fill-level of the ring exceeds 'thresh', or
34630 + * if the ring has been non-empty for been longer than 'timeout' nanoseconds.
34631 + * For timeout, an approximation to the desired nanosecond-granularity value is
34632 + * made, so there are get and set APIs to allow the user to see what actual
34633 + * timeout is set (compared to the timeout that was requested). */
34634 +int qbman_swp_dequeue_thresh(struct qbman_swp *s, unsigned int thresh);
34635 +int qbman_swp_dequeue_set_timeout(struct qbman_swp *s, unsigned int timeout);
34636 +int qbman_swp_dequeue_get_timeout(struct qbman_swp *s, unsigned int *timeout);
34638 +/* ------------------- */
34639 +/* Push-mode dequeuing */
34640 +/* ------------------- */
34642 +/* The user of a portal can enable and disable push-mode dequeuing of up to 16
34643 + * channels independently. It does not specify this toggling by channel IDs, but
34644 + * rather by specifying the index (from 0 to 15) that has been mapped to the
34645 + * desired channel.
34649 + * qbman_swp_push_get() - Get the push dequeue setup.
34650 + * @s: the software portal object.
34651 + * @channel_idx: the channel index to query.
34652 + * @enabled: returned boolean to show whether the push dequeue is enabled for
34653 + * the given channel.
34655 +void qbman_swp_push_get(struct qbman_swp *s, uint8_t channel_idx, int *enabled);
34658 + * qbman_swp_push_set() - Enable or disable push dequeue.
34659 + * @s: the software portal object.
34660 + * @channel_idx: the channel index..
34661 + * @enable: enable or disable push dequeue.
34663 + * The user of a portal can enable and disable push-mode dequeuing of up to 16
34664 + * channels independently. It does not specify this toggling by channel IDs, but
34665 + * rather by specifying the index (from 0 to 15) that has been mapped to the
34666 + * desired channel.
34668 +void qbman_swp_push_set(struct qbman_swp *s, uint8_t channel_idx, int enable);
34670 +/* ------------------- */
34671 +/* Pull-mode dequeuing */
34672 +/* ------------------- */
34675 + * struct qbman_pull_desc - the structure for pull dequeue descriptor
34676 + * @dont_manipulate_directly: the 6 32bit data to represent the whole
34677 + * possible settings for pull dequeue descriptor.
34679 +struct qbman_pull_desc {
34680 + uint32_t dont_manipulate_directly[6];
34683 +enum qbman_pull_type_e {
34684 + /* dequeue with priority precedence, respect intra-class scheduling */
34685 + qbman_pull_type_prio = 1,
34686 + /* dequeue with active FQ precedence, respect ICS */
34687 + qbman_pull_type_active,
34688 + /* dequeue with active FQ precedence, no ICS */
34689 + qbman_pull_type_active_noics
34693 + * qbman_pull_desc_clear() - Clear the contents of a descriptor to
34694 + * default/starting state.
34695 + * @d: the pull dequeue descriptor to be cleared.
34697 +void qbman_pull_desc_clear(struct qbman_pull_desc *d);
34700 + * qbman_pull_desc_set_storage()- Set the pull dequeue storage
34701 + * @d: the pull dequeue descriptor to be set.
34702 + * @storage: the pointer of the memory to store the dequeue result.
34703 + * @storage_phys: the physical address of the storage memory.
34704 + * @stash: to indicate whether write allocate is enabled.
34706 + * If not called, or if called with 'storage' as NULL, the result pull dequeues
34707 + * will produce results to DQRR. If 'storage' is non-NULL, then results are
34708 + * produced to the given memory location (using the physical/DMA address which
34709 + * the caller provides in 'storage_phys'), and 'stash' controls whether or not
34710 + * those writes to main-memory express a cache-warming attribute.
34712 +void qbman_pull_desc_set_storage(struct qbman_pull_desc *d,
34713 + struct qbman_result *storage,
34714 + dma_addr_t storage_phys,
34717 + * qbman_pull_desc_set_numframes() - Set the number of frames to be dequeued.
34718 + * @d: the pull dequeue descriptor to be set.
34719 + * @numframes: number of frames to be set, must be between 1 and 16, inclusive.
34721 +void qbman_pull_desc_set_numframes(struct qbman_pull_desc *d,
34722 + uint8_t numframes);
34724 + * qbman_pull_desc_set_token() - Set dequeue token for pull command
34725 + * @d: the dequeue descriptor
34726 + * @token: the token to be set
34728 + * token is the value that shows up in the dequeue response that can be used to
34729 + * detect when the results have been published. The easiest technique is to zero
34730 + * result "storage" before issuing a dequeue, and use any non-zero 'token' value
34732 +void qbman_pull_desc_set_token(struct qbman_pull_desc *d, uint8_t token);
34734 +/* Exactly one of the following descriptor "actions" should be set. (Calling any
34735 + * one of these will replace the effect of any prior call to one of these.)
34736 + * - pull dequeue from the given frame queue (FQ)
34737 + * - pull dequeue from any FQ in the given work queue (WQ)
34738 + * - pull dequeue from any FQ in any WQ in the given channel
34741 + * qbman_pull_desc_set_fq() - Set fqid from which the dequeue command dequeues.
34742 + * @fqid: the frame queue index of the given FQ.
34744 +void qbman_pull_desc_set_fq(struct qbman_pull_desc *d, uint32_t fqid);
34747 + * qbman_pull_desc_set_wq() - Set wqid from which the dequeue command dequeues.
34748 + * @wqid: composed of channel id and wqid within the channel.
34749 + * @dct: the dequeue command type.
34751 +void qbman_pull_desc_set_wq(struct qbman_pull_desc *d, uint32_t wqid,
34752 + enum qbman_pull_type_e dct);
34754 +/* qbman_pull_desc_set_channel() - Set channelid from which the dequeue command
34756 + * @chid: the channel id to be dequeued.
34757 + * @dct: the dequeue command type.
34759 +void qbman_pull_desc_set_channel(struct qbman_pull_desc *d, uint32_t chid,
34760 + enum qbman_pull_type_e dct);
34763 + * qbman_swp_pull() - Issue the pull dequeue command
34764 + * @s: the software portal object.
34765 + * @d: the software portal descriptor which has been configured with
34766 + * the set of qbman_pull_desc_set_*() calls.
34768 + * Return 0 for success, and -EBUSY if the software portal is not ready
34769 + * to do pull dequeue.
34771 +int qbman_swp_pull(struct qbman_swp *s, struct qbman_pull_desc *d);
34773 +/* -------------------------------- */
34774 +/* Polling DQRR for dequeue results */
34775 +/* -------------------------------- */
34778 + * qbman_swp_dqrr_next() - Get an valid DQRR entry.
34779 + * @s: the software portal object.
34781 + * Return NULL if there are no unconsumed DQRR entries. Return a DQRR entry
34782 + * only once, so repeated calls can return a sequence of DQRR entries, without
34783 + * requiring they be consumed immediately or in any particular order.
34785 +const struct qbman_result *qbman_swp_dqrr_next(struct qbman_swp *);
34788 + * qbman_swp_dqrr_consume() - Consume DQRR entries previously returned from
34789 + * qbman_swp_dqrr_next().
34790 + * @s: the software portal object.
34791 + * @dq: the DQRR entry to be consumed.
34793 +void qbman_swp_dqrr_consume(struct qbman_swp *s, const struct qbman_result *dq);
34796 + * qbman_get_dqrr_idx() - Get dqrr index from the given dqrr
34797 + * @dqrr: the given dqrr object.
34799 + * Return dqrr index.
34801 +uint8_t qbman_get_dqrr_idx(struct qbman_result *dqrr);
34804 + * qbman_get_dqrr_from_idx() - Use index to get the dqrr entry from the
34806 + * @s: the given portal.
34807 + * @idx: the dqrr index.
34809 + * Return dqrr entry object.
34811 +struct qbman_result *qbman_get_dqrr_from_idx(struct qbman_swp *s, uint8_t idx);
34813 +/* ------------------------------------------------- */
34814 +/* Polling user-provided storage for dequeue results */
34815 +/* ------------------------------------------------- */
34818 + * qbman_result_has_new_result() - Check and get the dequeue response from the
34819 + * dq storage memory set in pull dequeue command
34820 + * @s: the software portal object.
34821 + * @dq: the dequeue result read from the memory.
34823 + * Only used for user-provided storage of dequeue results, not DQRR. For
34824 + * efficiency purposes, the driver will perform any required endianness
34825 + * conversion to ensure that the user's dequeue result storage is in host-endian
34826 + * format (whether or not that is the same as the little-endian format that
34827 + * hardware DMA'd to the user's storage). As such, once the user has called
34828 + * qbman_result_has_new_result() and been returned a valid dequeue result,
34829 + * they should not call it again on the same memory location (except of course
34830 + * if another dequeue command has been executed to produce a new result to that
34833 + * Return 1 for getting a valid dequeue result, or 0 for not getting a valid
34834 + * dequeue result.
34836 +int qbman_result_has_new_result(struct qbman_swp *s,
34837 + const struct qbman_result *dq);
34839 +/* -------------------------------------------------------- */
34840 +/* Parsing dequeue entries (DQRR and user-provided storage) */
34841 +/* -------------------------------------------------------- */
34844 + * qbman_result_is_DQ() - check the dequeue result is a dequeue response or not
34845 + * @dq: the dequeue result to be checked.
34847 + * DQRR entries may contain non-dequeue results, ie. notifications
34849 +int qbman_result_is_DQ(const struct qbman_result *);
34852 + * qbman_result_is_SCN() - Check the dequeue result is notification or not
34853 + * @dq: the dequeue result to be checked.
34855 + * All the non-dequeue results (FQDAN/CDAN/CSCN/...) are "state change
34856 + * notifications" of one type or another. Some APIs apply to all of them, of the
34857 + * form qbman_result_SCN_***().
34859 +static inline int qbman_result_is_SCN(const struct qbman_result *dq)
34861 + return !qbman_result_is_DQ(dq);
34864 +/* Recognise different notification types, only required if the user allows for
34865 + * these to occur, and cares about them when they do.
34869 + * qbman_result_is_FQDAN() - Check for FQ Data Availability
34870 + * @dq: the qbman_result object.
34872 + * Return 1 if this is FQDAN.
34874 +int qbman_result_is_FQDAN(const struct qbman_result *dq);
34877 + * qbman_result_is_CDAN() - Check for Channel Data Availability
34878 + * @dq: the qbman_result object to check.
34880 + * Return 1 if this is CDAN.
34882 +int qbman_result_is_CDAN(const struct qbman_result *dq);
34885 + * qbman_result_is_CSCN() - Check for Congestion State Change
34886 + * @dq: the qbman_result object to check.
34888 + * Return 1 if this is CSCN.
34890 +int qbman_result_is_CSCN(const struct qbman_result *dq);
34893 + * qbman_result_is_BPSCN() - Check for Buffer Pool State Change.
34894 + * @dq: the qbman_result object to check.
34896 + * Return 1 if this is BPSCN.
34898 +int qbman_result_is_BPSCN(const struct qbman_result *dq);
34901 + * qbman_result_is_CGCU() - Check for Congestion Group Count Update.
34902 + * @dq: the qbman_result object to check.
34904 + * Return 1 if this is CGCU.
34906 +int qbman_result_is_CGCU(const struct qbman_result *dq);
34908 +/* Frame queue state change notifications; (FQDAN in theory counts too as it
34909 + * leaves a FQ parked, but it is primarily a data availability notification)
34913 + * qbman_result_is_FQRN() - Check for FQ Retirement Notification.
34914 + * @dq: the qbman_result object to check.
34916 + * Return 1 if this is FQRN.
34918 +int qbman_result_is_FQRN(const struct qbman_result *);
34921 + * qbman_result_is_FQRNI() - Check for FQ Retirement Immediate
34922 + * @dq: the qbman_result object to check.
34924 + * Return 1 if this is FQRNI.
34926 +int qbman_result_is_FQRNI(const struct qbman_result *);
34929 + * qbman_result_is_FQPN() - Check for FQ Park Notification
34930 + * @dq: the qbman_result object to check.
34932 + * Return 1 if this is FQPN.
34934 +int qbman_result_is_FQPN(const struct qbman_result *dq);
34936 +/* Parsing frame dequeue results (qbman_result_is_DQ() must be TRUE)
34939 +#define QBMAN_DQ_STAT_FQEMPTY 0x80
34940 +/* FQ held active */
34941 +#define QBMAN_DQ_STAT_HELDACTIVE 0x40
34942 +/* FQ force eligible */
34943 +#define QBMAN_DQ_STAT_FORCEELIGIBLE 0x20
34945 +#define QBMAN_DQ_STAT_VALIDFRAME 0x10
34946 +/* FQ ODP enable */
34947 +#define QBMAN_DQ_STAT_ODPVALID 0x04
34948 +/* Volatile dequeue */
34949 +#define QBMAN_DQ_STAT_VOLATILE 0x02
34950 +/* volatile dequeue command is expired */
34951 +#define QBMAN_DQ_STAT_EXPIRED 0x01
34954 + * qbman_result_DQ_flags() - Get the STAT field of dequeue response
34955 + * @dq: the dequeue result.
34957 + * Return the state field.
34959 +uint32_t qbman_result_DQ_flags(const struct qbman_result *dq);
34962 + * qbman_result_DQ_is_pull() - Check whether the dq response is from a pull
34964 + * @dq: the dequeue result.
34966 + * Return 1 for volatile(pull) dequeue, 0 for static dequeue.
34968 +static inline int qbman_result_DQ_is_pull(const struct qbman_result *dq)
34970 + return (int)(qbman_result_DQ_flags(dq) & QBMAN_DQ_STAT_VOLATILE);
34974 + * qbman_result_DQ_is_pull_complete() - Check whether the pull command is
34976 + * @dq: the dequeue result.
34978 + * Return boolean.
34980 +static inline int qbman_result_DQ_is_pull_complete(
34981 + const struct qbman_result *dq)
34983 + return (int)(qbman_result_DQ_flags(dq) & QBMAN_DQ_STAT_EXPIRED);
34987 + * qbman_result_DQ_seqnum() - Get the seqnum field in dequeue response
34988 + * seqnum is valid only if VALIDFRAME flag is TRUE
34989 + * @dq: the dequeue result.
34993 +uint16_t qbman_result_DQ_seqnum(const struct qbman_result *dq);
34996 + * qbman_result_DQ_odpid() - Get the seqnum field in dequeue response
34997 + * odpid is valid only if ODPVAILD flag is TRUE.
34998 + * @dq: the dequeue result.
35002 +uint16_t qbman_result_DQ_odpid(const struct qbman_result *dq);
35005 + * qbman_result_DQ_fqid() - Get the fqid in dequeue response
35006 + * @dq: the dequeue result.
35010 +uint32_t qbman_result_DQ_fqid(const struct qbman_result *dq);
35013 + * qbman_result_DQ_byte_count() - Get the byte count in dequeue response
35014 + * @dq: the dequeue result.
35016 + * Return the byte count remaining in the FQ.
35018 +uint32_t qbman_result_DQ_byte_count(const struct qbman_result *dq);
35021 + * qbman_result_DQ_frame_count - Get the frame count in dequeue response
35022 + * @dq: the dequeue result.
35024 + * Return the frame count remaining in the FQ.
35026 +uint32_t qbman_result_DQ_frame_count(const struct qbman_result *dq);
35029 + * qbman_result_DQ_fqd_ctx() - Get the frame queue context in dequeue response
35030 + * @dq: the dequeue result.
35032 + * Return the frame queue context.
35034 +uint64_t qbman_result_DQ_fqd_ctx(const struct qbman_result *dq);
35037 + * qbman_result_DQ_fd() - Get the frame descriptor in dequeue response
35038 + * @dq: the dequeue result.
35040 + * Return the frame descriptor.
35042 +const struct qbman_fd *qbman_result_DQ_fd(const struct qbman_result *dq);
35044 +/* State-change notifications (FQDAN/CDAN/CSCN/...). */
35047 + * qbman_result_SCN_state() - Get the state field in State-change notification
35048 + * @scn: the state change notification.
35050 + * Return the state in the notifiation.
35052 +uint8_t qbman_result_SCN_state(const struct qbman_result *scn);
35055 + * qbman_result_SCN_rid() - Get the resource id from the notification
35056 + * @scn: the state change notification.
35058 + * Return the resource id.
35060 +uint32_t qbman_result_SCN_rid(const struct qbman_result *scn);
35063 + * qbman_result_SCN_ctx() - get the context from the notification
35064 + * @scn: the state change notification.
35066 + * Return the context.
35068 +uint64_t qbman_result_SCN_ctx(const struct qbman_result *scn);
35071 + * qbman_result_SCN_state_in_mem() - Get the state in notification written
35073 + * @scn: the state change notification.
35075 + * Return the state.
35077 +uint8_t qbman_result_SCN_state_in_mem(const struct qbman_result *scn);
35080 + * qbman_result_SCN_rid_in_mem() - Get the resource id in notification written
35082 + * @scn: the state change notification.
35084 + * Return the resource id.
35086 +uint32_t qbman_result_SCN_rid_in_mem(const struct qbman_result *scn);
35088 +/* Type-specific "resource IDs". Mainly for illustration purposes, though it
35089 + * also gives the appropriate type widths.
35091 +/* Get the FQID from the FQDAN */
35092 +#define qbman_result_FQDAN_fqid(dq) qbman_result_SCN_rid(dq)
35093 +/* Get the FQID from the FQRN */
35094 +#define qbman_result_FQRN_fqid(dq) qbman_result_SCN_rid(dq)
35095 +/* Get the FQID from the FQRNI */
35096 +#define qbman_result_FQRNI_fqid(dq) qbman_result_SCN_rid(dq)
35097 +/* Get the FQID from the FQPN */
35098 +#define qbman_result_FQPN_fqid(dq) qbman_result_SCN_rid(dq)
35099 +/* Get the channel ID from the CDAN */
35100 +#define qbman_result_CDAN_cid(dq) ((uint16_t)qbman_result_SCN_rid(dq))
35101 +/* Get the CGID from the CSCN */
35102 +#define qbman_result_CSCN_cgid(dq) ((uint16_t)qbman_result_SCN_rid(dq))
35105 + * qbman_result_bpscn_bpid() - Get the bpid from BPSCN
35106 + * @scn: the state change notification.
35108 + * Return the buffer pool id.
35110 +uint16_t qbman_result_bpscn_bpid(const struct qbman_result *scn);
35113 + * qbman_result_bpscn_has_free_bufs() - Check whether there are free
35114 + * buffers in the pool from BPSCN.
35115 + * @scn: the state change notification.
35117 + * Return the number of free buffers.
35119 +int qbman_result_bpscn_has_free_bufs(const struct qbman_result *scn);
35122 + * qbman_result_bpscn_is_depleted() - Check BPSCN to see whether the
35123 + * buffer pool is depleted.
35124 + * @scn: the state change notification.
35126 + * Return the status of buffer pool depletion.
35128 +int qbman_result_bpscn_is_depleted(const struct qbman_result *scn);
35131 + * qbman_result_bpscn_is_surplus() - Check BPSCN to see whether the buffer
35132 + * pool is surplus or not.
35133 + * @scn: the state change notification.
35135 + * Return the status of buffer pool surplus.
35137 +int qbman_result_bpscn_is_surplus(const struct qbman_result *scn);
35140 + * qbman_result_bpscn_ctx() - Get the BPSCN CTX from BPSCN message
35141 + * @scn: the state change notification.
35143 + * Return the BPSCN context.
35145 +uint64_t qbman_result_bpscn_ctx(const struct qbman_result *scn);
35147 +/* Parsing CGCU */
35149 + * qbman_result_cgcu_cgid() - Check CGCU resouce id, i.e. cgid
35150 + * @scn: the state change notification.
35152 + * Return the CGCU resource id.
35154 +uint16_t qbman_result_cgcu_cgid(const struct qbman_result *scn);
35157 + * qbman_result_cgcu_icnt() - Get the I_CNT from CGCU
35158 + * @scn: the state change notification.
35160 + * Return instantaneous count in the CGCU notification.
35162 +uint64_t qbman_result_cgcu_icnt(const struct qbman_result *scn);
35169 + * struct qbman_eq_desc - structure of enqueue descriptor
35170 + * @dont_manipulate_directly: the 8 32bit data to represent the whole
35171 + * possible qbman enqueue setting in enqueue descriptor.
35173 +struct qbman_eq_desc {
35174 + uint32_t dont_manipulate_directly[8];
35178 + * struct qbman_eq_response - structure of enqueue response
35179 + * @dont_manipulate_directly: the 16 32bit data to represent the whole
35180 + * enqueue response.
35182 +struct qbman_eq_response {
35183 + uint32_t dont_manipulate_directly[16];
35187 + * qbman_eq_desc_clear() - Clear the contents of a descriptor to
35188 + * default/starting state.
35189 + * @d: the given enqueue descriptor.
35191 +void qbman_eq_desc_clear(struct qbman_eq_desc *d);
35193 +/* Exactly one of the following descriptor "actions" should be set. (Calling
35194 + * any one of these will replace the effect of any prior call to one of these.)
35195 + * - enqueue without order-restoration
35196 + * - enqueue with order-restoration
35197 + * - fill a hole in the order-restoration sequence, without any enqueue
35198 + * - advance NESN (Next Expected Sequence Number), without any enqueue
35199 + * 'respond_success' indicates whether an enqueue response should be DMA'd
35200 + * after success (otherwise a response is DMA'd only after failure).
35201 + * 'incomplete' indicates that other fragments of the same 'seqnum' are yet to
35206 + * qbman_eq_desc_set_no_orp() - Set enqueue descriptor without orp
35207 + * @d: the enqueue descriptor.
35208 + * @response_success: 1 = enqueue with response always; 0 = enqueue with
35209 + * rejections returned on a FQ.
35211 +void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success);
35213 + * qbman_eq_desc_set_orp() - Set order-resotration in the enqueue descriptor
35214 + * @d: the enqueue descriptor.
35215 + * @response_success: 1 = enqueue with response always; 0 = enqueue with
35216 + * rejections returned on a FQ.
35217 + * @opr_id: the order point record id.
35218 + * @seqnum: the order restoration sequence number.
35219 + * @incomplete: indiates whether this is the last fragments using the same
35220 + * sequeue number.
35222 +void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
35223 + uint32_t opr_id, uint32_t seqnum, int incomplete);
35226 + * qbman_eq_desc_set_orp_hole() - fill a hole in the order-restoration sequence
35227 + * without any enqueue
35228 + * @d: the enqueue descriptor.
35229 + * @opr_id: the order point record id.
35230 + * @seqnum: the order restoration sequence number.
35232 +void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, uint32_t opr_id,
35233 + uint32_t seqnum);
35236 + * qbman_eq_desc_set_orp_nesn() - advance NESN (Next Expected Sequence Number)
35237 + * without any enqueue
35238 + * @d: the enqueue descriptor.
35239 + * @opr_id: the order point record id.
35240 + * @seqnum: the order restoration sequence number.
35242 +void qbman_eq_desc_set_orp_nesn(struct qbman_eq_desc *d, uint32_t opr_id,
35243 + uint32_t seqnum);
35245 + * qbman_eq_desc_set_response() - Set the enqueue response info.
35246 + * @d: the enqueue descriptor
35247 + * @storage_phys: the physical address of the enqueue response in memory.
35248 + * @stash: indicate that the write allocation enabled or not.
35250 + * In the case where an enqueue response is DMA'd, this determines where that
35251 + * response should go. (The physical/DMA address is given for hardware's
35252 + * benefit, but software should interpret it as a "struct qbman_eq_response"
35253 + * data structure.) 'stash' controls whether or not the write to main-memory
35254 + * expresses a cache-warming attribute.
35256 +void qbman_eq_desc_set_response(struct qbman_eq_desc *d,
35257 + dma_addr_t storage_phys,
35261 + * qbman_eq_desc_set_token() - Set token for the enqueue command
35262 + * @d: the enqueue descriptor
35263 + * @token: the token to be set.
35265 + * token is the value that shows up in an enqueue response that can be used to
35266 + * detect when the results have been published. The easiest technique is to zero
35267 + * result "storage" before issuing an enqueue, and use any non-zero 'token'
35270 +void qbman_eq_desc_set_token(struct qbman_eq_desc *d, uint8_t token);
35273 + * Exactly one of the following descriptor "targets" should be set. (Calling any
35274 + * one of these will replace the effect of any prior call to one of these.)
35275 + * - enqueue to a frame queue
35276 + * - enqueue to a queuing destination
35277 + * Note, that none of these will have any affect if the "action" type has been
35278 + * set to "orp_hole" or "orp_nesn".
35281 + * qbman_eq_desc_set_fq() - Set Frame Queue id for the enqueue command
35282 + * @d: the enqueue descriptor
35283 + * @fqid: the id of the frame queue to be enqueued.
35285 +void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, uint32_t fqid);
35288 + * qbman_eq_desc_set_qd() - Set Queuing Destination for the enqueue command.
35289 + * @d: the enqueue descriptor
35290 + * @qdid: the id of the queuing destination to be enqueued.
35291 + * @qd_bin: the queuing destination bin
35292 + * @qd_prio: the queuing destination priority.
35294 +void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, uint32_t qdid,
35295 + uint32_t qd_bin, uint32_t qd_prio);
35298 + * qbman_eq_desc_set_eqdi() - enable/disable EQDI interrupt
35299 + * @d: the enqueue descriptor
35300 + * @enable: boolean to enable/disable EQDI
35302 + * Determines whether or not the portal's EQDI interrupt source should be
35303 + * asserted after the enqueue command is completed.
35305 +void qbman_eq_desc_set_eqdi(struct qbman_eq_desc *d, int enable);
35308 + * qbman_eq_desc_set_dca() - Set DCA mode in the enqueue command.
35309 + * @d: the enqueue descriptor.
35310 + * @enable: enabled/disable DCA mode.
35311 + * @dqrr_idx: DCAP_CI, the DCAP consumer index.
35312 + * @park: determine the whether park the FQ or not
35314 + * Determines whether or not a portal DQRR entry should be consumed once the
35315 + * enqueue command is completed. (And if so, and the DQRR entry corresponds to a
35316 + * held-active (order-preserving) FQ, whether the FQ should be parked instead of
35317 + * being rescheduled.)
35319 +void qbman_eq_desc_set_dca(struct qbman_eq_desc *d, int enable,
35320 + uint32_t dqrr_idx, int park);
35323 + * qbman_swp_enqueue() - Issue an enqueue command.
35324 + * @s: the software portal used for enqueue.
35325 + * @d: the enqueue descriptor.
35326 + * @fd: the frame descriptor to be enqueued.
35328 + * Please note that 'fd' should only be NULL if the "action" of the
35329 + * descriptor is "orp_hole" or "orp_nesn".
35331 + * Return 0 for a successful enqueue, -EBUSY if the EQCR is not ready.
35333 +int qbman_swp_enqueue(struct qbman_swp *s, const struct qbman_eq_desc *d,
35334 + const struct qbman_fd *fd);
35337 + * qbman_swp_enqueue_thresh() - Set threshold for EQRI interrupt.
35338 + * @s: the software portal.
35339 + * @thresh: the threshold to trigger the EQRI interrupt.
35341 + * An EQRI interrupt can be generated when the fill-level of EQCR falls below
35342 + * the 'thresh' value set here. Setting thresh==0 (the default) disables.
35344 +int qbman_swp_enqueue_thresh(struct qbman_swp *s, unsigned int thresh);
35346 + /*******************/
35347 + /* Buffer releases */
35348 + /*******************/
35350 + * struct qbman_release_desc - The structure for buffer release descriptor
35351 + * @dont_manipulate_directly: the 32bit data to represent the whole
35352 + * possible settings of qbman release descriptor.
35354 +struct qbman_release_desc {
35355 + uint32_t dont_manipulate_directly[1];
35359 + * qbman_release_desc_clear() - Clear the contents of a descriptor to
35360 + * default/starting state.
35361 + * @d: the qbman release descriptor.
35363 +void qbman_release_desc_clear(struct qbman_release_desc *d);
35366 + * qbman_release_desc_set_bpid() - Set the ID of the buffer pool to release to
35367 + * @d: the qbman release descriptor.
35369 +void qbman_release_desc_set_bpid(struct qbman_release_desc *d, uint32_t bpid);
35372 + * qbman_release_desc_set_rcdi() - Determines whether or not the portal's RCDI
35373 + * interrupt source should be asserted after the release command is completed.
35374 + * @d: the qbman release descriptor.
35376 +void qbman_release_desc_set_rcdi(struct qbman_release_desc *d, int enable);
35379 + * qbman_swp_release() - Issue a buffer release command.
35380 + * @s: the software portal object.
35381 + * @d: the release descriptor.
35382 + * @buffers: a pointer pointing to the buffer address to be released.
35383 + * @num_buffers: number of buffers to be released, must be less than 8.
35385 + * Return 0 for success, -EBUSY if the release command ring is not ready.
35387 +int qbman_swp_release(struct qbman_swp *s, const struct qbman_release_desc *d,
35388 + const uint64_t *buffers, unsigned int num_buffers);
35391 + * qbman_swp_release_thresh() - Set threshold for RCRI interrupt
35392 + * @s: the software portal.
35393 + * @thresh: the threshold.
35394 + * An RCRI interrupt can be generated when the fill-level of RCR falls below
35395 + * the 'thresh' value set here. Setting thresh==0 (the default) disables.
35397 +int qbman_swp_release_thresh(struct qbman_swp *s, unsigned int thresh);
35399 + /*******************/
35400 + /* Buffer acquires */
35401 + /*******************/
35403 + * qbman_swp_acquire() - Issue a buffer acquire command.
35404 + * @s: the software portal object.
35405 + * @bpid: the buffer pool index.
35406 + * @buffers: a pointer pointing to the acquired buffer address|es.
35407 + * @num_buffers: number of buffers to be acquired, must be less than 8.
35409 + * Return 0 for success, or negative error code if the acquire command
35412 +int qbman_swp_acquire(struct qbman_swp *s, uint32_t bpid, uint64_t *buffers,
35413 + unsigned int num_buffers);
35415 + /*****************/
35416 + /* FQ management */
35417 + /*****************/
35419 + * qbman_swp_fq_schedule() - Move the fq to the scheduled state.
35420 + * @s: the software portal object.
35421 + * @fqid: the index of frame queue to be scheduled.
35423 + * There are a couple of different ways that a FQ can end up parked state,
35424 + * This schedules it.
35426 + * Return 0 for success, or negative error code for failure.
35428 +int qbman_swp_fq_schedule(struct qbman_swp *s, uint32_t fqid);
35431 + * qbman_swp_fq_force() - Force the FQ to fully scheduled state.
35432 + * @s: the software portal object.
35433 + * @fqid: the index of frame queue to be forced.
35435 + * Force eligible will force a tentatively-scheduled FQ to be fully-scheduled
35436 + * and thus be available for selection by any channel-dequeuing behaviour (push
35437 + * or pull). If the FQ is subsequently "dequeued" from the channel and is still
35438 + * empty at the time this happens, the resulting dq_entry will have no FD.
35439 + * (qbman_result_DQ_fd() will return NULL.)
35441 + * Return 0 for success, or negative error code for failure.
35443 +int qbman_swp_fq_force(struct qbman_swp *s, uint32_t fqid);
35446 + * These functions change the FQ flow-control stuff between XON/XOFF. (The
35447 + * default is XON.) This setting doesn't affect enqueues to the FQ, just
35448 + * dequeues. XOFF FQs will remain in the tenatively-scheduled state, even when
35449 + * non-empty, meaning they won't be selected for scheduled dequeuing. If a FQ is
35450 + * changed to XOFF after it had already become truly-scheduled to a channel, and
35451 + * a pull dequeue of that channel occurs that selects that FQ for dequeuing,
35452 + * then the resulting dq_entry will have no FD. (qbman_result_DQ_fd() will
35456 + * qbman_swp_fq_xon() - XON the frame queue.
35457 + * @s: the software portal object.
35458 + * @fqid: the index of frame queue.
35460 + * Return 0 for success, or negative error code for failure.
35462 +int qbman_swp_fq_xon(struct qbman_swp *s, uint32_t fqid);
35464 + * qbman_swp_fq_xoff() - XOFF the frame queue.
35465 + * @s: the software portal object.
35466 + * @fqid: the index of frame queue.
35468 + * Return 0 for success, or negative error code for failure.
35470 +int qbman_swp_fq_xoff(struct qbman_swp *s, uint32_t fqid);
35472 + /**********************/
35473 + /* Channel management */
35474 + /**********************/
35477 + * If the user has been allocated a channel object that is going to generate
35478 + * CDANs to another channel, then these functions will be necessary.
35479 + * CDAN-enabled channels only generate a single CDAN notification, after which
35480 + * it they need to be reenabled before they'll generate another. (The idea is
35481 + * that pull dequeuing will occur in reaction to the CDAN, followed by a
35482 + * reenable step.) Each function generates a distinct command to hardware, so a
35483 + * combination function is provided if the user wishes to modify the "context"
35484 + * (which shows up in each CDAN message) each time they reenable, as a single
35485 + * command to hardware.
35489 + * qbman_swp_CDAN_set_context() - Set CDAN context
35490 + * @s: the software portal object.
35491 + * @channelid: the channel index.
35492 + * @ctx: the context to be set in CDAN.
35494 + * Return 0 for success, or negative error code for failure.
35496 +int qbman_swp_CDAN_set_context(struct qbman_swp *s, uint16_t channelid,
35500 + * qbman_swp_CDAN_enable() - Enable CDAN for the channel.
35501 + * @s: the software portal object.
35502 + * @channelid: the index of the channel to generate CDAN.
35504 + * Return 0 for success, or negative error code for failure.
35506 +int qbman_swp_CDAN_enable(struct qbman_swp *s, uint16_t channelid);
35509 + * qbman_swp_CDAN_disable() - disable CDAN for the channel.
35510 + * @s: the software portal object.
35511 + * @channelid: the index of the channel to generate CDAN.
35513 + * Return 0 for success, or negative error code for failure.
35515 +int qbman_swp_CDAN_disable(struct qbman_swp *s, uint16_t channelid);
35518 + * qbman_swp_CDAN_set_context_enable() - Set CDAN contest and enable CDAN
35519 + * @s: the software portal object.
35520 + * @channelid: the index of the channel to generate CDAN.
35521 + * @ctx: the context set in CDAN.
35523 + * Return 0 for success, or negative error code for failure.
35525 +int qbman_swp_CDAN_set_context_enable(struct qbman_swp *s, uint16_t channelid,
35527 +int qbman_swp_fill_ring(struct qbman_swp *s,
35528 + const struct qbman_eq_desc *d,
35529 + const struct qbman_fd *fd,
35530 + uint8_t burst_index);
35531 +int qbman_swp_flush_ring(struct qbman_swp *s);
35532 +void qbman_sync(void);
35533 +int qbman_swp_send_multiple(struct qbman_swp *s,
35534 + const struct qbman_eq_desc *d,
35535 + const struct qbman_fd *fd,
35536 + int frames_to_send);
35538 +int qbman_check_command_complete(struct qbman_swp *s,
35539 + const struct qbman_result *dq);
35540 +#endif /* !_FSL_QBMAN_PORTAL_H */
35541 diff --git a/drivers/net/dpaa2/rte_eth_dpaa2_pvt.h b/drivers/net/dpaa2/rte_eth_dpaa2_pvt.h
35542 new file mode 100644
35543 index 0000000..bd5d4d5
35545 +++ b/drivers/net/dpaa2/rte_eth_dpaa2_pvt.h
35550 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
35551 + * All rights reserved.
35553 + * Redistribution and use in source and binary forms, with or without
35554 + * modification, are permitted provided that the following conditions
35557 + * * Redistributions of source code must retain the above copyright
35558 + * notice, this list of conditions and the following disclaimer.
35559 + * * Redistributions in binary form must reproduce the above copyright
35560 + * notice, this list of conditions and the following disclaimer in
35561 + * the documentation and/or other materials provided with the
35563 + * * Neither the name of Freescale Semiconductor nor the names of its
35564 + * contributors may be used to endorse or promote products derived
35565 + * from this software without specific prior written permission.
35567 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35568 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35569 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35570 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35571 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35572 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35573 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35574 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35575 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35576 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35577 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35580 +#ifndef _RTE_ETH_DPAA2_PVT_H_
35581 +#define _RTE_ETH_DPAA2_PVT_H_
35583 +#include <rte_memory.h>
35584 +#include <rte_mbuf.h>
35585 +#include <rte_atomic.h>
35586 +#include <fsl_mc_sys.h>
35587 +#include <eal_vfio.h>
35588 +#include <eal_vfio_fsl_mc.h>
35589 +#include <rte_mempool.h>
35591 +typedef uint64_t dma_addr_t;
35596 +#define false FALSE
35601 +#define lower_32_bits(x) ((uint32_t)(x))
35602 +#define upper_32_bits(x) ((uint32_t)(((x) >> 16) >> 16))
35604 +#ifndef ETH_ADDR_LEN
35605 +#define ETH_ADDR_LEN 6
35607 +#ifndef ETH_VLAN_HLEN
35608 +#define ETH_VLAN_HLEN 4 /** < Vlan Header Length */
35611 +#define NUM_MAX_RECV_FRAMES 16
35613 +#define MC_PORTAL_INDEX 0
35614 +#define NUM_DPIO_REGIONS 2
35615 +#define NUM_DQS_PER_QUEUE 2
35616 +#define MC_PORTALS_BASE_PADDR 0x00080C000000ULL
35617 +#define MC_PORTAL_STRIDE 0x10000
35618 +#define MC_PORTAL_SIZE 64
35619 +#define MC_PORTAL_ID_TO_PADDR(portal_id) \
35620 +(MC_PORTALS_BASE_PADDR + (portal_id) * MC_PORTAL_STRIDE)
35622 +struct dpaa2_dpio_dev {
35623 + TAILQ_ENTRY(dpaa2_dpio_dev) next; /**< Pointer to Next device instance */
35624 + uint16_t index; /**< Index of a instance in the list */
35625 + rte_atomic16_t ref_count; /**< How many thread contexts are sharing this.*/
35626 + struct fsl_mc_io *dpio; /** handle to DPIO portal object */
35628 + struct qbman_swp *sw_portal; /** SW portal object */
35629 + const struct qbman_result *dqrr[4]; /**< DQRR Entry for this SW portal */
35630 + pthread_mutex_t lock; /** Required when Portal is shared */
35631 + void *mc_portal; /**< MC Portal for configuring this device */
35632 + uintptr_t qbman_portal_ce_paddr; /**< Physical address of Cache Enabled Area */
35633 + uintptr_t ce_size; /**< Size of the CE region */
35634 + uintptr_t qbman_portal_ci_paddr; /**< Physical address of Cache Inhibit Area */
35635 + uintptr_t ci_size; /**< Size of the CI region */
35636 + void *intr_handle;
35637 + int32_t vfio_fd; /**< File descriptor received via VFIO */
35638 + int32_t hw_id; /**< An unique ID of this DPIO device instance */
35641 +struct queue_storage_info_t {
35642 + struct qbman_result *dq_storage[NUM_DQS_PER_QUEUE];
35643 + struct qbman_result *active_dqs;
35647 +struct thread_io_info_t {
35648 + struct dpaa2_dpio_dev *dpio_dev;
35649 + struct dpaa2_dpio_dev *sec_dpio_dev;
35650 + struct qbman_result *global_active_dqs;
35653 +/*! Global per thread DPIO portal */
35654 +extern __thread struct thread_io_info_t thread_io_info;
35655 +/*! Global MCP list */
35656 +extern void *(*mcp_ptr_list);
35658 +/* Refer to Table 7-3 in SEC BG */
35659 +struct qbman_fle {
35660 + uint32_t addr_lo;
35661 + uint32_t addr_hi;
35663 + /* FMT must be 00, MSB is final bit */
35664 + uint32_t fin_bpid_offset;
35666 + uint32_t reserved[3]; /* Not used currently */
35669 +/* Maximum release/acquire from QBMAN */
35670 +#define DPAA2_MBUF_MAX_ACQ_REL 7
35672 +#define MAX_BPID 256
35674 +/*Macros to define operations on FD*/
35675 +#define DPAA2_SET_FD_ADDR(fd, addr) \
35676 + fd->simple.addr_lo = lower_32_bits((uint64_t)addr); \
35677 + fd->simple.addr_hi = upper_32_bits((uint64_t)addr);
35678 +#define DPAA2_SET_FD_LEN(fd, length) fd->simple.len = length
35679 +#define DPAA2_SET_FD_BPID(fd, bpid) fd->simple.bpid_offset |= bpid;
35680 +#define DPAA2_SET_FD_IVP(fd) ((fd->simple.bpid_offset |= 0x00004000))
35681 +#define DPAA2_SET_FD_OFFSET(fd, offset) (fd->simple.bpid_offset |= (uint32_t)(offset) << 16);
35682 +#define DPAA2_SET_FD_INTERNAL_JD(fd, len) fd->simple.frc = (0x80000000 | (len));
35683 +#define DPAA2_SET_FD_FRC(fd, frc) fd->simple.frc = frc;
35684 +#define DPAA2_RESET_FD_CTRL(fd) fd->simple.ctrl = 0;
35686 +#define DPAA2_SET_FD_ASAL(fd, asal) (fd->simple.ctrl |= (asal << 16))
35687 +#define DPAA2_SET_FD_FLC(fd, addr) \
35688 + fd->simple.flc_lo = lower_32_bits((uint64_t)addr); \
35689 + fd->simple.flc_hi = upper_32_bits((uint64_t)addr);
35690 +#define DPAA2_SET_FLE_INTERNAL_JD(fle, len) fle->frc = (0x80000000 | (len));
35691 +#define DPAA2_GET_FLE_ADDR(fle) \
35692 + (uint64_t)((((uint64_t)(fle->addr_hi)) << 32) + fle->addr_lo)
35693 +#define DPAA2_SET_FLE_ADDR(fle, addr) \
35694 + fle->addr_lo = lower_32_bits((uint64_t)addr); \
35695 + fle->addr_hi = upper_32_bits((uint64_t)addr);
35696 +#define DPAA2_SET_FLE_OFFSET(fle, offset) (fle)->fin_bpid_offset |= (uint32_t)(offset) << 16;
35697 +#define DPAA2_SET_FLE_BPID(fle, bpid) (fle)->fin_bpid_offset |= (uint64_t)bpid;
35698 +#define DPAA2_GET_FLE_BPID(fle, bpid) (fle->fin_bpid_offset & 0x000000ff)
35699 +#define DPAA2_SET_FLE_FIN(fle) fle->fin_bpid_offset |= (uint64_t)1 << 31;
35700 +#define DPAA2_SET_FLE_IVP(fle) (((fle)->fin_bpid_offset |= 0x00004000))
35701 +#define DPAA2_SET_FD_COMPOUND_FMT(fd) \
35702 + fd->simple.bpid_offset |= (uint32_t)1 << 28;
35703 +#define DPAA2_GET_FD_ADDR(fd) \
35704 + (uint64_t)((((uint64_t)(fd->simple.addr_hi)) << 32) + fd->simple.addr_lo)
35705 +#define DPAA2_GET_FD_LEN(fd) (fd->simple.len)
35706 +#define DPAA2_GET_FD_BPID(fd) ((fd->simple.bpid_offset & 0x00003FFF))
35707 +#define DPAA2_GET_FD_IVP(fd) ((fd->simple.bpid_offset & 0x00004000) >> 14)
35708 +#define DPAA2_GET_FD_OFFSET(fd) ((fd->simple.bpid_offset & 0x0FFF0000) >> 16)
35709 +#define DPAA2_GET_FD_FRC(fd) (fd->simple.frc)
35710 +#define DPAA2_GET_FD_FLC(fd) \
35711 + (uint64_t)((((uint64_t)(fd->simple.flc_hi)) << 32) + fd->simple.flc_lo)
35713 +#define DPAA2_SET_FLE_SG_EXT(fle) fle->fin_bpid_offset |= (uint64_t)1 << 29;
35714 +#define DPAA2_IS_SET_FLE_SG_EXT(fle) \
35715 + (fle->fin_bpid_offset & ((uint64_t)1 << 29)) ? 1 : 0
35717 +#define DPAA2_INLINE_MBUF_FROM_BUF(buf, meta_data_size) \
35718 + ((struct rte_mbuf *)((uint64_t)buf - meta_data_size))
35719 +#define DPAA2_BUF_FROM_INLINE_MBUF(mbuf, meta_data_size) \
35720 + ((uint8_t *)((uint64_t)mbuf + meta_data_size))
35722 +#define DPAA2_ASAL_VAL (DPAA2_MBUF_HW_ANNOTATION / 64)
35724 +/*Macros to define QBMAN enqueue options */
35725 +#define DPAA2_ETH_EQ_DISABLE 0 /*!< Dont Enqueue the Frame */
35726 +#define DPAA2_ETH_EQ_RESP_ON_SUCC 1 /*!< Enqueue the Frame with
35727 + response after success*/
35728 +#define DPAA2_ETH_EQ_RESP_ON_FAIL 2 /*!< Enqueue the Frame with
35729 + response after failure*/
35730 +#define DPAA2_ETH_EQ_NO_RESP 3 /*!< Enqueue the Frame without
35732 +/* Only Enqueue Error responses will be
35733 + * pushed on FQID_ERR of Enqueue FQ */
35734 +#define DPAA2_EQ_RESP_ERR_FQ 0
35735 +/* All Enqueue responses will be pushed on address
35736 + * set with qbman_eq_desc_set_response */
35737 +#define DPAA2_EQ_RESP_ALWAYS 1
35739 +#define DPAA2_MAX_BUF_POOLS 8
35741 +struct dpbp_node {
35742 + struct dpbp_node *next;
35743 + struct fsl_mc_io dpbp;
35748 +struct buf_pool_cfg {
35749 + void *addr; /*!< The address from where DPAA2 will carve out the
35750 + * buffers. 'addr' should be 'NULL' if user wants
35751 + * to create buffers from the memory which user
35752 + * asked DPAA2 to reserve during 'nadk init' */
35753 + phys_addr_t phys_addr; /*!< corresponding physical address
35754 + * of the memory provided in addr */
35755 + uint32_t num; /*!< number of buffers */
35756 + uint32_t size; /*!< size of each buffer. 'size' should include
35757 + * any headroom to be reserved and alignment */
35758 + uint16_t align; /*!< Buffer alignment (in bytes) */
35759 + uint16_t bpid; /*!< The buffer pool id. This will be filled
35760 + *in by DPAA2 for each buffer pool */
35765 + uint32_t num_bufs;
35767 + uint8_t *h_bpool_mem;
35768 + struct rte_mempool *mp;
35769 + struct dpbp_node *dpbp_node;
35773 + * Buffer pool list configuration structure. User need to give DPAA2 the
35774 + * valid number of 'num_buf_pools'.
35776 +struct dpaa2_bp_list_cfg {
35777 + struct buf_pool_cfg buf_pool; /* Configuration
35778 + * of each buffer pool */
35781 +struct dpaa2_bp_list {
35782 + struct dpaa2_bp_list *next;
35783 + struct rte_mempool *mp;
35784 + struct buf_pool buf_pool;
35788 + uint32_t meta_data_size;
35790 + struct dpaa2_bp_list *bp_list;
35793 +#define mempool_to_bpinfo(mp) ((struct bp_info *)mp->pool_data)
35794 +#define mempool_to_bpid(mp) ((mempool_to_bpinfo(mp))->bpid)
35796 +extern struct dpaa2_bp_list *h_bp_list;
35798 +/* todo - this is costly, need to write a fast coversion routine */
35799 +static void *dpaa2_mem_ptov(phys_addr_t paddr)
35801 + const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
35804 + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) {
35805 + if (paddr >= memseg[i].phys_addr &&
35806 + (char *)paddr < (char *)memseg[i].phys_addr + memseg[i].len)
35807 + return (void *)(memseg[i].addr_64 + (paddr - memseg[i].phys_addr));
35812 +static phys_addr_t dpaa2_mem_vtop(uint64_t vaddr)
35814 + const struct rte_memseg *memseg = rte_eal_get_physmem_layout();
35817 + for (i = 0; i < RTE_MAX_MEMSEG && memseg[i].addr_64 != 0; i++) {
35818 + if (vaddr >= memseg[i].addr_64 &&
35819 + vaddr < memseg[i].addr_64 + memseg[i].len)
35820 + return memseg[i].phys_addr + (vaddr - memseg[i].addr_64);
35822 + return (phys_addr_t)(NULL);
35825 +#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
35827 + * When we are using Physical addresses as IO Virtual Addresses,
35828 + * we call conversion routines nadk_mem_vtop & nadk_mem_ptov wherever required.
35829 + * These routines are called with help of below MACRO's
35832 +#define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) (mbuf->buf_physaddr)
35833 +#define DPAA2_OP_VADDR_TO_IOVA(op) (op->phys_addr)
35836 + * macro to convert Virtual address to IOVA
35838 +#define DPAA2_VADDR_TO_IOVA(_vaddr) dpaa2_mem_vtop((uint64_t)(_vaddr))
35841 + * macro to convert IOVA to Virtual address
35843 +#define DPAA2_IOVA_TO_VADDR(_iova) dpaa2_mem_ptov((phys_addr_t)(_iova))
35846 + * macro to convert modify the memory containing Virtual address to IOVA
35848 +#define DPAA2_MODIFY_VADDR_TO_IOVA(_mem, _type) \
35849 + {_mem = (_type)(dpaa2_mem_vtop((uint64_t)(_mem))); }
35852 + * macro to convert modify the memory containing IOVA to Virtual address
35854 +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type) \
35855 + {_mem = (_type)(dpaa2_mem_ptov((phys_addr_t)(_mem))); }
35858 +#define DPAA2_MBUF_VADDR_TO_IOVA(mbuf) (mbuf->buf_addr)
35859 +#define DPAA2_OP_VADDR_TO_IOVA(op) (op)
35861 +#define DPAA2_VADDR_TO_IOVA(_vaddr) (_vaddr)
35862 +#define DPAA2_IOVA_TO_VADDR(_iova) (_iova)
35863 +#define DPAA2_MODIFY_VADDR_TO_IOVA(_mem, _type)
35864 +#define DPAA2_MODIFY_IOVA_TO_VADDR(_mem, _type)
35867 +/* Function definitions for Mempool operations */
35868 +int hw_mbuf_init(struct rte_mempool *mp, void *_m);
35869 +int hw_mbuf_free_bulk(struct rte_mempool *pool, void * const *obj_table,
35871 +int hw_mbuf_alloc_bulk(struct rte_mempool *pool, void **obj_table,
35873 +int hw_mbuf_create_pool(struct rte_mempool *mp);
35874 +unsigned hw_mbuf_get_count(const struct rte_mempool *mp);
35877 diff --git a/drivers/net/dpaa2/rte_eth_dpbp.c b/drivers/net/dpaa2/rte_eth_dpbp.c
35878 new file mode 100644
35879 index 0000000..a4d29c9
35881 +++ b/drivers/net/dpaa2/rte_eth_dpbp.c
35886 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
35887 + * All rights reserved.
35889 + * Redistribution and use in source and binary forms, with or without
35890 + * modification, are permitted provided that the following conditions
35893 + * * Redistributions of source code must retain the above copyright
35894 + * notice, this list of conditions and the following disclaimer.
35895 + * * Redistributions in binary form must reproduce the above copyright
35896 + * notice, this list of conditions and the following disclaimer in
35897 + * the documentation and/or other materials provided with the
35899 + * * Neither the name of Freescale Semiconductor nor the names of its
35900 + * contributors may be used to endorse or promote products derived
35901 + * from this software without specific prior written permission.
35903 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
35904 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
35905 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
35906 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35907 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35908 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
35909 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
35910 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35911 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35912 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35913 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35916 +#include <unistd.h>
35917 +#include <stdio.h>
35918 +#include <sys/types.h>
35919 +#include <string.h>
35920 +#include <stdlib.h>
35921 +#include <fcntl.h>
35922 +#include <errno.h>
35923 +#include <sys/ioctl.h>
35924 +#include <sys/stat.h>
35925 +#include <sys/types.h>
35926 +#include <sys/mman.h>
35927 +#include <sys/vfs.h>
35928 +#include <libgen.h>
35929 +#include <rte_mbuf.h>
35931 +#include "rte_pci.h"
35932 +#include "rte_memzone.h"
35934 +#include "rte_eth_dpaa2_pvt.h"
35935 +#include "fsl_qbman_portal.h"
35936 +#include <fsl_dpbp.h>
35938 +#include <rte_log.h>
35939 +#include "dpaa2_logs.h"
35941 +static struct dpbp_node *g_dpbp_list;
35942 +static struct dpbp_node *avail_dpbp;
35944 +struct bp_info bpid_info[MAX_BPID];
35946 +struct dpaa2_bp_list *h_bp_list;
35949 +dpaa2_create_dpbp_device(
35952 + struct dpbp_node *dpbp_node;
35955 + /* Allocate DPAA2 dpbp handle */
35956 + dpbp_node = (struct dpbp_node *)malloc(sizeof(struct dpbp_node));
35957 + if (!dpbp_node) {
35958 + PMD_DRV_LOG(ERR, "Memory allocation failed for DPBP Device\n");
35962 + /* Open the dpbp object */
35963 + dpbp_node->dpbp.regs = mcp_ptr_list[MC_PORTAL_INDEX];
35964 + ret = dpbp_open(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_id, &dpbp_node->token);
35966 + PMD_DRV_LOG(ERR, "Resource allocation failure with err code: %d",
35972 + /* Clean the device first */
35973 + ret = dpbp_reset(&dpbp_node->dpbp, CMD_PRI_LOW, dpbp_node->token);
35975 + PMD_DRV_LOG(ERR, "Failure cleaning dpbp device with"
35976 + "error code %d\n", ret);
35980 + dpbp_node->dpbp_id = dpbp_id;
35981 + /* Add the dpbp handle into the global list */
35982 + dpbp_node->next = g_dpbp_list;
35983 + g_dpbp_list = dpbp_node;
35984 + avail_dpbp = g_dpbp_list;
35986 + PMD_DRV_LOG(INFO, "Buffer resource initialized");
35991 +int hw_mbuf_create_pool(struct rte_mempool *mp)
35993 + struct dpaa2_bp_list *bp_list;
35994 + struct dpbp_attr dpbp_attr;
35998 + if (!avail_dpbp) {
35999 + PMD_DRV_LOG(ERR, "DPAA2 resources not available\n");
36003 + ret = dpbp_enable(&avail_dpbp->dpbp, CMD_PRI_LOW, avail_dpbp->token);
36005 + PMD_DRV_LOG(ERR, "Resource enable failure with"
36006 + "err code: %d\n", ret);
36010 + ret = dpbp_get_attributes(&avail_dpbp->dpbp, CMD_PRI_LOW,
36011 + avail_dpbp->token, &dpbp_attr);
36013 + PMD_DRV_LOG(ERR, "Resource read failure with"
36014 + "err code: %d\n", ret);
36015 + ret = dpbp_disable(&avail_dpbp->dpbp, CMD_PRI_LOW,
36016 + avail_dpbp->token);
36020 + /* Allocate the bp_list which will be added into global_bp_list */
36021 + bp_list = (struct dpaa2_bp_list *)malloc(sizeof(struct dpaa2_bp_list));
36023 + PMD_DRV_LOG(ERR, "No heap memory available\n");
36027 + /* Set parameters of buffer pool list */
36028 + bp_list->buf_pool.num_bufs = mp->size;
36029 + bp_list->buf_pool.size = mp->elt_size
36030 + - sizeof(struct rte_mbuf) - rte_pktmbuf_priv_size(mp);
36031 + bp_list->buf_pool.bpid = dpbp_attr.bpid;
36032 + bp_list->buf_pool.h_bpool_mem = NULL;
36033 + bp_list->buf_pool.mp = mp;
36034 + bp_list->buf_pool.dpbp_node = avail_dpbp;
36035 + bp_list->next = h_bp_list;
36037 + bpid = dpbp_attr.bpid;
36039 + /* Increment the available DPBP */
36040 + avail_dpbp = avail_dpbp->next;
36042 + bpid_info[bpid].meta_data_size = sizeof(struct rte_mbuf)
36043 + + rte_pktmbuf_priv_size(mp);
36044 + bpid_info[bpid].bp_list = bp_list;
36045 + bpid_info[bpid].bpid = bpid;
36047 + mp->pool_data = (void *)&bpid_info[bpid];
36049 + PMD_DRV_LOG(INFO, "BP List created for bpid =%d\n", dpbp_attr.bpid);
36051 + h_bp_list = bp_list;
36052 + /* TODO: Replace with mp->pool_data->flags after creating appropriate
36053 + * pool_data structure
36055 + mp->flags |= MEMPOOL_F_HW_PKT_POOL;
36059 +void hw_mbuf_free_pool(struct rte_mempool *mp __rte_unused)
36062 + * 1. Release bp_list memory allocation
36063 + * 2. opposite of dpbp_enable()
36066 + struct dpaa2_bp_list *bp;
36068 + /* Iterate over h_bp_list linked list and release each element */
36069 + while (h_bp_list) {
36071 + h_bp_list = bp->next;
36073 + /* TODO: Should be changed to rte_free */
36077 + PMD_DRV_LOG(DEBUG, "(%s) called\n", __func__);
36081 +static inline void dpaa2_mbuf_release(uint64_t buf, uint32_t bpid)
36083 + struct qbman_release_desc releasedesc;
36084 + struct qbman_swp *swp;
36087 + if (!thread_io_info.dpio_dev) {
36088 + ret = dpaa2_affine_qbman_swp();
36090 + PMD_DRV_LOG(ERR, "Failed to allocate IO portal");
36094 + swp = thread_io_info.dpio_dev->sw_portal;
36096 + /* Create a release descriptor required for releasing
36097 + * buffers into BMAN */
36098 + qbman_release_desc_clear(&releasedesc);
36099 + qbman_release_desc_set_bpid(&releasedesc, bpid);
36102 + /* Release buffer into the BMAN */
36103 + ret = qbman_swp_release(swp, &releasedesc, &buf, 1);
36104 + } while (ret == -EBUSY);
36105 + PMD_TX_FREE_LOG(DEBUG, "Released %p address to BMAN\n", buf);
36108 +int hw_mbuf_alloc_bulk(struct rte_mempool *pool,
36109 + void **obj_table, unsigned count)
36111 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_DRIVER
36112 + static int alloc;
36114 + struct qbman_swp *swp;
36115 + uint32_t mbuf_size;
36117 + uint64_t bufs[RTE_MEMPOOL_CACHE_MAX_SIZE + 1];
36119 + unsigned i, n = 0;
36120 + struct bp_info *bp_info;
36122 + PMD_DRV_LOG_RAW(INFO, "%s/n", __func__);
36123 + bp_info = mempool_to_bpinfo(pool);
36125 + if (!(bp_info->bp_list)) {
36126 + printf("\nDPAA2 buffer pool not configured\n");
36130 + bpid = bp_info->bpid;
36132 + if (!thread_io_info.dpio_dev) {
36133 + ret = dpaa2_affine_qbman_swp();
36135 + PMD_DRV_LOG(ERR, "Failed to allocate IO portal");
36139 + swp = thread_io_info.dpio_dev->sw_portal;
36141 + /* if number of buffers requested is less than 7 */
36142 + if (count < DPAA2_MBUF_MAX_ACQ_REL) {
36143 + ret = qbman_swp_acquire(swp, bpid, &bufs[n], count);
36145 + PMD_DRV_LOG(ERR, "Failed to allocate buffers %d", ret);
36152 + while (n < count) {
36154 + /* Acquire is all-or-nothing, so we drain in 7s,
36155 + * then the remainder.
36157 + if ((count - n) > DPAA2_MBUF_MAX_ACQ_REL) {
36158 + ret = qbman_swp_acquire(swp, bpid, &bufs[n],
36159 + DPAA2_MBUF_MAX_ACQ_REL);
36160 + if (ret == DPAA2_MBUF_MAX_ACQ_REL) {
36164 + ret = qbman_swp_acquire(swp, bpid, &bufs[n], count - n);
36166 + PMD_DRV_LOG(DEBUG, "Drained buffer: %x",
36171 + /* In case of less than requested number of buffers available
36172 + * in pool, qbman_swp_acquire returns 0
36175 + PMD_DRV_LOG(WARNING, "Buffer aquire failed with"
36176 + "err code: %d", ret);
36181 + /* This function either returns expected buffers or error */
36182 + if (count != n) {
36184 + /* Releasing all buffers allocated */
36186 + dpaa2_mbuf_release(bufs[i], bpid);
36192 + if (ret < 0 || n == 0) {
36193 + PMD_DRV_LOG_RAW(ERR, "Failed to allocate buffers %d", ret);
36198 + mbuf_size = sizeof(struct rte_mbuf) + rte_pktmbuf_priv_size(pool);
36200 + for (i = 0; i < n; i++) {
36201 + DPAA2_MODIFY_IOVA_TO_VADDR(bufs[i], uint64_t);
36202 + obj_table[i] = (struct rte_mbuf *)(bufs[i] - mbuf_size);
36203 + PMD_DRV_LOG(DEBUG, "Acquired %p address %p from BMAN\n",
36204 + (void *)bufs[i], (void *)obj_table[i]);
36207 +#ifdef RTE_LIBRTE_DPAA2_DEBUG_DRIVER
36209 + PMD_DRV_LOG_RAW(INFO, "Total = %d , req = %d done = %d",
36210 + alloc, count, n);
36215 +int hw_mbuf_free_bulk(struct rte_mempool *pool, void * const *obj_table,
36219 + struct bp_info *bp_info;
36221 + PMD_DRV_LOG_RAW(INFO, "%s/n", __func__);
36223 + bp_info = mempool_to_bpinfo(pool);
36224 + if (!(bp_info->bp_list)) {
36225 + PMD_DRV_LOG(INFO, "DPAA2 buffer pool not configured\n");
36228 + /* TODO - optimize it */
36229 + for (i = 0; i < n; i++) {
36230 +#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
36231 + dpaa2_mbuf_release(
36232 + (uint64_t)rte_mempool_virt2phy(pool, obj_table[i])
36233 + + bp_info->meta_data_size, bp_info->bpid);
36235 + dpaa2_mbuf_release((uint64_t)obj_table[i]
36236 + + bp_info->meta_data_size, bp_info->bpid);
36244 +unsigned hw_mbuf_get_count(const struct rte_mempool *mp __rte_unused)
36246 + /* TODO: incomplete */
36250 +struct rte_mempool_ops dpaa2_mpool_ops = {
36252 + .alloc = hw_mbuf_create_pool,
36253 + .free = hw_mbuf_free_pool,
36254 + .enqueue = hw_mbuf_free_bulk,
36255 + .dequeue = hw_mbuf_alloc_bulk,
36256 + .get_count = hw_mbuf_get_count,
36259 +MEMPOOL_REGISTER_OPS(dpaa2_mpool_ops);
36260 diff --git a/drivers/net/dpaa2/rte_eth_dpio.c b/drivers/net/dpaa2/rte_eth_dpio.c
36261 new file mode 100644
36262 index 0000000..2d06923
36264 +++ b/drivers/net/dpaa2/rte_eth_dpio.c
36269 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
36270 + * All rights reserved.
36272 + * Redistribution and use in source and binary forms, with or without
36273 + * modification, are permitted provided that the following conditions
36276 + * * Redistributions of source code must retain the above copyright
36277 + * notice, this list of conditions and the following disclaimer.
36278 + * * Redistributions in binary form must reproduce the above copyright
36279 + * notice, this list of conditions and the following disclaimer in
36280 + * the documentation and/or other materials provided with the
36282 + * * Neither the name of Freescale Semiconductor nor the names of its
36283 + * contributors may be used to endorse or promote products derived
36284 + * from this software without specific prior written permission.
36286 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36287 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36288 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
36289 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36290 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36291 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36292 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36293 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36294 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36295 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36296 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36299 +#include <unistd.h>
36300 +#include <stdio.h>
36301 +#include <sys/types.h>
36302 +#include <string.h>
36303 +#include <stdlib.h>
36304 +#include <fcntl.h>
36305 +#include <errno.h>
36306 +#include <sys/ioctl.h>
36307 +#include <sys/stat.h>
36308 +#include <sys/types.h>
36309 +#include <sys/mman.h>
36310 +#include <sys/vfs.h>
36311 +#include <libgen.h>
36313 +#include "rte_pci.h"
36314 +#include "rte_memzone.h"
36315 +#include <rte_malloc.h>
36317 +#include "rte_eth_dpaa2_pvt.h"
36318 +#include "fsl_qbman_portal.h"
36319 +#include <fsl_dpio.h>
36321 +#include <rte_log.h>
36322 +#include "dpaa2_logs.h"
36324 +#define NUM_HOST_CPUS RTE_MAX_LCORE
36326 +__thread struct thread_io_info_t thread_io_info;
36328 +TAILQ_HEAD(dpio_device_list, dpaa2_dpio_dev);
36329 +static struct dpio_device_list *dpio_dev_list; /*!< DPIO device list */
36330 +static uint32_t io_space_count;
36332 +/*Stashing Macros*/
36333 +#define DPAA2_CORE_CLUSTER_BASE 0x04
36334 +#define DPAA2_CORE_CLUSTER_FIRST (DPAA2_CORE_CLUSTER_BASE + 0)
36335 +#define DPAA2_CORE_CLUSTER_SECOND (DPAA2_CORE_CLUSTER_BASE + 1)
36336 +#define DPAA2_CORE_CLUSTER_THIRD (DPAA2_CORE_CLUSTER_BASE + 2)
36337 +#define DPAA2_CORE_CLUSTER_FOURTH (DPAA2_CORE_CLUSTER_BASE + 3)
36339 +#define DPAA2_CORE_CLUSTER_GET(sdest, cpu_id) \
36341 + if (cpu_id == 0 || cpu_id == 1) \
36342 + sdest = DPAA2_CORE_CLUSTER_FIRST; \
36343 + else if (cpu_id == 2 || cpu_id == 3) \
36344 + sdest = DPAA2_CORE_CLUSTER_SECOND; \
36345 + else if (cpu_id == 4 || cpu_id == 5) \
36346 + sdest = DPAA2_CORE_CLUSTER_THIRD; \
36348 + sdest = DPAA2_CORE_CLUSTER_FOURTH; \
36352 +configure_dpio_qbman_swp(struct dpaa2_dpio_dev *dpio_dev)
36354 + struct qbman_swp_desc p_des;
36355 + struct dpio_attr attr;
36357 + dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
36358 + if (!dpio_dev->dpio) {
36359 + PMD_DRV_LOG(ERR, "Memory allocation failure\n");
36363 + PMD_DRV_LOG(INFO, "\t Alocated DPIO[%p]", dpio_dev->dpio);
36364 + dpio_dev->dpio->regs = dpio_dev->mc_portal;
36365 + if (dpio_open(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->hw_id,
36366 + &dpio_dev->token)) {
36367 + PMD_DRV_LOG(ERR, "Failed to allocate IO space\n");
36368 + free(dpio_dev->dpio);
36372 + if (dpio_reset(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
36373 + PMD_DRV_LOG(ERR, "Failed to reset dpio\n");
36374 + dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
36375 + free(dpio_dev->dpio);
36379 + if (dpio_enable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token)) {
36380 + PMD_DRV_LOG(ERR, "Failed to Enable dpio\n");
36381 + dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
36382 + free(dpio_dev->dpio);
36386 + if (dpio_get_attributes(dpio_dev->dpio, CMD_PRI_LOW,
36387 + dpio_dev->token, &attr)) {
36388 + PMD_DRV_LOG(ERR, "DPIO Get attribute failed\n");
36389 + dpio_disable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
36390 + dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
36391 + free(dpio_dev->dpio);
36395 + PMD_DRV_LOG(INFO, "Qbman Portal ID %d", attr.qbman_portal_id);
36396 + PMD_DRV_LOG(INFO, "Portal CE addr 0x%lX", attr.qbman_portal_ce_offset);
36397 + PMD_DRV_LOG(INFO, "Portal CI addr 0x%lX", attr.qbman_portal_ci_offset);
36399 + /* Configure & setup SW portal */
36400 + p_des.block = NULL;
36401 + p_des.idx = attr.qbman_portal_id;
36402 + p_des.cena_bar = (void *)(dpio_dev->qbman_portal_ce_paddr);
36403 + p_des.cinh_bar = (void *)(dpio_dev->qbman_portal_ci_paddr);
36405 + p_des.qman_version = attr.qbman_version;
36407 + PMD_DRV_LOG(INFO, "Portal CE addr 0x%p", p_des.cena_bar);
36408 + PMD_DRV_LOG(INFO, "Portal CI addr 0x%p", p_des.cinh_bar);
36410 + dpio_dev->sw_portal = qbman_swp_init(&p_des);
36411 + if (dpio_dev->sw_portal == NULL) {
36412 + PMD_DRV_LOG(ERR, " QBMan SW Portal Init failed\n");
36413 + dpio_close(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
36414 + free(dpio_dev->dpio);
36418 + PMD_DRV_LOG(INFO, "QBMan SW Portal 0x%p\n", dpio_dev->sw_portal);
36423 +int dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev)
36428 + /* Set the Stashing Destination */
36429 + cpu_id = rte_lcore_id();
36430 + if (cpu_id < 0) {
36431 + cpu_id = rte_get_master_lcore();
36432 + if (cpu_id < 0) {
36433 + PMD_DRV_LOG(ERR, "\tGetting CPU Index failed\n");
36439 + * In case of running DPDK on the Virtual Machine the Stashing
36440 + * Destination gets set in the H/W w.r.t. the Virtual CPU ID's.
36441 + * As a W.A. environment variable HOST_START_CPU tells which
36442 + * the offset of the host start core of the Virtual Machine threads.
36444 + if (getenv("HOST_START_CPU")) {
36446 + atoi(getenv("HOST_START_CPU"));
36447 + cpu_id = cpu_id % NUM_HOST_CPUS;
36450 + /* Set the STASH Destination depending on Current CPU ID.
36451 + Valid values of SDEST are 4,5,6,7. Where,
36452 + CPU 0-1 will have SDEST 4
36453 + CPU 2-3 will have SDEST 5.....and so on.
36455 + DPAA2_CORE_CLUSTER_GET(sdest, cpu_id);
36456 + PMD_DRV_LOG(INFO, "Portal= %d CPU= %u SDEST= %d\n",
36457 + dpio_dev->index, cpu_id, sdest);
36459 + ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
36460 + dpio_dev->token, sdest);
36462 + PMD_DRV_LOG(ERR, "%d ERROR in SDEST\n", ret);
36469 +static inline struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(void)
36471 + struct dpaa2_dpio_dev *dpio_dev = NULL;
36474 + /* Get DPIO dev handle from list using index */
36475 + TAILQ_FOREACH(dpio_dev, dpio_dev_list, next) {
36476 + if (dpio_dev && rte_atomic16_test_and_set(&dpio_dev->ref_count))
36482 + ret = dpaa2_configure_stashing(dpio_dev);
36484 + RTE_LOG(ERR, EAL, "dpaa2_configure_stashing failed");
36489 +dpaa2_affine_qbman_swp(void)
36491 + if (thread_io_info.dpio_dev)
36494 + /* Populate the thread_io_info structure */
36495 + thread_io_info.dpio_dev = dpaa2_get_qbman_swp();
36496 + if (thread_io_info.dpio_dev)
36503 +dpaa2_affine_qbman_swp_sec(void)
36505 + if (thread_io_info.sec_dpio_dev)
36508 + /* Populate the thread_io_info structure */
36509 + thread_io_info.sec_dpio_dev = dpaa2_get_qbman_swp();
36510 + if (thread_io_info.sec_dpio_dev)
36517 +dpaa2_create_dpio_device(struct fsl_vfio_device *vdev,
36518 + struct vfio_device_info *obj_info,
36521 + struct dpaa2_dpio_dev *dpio_dev;
36522 + struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
36524 + if (obj_info->num_regions < NUM_DPIO_REGIONS) {
36525 + PMD_DRV_LOG(ERR, "ERROR, Not sufficient number "
36526 + "of DPIO regions.\n");
36530 + if (!dpio_dev_list) {
36531 + dpio_dev_list = malloc(sizeof(struct dpio_device_list));
36532 + if (NULL == dpio_dev_list) {
36533 + PMD_DRV_LOG(ERR, "Memory allocation failed for DPIO list\n");
36537 + /* Initialize the DPIO List */
36538 + TAILQ_INIT(dpio_dev_list);
36541 + dpio_dev = malloc(sizeof(struct dpaa2_dpio_dev));
36543 + PMD_DRV_LOG(ERR, "Memory allocation failed for DPIO Device\n");
36547 + PMD_DRV_LOG(INFO, "\t Aloocated DPIO [%p]", dpio_dev);
36548 + dpio_dev->dpio = NULL;
36549 + dpio_dev->hw_id = object_id;
36550 + dpio_dev->vfio_fd = vdev->fd;
36551 + rte_atomic16_init(&dpio_dev->ref_count);
36552 + /* Using single portal for all devices */
36553 + dpio_dev->mc_portal = mcp_ptr_list[MC_PORTAL_INDEX];
36555 + reg_info.index = 0;
36556 + if (ioctl(dpio_dev->vfio_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
36557 + printf("vfio: error getting region info\n");
36561 + PMD_DRV_LOG(INFO, "\t Region Offset = %llx", reg_info.offset);
36562 + PMD_DRV_LOG(INFO, "\t Region Size = %llx", reg_info.size);
36563 + dpio_dev->ce_size = reg_info.size;
36564 + dpio_dev->qbman_portal_ce_paddr = (uint64_t)mmap(NULL, reg_info.size,
36565 + PROT_WRITE | PROT_READ, MAP_SHARED,
36566 + dpio_dev->vfio_fd, reg_info.offset);
36568 + /* Create Mapping for QBMan Cache Enabled area. This is a fix for
36569 + SMMU fault for DQRR statshing transaction. */
36570 + if (vfio_dmamap_mem_region(dpio_dev->qbman_portal_ce_paddr,
36571 + reg_info.offset, reg_info.size)) {
36572 + PMD_DRV_LOG(ERR, "DMAMAP for Portal CE area failed.\n");
36576 + reg_info.index = 1;
36577 + if (ioctl(dpio_dev->vfio_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info)) {
36578 + printf("vfio: error getting region info\n");
36582 + PMD_DRV_LOG(INFO, "\t Region Offset = %llx", reg_info.offset);
36583 + PMD_DRV_LOG(INFO, "\t Region Size = %llx", reg_info.size);
36584 + dpio_dev->ci_size = reg_info.size;
36585 + dpio_dev->qbman_portal_ci_paddr = (uint64_t)mmap(NULL, reg_info.size,
36586 + PROT_WRITE | PROT_READ, MAP_SHARED,
36587 + dpio_dev->vfio_fd, reg_info.offset);
36589 + if (configure_dpio_qbman_swp(dpio_dev)) {
36591 + "Failed in configuring the qbman portal for dpio %d\n",
36592 + dpio_dev->hw_id);
36596 + io_space_count++;
36597 + dpio_dev->index = io_space_count;
36598 + TAILQ_INSERT_HEAD(dpio_dev_list, dpio_dev, next);
36602 diff --git a/drivers/net/dpaa2/rte_eth_dpni.c b/drivers/net/dpaa2/rte_eth_dpni.c
36603 new file mode 100644
36604 index 0000000..c1587dc
36606 +++ b/drivers/net/dpaa2/rte_eth_dpni.c
36611 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
36613 + * Redistribution and use in source and binary forms, with or without
36614 + * modification, are permitted provided that the following conditions
36617 + * * Redistributions of source code must retain the above copyright
36618 + * notice, this list of conditions and the following disclaimer.
36619 + * * Redistributions in binary form must reproduce the above copyright
36620 + * notice, this list of conditions and the following disclaimer in
36621 + * the documentation and/or other materials provided with the
36623 + * * Neither the name of Freescale Semiconductor, Inc nor the names of its
36624 + * contributors may be used to endorse or promote products derived
36625 + * from this software without specific prior written permission.
36627 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
36628 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
36629 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
36630 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36631 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
36632 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36633 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
36634 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
36635 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36636 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36637 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36641 +#include <rte_mbuf.h>
36642 +#include <rte_ethdev.h>
36643 +#include <rte_malloc.h>
36644 +#include <rte_memcpy.h>
36645 +#include <rte_string_fns.h>
36646 +#include <rte_cycles.h>
36647 +#include <rte_kvargs.h>
36648 +#include <rte_dev.h>
36650 +#include <net/if.h>
36651 +/* MC header files */
36652 +#include <fsl_dpbp.h>
36653 +#include <fsl_dpni.h>
36654 +#include "rte_eth_dpaa2_pvt.h"
36655 +#include "rte_eth_dpni_annot.h"
36656 +#include "dpaa2_logs.h"
36658 +#include <fsl_qbman_portal.h>
36659 +#include <fsl_dpio.h>
36661 +#define DPAA2_STASHING
36663 +/* tx fd send batching */
36664 +#define QBMAN_MULTI_TX
36665 +/* #define DPAA2_CGR_SUPPORT */
36668 +#define DPAA2_MIN_RX_BUF_SIZE 512
36669 +#define DPAA2_MAX_RX_PKT_LEN 10240 /*WRIOP support*/
36671 +#define RTE_ETH_DPAA2_SNAPSHOT_LEN 65535
36672 +#define RTE_ETH_DPAA2_SNAPLEN 4096
36673 +#define RTE_ETH_DPAA2_PROMISC 1
36674 +#define RTE_ETH_DPAA2_TIMEOUT -1
36675 +#define ETH_DPAA2_RX_IFACE_ARG "rx_iface"
36676 +#define ETH_DPAA2_TX_IFACE_ARG "tx_iface"
36677 +#define ETH_DPAA2_IFACE_ARG "iface"
36679 +static const char *drivername = "DPNI PMD";
36681 +#define MAX_TCS DPNI_MAX_TC
36682 +#define MAX_RX_QUEUES 64
36683 +#define MAX_TX_QUEUES 64
36685 +/*Maximum number of slots available in TX ring*/
36686 +#define MAX_SLOTS 8
36688 +/*Threshold for a queue to *Enter* Congestion state.
36689 + It is set to 128 frames of size 64 bytes.*/
36690 +#define CONG_ENTER_THRESHOLD (128 * 64)
36692 +/*Threshold for a queue to *Exit* Congestion state.
36693 + It is set to 98 frames of size 64 bytes*/
36694 +#define CONG_EXIT_THRESHOLD (98 * 64)
36696 +/*! Maximum number of flow distributions per traffic class */
36697 +#define MAX_DIST_PER_TC 16
36699 +/* Size of the input SMMU mapped memory required by MC */
36700 +#define DIST_PARAM_IOVA_SIZE 256
36702 +struct dpaa2_queue {
36704 + int32_t eventfd; /*!< Event Fd of this queue */
36705 + uint32_t fqid; /*!< Unique ID of this queue */
36706 + uint8_t tc_index; /*!< traffic class identifier */
36707 + uint16_t flow_id; /*!< To be used by DPAA2 frmework */
36708 + uint64_t rx_pkts;
36709 + uint64_t tx_pkts;
36710 + uint64_t err_pkts;
36712 + struct queue_storage_info_t *q_storage;
36713 + struct qbman_result *cscn;
36717 +struct dpaa2_dev_priv {
36722 + uint8_t nb_tx_queues;
36723 + uint8_t nb_rx_queues;
36724 + void *rx_vq[MAX_RX_QUEUES];
36725 + void *tx_vq[MAX_TX_QUEUES];
36727 + struct dpaa2_bp_list *bp_list; /**<Attached buffer pool list */
36728 + uint16_t num_dist_per_tc[MAX_TCS];
36730 + uint8_t max_unicast_filters;
36731 + uint8_t max_multicast_filters;
36732 + uint8_t max_vlan_filters;
36734 + uint32_t options;
36737 +static struct rte_pci_id pci_id_dpaa2_map[] = {
36738 + {RTE_PCI_DEVICE(FSL_VENDOR_ID, FSL_MC_DPNI_DEVID)},
36741 +extern struct bp_info bpid_info[MAX_BPID];
36743 +static void dpaa2_print_stats(struct rte_eth_dev *dev)
36745 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
36746 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
36749 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_ING_FRAME, &value);
36750 + printf("Rx packets: %ld\n", value);
36751 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_ING_BYTE, &value);
36752 + printf("Rx bytes: %ld\n", value);
36753 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_ING_MCAST_FRAME, &value);
36754 + printf("Rx Multicast: %ld\n", value);
36755 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_ING_FRAME_DROP, &value);
36756 + printf("Rx dropped: %ld\n", value);
36757 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_ING_FRAME_DISCARD, &value);
36758 + printf("Rx discarded: %ld\n", value);
36759 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_EGR_FRAME, &value);
36760 + printf("Tx packets: %ld\n", value);
36761 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_EGR_BYTE, &value);
36762 + printf("Tx bytes: %ld\n", value);
36763 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token, DPNI_CNT_EGR_FRAME_DISCARD, &value);
36764 + printf("Tx dropped: %ld\n", value);
36768 + * Atomically reads the link status information from global
36769 + * structure rte_eth_dev.
36772 + * - Pointer to the structure rte_eth_dev to read from.
36773 + * - Pointer to the buffer to be saved with the link status.
36776 + * - On success, zero.
36777 + * - On failure, negative value.
36780 +rte_dpni_dev_atomic_read_link_status(struct rte_eth_dev *dev,
36781 + struct rte_eth_link *link)
36783 + struct rte_eth_link *dst = link;
36784 + struct rte_eth_link *src = &dev->data->dev_link;
36786 + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
36787 + *(uint64_t *)src) == 0)
36794 + * Atomically writes the link status information into global
36795 + * structure rte_eth_dev.
36798 + * - Pointer to the structure rte_eth_dev to read from.
36799 + * - Pointer to the buffer to be saved with the link status.
36802 + * - On success, zero.
36803 + * - On failure, negative value.
36806 +rte_dpni_dev_atomic_write_link_status(struct rte_eth_dev *dev,
36807 + struct rte_eth_link *link)
36809 + struct rte_eth_link *dst = &dev->data->dev_link;
36810 + struct rte_eth_link *src = link;
36812 + if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
36813 + *(uint64_t *)src) == 0)
36819 +static inline void
36820 +dpaa2_eth_parse_packet(struct rte_mbuf *mbuf, uint64_t hw_annot_addr)
36822 + uint32_t pkt_type = 0;
36823 + struct pkt_annotation *annotation =
36824 + (struct pkt_annotation *)hw_annot_addr;
36826 + PMD_DRV_LOG(DEBUG, "\n 1 annotation = 0x%lx ", annotation->word4);
36828 + if (BIT_ISSET_AT_POS(annotation->word3, L2_ETH_MAC_PRESENT))
36829 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L2_ETHER;
36831 + if (BIT_ISSET_AT_POS(annotation->word4, L3_IPV4_1_PRESENT))
36832 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L3_IPV4;
36834 + if (BIT_ISSET_AT_POS(annotation->word4, L3_IPV6_1_PRESENT))
36835 + pkt_type /* mbuf->packet_type */ |= RTE_PTYPE_L3_IPV6;
36837 + if (BIT_ISSET_AT_POS(annotation->word4, L3_IP_1_OPT_PRESENT))
36838 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L3_IPV4_EXT;
36840 + if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_UDP_PRESENT))
36841 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L4_UDP;
36843 + if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_TCP_PRESENT))
36844 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L4_TCP;
36846 + if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_SCTP_PRESENT))
36847 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L4_SCTP;
36849 + if (BIT_ISSET_AT_POS(annotation->word4, L3_PROTO_ICMP_PRESENT))
36850 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_L4_ICMP;
36852 + if (BIT_ISSET_AT_POS(annotation->word4, L3_IP_UNKNOWN_PROTOCOL))
36853 + pkt_type/* mbuf->packet_type */ |= RTE_PTYPE_UNKNOWN;
36855 + mbuf->packet_type = pkt_type;
36859 +struct rte_mbuf *eth_fd_to_mbuf(const struct qbman_fd *fd)
36861 + struct rte_mbuf *mbuf = DPAA2_INLINE_MBUF_FROM_BUF(
36862 + DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd)),
36863 + bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size);
36864 + /* need to repopulated some of the fields,
36865 + as they may have changed in last transmission*/
36868 + mbuf->data_off = DPAA2_GET_FD_OFFSET(fd);
36869 + mbuf->data_len = DPAA2_GET_FD_LEN(fd);
36870 + mbuf->pkt_len = mbuf->data_len;
36871 + mbuf->next = NULL;
36872 + rte_mbuf_refcnt_set(mbuf, 1);
36874 + PMD_DRV_LOG(DEBUG, "to mbuf - mbuf =%p, mbuf->buf_addr =%p, off = %d,"
36875 + "fd_off=%d fd =%lx, meta = %d bpid =%d, len=%d\n",
36876 + mbuf, mbuf->buf_addr, mbuf->data_off,
36877 + DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd),
36878 + bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
36879 + DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd));
36881 + /* Parse the packet */
36882 + /* parse results are after the private - sw annotation area */
36883 + dpaa2_eth_parse_packet(mbuf,
36884 + (uint64_t)DPAA2_IOVA_TO_VADDR(DPAA2_GET_FD_ADDR(fd))
36885 + + DPAA2_FD_PTA_SIZE);
36887 + mbuf->nb_segs = 1;
36888 + mbuf->ol_flags = 0;
36893 +static void __attribute__ ((noinline)) eth_mbuf_to_fd(struct rte_mbuf *mbuf,
36894 + struct qbman_fd *fd, uint16_t bpid)
36896 + /*Resetting the buffer pool id and offset field*/
36897 + fd->simple.bpid_offset = 0;
36899 + DPAA2_SET_FD_ADDR(fd, DPAA2_MBUF_VADDR_TO_IOVA(mbuf));
36900 + DPAA2_SET_FD_LEN(fd, mbuf->data_len);
36901 + DPAA2_SET_FD_BPID(fd, bpid);
36902 + DPAA2_SET_FD_OFFSET(fd, mbuf->data_off);
36903 + DPAA2_SET_FD_ASAL(fd, DPAA2_ASAL_VAL);
36905 + PMD_DRV_LOG(DEBUG, "mbuf =%p, mbuf->buf_addr =%p, off = %d,"
36906 + "fd_off=%d fd =%lx, meta = %d bpid =%d, len=%d\n",
36907 + mbuf, mbuf->buf_addr, mbuf->data_off,
36908 + DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_ADDR(fd),
36909 + bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
36910 + DPAA2_GET_FD_BPID(fd), DPAA2_GET_FD_LEN(fd));
36915 +static int eth_copy_mbuf_to_fd(struct rte_mbuf *mbuf,
36916 + struct qbman_fd *fd, uint16_t bpid)
36918 + struct rte_mbuf *m;
36921 + if (hw_mbuf_alloc_bulk(bpid_info[bpid].bp_list->buf_pool.mp, &mb, 1)) {
36922 + PMD_DRV_LOG(WARNING, "Unable to allocated DPAA2 buffer");
36923 + rte_pktmbuf_free(mbuf);
36926 + m = (struct rte_mbuf *)mb;
36927 + memcpy((char *)m->buf_addr + mbuf->data_off,
36928 + (void *)((char *)mbuf->buf_addr + mbuf->data_off),
36931 + /*Resetting the buffer pool id and offset field*/
36932 + fd->simple.bpid_offset = 0;
36934 + DPAA2_SET_FD_ADDR(fd, DPAA2_MBUF_VADDR_TO_IOVA(m));
36935 + DPAA2_SET_FD_LEN(fd, mbuf->data_len);
36936 + DPAA2_SET_FD_BPID(fd, bpid);
36937 + DPAA2_SET_FD_OFFSET(fd, mbuf->data_off);
36938 + DPAA2_SET_FD_ASAL(fd, DPAA2_ASAL_VAL);
36940 + PMD_DRV_LOG(DEBUG, "\nmbuf %p BMAN buf addr %p",
36941 + (void *)mbuf, mbuf->buf_addr);
36943 + PMD_DRV_LOG(DEBUG, "\nfdaddr =%lx bpid =%d meta =%d off =%d, len =%d\n",
36944 + DPAA2_GET_FD_ADDR(fd),
36945 + DPAA2_GET_FD_BPID(fd),
36946 + bpid_info[DPAA2_GET_FD_BPID(fd)].meta_data_size,
36947 + DPAA2_GET_FD_OFFSET(fd),
36948 + DPAA2_GET_FD_LEN(fd));
36949 + /*free the original packet */
36950 + rte_pktmbuf_free(mbuf);
36956 +eth_dpaa2_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
36958 + /* Function is responsible to receive frames for a given device and VQ*/
36959 + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
36960 + struct qbman_result *dq_storage;
36961 + uint32_t fqid = dpaa2_q->fqid;
36962 + int ret, num_rx = 0;
36963 + uint8_t is_last = 0, status;
36964 + struct qbman_swp *swp;
36965 + const struct qbman_fd *fd;
36966 + struct qbman_pull_desc pulldesc;
36967 + struct rte_eth_dev *dev = dpaa2_q->dev;
36969 + if (!thread_io_info.dpio_dev) {
36970 + ret = dpaa2_affine_qbman_swp();
36972 + PMD_DRV_LOG(ERR, "Failure in affining portal\n");
36976 + swp = thread_io_info.dpio_dev->sw_portal;
36977 + dq_storage = dpaa2_q->q_storage->dq_storage[0];
36979 + qbman_pull_desc_clear(&pulldesc);
36980 + qbman_pull_desc_set_numframes(&pulldesc, nb_pkts);
36981 + qbman_pull_desc_set_fq(&pulldesc, fqid);
36982 + /* todo optimization - we can have dq_storage_phys available*/
36983 + qbman_pull_desc_set_storage(&pulldesc, dq_storage,
36984 + (dma_addr_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
36986 + /*Issue a volatile dequeue command. */
36988 + if (qbman_swp_pull(swp, &pulldesc)) {
36989 + PMD_DRV_LOG(ERR, "VDQ command is not issued."
36990 + "QBMAN is busy\n");
36991 + /* Portal was busy, try again */
36997 + /* Receive the packets till Last Dequeue entry is found with
36998 + respect to the above issues PULL command.
37000 + while (!is_last) {
37001 + /*Check if the previous issued command is completed.
37002 + *Also seems like the SWP is shared between the Ethernet Driver
37003 + *and the SEC driver.*/
37004 + while (!qbman_check_command_complete(swp, dq_storage))
37006 + /* Loop until the dq_storage is updated with
37007 + * new token by QBMAN */
37008 + while (!qbman_result_has_new_result(swp, dq_storage))
37010 + /* Check whether Last Pull command is Expired and
37011 + setting Condition for Loop termination */
37012 + if (qbman_result_DQ_is_pull_complete(dq_storage)) {
37014 + /* Check for valid frame. */
37015 + status = (uint8_t)qbman_result_DQ_flags(dq_storage);
37016 + if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) {
37017 + PMD_DRV_LOG(DEBUG, "No frame is delivered\n");
37022 + fd = qbman_result_DQ_fd(dq_storage);
37023 + bufs[num_rx] = eth_fd_to_mbuf(fd);
37024 + bufs[num_rx]->port = dev->data->port_id;
37028 + } /* End of Packet Rx loop */
37030 + dpaa2_q->rx_pkts += num_rx;
37032 + PMD_DRV_LOG(INFO, "Ethernet Received %d Packets\n", num_rx);
37033 + /*Return the total number of packets received to DPAA2 app*/
37038 +eth_dpaa2_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
37040 + /* Function is responsible to receive frames for a given device and VQ*/
37041 + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
37042 + struct qbman_result *dq_storage;
37043 + uint32_t fqid = dpaa2_q->fqid;
37044 + int ret, i, num_rx = 0;
37045 + uint8_t is_last = 0, status;
37046 + struct qbman_swp *swp;
37047 + const struct qbman_fd *fd[16];
37048 + struct qbman_pull_desc pulldesc;
37049 + struct queue_storage_info_t *q_storage = dpaa2_q->q_storage;
37050 + struct rte_eth_dev *dev = dpaa2_q->dev;
37052 + if (!thread_io_info.dpio_dev) {
37053 + ret = dpaa2_affine_qbman_swp();
37055 + PMD_DRV_LOG(ERR, "Failure in affining portal\n");
37059 + swp = thread_io_info.dpio_dev->sw_portal;
37061 + if (!q_storage->active_dqs) {
37062 + q_storage->toggle = 0;
37063 + dq_storage = q_storage->dq_storage[q_storage->toggle];
37064 + qbman_pull_desc_clear(&pulldesc);
37065 + qbman_pull_desc_set_numframes(&pulldesc, nb_pkts);
37066 + qbman_pull_desc_set_fq(&pulldesc, fqid);
37067 + qbman_pull_desc_set_storage(&pulldesc, dq_storage,
37068 + (dma_addr_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
37069 + if (thread_io_info.global_active_dqs) {
37070 + while (!qbman_check_command_complete(swp, thread_io_info.global_active_dqs))
37074 + if (qbman_swp_pull(swp, &pulldesc)) {
37075 + PMD_DRV_LOG(WARNING, "VDQ command is not issued."
37076 + "QBMAN is busy\n");
37077 + /* Portal was busy, try again */
37082 + q_storage->active_dqs = dq_storage;
37083 + thread_io_info.global_active_dqs = dq_storage;
37085 + if (thread_io_info.global_active_dqs)
37086 + while (!qbman_check_command_complete(swp, thread_io_info.global_active_dqs))
37088 + dq_storage = q_storage->active_dqs;
37089 + while (!is_last) {
37090 + /* Loop until the dq_storage is updated with
37091 + * new token by QBMAN */
37092 + struct rte_mbuf *mbuf;
37094 + while (!qbman_result_has_new_result(swp, dq_storage))
37096 + rte_prefetch0((void *)((uint64_t)(dq_storage + 1)));
37097 + /* Check whether Last Pull command is Expired and
37098 + setting Condition for Loop termination */
37099 + if (qbman_result_DQ_is_pull_complete(dq_storage)) {
37101 + /* Check for valid frame. */
37102 + status = (uint8_t)qbman_result_DQ_flags(dq_storage);
37103 + if (unlikely((status & QBMAN_DQ_STAT_VALIDFRAME) == 0)) {
37104 + PMD_DRV_LOG2(DEBUG, "No frame is delivered\n");
37108 + fd[num_rx] = qbman_result_DQ_fd(dq_storage);
37109 + mbuf = (struct rte_mbuf *)DPAA2_IOVA_TO_VADDR(
37110 + DPAA2_GET_FD_ADDR(fd[num_rx])
37111 + - bpid_info[DPAA2_GET_FD_BPID(fd[num_rx])].meta_data_size);
37112 + /* Prefeth mbuf */
37113 + rte_prefetch0(mbuf);
37114 + /* Prefetch Annotation address from where we get parse results */
37115 + rte_prefetch0((void *)((uint64_t)DPAA2_GET_FD_ADDR(fd[num_rx]) + DPAA2_FD_PTA_SIZE + 16));
37116 + /*Prefetch Data buffer*/
37117 + /* rte_prefetch0((void *)((uint64_t)DPAA2_GET_FD_ADDR(fd[num_rx]) + DPAA2_GET_FD_OFFSET(fd[num_rx]))); */
37121 + } /* End of Packet Rx loop */
37123 + for (i = 0; i < num_rx; i++) {
37124 + bufs[i] = eth_fd_to_mbuf(fd[i]);
37125 + bufs[i]->port = dev->data->port_id;
37128 + q_storage->toggle ^= 1;
37129 + dq_storage = q_storage->dq_storage[q_storage->toggle];
37130 + qbman_pull_desc_clear(&pulldesc);
37131 + qbman_pull_desc_set_numframes(&pulldesc, nb_pkts);
37132 + qbman_pull_desc_set_fq(&pulldesc, fqid);
37133 + qbman_pull_desc_set_storage(&pulldesc, dq_storage,
37134 + (dma_addr_t)(DPAA2_VADDR_TO_IOVA(dq_storage)), 1);
37135 + /*Issue a volatile dequeue command. */
37138 + if (qbman_swp_pull(swp, &pulldesc)) {
37139 + PMD_DRV_LOG(WARNING, "VDQ command is not issued."
37140 + "QBMAN is busy\n");
37145 + q_storage->active_dqs = dq_storage;
37146 + thread_io_info.global_active_dqs = dq_storage;
37148 + dpaa2_q->rx_pkts += num_rx;
37150 + PMD_DRV_LOG2(INFO, "Ethernet Received %d Packets\n", num_rx);
37151 + /*Return the total number of packets received to DPAA2 app*/
37156 + * Callback to handle sending packets through a real NIC.
37159 +eth_dpaa2_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
37161 + /* Function to transmit the frames to given device and VQ*/
37164 +#ifdef QBMAN_MULTI_TX
37165 + struct qbman_fd fd_arr[8];
37166 + uint32_t frames_to_send;
37168 + struct qbman_fd fd;
37170 + struct rte_mempool *mp;
37171 + struct qbman_eq_desc eqdesc;
37172 + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)queue;
37173 + struct qbman_swp *swp;
37174 + uint16_t num_tx = 0;
37176 + struct rte_eth_dev *dev = dpaa2_q->dev;
37177 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37179 + if (!thread_io_info.dpio_dev) {
37180 + ret = dpaa2_affine_qbman_swp();
37182 + PMD_DRV_LOG(ERR, "Failure in affining portal\n");
37186 + swp = thread_io_info.dpio_dev->sw_portal;
37188 + PMD_DRV_LOG(DEBUG, "===> dev =%p, fqid =%d", dev, dpaa2_q->fqid);
37190 + /*Prepare enqueue descriptor*/
37191 + qbman_eq_desc_clear(&eqdesc);
37192 + qbman_eq_desc_set_no_orp(&eqdesc, DPAA2_EQ_RESP_ERR_FQ);
37193 + qbman_eq_desc_set_response(&eqdesc, 0, 0);
37194 + qbman_eq_desc_set_qd(&eqdesc, priv->qdid,
37195 + dpaa2_q->flow_id, dpaa2_q->tc_index);
37197 + /*Clear the unused FD fields before sending*/
37198 +#ifdef QBMAN_MULTI_TX
37199 + while (nb_pkts) {
37200 +#ifdef DPAA2_CGR_SUPPORT
37201 + /*Check if the queue is congested*/
37202 + if (qbman_result_is_CSCN(dpaa2_q->cscn))
37205 + frames_to_send = (nb_pkts >> 3) ? MAX_SLOTS : nb_pkts;
37207 + for (loop = 0; loop < frames_to_send; loop++) {
37208 + fd_arr[loop].simple.frc = 0;
37209 + DPAA2_RESET_FD_CTRL((&fd_arr[loop]));
37210 + DPAA2_SET_FD_FLC((&fd_arr[loop]), NULL);
37211 + mp = (*bufs)->pool;
37212 + /* Not a hw_pkt pool allocated frame */
37213 + if (mp && !(mp->flags & MEMPOOL_F_HW_PKT_POOL)) {
37214 + printf("\n non hw offload bufffer ");
37215 + /* alloc should be from the default buffer pool
37216 + attached to this interface */
37217 + if (priv->bp_list) {
37218 + bpid = priv->bp_list->buf_pool.bpid;
37220 + printf("\n ??? why no bpool attached");
37224 + if (eth_copy_mbuf_to_fd(*bufs, &fd_arr[loop], bpid)) {
37230 + bpid = mempool_to_bpid(mp);
37231 + eth_mbuf_to_fd(*bufs, &fd_arr[loop], bpid);
37236 + while (loop < frames_to_send) {
37237 + loop += qbman_swp_send_multiple(swp, &eqdesc,
37238 + &fd_arr[loop], frames_to_send - loop);
37241 + num_tx += frames_to_send;
37242 + dpaa2_q->tx_pkts += frames_to_send;
37243 + nb_pkts -= frames_to_send;
37246 +#ifdef DPAA2_CGR_SUPPORT
37247 + /*Check if the queue is congested*/
37248 + if(qbman_result_is_CSCN(dpaa2_q->cscn))
37252 + fd.simple.frc = 0;
37253 + DPAA2_RESET_FD_CTRL((&fd));
37254 + DPAA2_SET_FD_FLC((&fd), NULL);
37257 + while (loop < nb_pkts) {
37258 + /*Prepare each packet which is to be sent*/
37259 + mp = bufs[loop]->pool;
37260 + /* Not a hw_pkt pool allocated frame */
37261 + if (mp && !(mp->flags & MEMPOOL_F_HW_PKT_POOL)) {
37262 + /* alloc should be from the default buffer pool
37263 + attached to this interface */
37264 + if (priv->bp_list) {
37265 + bpid = priv->bp_list->buf_pool.bpid;
37267 + /* Buffer not from offloaded area as well as
37268 + * lacks buffer pool identifier. Cannot
37271 + PMD_DRV_LOG(ERR, "No Buffer pool "
37277 + if (eth_copy_mbuf_to_fd(bufs[loop], &fd, bpid)) {
37283 + bpid = mempool_to_bpid(mp);
37284 + eth_mbuf_to_fd(bufs[loop], &fd, bpid);
37286 + /*Enqueue a single packet to the QBMAN*/
37288 + ret = qbman_swp_enqueue(swp, &eqdesc, &fd);
37290 + PMD_DRV_LOG(DEBUG, "Error in transmiting the frame\n");
37292 + } while (ret != 0);
37294 + /* Free the buffer shell */
37295 + /* rte_pktmbuf_free(bufs[loop]); */
37296 + num_tx++; loop++;
37298 + dpaa2_q->tx_pkts += num_tx;
37299 + dpaa2_q->err_pkts += nb_pkts - num_tx;
37306 +dpaa2_vlan_stripping_set(struct rte_eth_dev *dev, int on)
37309 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37310 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
37312 + PMD_INIT_FUNC_TRACE();
37314 + if (dpni == NULL) {
37315 + PMD_DRV_LOG(ERR, "dpni is NULL");
37319 + ret = dpni_set_vlan_removal(dpni, CMD_PRI_LOW, priv->token, on);
37321 + PMD_DRV_LOG(ERR, "Unable to dpni_set_vlan_removal hwid =%d",
37327 +dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
37330 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37331 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
37333 + if (dpni == NULL) {
37334 + PMD_DRV_LOG(ERR, "dpni is NULL");
37339 + ret = dpni_add_vlan_id(dpni, CMD_PRI_LOW, priv->token, vlan_id);
37341 + ret = dpni_remove_vlan_id(dpni, CMD_PRI_LOW, priv->token, vlan_id);
37344 + PMD_DRV_LOG(ERR, "ret = %d Unable to add/rem vlan %d hwid =%d",
37345 + ret, vlan_id, priv->hw_id);
37347 + /*todo this should on global basis */
37348 +/* ret = dpni_set_vlan_filters(dpni, CMD_PRI_LOW, priv->token, on);
37350 + PMD_DRV_LOG(ERR, "Unable to set vlan filter");
37355 +dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask)
37357 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37358 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
37361 + if (mask & ETH_VLAN_FILTER_MASK) {
37362 + if (dev->data->dev_conf.rxmode.hw_vlan_filter)
37363 + ret = dpni_set_vlan_filters(dpni, CMD_PRI_LOW, priv->token, TRUE);
37365 + ret = dpni_set_vlan_filters(dpni, CMD_PRI_LOW, priv->token, FALSE);
37367 + PMD_DRV_LOG(ERR, "ret = %d Unable to set vlan filter", ret);
37370 + if (mask & ETH_VLAN_STRIP_MASK) {
37371 + /* Enable or disable VLAN stripping */
37372 + if (dev->data->dev_conf.rxmode.hw_vlan_strip)
37373 + dpaa2_vlan_stripping_set(dev, TRUE);
37375 + dpaa2_vlan_stripping_set(dev, FALSE);
37378 + if (mask & ETH_VLAN_EXTEND_MASK) {
37379 + PMD_INIT_FUNC_TRACE();
37380 +/* if (dev->data->dev_conf.rxmode.hw_vlan_extend)
37381 + i40e_vsi_config_double_vlan(vsi, TRUE);
37383 + i40e_vsi_config_double_vlan(vsi, FALSE);
37388 +dpaa2_eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
37390 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37392 + dev_info->driver_name = drivername;
37393 + dev_info->if_index = priv->hw_id;
37394 + dev_info->max_mac_addrs = priv->max_unicast_filters;
37395 + dev_info->max_rx_pktlen = DPAA2_MAX_RX_PKT_LEN;
37396 + dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
37397 + dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
37398 + dev_info->min_rx_bufsize = DPAA2_MIN_RX_BUF_SIZE;
37399 + dev_info->pci_dev = dev->pci_dev;
37400 +/* dev_info->rx_offload_capa =
37401 + DEV_RX_OFFLOAD_IPV4_CKSUM |
37402 + DEV_RX_OFFLOAD_UDP_CKSUM |
37403 + DEV_RX_OFFLOAD_TCP_CKSUM;
37404 + dev_info->tx_offload_capa =
37405 + DEV_TX_OFFLOAD_IPV4_CKSUM |
37406 + DEV_TX_OFFLOAD_UDP_CKSUM |
37407 + DEV_TX_OFFLOAD_TCP_CKSUM |
37408 + DEV_TX_OFFLOAD_SCTP_CKSUM;
37413 +dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
37415 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37417 + uint16_t dist_idx;
37419 + struct dpaa2_queue *mc_q, *mcq;
37420 + uint32_t tot_queues;
37422 + struct dpaa2_queue *dpaa2_q;
37424 + tot_queues = priv->nb_rx_queues + priv->nb_tx_queues;
37425 + mc_q = rte_malloc(NULL, sizeof(struct dpaa2_queue) * tot_queues,
37426 + RTE_CACHE_LINE_SIZE);
37428 + PMD_DRV_LOG(ERR, "malloc failed for rx/tx queues\n");
37432 + for (i = 0; i < priv->nb_rx_queues; i++) {
37434 + priv->rx_vq[i] = mc_q++;
37435 + dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
37436 + dpaa2_q->q_storage = rte_malloc("dq_storage",
37437 + sizeof(struct queue_storage_info_t),
37438 + RTE_CACHE_LINE_SIZE);
37439 + if (!dpaa2_q->q_storage)
37442 + memset(dpaa2_q->q_storage, 0, sizeof(struct queue_storage_info_t));
37445 + for (i = 0; i < priv->nb_tx_queues; i++) {
37447 + mc_q->flow_id = DPNI_NEW_FLOW_ID;
37448 + priv->tx_vq[i] = mc_q++;
37452 + for (tc_idx = 0; tc_idx < priv->num_tc; tc_idx++) {
37453 + for (dist_idx = 0; dist_idx < priv->num_dist_per_tc[tc_idx]; dist_idx++) {
37454 + mcq = (struct dpaa2_queue *)priv->rx_vq[vq_id];
37455 + mcq->tc_index = tc_idx;
37456 + mcq->flow_id = dist_idx;
37465 + dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
37466 + rte_free(dpaa2_q->q_storage);
37471 +static void dpaa2_distset_to_dpkg_profile_cfg(
37472 + uint32_t req_dist_set,
37473 + struct dpkg_profile_cfg *kg_cfg)
37475 + uint32_t loop = 0, i = 0, dist_field = 0;
37476 + int l2_configured = 0, l3_configured = 0;
37477 + int l4_configured = 0, sctp_configured = 0;
37479 + memset(kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
37480 + while (req_dist_set) {
37481 + if (req_dist_set % 2 != 0) {
37482 + dist_field = 1U << loop;
37483 + switch (dist_field) {
37484 + case ETH_RSS_L2_PAYLOAD:
37486 + if (l2_configured)
37488 + l2_configured = 1;
37490 + kg_cfg->extracts[i].extract.from_hdr.prot =
37492 + kg_cfg->extracts[i].extract.from_hdr.field =
37494 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37495 + kg_cfg->extracts[i].extract.from_hdr.type =
37500 + case ETH_RSS_IPV4:
37501 + case ETH_RSS_FRAG_IPV4:
37502 + case ETH_RSS_NONFRAG_IPV4_OTHER:
37503 + case ETH_RSS_IPV6:
37504 + case ETH_RSS_FRAG_IPV6:
37505 + case ETH_RSS_NONFRAG_IPV6_OTHER:
37506 + case ETH_RSS_IPV6_EX:
37508 + if (l3_configured)
37510 + l3_configured = 1;
37512 + kg_cfg->extracts[i].extract.from_hdr.prot =
37514 + kg_cfg->extracts[i].extract.from_hdr.field =
37516 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37517 + kg_cfg->extracts[i].extract.from_hdr.type =
37521 + kg_cfg->extracts[i].extract.from_hdr.prot =
37523 + kg_cfg->extracts[i].extract.from_hdr.field =
37525 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37526 + kg_cfg->extracts[i].extract.from_hdr.type =
37530 + kg_cfg->extracts[i].extract.from_hdr.prot =
37532 + kg_cfg->extracts[i].extract.from_hdr.field =
37534 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37535 + kg_cfg->extracts[i].extract.from_hdr.type =
37537 + kg_cfg->num_extracts++;
37541 + case ETH_RSS_NONFRAG_IPV4_TCP:
37542 + case ETH_RSS_NONFRAG_IPV6_TCP:
37543 + case ETH_RSS_NONFRAG_IPV4_UDP:
37544 + case ETH_RSS_NONFRAG_IPV6_UDP:
37546 + if (l4_configured)
37548 + l4_configured = 1;
37550 + kg_cfg->extracts[i].extract.from_hdr.prot =
37552 + kg_cfg->extracts[i].extract.from_hdr.field =
37553 + NH_FLD_TCP_PORT_SRC;
37554 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37555 + kg_cfg->extracts[i].extract.from_hdr.type =
37559 + kg_cfg->extracts[i].extract.from_hdr.prot =
37561 + kg_cfg->extracts[i].extract.from_hdr.field =
37562 + NH_FLD_TCP_PORT_SRC;
37563 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37564 + kg_cfg->extracts[i].extract.from_hdr.type =
37569 + case ETH_RSS_NONFRAG_IPV4_SCTP:
37570 + case ETH_RSS_NONFRAG_IPV6_SCTP:
37572 + if (sctp_configured)
37574 + sctp_configured = 1;
37576 + kg_cfg->extracts[i].extract.from_hdr.prot =
37578 + kg_cfg->extracts[i].extract.from_hdr.field =
37579 + NH_FLD_SCTP_PORT_SRC;
37580 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37581 + kg_cfg->extracts[i].extract.from_hdr.type =
37585 + kg_cfg->extracts[i].extract.from_hdr.prot =
37587 + kg_cfg->extracts[i].extract.from_hdr.field =
37588 + NH_FLD_SCTP_PORT_DST;
37589 + kg_cfg->extracts[i].type = DPKG_EXTRACT_FROM_HDR;
37590 + kg_cfg->extracts[i].extract.from_hdr.type =
37596 + PMD_DRV_LOG(WARNING, "Bad flow distribution option %x\n", dist_field);
37599 + req_dist_set = req_dist_set >> 1;
37602 + kg_cfg->num_extracts = i;
37605 +static int dpaa2_setup_flow_distribution(struct rte_eth_dev *eth_dev,
37606 + uint32_t req_dist_set)
37608 + struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
37609 + struct fsl_mc_io *dpni = priv->hw;
37610 + struct dpni_rx_tc_dist_cfg tc_cfg;
37611 + struct dpkg_profile_cfg kg_cfg;
37613 + int ret, tc_index = 0;
37615 + p_params = rte_malloc(
37616 + NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
37618 + PMD_DRV_LOG(ERR, "Memory unavaialble\n");
37621 + memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
37622 + memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
37624 + dpaa2_distset_to_dpkg_profile_cfg(req_dist_set, &kg_cfg);
37625 + tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params));
37626 + tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
37627 + tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
37629 + ret = dpni_prepare_key_cfg(&kg_cfg, p_params);
37631 + PMD_DRV_LOG(ERR, "Unable to prepare extract parameters\n");
37632 + rte_free(p_params);
37636 + ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
37638 + rte_free(p_params);
37640 + PMD_DRV_LOG(ERR, "Setting distribution for Rx failed with"
37641 + "err code: %d\n", ret);
37649 +dpaa2_remove_flow_distribution(struct rte_eth_dev *eth_dev, uint8_t tc_index)
37651 + struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
37652 + struct fsl_mc_io *dpni = priv->hw;
37653 + struct dpni_rx_tc_dist_cfg tc_cfg;
37654 + struct dpkg_profile_cfg kg_cfg;
37658 + p_params = rte_malloc(
37659 + NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
37661 + PMD_DRV_LOG(ERR, "Memory unavaialble\n");
37664 + memset(p_params, 0, DIST_PARAM_IOVA_SIZE);
37665 + memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
37667 + tc_cfg.key_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(p_params));
37668 + tc_cfg.dist_size = 0;
37669 + tc_cfg.dist_mode = DPNI_DIST_MODE_NONE;
37671 + ret = dpni_prepare_key_cfg(&kg_cfg, p_params);
37673 + PMD_DRV_LOG(ERR, "Unable to prepare extract parameters\n");
37674 + rte_free(p_params);
37678 + ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
37680 + rte_free(p_params);
37682 + PMD_DRV_LOG(ERR, "Setting distribution for Rx failed with"
37683 + "err code: %d\n", ret);
37690 +dpaa2_alloc_dq_storage(struct queue_storage_info_t *q_storage)
37694 + for (i = 0; i < NUM_DQS_PER_QUEUE; i++) {
37695 + q_storage->dq_storage[i] = rte_malloc(NULL,
37696 + NUM_MAX_RECV_FRAMES * sizeof(struct qbman_result),
37697 + RTE_CACHE_LINE_SIZE);
37698 + if (!q_storage->dq_storage[i])
37700 + /*setting toggle for initial condition*/
37701 + q_storage->toggle = -1;
37707 + rte_free(q_storage->dq_storage[i]);
37713 +dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
37715 + struct rte_eth_dev_data *data = dev->data;
37716 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37717 + struct rte_eth_conf *eth_conf = &data->dev_conf;
37718 + struct dpaa2_queue *dpaa2_q;
37721 + for (i = 0; i < data->nb_rx_queues; i++) {
37722 + data->rx_queues[i] = priv->rx_vq[i];
37723 + dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i];
37724 + if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage))
37728 + for (i = 0; i < data->nb_tx_queues; i++) {
37729 + data->tx_queues[i] = priv->tx_vq[i];
37730 + dpaa2_q = (struct dpaa2_queue *)data->tx_queues[i];
37731 + dpaa2_q->cscn = rte_malloc(NULL, sizeof(struct qbman_result), 16);
37732 + if (!dpaa2_q->cscn)
37733 + goto fail_tx_queue;
37736 + /* Check for correct configuration */
37737 + if (eth_conf->rxmode.mq_mode != ETH_MQ_RX_RSS &&
37738 + data->nb_rx_queues > 1) {
37739 + PMD_DRV_LOG(ERR, "Distribution is not enabled, "
37740 + "but Rx queues more than 1\n");
37744 + if (eth_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) {
37745 + /* Return in case number of Rx queues is 1 */
37746 + if (data->nb_rx_queues == 1)
37748 + ret = dpaa2_setup_flow_distribution(dev,
37749 + eth_conf->rx_adv_conf.rss_conf.rss_hf);
37751 + PMD_DRV_LOG(ERR, "dpaa2_setup_flow_distribution failed\n");
37760 + dpaa2_q = (struct dpaa2_queue *)data->tx_queues[i];
37761 + rte_free(dpaa2_q->cscn);
37766 +static int dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
37769 + /* Function to attach a DPNI with a buffer pool list. Buffer pool list
37770 + * handle is passed in blist.
37773 + struct fsl_mc_io *dpni = priv->hw;
37774 + struct dpni_pools_cfg bpool_cfg;
37775 + struct dpaa2_bp_list *bp_list = (struct dpaa2_bp_list *)blist;
37776 + struct dpni_buffer_layout layout;
37779 + /* ... rx buffer layout .
37780 + Check alignment for buffer layouts first*/
37782 + /* ... rx buffer layout ... */
37783 + tot_size = DPAA2_HW_BUF_RESERVE + RTE_PKTMBUF_HEADROOM;
37784 + tot_size = RTE_ALIGN_CEIL(tot_size,
37785 + DPAA2_PACKET_LAYOUT_ALIGN);
37787 + memset(&layout, 0, sizeof(struct dpni_buffer_layout));
37788 + layout.options = DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM;
37790 + layout.data_head_room = tot_size - DPAA2_FD_PTA_SIZE - DPAA2_MBUF_HW_ANNOTATION;
37791 + retcode = dpni_set_rx_buffer_layout(dpni, CMD_PRI_LOW, priv->token,
37794 + PMD_DRV_LOG(ERR, "Err(%d) in setting rx buffer layout\n", retcode);
37798 + /*Attach buffer pool to the network interface as described by the user*/
37799 + bpool_cfg.num_dpbp = 1;
37800 + bpool_cfg.pools[0].dpbp_id = bp_list->buf_pool.dpbp_node->dpbp_id;
37801 + bpool_cfg.pools[0].backup_pool = 0;
37802 + bpool_cfg.pools[0].buffer_size =
37803 + RTE_ALIGN_CEIL(bp_list->buf_pool.size,
37804 + 256 /*DPAA2_PACKET_LAYOUT_ALIGN*/);
37806 + retcode = dpni_set_pools(dpni, CMD_PRI_LOW, priv->token, &bpool_cfg);
37807 + if (retcode != 0) {
37808 + PMD_DRV_LOG(ERR, "Error in attaching the buffer pool list"
37809 + "bpid = %d Error code = %d\n",
37810 + bpool_cfg.pools[0].dpbp_id, retcode);
37814 + priv->bp_list = bp_list;
37818 +/* Function to setup RX flow information. It contains traffic class ID,
37819 + * flow ID, destination configuration etc.
37822 +dpaa2_rx_queue_setup(struct rte_eth_dev *dev,
37823 + uint16_t rx_queue_id,
37824 + uint16_t nb_rx_desc __rte_unused,
37825 + unsigned int socket_id __rte_unused,
37826 + const struct rte_eth_rxconf *rx_conf __rte_unused,
37827 + struct rte_mempool *mb_pool)
37829 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37830 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
37831 + struct dpaa2_queue *dpaa2_q;
37832 + struct dpni_queue_cfg cfg;
37833 + uint8_t tc_id, flow_id;
37837 + PMD_DRV_LOG(INFO, "dev =%p, queue =%d, pool = %p, conf =%p",
37838 + dev, rx_queue_id, mb_pool, rx_conf);
37840 + if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
37841 + RTE_VERIFY(mb_pool->pool_data);
37842 + bpid = mempool_to_bpid(mb_pool);
37843 + ret = dpaa2_attach_bp_list(priv,
37844 + bpid_info[bpid].bp_list);
37848 + dpaa2_q = (struct dpaa2_queue *)dev->data->rx_queues[rx_queue_id];
37850 + /*Get the tc id and flow id from given VQ id*/
37851 + tc_id = rx_queue_id / MAX_DIST_PER_TC;
37852 + flow_id = rx_queue_id % MAX_DIST_PER_TC;
37853 + memset(&cfg, 0, sizeof(struct dpni_queue_cfg));
37855 + cfg.options = cfg.options | DPNI_QUEUE_OPT_USER_CTX;
37857 +#ifdef DPAA2_STASHING
37858 + cfg.options = cfg.options | DPNI_QUEUE_OPT_FLC;
37861 + cfg.user_ctx = (uint64_t)(dpaa2_q);
37862 +#ifdef DPAA2_STASHING
37863 + cfg.flc_cfg.flc_type = DPNI_FLC_STASH;
37864 + cfg.flc_cfg.frame_data_size = DPNI_STASH_SIZE_64B;
37865 + /* Enabling Annotation stashing */
37866 + cfg.options |= DPNI_FLC_STASH_FRAME_ANNOTATION;
37867 + cfg.flc_cfg.options = DPNI_FLC_STASH_FRAME_ANNOTATION;
37869 + ret = dpni_set_rx_flow(dpni, CMD_PRI_LOW, priv->token,
37870 + tc_id, flow_id, &cfg);
37872 + PMD_DRV_LOG(ERR, "Error in setting the rx flow: = %d\n", ret);
37879 +dpaa2_tx_queue_setup(struct rte_eth_dev *dev,
37880 + uint16_t tx_queue_id,
37881 + uint16_t nb_tx_desc __rte_unused,
37882 + unsigned int socket_id __rte_unused,
37883 + const struct rte_eth_txconf *tx_conf __rte_unused)
37885 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
37886 + struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)
37887 + dev->data->tx_queues[tx_queue_id];
37888 + struct fsl_mc_io *dpni = priv->hw;
37889 + struct dpni_tx_flow_cfg cfg;
37890 + struct dpni_tx_conf_cfg tx_conf_cfg;
37891 +#ifdef DPAA2_CGR_SUPPORT
37892 + struct dpni_congestion_notification_cfg cong_notif_cfg;
37897 + PMD_INIT_FUNC_TRACE();
37899 + /* Return if queue already configured */
37900 + if (dpaa2_q->flow_id != DPNI_NEW_FLOW_ID)
37903 + memset(&cfg, 0, sizeof(struct dpni_tx_flow_cfg));
37904 + cfg.l3_chksum_gen = 1;
37905 + cfg.options |= DPNI_TX_FLOW_OPT_L3_CHKSUM_GEN;
37906 + cfg.l4_chksum_gen = 1;
37907 + cfg.options = DPNI_TX_FLOW_OPT_L4_CHKSUM_GEN;
37908 + memset(&tx_conf_cfg, 0, sizeof(struct dpni_tx_conf_cfg));
37909 + tx_conf_cfg.errors_only = TRUE;
37912 + if (action & DPAA2BUF_TX_CONF_REQUIRED) {
37913 + cfg.options = DPNI_TX_FLOW_OPT_TX_CONF_ERROR;
37914 + cfg.use_common_tx_conf_queue =
37915 + ((action & DPAA2BUF_TX_CONF_ERR_ON_COMMON_Q) ?
37917 + tx_conf_cfg.errors_only = FALSE;
37920 + if (priv->num_tc == 1)
37923 + tc_idx = tx_queue_id;
37925 + ret = dpni_set_tx_flow(dpni, CMD_PRI_LOW, priv->token,
37926 + &(dpaa2_q->flow_id), &cfg);
37928 + PMD_DRV_LOG(ERR, "Error in setting the tx flow:"
37929 + "ErrorCode = %x\n", ret);
37932 + /*Set tx-conf and error configuration*/
37933 + ret = dpni_set_tx_conf(dpni, CMD_PRI_LOW, priv->token,
37934 + dpaa2_q->flow_id, &tx_conf_cfg);
37936 + PMD_DRV_LOG(ERR, "Error in setting tx conf settings: "
37937 + "ErrorCode = %x", ret);
37941 + if (tx_queue_id == 0) {
37942 + /*Set tx-conf and error configuration*/
37943 + ret = dpni_set_tx_conf(dpni, CMD_PRI_LOW, priv->token,
37944 + DPNI_COMMON_TX_CONF, &tx_conf_cfg);
37946 + PMD_DRV_LOG(ERR, "Error in setting tx conf settings: "
37947 + "ErrorCode = %x", ret);
37951 + dpaa2_q->tc_index = tc_idx;
37953 +#ifdef DPAA2_CGR_SUPPORT
37954 + cong_notif_cfg.units = DPNI_CONGESTION_UNIT_BYTES;
37955 + /*Notify about congestion when the queue size is 128 frames with each \
37956 + frame 64 bytes size*/
37957 + cong_notif_cfg.threshold_entry = CONG_ENTER_THRESHOLD;
37958 + /*Notify that the queue is not congested when the number of frames in \
37959 + the queue is below this thershold.
37960 + TODO: Check if this value is the optimum value for better performance*/
37961 + cong_notif_cfg.threshold_exit = CONG_EXIT_THRESHOLD;
37962 + cong_notif_cfg.message_ctx = 0;
37963 + cong_notif_cfg.message_iova = (uint64_t)dpaa2_q->cscn;
37964 + cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE;
37965 + cong_notif_cfg.options = DPNI_CONG_OPT_WRITE_MEM_ON_ENTER |
37966 + DPNI_CONG_OPT_WRITE_MEM_ON_EXIT | DPNI_CONG_OPT_COHERENT_WRITE;
37968 + ret = dpni_set_tx_tc_congestion_notification(dpni, CMD_PRI_LOW,
37970 + tc_idx, &cong_notif_cfg);
37972 + PMD_DRV_LOG(ERR, "Error in setting tx congestion notification "
37973 + "settings: ErrorCode = %x", ret);
37981 +dpaa2_rx_queue_release(void *q)
37983 + printf("\n(%s) called for 1=%p\n", __func__, q);
37988 +dpaa2_tx_queue_release(void *q)
37990 + printf("\n(%s) called for 1=%p\n", __func__, q);
37994 +static const uint32_t *
37995 +dpaa2_supported_ptypes_get(struct rte_eth_dev *dev)
37997 + static const uint32_t ptypes[] = {
37998 + /*todo -= add more types */
37999 + RTE_PTYPE_L2_ETHER,
38000 + RTE_PTYPE_L3_IPV4,
38001 + RTE_PTYPE_L3_IPV4_EXT,
38002 + RTE_PTYPE_L3_IPV6,
38003 + RTE_PTYPE_L3_IPV6_EXT,
38004 + RTE_PTYPE_L4_TCP,
38005 + RTE_PTYPE_L4_UDP,
38006 + RTE_PTYPE_L4_SCTP,
38007 + RTE_PTYPE_L4_ICMP,
38008 + RTE_PTYPE_UNKNOWN
38011 + if (dev->rx_pkt_burst == eth_dpaa2_prefetch_rx ||
38012 + dev->rx_pkt_burst == eth_dpaa2_rx)
38018 +dpaa2_dev_start(struct rte_eth_dev *dev)
38020 + struct rte_eth_dev_data *data = dev->data;
38021 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38022 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38023 + struct dpni_queue_attr cfg;
38025 + struct dpaa2_queue *dpaa2_q;
38026 + int ret, i, mask = 0;
38028 + PMD_INIT_FUNC_TRACE();
38030 + dev->data->dev_link.link_status = 1;
38032 + ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
38034 + PMD_DRV_LOG(ERR, "Failure %d in enabling dpni %d device\n",
38035 + ret, priv->hw_id);
38039 + ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token, &qdid);
38041 + PMD_DRV_LOG(ERR, "Error to get qdid:ErrorCode = %d\n", ret);
38044 + priv->qdid = qdid;
38046 + for (i = 0; i < data->nb_rx_queues; i++) {
38047 + dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i];
38048 + ret = dpni_get_rx_flow(dpni, CMD_PRI_LOW, priv->token,
38049 + dpaa2_q->tc_index, dpaa2_q->flow_id, &cfg);
38051 + PMD_DRV_LOG(ERR, "Error to get flow "
38052 + "information Error code = %d\n", ret);
38055 + dpaa2_q->fqid = cfg.fqid;
38058 + * VLAN Offload Settings
38060 + if (priv->options & DPNI_OPT_VLAN_FILTER)
38061 + mask = ETH_VLAN_FILTER_MASK;
38063 + if (priv->options & DPNI_OPT_VLAN_MANIPULATION)
38064 + mask = ETH_VLAN_STRIP_MASK;
38067 + dpaa2_vlan_offload_set(dev, mask);
38072 +/*********************************************************************
38074 + * This routine disables all traffic on the adapter by issuing a
38075 + * global reset on the MAC.
38077 + **********************************************************************/
38079 +dpaa2_dev_stop(struct rte_eth_dev *dev)
38081 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38082 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38084 + struct rte_eth_link link;
38086 + dev->data->dev_link.link_status = 0;
38088 + ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token);
38090 + PMD_DRV_LOG(ERR, "Failure in disabling dpni %d device\n", priv->hw_id);
38094 + /* clear the recorded link status */
38095 + memset(&link, 0, sizeof(link));
38096 + rte_dpni_dev_atomic_write_link_status(dev, &link);
38100 +dpaa2_dev_close(struct rte_eth_dev *dev)
38102 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38103 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38105 + struct rte_eth_link link;
38107 + /*Function is reverse of dpaa2_dev_init.
38108 + * It does the following:
38109 + * 1. Detach a DPNI from attached resources i.e. buffer pools, dpbp_id.
38110 + * 2. Close the DPNI device
38111 + * 3. Free the allocated reqources.
38114 + /* Clean the device first */
38115 + ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
38117 + PMD_DRV_LOG(ERR, "Failure cleaning dpni device with"
38118 + "error code %d\n", ret);
38122 + /*Close the device at underlying layer*/
38123 + ret = dpni_close(dpni, CMD_PRI_LOW, priv->token);
38125 + PMD_DRV_LOG(ERR, "Failure closing dpni device with"
38126 + "error code %d\n", ret);
38130 + /*Free the allocated memory for ethernet private data and dpni*/
38134 + memset(&link, 0, sizeof(link));
38135 + rte_dpni_dev_atomic_write_link_status(dev, &link);
38139 +dpaa2_dev_promiscuous_enable(
38140 + struct rte_eth_dev *dev)
38143 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38144 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38146 + if (dpni == NULL) {
38147 + PMD_DRV_LOG(ERR, "dpni is NULL");
38151 + ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, TRUE);
38153 + PMD_DRV_LOG(ERR, "Unable to enable promiscuous mode");
38158 +dpaa2_dev_promiscuous_disable(
38159 + struct rte_eth_dev *dev)
38162 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38163 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38165 + if (dpni == NULL) {
38166 + PMD_DRV_LOG(ERR, "dpni is NULL");
38170 + ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, FALSE);
38172 + PMD_DRV_LOG(ERR, "Unable to disable promiscuous mode");
38177 +dpaa2_dev_allmulticast_enable(
38178 + struct rte_eth_dev *dev)
38181 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38182 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38184 + if (dpni == NULL) {
38185 + PMD_DRV_LOG(ERR, "dpni is NULL");
38189 + ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
38191 + PMD_DRV_LOG(ERR, "Unable to enable promiscuous mode");
38196 +dpaa2_dev_allmulticast_disable(struct rte_eth_dev *dev)
38199 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38200 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38202 + if (dpni == NULL) {
38203 + PMD_DRV_LOG(ERR, "dpni is NULL");
38207 + ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
38209 + PMD_DRV_LOG(ERR, "Unable to enable promiscuous mode");
38213 +static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
38216 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38217 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38218 + uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
38220 + if (dpni == NULL) {
38221 + PMD_DRV_LOG(ERR, "dpni is NULL");
38225 + /* check that mtu is within the allowed range */
38226 + if ((mtu < ETHER_MIN_MTU) || (frame_size > DPAA2_MAX_RX_PKT_LEN))
38229 + /* Set the Max Rx frame length as 'mtu' +
38230 + * Maximum Ethernet header length */
38231 + ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, priv->token,
38232 + mtu + ETH_VLAN_HLEN);
38234 + PMD_DRV_LOG(ERR, "setting the max frame length failed");
38237 + if (priv->options & DPNI_OPT_IPF) {
38238 + ret = dpni_set_mtu(dpni, CMD_PRI_LOW, priv->token, mtu);
38240 + PMD_DRV_LOG(ERR, "Setting the MTU failed");
38245 + PMD_DRV_LOG(INFO, "MTU is configured %d for the device\n", mtu);
38250 +dpaa2_flow_ctrl_set(struct rte_eth_dev *dev __rte_unused,
38251 + struct rte_eth_fc_conf *fc_conf __rte_unused)
38256 +dpaa2_dev_add_mac_addr(struct rte_eth_dev *dev,
38257 + struct ether_addr *addr,
38258 + __rte_unused uint32_t index,
38259 + __rte_unused uint32_t pool)
38262 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38263 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38265 + if (dpni == NULL) {
38266 + PMD_DRV_LOG(ERR, "dpni is NULL");
38270 + ret = dpni_add_mac_addr(dpni, CMD_PRI_LOW,
38271 + priv->token, addr->addr_bytes);
38273 + PMD_DRV_LOG(ERR, "Adding the MAC ADDR failed");
38280 +dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev,
38284 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38285 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38286 + struct rte_eth_dev_data *data = dev->data;
38287 + struct ether_addr *macaddr;
38289 + macaddr = &data->mac_addrs[index];
38291 + if (dpni == NULL) {
38292 + PMD_DRV_LOG(ERR, "dpni is NULL");
38296 + ret = dpni_remove_mac_addr(dpni, CMD_PRI_LOW,
38297 + priv->token, macaddr->addr_bytes);
38299 + PMD_DRV_LOG(ERR, "Removing the MAC ADDR failed");
38306 +dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
38307 + struct ether_addr *addr)
38310 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38311 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38313 + if (dpni == NULL) {
38314 + PMD_DRV_LOG(ERR, "dpni is NULL");
38318 + ret = dpni_set_primary_mac_addr(dpni, CMD_PRI_LOW,
38319 + priv->token, addr->addr_bytes);
38322 + PMD_DRV_LOG(ERR, "Setting the MAC ADDR failed");
38328 +int dpaa2_dev_get_mac_addr(struct rte_eth_dev *dev,
38329 + struct ether_addr *addr)
38332 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38333 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38335 + if (dpni == NULL) {
38336 + PMD_DRV_LOG(ERR, "dpni is NULL");
38340 + ret = dpni_get_primary_mac_addr(dpni, CMD_PRI_LOW,
38341 + priv->token, addr->addr_bytes);
38344 + PMD_DRV_LOG(ERR, "Getting the MAC ADDR failed");
38350 +/*int dpni_clear_mac_filters(struct fsl_mc_io *mc_io,
38351 + uint32_t cmd_flags,
38356 +int dpni_set_vlan_insertion(struct fsl_mc_io *mc_io,
38357 + uint32_t cmd_flags,
38361 +dpni_set_errors_behavior
38363 +int dpni_get_l3_chksum_validation(struct fsl_mc_io *mc_io,
38364 + uint32_t cmd_flags,
38368 +int dpni_set_l3_chksum_validation(struct fsl_mc_io *mc_io,
38369 + uint32_t cmd_flags,
38373 +int dpni_get_l4_chksum_validation(struct fsl_mc_io *mc_io,
38374 + uint32_t cmd_flags,
38378 +int dpni_set_l4_chksum_validation(struct fsl_mc_io *mc_io,
38379 + uint32_t cmd_flags,
38385 +static int dpaa2_timestamp_enable(struct rte_eth_dev *dev)
38387 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38388 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38390 + struct dpni_buffer_layout layout;
38393 + layout.options = DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
38394 + layout.pass_timestamp = TRUE;
38396 + ret = dpni_set_rx_buffer_layout(dpni, CMD_PRI_LOW, priv->token, &layout);
38398 + PMD_DRV_LOG(ERR, "Enabling timestamp for Rx failed with"
38399 + "err code: %d", ret);
38403 + ret = dpni_set_tx_buffer_layout(dpni, CMD_PRI_LOW, priv->token, &layout);
38405 + PMD_DRV_LOG(ERR, "Enabling timestamp failed for Tx with"
38406 + "err code: %d", ret);
38410 + ret = dpni_set_tx_conf_buffer_layout(dpni, CMD_PRI_LOW,
38411 + priv->token, &layout);
38413 + PMD_DRV_LOG(ERR, "Enabling timestamp failed for Tx-conf with"
38414 + "err code: %d", ret);
38421 +static int dpaa2_timestamp_disable(struct rte_eth_dev *dev)
38423 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38424 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38425 + struct dpni_buffer_layout layout;
38428 + layout.options = DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
38429 + layout.pass_timestamp = FALSE;
38431 + ret = dpni_set_rx_buffer_layout(dpni, CMD_PRI_LOW, priv->token, &layout);
38433 + PMD_DRV_LOG(ERR, "Disabling timestamp failed for Rx with"
38434 + "err code: %d", ret);
38438 + ret = dpni_set_tx_buffer_layout(dpni, CMD_PRI_LOW, priv->token, &layout);
38440 + PMD_DRV_LOG(ERR, "Disabling timestamp failed for Tx with"
38441 + "err code: %d", ret);
38445 + ret = dpni_set_tx_conf_buffer_layout(dpni, CMD_PRI_LOW,
38446 + priv->token, &layout);
38448 + PMD_DRV_LOG(ERR, "Disabling timestamp failed for Tx-conf with"
38449 + "err code: %d", ret);
38456 +/* return 0 means link status changed, -1 means not changed */
38458 +dpaa2_dev_get_link_info(struct rte_eth_dev *dev,
38459 + int wait_to_complete __rte_unused)
38462 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38463 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38464 + struct rte_eth_link link, old;
38465 + struct dpni_link_state state = {0};
38467 + if (dpni == NULL) {
38468 + PMD_DRV_LOG(ERR, "dpni is NULL");
38471 + memset(&old, 0, sizeof(old));
38472 + rte_dpni_dev_atomic_read_link_status(dev, &old);
38474 + ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
38476 + PMD_DRV_LOG(ERR, "dpni_get_link_state");
38480 + if (state.up == 0) {
38481 + rte_dpni_dev_atomic_write_link_status(dev, &link);
38482 + if (state.up == old.link_status)
38486 + link.link_status = state.up;
38487 + link.link_speed = state.rate;
38489 + if (state.options & DPNI_LINK_OPT_HALF_DUPLEX)
38490 + link.link_duplex = ETH_LINK_HALF_DUPLEX;
38492 + link.link_duplex = ETH_LINK_FULL_DUPLEX;
38494 + rte_dpni_dev_atomic_write_link_status(dev, &link);
38496 + if (link.link_status == old.link_status)
38503 +void dpaa2_dev_stats_get(struct rte_eth_dev *dev,
38504 + struct rte_eth_stats *stats)
38506 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38507 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38512 + if (dpni == NULL) {
38513 + PMD_DRV_LOG(ERR, "dpni is NULL");
38518 + PMD_DRV_LOG(ERR, "stats is NULL");
38522 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38523 + DPNI_CNT_ING_FRAME, &value);
38526 + stats->ipackets = value;
38527 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38528 + DPNI_CNT_ING_BYTE, &value);
38531 + stats->ibytes = value;
38532 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38533 + DPNI_CNT_ING_FRAME_DROP, &value);
38536 + stats->ierrors = value;
38537 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38538 + DPNI_CNT_ING_FRAME_DISCARD, &value);
38541 + stats->ierrors = stats->ierrors + value;
38542 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38543 + DPNI_CNT_EGR_FRAME, &value);
38546 + stats->opackets = value;
38547 + dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38548 + DPNI_CNT_EGR_BYTE, &value);
38551 + stats->obytes = value;
38552 + retcode = dpni_get_counter(dpni, CMD_PRI_LOW, priv->token,
38553 + DPNI_CNT_EGR_FRAME_DISCARD, &value);
38556 + stats->oerrors = value;
38561 + PMD_DRV_LOG(ERR, "Operation not completed:Error Code = %d\n", retcode);
38566 +void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
38568 + struct dpaa2_dev_priv *priv = dev->data->dev_private;
38569 + struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
38573 + if (dpni == NULL) {
38574 + PMD_DRV_LOG(ERR, "dpni is NULL");
38578 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38579 + DPNI_CNT_ING_FRAME, 0);
38582 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38583 + DPNI_CNT_ING_BYTE, 0);
38586 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38587 + DPNI_CNT_ING_BCAST_FRAME, 0);
38590 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38591 + DPNI_CNT_ING_BCAST_BYTES, 0);
38594 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38595 + DPNI_CNT_ING_MCAST_FRAME, 0);
38598 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38599 + DPNI_CNT_ING_MCAST_BYTE, 0);
38602 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38603 + DPNI_CNT_ING_FRAME_DROP, 0);
38606 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38607 + DPNI_CNT_ING_FRAME_DISCARD, 0);
38610 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38611 + DPNI_CNT_EGR_FRAME, 0);
38614 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38615 + DPNI_CNT_EGR_BYTE, 0);
38618 + retcode = dpni_set_counter(dpni, CMD_PRI_LOW, priv->token,
38619 + DPNI_CNT_EGR_FRAME_DISCARD, 0);
38626 + PMD_DRV_LOG(ERR, "Operation not completed:Error Code = %d\n", retcode);
38630 +static struct eth_dev_ops ops = {
38631 + .dev_configure = dpaa2_eth_dev_configure,
38632 + .dev_start = dpaa2_dev_start,
38633 + .dev_stop = dpaa2_dev_stop,
38634 + .dev_close = dpaa2_dev_close,
38635 + .promiscuous_enable = dpaa2_dev_promiscuous_enable,
38636 + .promiscuous_disable = dpaa2_dev_promiscuous_disable,
38637 + .allmulticast_enable = dpaa2_dev_allmulticast_enable,
38638 + .allmulticast_disable = dpaa2_dev_allmulticast_disable,
38639 + .dev_set_link_up = NULL,
38640 + .dev_set_link_down = NULL,
38641 + .link_update = dpaa2_dev_get_link_info,
38642 + .stats_get = dpaa2_dev_stats_get,
38643 + .stats_reset = dpaa2_dev_stats_reset,
38644 + .dev_infos_get = dpaa2_eth_dev_info,
38645 + .dev_supported_ptypes_get = dpaa2_supported_ptypes_get,
38646 + .mtu_set = dpaa2_dev_mtu_set,
38647 + .vlan_filter_set = dpaa2_vlan_filter_set,
38648 + .vlan_tpid_set = NULL,
38649 + .vlan_offload_set = dpaa2_vlan_offload_set,
38650 + .vlan_strip_queue_set = NULL,
38651 + .vlan_pvid_set = NULL,
38652 + .rx_queue_setup = dpaa2_rx_queue_setup,
38653 + .rx_queue_release = dpaa2_rx_queue_release,
38654 + .tx_queue_setup = dpaa2_tx_queue_setup,
38655 + .tx_queue_release = dpaa2_tx_queue_release,
38656 + .dev_led_on = NULL,
38657 + .dev_led_off = NULL,
38658 + .set_queue_rate_limit = NULL,
38659 + .flow_ctrl_get = NULL,
38660 + .flow_ctrl_set = dpaa2_flow_ctrl_set,
38661 + .priority_flow_ctrl_set = NULL,
38662 + .mac_addr_add = dpaa2_dev_add_mac_addr,
38663 + .mac_addr_remove = dpaa2_dev_remove_mac_addr,
38664 + .rxq_info_get = NULL,
38665 + .txq_info_get = NULL,
38666 + .timesync_enable = dpaa2_timestamp_enable,
38667 + .timesync_disable = dpaa2_timestamp_disable,
38668 + .mac_addr_set = dpaa2_dev_set_mac_addr,
38672 +dpaa2_dev_init(struct rte_eth_dev *eth_dev)
38674 + struct rte_eth_dev_data *data = eth_dev->data;
38675 + struct fsl_mc_io *dpni_dev;
38676 + struct dpni_attr attr;
38677 + struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
38678 + struct dpni_buffer_layout layout;
38679 + int i, ret, hw_id = eth_dev->pci_dev->addr.devid;
38680 + struct dpni_extended_cfg *ext_cfg = NULL;
38683 + PMD_INIT_FUNC_TRACE();
38685 + dpni_dev = (struct fsl_mc_io *)malloc(sizeof(struct fsl_mc_io));
38687 + PMD_DRV_LOG(ERR, "malloc failed for dpni device\n");
38691 + dpni_dev->regs = mcp_ptr_list[0];
38692 + ret = dpni_open(dpni_dev, CMD_PRI_LOW, hw_id, &priv->token);
38694 + PMD_DRV_LOG(ERR, "Failure in opening dpni@%d device with"
38695 + "error code %d\n", hw_id, ret);
38699 + /* Clean the device first */
38700 + ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token);
38702 + PMD_DRV_LOG(ERR, "Failure cleaning dpni@%d device with"
38703 + "error code %d\n", hw_id, ret);
38707 + ext_cfg = (struct dpni_extended_cfg *)rte_malloc(NULL, 256,
38708 + RTE_CACHE_LINE_SIZE);
38710 + PMD_DRV_LOG(ERR, "No data memory\n");
38713 + attr.ext_cfg_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(ext_cfg));
38715 + ret = dpni_get_attributes(dpni_dev, CMD_PRI_LOW, priv->token, &attr);
38717 + PMD_DRV_LOG(ERR, "Failure in getting dpni@%d attribute, "
38718 + "error code %d\n", hw_id, ret);
38722 + priv->num_tc = attr.max_tcs;
38723 + for (i = 0; i < attr.max_tcs; i++) {
38724 + priv->num_dist_per_tc[i] = ext_cfg->tc_cfg[i].max_dist;
38725 + priv->nb_rx_queues += priv->num_dist_per_tc[i];
38728 + if (attr.max_tcs == 1)
38729 + priv->nb_tx_queues = attr.max_senders;
38731 + priv->nb_tx_queues = attr.max_tcs;
38732 + PMD_DRV_LOG(INFO, "num_tc %d", priv->num_tc);
38733 + PMD_DRV_LOG(INFO, "nb_rx_queues %d", priv->nb_rx_queues);
38735 + eth_dev->data->nb_rx_queues = priv->nb_rx_queues;
38736 + eth_dev->data->nb_tx_queues = priv->nb_tx_queues;
38738 + priv->hw = dpni_dev;
38739 + priv->hw_id = hw_id;
38740 + priv->options = attr.options;
38742 + priv->max_unicast_filters = attr.max_unicast_filters;
38743 + priv->max_multicast_filters = attr.max_multicast_filters;
38745 + if (attr.options & DPNI_OPT_VLAN_FILTER)
38746 + priv->max_vlan_filters = attr.max_vlan_filters;
38748 + priv->max_vlan_filters = 0;
38750 + ret = dpaa2_alloc_rx_tx_queues(eth_dev);
38752 + PMD_DRV_LOG(ERR, "dpaa2_alloc_rx_tx_queuesFailed\n");
38756 + data->mac_addrs = (struct ether_addr *)malloc(sizeof(struct ether_addr));
38758 + /* Allocate memory for storing MAC addresses */
38759 + eth_dev->data->mac_addrs = rte_zmalloc("dpni",
38760 + ETHER_ADDR_LEN * attr.max_unicast_filters, 0);
38761 + if (eth_dev->data->mac_addrs == NULL) {
38762 + PMD_DRV_LOG(ERR, "Failed to allocate %d bytes needed to "
38763 + "store MAC addresses",
38764 + ETHER_ADDR_LEN * attr.max_unicast_filters);
38768 + ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
38770 + (uint8_t *)(data->mac_addrs[0].addr_bytes));
38772 + PMD_DRV_LOG(ERR, "DPNI get mac address failed:"
38773 + " Error Code = %d\n", ret);
38777 + PMD_DRV_LOG(INFO, "Adding Broadcast Address...");
38778 + memset(data->mac_addrs[1].addr_bytes, 0xff, ETH_ADDR_LEN);
38779 + ret = dpni_add_mac_addr(dpni_dev, CMD_PRI_LOW,
38781 + (uint8_t *)(data->mac_addrs[1].addr_bytes));
38783 + PMD_DRV_LOG(ERR, "DPNI set broadcast mac address failed:"
38784 + " Error Code = %0x\n", ret);
38788 + /* ... rx buffer layout ... */
38789 + tot_size = DPAA2_HW_BUF_RESERVE + RTE_PKTMBUF_HEADROOM;
38790 + tot_size = RTE_ALIGN_CEIL(tot_size,
38791 + DPAA2_PACKET_LAYOUT_ALIGN);
38793 + memset(&layout, 0, sizeof(struct dpni_buffer_layout));
38794 + layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
38795 + DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
38796 + DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
38797 + DPNI_BUF_LAYOUT_OPT_DATA_HEAD_ROOM |
38798 + DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
38800 + layout.pass_frame_status = 1;
38801 + layout.data_head_room = tot_size
38802 + - DPAA2_FD_PTA_SIZE - DPAA2_MBUF_HW_ANNOTATION;
38803 + layout.private_data_size = DPAA2_FD_PTA_SIZE;
38804 + layout.pass_timestamp = 1;
38805 + layout.pass_parser_result = 1;
38806 + PMD_DRV_LOG(INFO, "Tot_size = %d, head room = %d, private = %d",
38807 + tot_size, layout.data_head_room, layout.private_data_size);
38808 + ret = dpni_set_rx_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
38811 + PMD_DRV_LOG(ERR, "Err(%d) in setting rx buffer layout\n", ret);
38815 + /* ... tx buffer layout ... */
38816 + memset(&layout, 0, sizeof(struct dpni_buffer_layout));
38817 + layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
38818 + DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
38819 + layout.pass_frame_status = 1;
38820 + layout.pass_timestamp = 1;
38821 + ret = dpni_set_tx_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token, &layout);
38823 + PMD_DRV_LOG(ERR, "Error (%d) in setting tx buffer layout\n", ret);
38827 + /* ... tx-conf and error buffer layout ... */
38828 + memset(&layout, 0, sizeof(struct dpni_buffer_layout));
38829 + layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
38830 + DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
38831 + layout.pass_frame_status = 1;
38832 + layout.pass_timestamp = 1;
38833 + ret = dpni_set_tx_conf_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token, &layout);
38835 + PMD_DRV_LOG(ERR, "Error (%d) in setting tx-conf buffer layout\n", ret);
38839 + /* TODO - Set the MTU if required */
38841 + eth_dev->dev_ops = &ops;
38842 + eth_dev->rx_pkt_burst = eth_dpaa2_prefetch_rx;/*eth_dpaa2_rx;*/
38843 + eth_dev->tx_pkt_burst = eth_dpaa2_tx;
38845 + rte_free(ext_cfg);
38850 +static struct eth_driver rte_dpaa2_dpni = {
38852 + .name = "rte_dpaa2_dpni",
38853 + .id_table = pci_id_dpaa2_map,
38855 + .eth_dev_init = dpaa2_dev_init,
38856 + .dev_private_size = sizeof(struct dpaa2_dev_priv),
38860 +rte_pmd_dpaa2_devinit(
38861 + const char *name __rte_unused,
38862 + const char *params __rte_unused)
38864 + PMD_DRV_LOG(INFO, "Initializing dpaa2_pmd for %s\n", name);
38865 + rte_eth_driver_register(&rte_dpaa2_dpni);
38870 +static struct rte_driver pmd_dpaa2_drv = {
38871 + .name = "dpaa2_pmd",
38872 + .type = PMD_PDEV,
38873 + .init = rte_pmd_dpaa2_devinit,
38876 +PMD_REGISTER_DRIVER(pmd_dpaa2_drv, dpaa2);
38877 diff --git a/drivers/net/dpaa2/rte_eth_dpni_annot.h b/drivers/net/dpaa2/rte_eth_dpni_annot.h
38878 new file mode 100644
38879 index 0000000..0c3ae82
38881 +++ b/drivers/net/dpaa2/rte_eth_dpni_annot.h
38886 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
38888 + * Redistribution and use in source and binary forms, with or without
38889 + * modification, are permitted provided that the following conditions
38892 + * * Redistributions of source code must retain the above copyright
38893 + * notice, this list of conditions and the following disclaimer.
38894 + * * Redistributions in binary form must reproduce the above copyright
38895 + * notice, this list of conditions and the following disclaimer in
38896 + * the documentation and/or other materials provided with the
38898 + * * Neither the name of Freescale Semiconductor, Inc nor the names of its
38899 + * contributors may be used to endorse or promote products derived
38900 + * from this software without specific prior written permission.
38902 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38903 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38904 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
38905 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
38906 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
38907 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
38908 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
38909 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38910 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38911 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38912 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38918 + * DPNI packet parse results - implementation internal
38921 +#ifndef RTE_ETH_DPNI_ANNOT_H_
38922 +#define RTE_ETH_DPNI_ANNOT_H_
38924 +#ifdef __cplusplus
38928 +/* Annotation valid bits in FD FRC */
38929 +#define DPAA2_FD_FRC_FASV 0x8000
38930 +#define DPAA2_FD_FRC_FAEADV 0x4000
38931 +#define DPAA2_FD_FRC_FAPRV 0x2000
38932 +#define DPAA2_FD_FRC_FAIADV 0x1000
38933 +#define DPAA2_FD_FRC_FASWOV 0x0800
38934 +#define DPAA2_FD_FRC_FAICFDV 0x0400
38936 +/* Annotation bits in FD CTRL */
38937 +#define DPAA2_FD_CTRL_ASAL 0x00020000 /* ASAL = 128 */
38938 +#define DPAA2_FD_CTRL_PTA 0x00800000
38939 +#define DPAA2_FD_CTRL_PTV1 0x00400000
38941 +/* Frame annotation status */
38942 +struct dpaa2_fas {
38943 + uint8_t reserved;
38950 + * Internal Packet annotation header
38952 +struct pkt_annotation {
38953 + /**< word1: Frame Annotation Status (8 bytes)*/
38955 + /**< word2: Time Stamp (8 bytes)*/
38957 + /**< word3: Next Hdr + FAF Extension + FAF (2 + 2 + 4 bytes)*/
38959 + /**< word4: Frame Annotation Flags-FAF (8 bytes) */
38962 + ShimOffset_1 + ShimOffset_2 + IPPIDOffset + EthOffset +
38963 + LLC+SNAPOffset + VLANTCIOffset_1 + VLANTCIOffset_n +
38964 + LastETypeOffset (1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes)
38968 + PPPoEOffset + MPLSOffset_1 + MPLSOffset_n + ARPorIPOffset_1
38969 + + IPOffset_norMInEncapO + GREOffset + L4Offset +
38970 + GTPorESPorIPSecOffset(1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 bytes)
38974 + RoutingHdrOfset1 + RoutingHdrOfset2 + NxtHdrOffset + IPv6FragOffset +
38975 + GrossRunningSum + RunningSum(1 + 1 + 1 + 1 + 2 + 2 bytes)
38979 + ParseErrorcode + Soft Parsing Context (1 + 7 bytes)
38981 + uint64_t word8; /**< Layer 4 length */
38985 + * Internal Macros to get/set Packet annotation header
38988 +/** General Macro to define a particular bit position*/
38989 +#define BIT_POS(x) ((uint64_t)1 << ((x)))
38990 +/** Set a bit in the variable */
38991 +#define BIT_SET_AT_POS(var, pos) (var |= pos)
38992 +/** Reset the bit in the variable */
38993 +#define BIT_RESET_AT_POS(var, pos) (var &= ~(pos))
38994 +/** Check the bit is set in the variable */
38995 +#define BIT_ISSET_AT_POS(var, pos) ((var & pos) ? 1 : 0)
38997 + * Macrso to define bit position in word3
38999 +#define NEXT_HDR(var) ((uint64_t)var & 0xFFFF000000000000)
39000 +#define FAF_EXTN_IPV6_ROUTE_HDR_PRESENT(var) BIT_POS(16)
39001 +#define FAF_EXTN_RESERVED(var) ((uint64_t)var & 0x00007FFF00000000)
39002 +#define FAF_USER_DEFINED_RESERVED(var) ((uint64_t)var & 0x00000000FF000000)
39003 +#define SHIM_SHELL_SOFT_PARSING_ERRROR BIT_POS(23)
39004 +#define PARSING_ERROR BIT_POS(22)
39005 +#define L2_ETH_MAC_PRESENT BIT_POS(21)
39006 +#define L2_ETH_MAC_UNICAST BIT_POS(20)
39007 +#define L2_ETH_MAC_MULTICAST BIT_POS(19)
39008 +#define L2_ETH_MAC_BROADCAST BIT_POS(18)
39009 +#define L2_ETH_FRAME_IS_BPDU BIT_POS(17)
39010 +#define L2_ETH_FCOE_PRESENT BIT_POS(16)
39011 +#define L2_ETH_FIP_PRESENT BIT_POS(15)
39012 +#define L2_ETH_PARSING_ERROR BIT_POS(14)
39013 +#define L2_LLC_SNAP_PRESENT BIT_POS(13)
39014 +#define L2_UNKNOWN_LLC_OUI BIT_POS(12)
39015 +#define L2_LLC_SNAP_ERROR BIT_POS(11)
39016 +#define L2_VLAN_1_PRESENT BIT_POS(10)
39017 +#define L2_VLAN_N_PRESENT BIT_POS(9)
39018 +#define L2_VLAN_CFI_BIT_PRESENT BIT_POS(8)
39019 +#define L2_VLAN_PARSING_ERROR BIT_POS(7)
39020 +#define L2_PPPOE_PPP_PRESENT BIT_POS(6)
39021 +#define L2_PPPOE_PPP_PARSING_ERROR BIT_POS(5)
39022 +#define L2_MPLS_1_PRESENT BIT_POS(4)
39023 +#define L2_MPLS_N_PRESENT BIT_POS(3)
39024 +#define L2_MPLS_PARSING_ERROR BIT_POS(2)
39025 +#define L2_ARP_PRESENT BIT_POS(1)
39026 +#define L2_ARP_PARSING_ERROR BIT_POS(0)
39028 + * Macrso to define bit position in word4
39030 +#define L2_UNKNOWN_PROTOCOL BIT_POS(63)
39031 +#define L2_SOFT_PARSING_ERROR BIT_POS(62)
39032 +#define L3_IPV4_1_PRESENT BIT_POS(61)
39033 +#define L3_IPV4_1_UNICAST BIT_POS(60)
39034 +#define L3_IPV4_1_MULTICAST BIT_POS(59)
39035 +#define L3_IPV4_1_BROADCAST BIT_POS(58)
39036 +#define L3_IPV4_N_PRESENT BIT_POS(57)
39037 +#define L3_IPV4_N_UNICAST BIT_POS(56)
39038 +#define L3_IPV4_N_MULTICAST BIT_POS(55)
39039 +#define L3_IPV4_N_BROADCAST BIT_POS(54)
39040 +#define L3_IPV6_1_PRESENT BIT_POS(53)
39041 +#define L3_IPV6_1_UNICAST BIT_POS(52)
39042 +#define L3_IPV6_1_MULTICAST BIT_POS(51)
39043 +#define L3_IPV6_N_PRESENT BIT_POS(50)
39044 +#define L3_IPV6_N_UNICAST BIT_POS(49)
39045 +#define L3_IPV6_N_MULTICAST BIT_POS(48)
39046 +#define L3_IP_1_OPT_PRESENT BIT_POS(47)
39047 +#define L3_IP_1_UNKNOWN_PROTOCOL BIT_POS(46)
39048 +#define L3_IP_1_MORE_FRAGMENT BIT_POS(45)
39049 +#define L3_IP_1_FIRST_FRAGMENT BIT_POS(44)
39050 +#define L3_IP_1_PARSING_ERROR BIT_POS(43)
39051 +#define L3_IP_N_OPT_PRESENT BIT_POS(42)
39052 +#define L3_IP_N_UNKNOWN_PROTOCOL BIT_POS(41)
39053 +#define L3_IP_N_MORE_FRAGMENT BIT_POS(40)
39054 +#define L3_IP_N_FIRST_FRAGMENT BIT_POS(39)
39055 +#define L3_PROTO_ICMP_PRESENT BIT_POS(38)
39056 +#define L3_PROTO_IGMP_PRESENT BIT_POS(37)
39057 +#define L3_PROTO_ICMPV6_PRESENT BIT_POS(36)
39058 +#define L3_PROTO_UDP_LIGHT_PRESENT BIT_POS(35)
39059 +#define L3_IP_N_PARSING_ERROR BIT_POS(34)
39060 +#define L3_MIN_ENCAP_PRESENT BIT_POS(33)
39061 +#define L3_MIN_ENCAP_SBIT_PRESENT BIT_POS(32)
39062 +#define L3_MIN_ENCAP_PARSING_ERROR BIT_POS(31)
39063 +#define L3_PROTO_GRE_PRESENT BIT_POS(30)
39064 +#define L3_PROTO_GRE_RBIT_PRESENT BIT_POS(29)
39065 +#define L3_PROTO_GRE_PARSING_ERROR BIT_POS(28)
39066 +#define L3_IP_UNKNOWN_PROTOCOL BIT_POS(27)
39067 +#define L3_SOFT_PARSING_ERROR BIT_POS(26)
39068 +#define L3_PROTO_UDP_PRESENT BIT_POS(25)
39069 +#define L3_PROTO_UDP_PARSING_ERROR BIT_POS(24)
39070 +#define L3_PROTO_TCP_PRESENT BIT_POS(23)
39071 +#define L3_PROTO_TCP_OPT_PRESENT BIT_POS(22)
39072 +#define L3_PROTO_TCP_CTRL_BIT_6_TO_11_PRESENT BIT_POS(21)
39073 +#define L3_PROTO_TCP_CTRL_BIT_3_TO_5_PRESENT BIT_POS(20)
39074 +#define L3_PROTO_TCP_PARSING_ERROR BIT_POS(19)
39075 +#define L3_PROTO_IPSEC_PRESENT BIT_POS(18)
39076 +#define L3_PROTO_IPSEC_ESP_PRESENT BIT_POS(17)
39077 +#define L3_PROTO_IPSEC_AH_PRESENT BIT_POS(16)
39078 +#define L3_PROTO_IPSEC_PARSING_ERROR BIT_POS(15)
39079 +#define L3_PROTO_SCTP_PRESENT BIT_POS(14)
39080 +#define L3_PROTO_SCTP_PARSING_ERROR BIT_POS(13)
39081 +#define L3_PROTO_DCCP_PRESENT BIT_POS(12)
39082 +#define L3_PROTO_DCCP_PARSING_ERROR BIT_POS(11)
39083 +#define L4_UNKNOWN_PROTOCOL BIT_POS(10)
39084 +#define L4_SOFT_PARSING_ERROR BIT_POS(9)
39085 +#define L3_PROTO_GTP_PRESENT BIT_POS(8)
39086 +#define L3_PROTO_GTP_PARSING_ERROR BIT_POS(7)
39087 +#define L3_PROTO_ESP_PRESENT BIT_POS(6)
39088 +#define L3_PROTO_ESP_PARSING_ERROR BIT_POS(5)
39089 +#define L3_PROTO_ISCSI_PRESENT BIT_POS(4)
39090 +#define L3_PROTO_CAPWAN__CTRL_PRESENT BIT_POS(3)
39091 +#define L3_PROTO_CAPWAN__DATA_PRESENT BIT_POS(2)
39092 +#define L5_SOFT_PARSING_ERROR BIT_POS(1)
39093 +#define L3_IPV6_ROUTE_HDR_PRESENT BIT_POS(0)
39096 + * Macros to get values in word5
39098 +#define SHIM_OFFSET_1(var) ((uint64_t)var & 0xFF00000000000000)
39099 +#define SHIM_OFFSET_2(var) ((uint64_t)var & 0x00FF000000000000)
39100 +#define IP_PID_OFFSET(var) ((uint64_t)var & 0x0000FF0000000000)
39101 +#define ETH_OFFSET(var) ((uint64_t)var & 0x000000FF00000000)
39102 +#define LLC_SNAP_OFFSET(var) ((uint64_t)var & 0x00000000FF000000)
39103 +#define VLAN_TCI_OFFSET_1(var) ((uint64_t)var & 0x0000000000FF0000)
39104 +#define VLAN_TCI_OFFSET_N(var) ((uint64_t)var & 0x000000000000FF00)
39105 +#define LAST_ETYPE_OFFSET(var) ((uint64_t)var & 0x00000000000000FF)
39108 + * Macros to get values in word6
39110 +#define PPPOE_OFFSET(var) ((uint64_t)var & 0xFF00000000000000)
39111 +#define MPLS_OFFSET_1(var) ((uint64_t)var & 0x00FF000000000000)
39112 +#define MPLS_OFFSET_N(var) ((uint64_t)var & 0x0000FF0000000000)
39113 +#define ARP_OR_IP_OFFSET_1(var) ((uint64_t)var & 0x000000FF00000000)
39114 +#define IP_N_OR_MIN_ENCAP_OFFSET(var) ((uint64_t)var & 0x00000000FF000000)
39115 +#define GRE_OFFSET(var) ((uint64_t)var & 0x0000000000FF0000)
39116 +#define L4_OFFSET(var) ((uint64_t)var & 0x000000000000FF00)
39117 +#define GTP_OR_ESP_OR_IPSEC_OFFSET(var) ((uint64_t)var & 0x00000000000000FF)
39120 + * Macros to get values in word7
39122 +#define IPV6_ROUTING_HDR_OFFSET_1(var) ((uint64_t)var & 0xFF00000000000000)
39123 +#define IPV6_ROUTING_HDR_OFFSET_2(var) ((uint64_t)var & 0x00FF000000000000)
39124 +#define NEXT_HDR_OFFSET(var) ((uint64_t)var & 0x0000FF0000000000)
39125 +#define IPV6_FRAG_OFFSET(var) ((uint64_t)var & 0x000000FF00000000)
39126 +#define GROSS_RUNNING_SUM(var) ((uint64_t)var & 0x00000000FFFF0000)
39127 +#define RUNNING_SUM(var) ((uint64_t)var & 0x000000000000FFFF)
39130 + * Macros to get values in word8
39132 +#define PARSE_ERROR_CODE(var) ((uint64_t)var & 0xFF00000000000000)
39133 +#define SOFT_PARSING_CONTEXT(var) ((uint64_t)var & 0x00FFFFFFFFFFFFFF)
39135 +/* Debug frame, otherwise supposed to be discarded */
39136 +#define DPAA2_ETH_FAS_DISC 0x80000000
39137 +/* MACSEC frame */
39138 +#define DPAA2_ETH_FAS_MS 0x40000000
39139 +#define DPAA2_ETH_FAS_PTP 0x08000000
39140 +/* Ethernet multicast frame */
39141 +#define DPAA2_ETH_FAS_MC 0x04000000
39142 +/* Ethernet broadcast frame */
39143 +#define DPAA2_ETH_FAS_BC 0x02000000
39144 +#define DPAA2_ETH_FAS_KSE 0x00040000
39145 +#define DPAA2_ETH_FAS_EOFHE 0x00020000
39146 +#define DPAA2_ETH_FAS_MNLE 0x00010000
39147 +#define DPAA2_ETH_FAS_TIDE 0x00008000
39148 +#define DPAA2_ETH_FAS_PIEE 0x00004000
39149 +/* Frame length error */
39150 +#define DPAA2_ETH_FAS_FLE 0x00002000
39151 +/* Frame physical error; our favourite pastime */
39152 +#define DPAA2_ETH_FAS_FPE 0x00001000
39153 +#define DPAA2_ETH_FAS_PTE 0x00000080
39154 +#define DPAA2_ETH_FAS_ISP 0x00000040
39155 +#define DPAA2_ETH_FAS_PHE 0x00000020
39156 +#define DPAA2_ETH_FAS_BLE 0x00000010
39157 +/* L3 csum validation performed */
39158 +#define DPAA2_ETH_FAS_L3CV 0x00000008
39159 +/* L3 csum error */
39160 +#define DPAA2_ETH_FAS_L3CE 0x00000004
39161 +/* L4 csum validation performed */
39162 +#define DPAA2_ETH_FAS_L4CV 0x00000002
39163 +/* L4 csum error */
39164 +#define DPAA2_ETH_FAS_L4CE 0x00000001
39166 +/* These bits always signal errors */
39167 +#define DPAA2_ETH_RX_ERR_MASK (DPAA2_ETH_FAS_KSE | \
39168 + DPAA2_ETH_FAS_EOFHE | \
39169 + DPAA2_ETH_FAS_MNLE | \
39170 + DPAA2_ETH_FAS_TIDE | \
39171 + DPAA2_ETH_FAS_PIEE | \
39172 + DPAA2_ETH_FAS_FLE | \
39173 + DPAA2_ETH_FAS_FPE | \
39174 + DPAA2_ETH_FAS_PTE | \
39175 + DPAA2_ETH_FAS_ISP | \
39176 + DPAA2_ETH_FAS_PHE | \
39177 + DPAA2_ETH_FAS_BLE | \
39178 + DPAA2_ETH_FAS_L3CE | \
39179 + DPAA2_ETH_FAS_L4CE)
39180 +/* Unsupported features in the ingress */
39181 +#define DPAA2_ETH_RX_UNSUPP_MASK DPAA2_ETH_FAS_MS
39183 +#define DPAA2_ETH_TXCONF_ERR_MASK (DPAA2_ETH_FAS_KSE | \
39184 + DPAA2_ETH_FAS_EOFHE | \
39185 + DPAA2_ETH_FAS_MNLE | \
39186 + DPAA2_ETH_FAS_TIDE)
39188 +#ifdef __cplusplus
39193 diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/common/eal_private.h
39194 index 857dc3e..3dc9544 100644
39195 --- a/lib/librte_eal/common/eal_private.h
39196 +++ b/lib/librte_eal/common/eal_private.h
39197 @@ -325,4 +325,11 @@ int rte_eal_hugepage_init(void);
39199 int rte_eal_hugepage_attach(void);
39201 +#ifdef RTE_LIBRTE_DPAA2_PMD
39203 + * Initialize any soc init related functions if any before thread creation
39205 +int rte_eal_soc_pre_init(void);
39208 #endif /* _EAL_PRIVATE_H_ */
39209 diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile
39210 index 182729c..ed5be74 100644
39211 --- a/lib/librte_eal/linuxapp/eal/Makefile
39212 +++ b/lib/librte_eal/linuxapp/eal/Makefile
39213 @@ -76,6 +76,10 @@ SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_lcore.c
39214 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_timer.c
39215 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_interrupts.c
39216 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_alarm.c
39217 +ifeq ($(CONFIG_RTE_LIBRTE_DPAA2_PMD),y)
39218 +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_soc.c
39219 +SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_vfio_fsl_mc.c
39221 ifeq ($(CONFIG_RTE_LIBRTE_IVSHMEM),y)
39222 SRCS-$(CONFIG_RTE_EXEC_ENV_LINUXAPP) += eal_ivshmem.c
39224 diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c
39225 index 3fb2188..832c252 100644
39226 --- a/lib/librte_eal/linuxapp/eal/eal.c
39227 +++ b/lib/librte_eal/linuxapp/eal/eal.c
39228 @@ -814,6 +814,11 @@ rte_eal_init(int argc, char **argv)
39229 if (rte_eal_tailqs_init() < 0)
39230 rte_panic("Cannot init tail queues for objects\n");
39232 +#ifdef RTE_LIBRTE_DPAA2_PMD
39233 + if (rte_eal_soc_pre_init() < 0)
39234 + rte_panic("Cannot pre init soc\n");
39237 #ifdef RTE_LIBRTE_IVSHMEM
39238 if (rte_eal_ivshmem_obj_init() < 0)
39239 rte_panic("Cannot init IVSHMEM objects\n");
39240 diff --git a/lib/librte_eal/linuxapp/eal/eal_soc.c b/lib/librte_eal/linuxapp/eal/eal_soc.c
39241 new file mode 100644
39242 index 0000000..1595f68
39244 +++ b/lib/librte_eal/linuxapp/eal/eal_soc.c
39249 + * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
39251 + * Redistribution and use in source and binary forms, with or without
39252 + * modification, are permitted provided that the following conditions
39255 + * * Redistributions of source code must retain the above copyright
39256 + * notice, this list of conditions and the following disclaimer.
39257 + * * Redistributions in binary form must reproduce the above copyright
39258 + * notice, this list of conditions and the following disclaimer in
39259 + * the documentation and/or other materials provided with the
39261 + * * Neither the name of Freescale Semiconductor, Inc or the names of its
39262 + * contributors may be used to endorse or promote products derived
39263 + * from this software without specific prior written permission.
39265 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39266 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39267 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39268 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39269 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39270 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39271 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39272 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39273 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39274 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39275 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39278 +#include <unistd.h>
39279 +#include <limits.h>
39280 +#include <string.h>
39281 +#include <dirent.h>
39283 +#include <rte_log.h>
39284 +#include <rte_eal.h>
39285 +#include <rte_lcore.h>
39286 +#include <rte_common.h>
39287 +#include <rte_string_fns.h>
39288 +#include <rte_debug.h>
39289 +#include "eal_private.h"
39291 +#ifdef RTE_LIBRTE_DPAA2_PMD
39292 +#include "eal_vfio_fsl_mc.h"
39295 +#if (defined RTE_LIBRTE_DPAA_PMD)
39296 +extern int usdpaa_pre_rte_eal_init(void);
39299 +/* Initialize any soc init related functions if any before thread creation*/
39301 +rte_eal_soc_pre_init(void)
39303 +#ifdef RTE_LIBRTE_DPAA2_PMD
39304 + if (rte_eal_dpaa2_init() < 0)
39305 + RTE_LOG(WARNING, EAL, "Cannot init FSL_MC SCAN\n");
39307 +#if (defined RTE_LIBRTE_DPAA_PMD)
39308 + if (usdpaa_pre_rte_eal_init())
39309 + RTE_LOG(WARNING, EAL, "Cannot init FSL_DPAA \n");
39313 diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.c b/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.c
39314 new file mode 100644
39315 index 0000000..0ddaef9
39317 +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.c
39322 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
39324 + * Redistribution and use in source and binary forms, with or without
39325 + * modification, are permitted provided that the following conditions
39328 + * * Redistributions of source code must retain the above copyright
39329 + * notice, this list of conditions and the following disclaimer.
39330 + * * Redistributions in binary form must reproduce the above copyright
39331 + * notice, this list of conditions and the following disclaimer in
39332 + * the documentation and/or other materials provided with the
39334 + * * Neither the name of Freescale Semiconductor nor the names of its
39335 + * contributors may be used to endorse or promote products derived
39336 + * from this software without specific prior written permission.
39338 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39339 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39340 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39341 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39342 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39343 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
39344 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39345 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
39346 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39347 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
39348 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39351 +#include <unistd.h>
39352 +#include <stdio.h>
39353 +#include <sys/types.h>
39354 +#include <string.h>
39355 +#include <stdlib.h>
39356 +#include <fcntl.h>
39357 +#include <errno.h>
39358 +#include <sys/ioctl.h>
39359 +#include <sys/stat.h>
39360 +#include <sys/types.h>
39361 +#include <sys/mman.h>
39362 +#include <sys/vfs.h>
39363 +#include <libgen.h>
39364 +#include <dirent.h>
39366 +#include "rte_pci.h"
39367 +#include "eal_vfio.h"
39369 +#include <rte_log.h>
39371 +#include "eal_vfio_fsl_mc.h"
39373 +#include "rte_pci_dev_ids.h"
39374 +#include "eal_filesystem.h"
39375 +#include "eal_private.h"
39377 +#ifndef VFIO_MAX_GROUPS
39378 +#define VFIO_MAX_GROUPS 64
39381 +/* #define DPAA2_STAGE2_STASHING */
39383 +/** Pathname of FSL-MC devices directory. */
39384 +#define SYSFS_FSL_MC_DEVICES "/sys/bus/fsl-mc/devices"
39386 +/* Number of VFIO containers & groups with in */
39387 +static struct fsl_vfio_group vfio_groups[VFIO_MAX_GRP];
39388 +static struct fsl_vfio_container vfio_containers[VFIO_MAX_CONTAINERS];
39389 +static char *ls2bus_container;
39390 +static int container_device_fd;
39391 +static uint32_t *msi_intr_vaddr;
39392 +void *(*mcp_ptr_list);
39393 +static uint32_t mcp_id;
39395 +static int vfio_connect_container(struct fsl_vfio_group *vfio_group)
39397 + struct fsl_vfio_container *container;
39400 + /* Try connecting to vfio container already created */
39401 + for (i = 0; i < VFIO_MAX_CONTAINERS; i++) {
39402 + container = &vfio_containers[i];
39403 + if (!ioctl(vfio_group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) {
39404 + RTE_LOG(ERR, EAL, "Container pre-exists with FD[0x%x]"
39405 + " for this group\n", container->fd);
39406 + vfio_group->container = container;
39411 + /* Opens main vfio file descriptor which represents the "container" */
39412 + fd = open("/dev/vfio/vfio", O_RDWR);
39414 + RTE_LOG(ERR, EAL, "vfio: failed to open /dev/vfio/vfio\n");
39418 + ret = ioctl(fd, VFIO_GET_API_VERSION);
39419 + if (ret != VFIO_API_VERSION) {
39420 + RTE_LOG(ERR, EAL, "vfio: supported vfio version: %d, "
39421 + "reported version: %d", VFIO_API_VERSION, ret);
39425 +#ifndef DPAA2_STAGE2_STASHING
39426 + /* Check whether support for SMMU type IOMMU prresent or not */
39427 + if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
39428 + /* Connect group to container */
39429 + ret = ioctl(vfio_group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
39431 + RTE_LOG(ERR, EAL, "vfio: failed to set group container:\n");
39436 + ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
39438 + RTE_LOG(ERR, EAL, "vfio: failed to set iommu for container:\n");
39443 + RTE_LOG(ERR, EAL, "vfio error: No supported IOMMU\n");
39448 + /* Check whether support for SMMU type IOMMU stage 2 present or not */
39449 + if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_NESTING_IOMMU)) {
39450 + /* Connect group to container */
39451 + ret = ioctl(vfio_group->fd, VFIO_GROUP_SET_CONTAINER, &fd);
39453 + RTE_LOG(ERR, EAL, "vfio: failed to set group container:\n");
39458 + ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_NESTING_IOMMU);
39460 + RTE_LOG(ERR, EAL, "vfio: failed to set iommu-2 for container:\n");
39465 + RTE_LOG(ERR, EAL, "vfio error: No supported IOMMU-2\n");
39470 + container = NULL;
39471 + for (i = 0; i < VFIO_MAX_CONTAINERS; i++) {
39472 + if (vfio_containers[i].used)
39474 + RTE_LOG(ERR, EAL, "DPAA2-Unused container at index %d\n", i);
39475 + container = &vfio_containers[i];
39477 + if (!container) {
39478 + RTE_LOG(ERR, EAL, "vfio error: No Free Container Found\n");
39483 + container->used = 1;
39484 + container->fd = fd;
39485 + container->group_list[container->index] = vfio_group;
39486 + vfio_group->container = container;
39487 + container->index++;
39491 +static int vfio_map_irq_region(struct fsl_vfio_group *group)
39494 + unsigned long *vaddr = NULL;
39495 + struct vfio_iommu_type1_dma_map map = {
39496 + .argsz = sizeof(map),
39497 + .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
39498 + .vaddr = 0x6030000,
39499 + .iova = 0x6030000,
39503 + vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
39504 + PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
39505 + if (vaddr == MAP_FAILED) {
39506 + RTE_LOG(ERR, EAL, " mapping GITS region (errno = %d)", errno);
39510 + msi_intr_vaddr = (uint32_t *)((char *)(vaddr) + 64);
39511 + map.vaddr = (unsigned long)vaddr;
39512 + ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &map);
39516 + RTE_LOG(ERR, EAL, "vfio_map_irq_region fails (errno = %d)", errno);
39520 +int vfio_dmamap_mem_region(uint64_t vaddr,
39524 + struct fsl_vfio_group *group;
39525 + struct vfio_iommu_type1_dma_map dma_map = {
39526 + .argsz = sizeof(dma_map),
39527 + .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
39530 + dma_map.vaddr = vaddr;
39531 + dma_map.size = size;
39532 + dma_map.iova = iova;
39534 + /* SET DMA MAP for IOMMU */
39535 + group = &vfio_groups[0];
39536 + if (ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map)) {
39537 + RTE_LOG(ERR, EAL, "SWP: VFIO_IOMMU_MAP_DMA API Error %d.\n", errno);
39543 +static int32_t setup_dmamap(void)
39546 + struct fsl_vfio_group *group;
39547 + struct vfio_iommu_type1_dma_map dma_map = {
39548 + .argsz = sizeof(struct vfio_iommu_type1_dma_map),
39549 + .flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
39553 + const struct rte_memseg *memseg;
39555 + for (i = 0; i < RTE_MAX_MEMSEG; i++) {
39556 + memseg = rte_eal_get_physmem_layout();
39557 + if (memseg == NULL) {
39558 + RTE_LOG(ERR, EAL,
39559 + "\nError Cannot get physical layout\n");
39563 + if (memseg[i].addr == NULL && memseg[i].len == 0) {
39567 + dma_map.size = memseg[i].len;
39568 + dma_map.vaddr = memseg[i].addr_64;
39569 +#ifdef RTE_LIBRTE_DPAA2_USE_PHYS_IOVA
39570 + dma_map.iova = memseg[i].phys_addr;
39572 + dma_map.iova = dma_map.vaddr;
39575 + /* SET DMA MAP for IOMMU */
39576 + group = &vfio_groups[0];
39578 + printf("-->Initial SHM Virtual ADDR %llX\n", dma_map.vaddr);
39579 + printf("-----> DMA size 0x%llX\n", dma_map.size);
39580 + ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA, &dma_map);
39582 + RTE_LOG(ERR, EAL,
39583 + "\nErr: VFIO_IOMMU_MAP_DMA API Error %d.\n",
39587 + printf("-----> dma_map.vaddr = 0x%llX\n", dma_map.vaddr);
39590 + /* TODO - This is a W.A. as VFIO currently does not add the mapping of
39591 + the interrupt region to SMMU. This should be removed once the
39592 + support is added in the Kernel.
39594 + vfio_map_irq_region(group);
39599 +static int vfio_set_group(struct fsl_vfio_group *group, int groupid)
39601 + char path[PATH_MAX];
39602 + struct vfio_group_status status = { .argsz = sizeof(status) };
39604 + /* Open the VFIO file corresponding to the IOMMU group */
39605 + snprintf(path, sizeof(path), "/dev/vfio/%d", groupid);
39607 + group->fd = open(path, O_RDWR);
39608 + if (group->fd < 0) {
39609 + RTE_LOG(ERR, EAL, "vfio: error opening %s\n", path);
39613 + /* Test & Verify that group is VIABLE & AVAILABLE */
39614 + if (ioctl(group->fd, VFIO_GROUP_GET_STATUS, &status)) {
39615 + RTE_LOG(ERR, EAL, "vfio: error getting group status\n");
39616 + close(group->fd);
39619 + if (!(status.flags & VFIO_GROUP_FLAGS_VIABLE)) {
39620 + RTE_LOG(ERR, EAL, "vfio: group not viable\n");
39621 + close(group->fd);
39624 + /* Since Group is VIABLE, Store the groupid */
39625 + group->groupid = groupid;
39627 + /* Now connect this IOMMU group to given container */
39628 + if (vfio_connect_container(group)) {
39629 + RTE_LOG(ERR, EAL,
39630 + "vfio: error sonnecting container with group %d\n",
39632 + close(group->fd);
39639 +static int32_t setup_vfio_grp(char *vfio_container)
39641 + char path[PATH_MAX];
39642 + char iommu_group_path[PATH_MAX], *group_name;
39643 + struct fsl_vfio_group *group = NULL;
39648 + printf("\tProcessing Container = %s\n", vfio_container);
39649 + sprintf(path, "/sys/bus/fsl-mc/devices/%s", vfio_container);
39650 + /* Check whether ls-container exists or not */
39651 + printf("\tcontainer device path = %s\n", path);
39652 + if (stat(path, &st) < 0) {
39653 + RTE_LOG(ERR, EAL, "vfio: Error (%d) getting FSL-MC device (%s)\n",
39658 + /* DPRC container exists. NOw checkout the IOMMU Group */
39659 + strncat(path, "/iommu_group", sizeof(path) - strlen(path) - 1);
39661 + len = readlink(path, iommu_group_path, PATH_MAX);
39663 + RTE_LOG(ERR, EAL, "\tvfio: error no iommu_group for device\n");
39664 + RTE_LOG(ERR, EAL, "\t%s: len = %d, errno = %d\n",
39665 + path, len, errno);
39669 + iommu_group_path[len] = 0;
39670 + group_name = basename(iommu_group_path);
39671 + if (sscanf(group_name, "%d", &groupid) != 1) {
39672 + RTE_LOG(ERR, EAL, "\tvfio: error reading %s: %m\n", path);
39676 + RTE_LOG(INFO, EAL, "\tvfio: iommu group id = %d\n", groupid);
39678 + /* Check if group already exists */
39679 + for (i = 0; i < VFIO_MAX_GRP; i++) {
39680 + group = &vfio_groups[i];
39681 + if (group->groupid == groupid) {
39682 + RTE_LOG(ERR, EAL, "groupid already exists %d\n", groupid);
39687 + if (vfio_set_group(group, groupid)) {
39688 + RTE_LOG(ERR, EAL, "group setup failure - %d\n", groupid);
39692 + /* Get Device information */
39693 + ret = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, vfio_container);
39695 + RTE_LOG(ERR, EAL, "\tvfio: error getting device %s fd from group %d\n",
39696 + vfio_container, group->groupid);
39699 + container_device_fd = ret;
39700 + RTE_LOG(INFO, EAL, "vfio: Container FD is [0x%X]\n", container_device_fd);
39701 + /* Set up SMMU */
39702 + ret = setup_dmamap();
39704 + RTE_LOG(ERR, EAL, ": Setting dma map\n");
39711 +static int64_t vfio_map_mcp_obj(struct fsl_vfio_group *group, char *mcp_obj)
39713 + int64_t v_addr = (int64_t)MAP_FAILED;
39714 + int32_t ret, mc_fd;
39716 + struct vfio_device_info d_info = { .argsz = sizeof(d_info) };
39717 + struct vfio_region_info reg_info = { .argsz = sizeof(reg_info) };
39719 + /* getting the mcp object's fd*/
39720 + mc_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, mcp_obj);
39722 + RTE_LOG(ERR, EAL, "vfio: error getting device %s fd from group %d\n",
39723 + mcp_obj, group->fd);
39727 + /* getting device info*/
39728 + ret = ioctl(mc_fd, VFIO_DEVICE_GET_INFO, &d_info);
39730 + RTE_LOG(ERR, EAL, "vfio: error getting DEVICE_INFO\n");
39734 + /* getting device region info*/
39735 + ret = ioctl(mc_fd, VFIO_DEVICE_GET_REGION_INFO, ®_info);
39737 + RTE_LOG(ERR, EAL, "vfio: error getting REGION_INFO\n");
39741 + RTE_LOG(INFO, EAL, "region offset = %llx , region size = %llx\n",
39742 + reg_info.offset, reg_info.size);
39744 + v_addr = (uint64_t)mmap(NULL, reg_info.size,
39745 + PROT_WRITE | PROT_READ, MAP_SHARED,
39746 + mc_fd, reg_info.offset);
39754 +/* Following function shall fetch total available list of MC devices
39755 + * from VFIO container & populate private list of devices and other
39756 + * data structures
39758 +static int vfio_process_group_devices(void)
39760 + struct fsl_vfio_device *vdev;
39761 + struct vfio_device_info device_info = { .argsz = sizeof(device_info) };
39762 + char *temp_obj, *object_type, *mcp_obj, *dev_name;
39763 + int32_t object_id, i, dev_fd, ret;
39765 + struct dirent *dir;
39766 + char path[PATH_MAX];
39769 + struct fsl_vfio_group *group = &vfio_groups[0];
39771 + sprintf(path, "/sys/kernel/iommu_groups/%d/devices", group->groupid);
39773 + d = opendir(path);
39775 + RTE_LOG(ERR, EAL, "Unable to open directory %s\n", path);
39779 + /*Counting the number of devices in a group and getting the mcp ID*/
39782 + while ((dir = readdir(d)) != NULL) {
39783 + if (dir->d_type == DT_LNK) {
39785 + if (!strncmp("dpmcp", dir->d_name, 5)) {
39788 + mcp_obj = malloc(sizeof(dir->d_name));
39790 + RTE_LOG(ERR, EAL,
39791 + "Unable to allocate memory\n");
39794 + strcpy(mcp_obj, dir->d_name);
39795 + temp_obj = strtok(dir->d_name, ".");
39796 + temp_obj = strtok(NULL, ".");
39797 + sscanf(temp_obj, "%d", &mcp_id);
39804 + RTE_LOG(ERR, EAL, "MCP Object not Found\n");
39807 + RTE_LOG(INFO, EAL, "Total devices in conatiner = %d, MCP ID = %d\n",
39808 + ndev_count, mcp_id);
39810 + /* Allocate the memory depends upon number of objects in a group*/
39811 + group->vfio_device = (struct fsl_vfio_device *)malloc(ndev_count * sizeof(struct fsl_vfio_device));
39812 + if (!(group->vfio_device)) {
39813 + RTE_LOG(ERR, EAL, "Unable to allocate memory\n");
39818 + /* Allocate memory for MC Portal list */
39819 + mcp_ptr_list = malloc(sizeof(void *) * 1);
39820 + if (!mcp_ptr_list) {
39821 + RTE_LOG(ERR, EAL, "NO Memory!\n");
39826 + v_addr = vfio_map_mcp_obj(group, mcp_obj);
39828 + if (v_addr == (int64_t)MAP_FAILED) {
39829 + RTE_LOG(ERR, EAL, "mapping region (errno = %d)\n", errno);
39833 + RTE_LOG(INFO, EAL, "MC has VIR_ADD = 0x%ld\n", v_addr);
39835 + mcp_ptr_list[0] = (void *)v_addr;
39837 + d = opendir(path);
39839 + RTE_LOG(ERR, EAL, "Directory %s not able to open\n", path);
39844 + printf("\nDPAA2 - Parsing MC Device Objects:\n");
39845 + /* Parsing each object and initiating them*/
39846 + while ((dir = readdir(d)) != NULL) {
39847 + if (dir->d_type != DT_LNK)
39849 + if (!strncmp("dprc", dir->d_name, 4) || !strncmp("dpmcp", dir->d_name, 5))
39851 + dev_name = malloc(sizeof(dir->d_name));
39853 + RTE_LOG(ERR, EAL, "Unable to allocate memory\n");
39856 + strcpy(dev_name, dir->d_name);
39857 + object_type = strtok(dir->d_name, ".");
39858 + temp_obj = strtok(NULL, ".");
39859 + sscanf(temp_obj, "%d", &object_id);
39860 + RTE_LOG(INFO, EAL, "%s ", dev_name);
39862 + /* getting the device fd*/
39863 + dev_fd = ioctl(group->fd, VFIO_GROUP_GET_DEVICE_FD, dev_name);
39864 + if (dev_fd < 0) {
39865 + RTE_LOG(ERR, EAL, "vfio getting device %s fd from group %d\n",
39866 + dev_name, group->fd);
39872 + vdev = &group->vfio_device[group->object_index++];
39873 + vdev->fd = dev_fd;
39876 + /* Get Device inofrmation */
39877 + if (ioctl(vdev->fd, VFIO_DEVICE_GET_INFO, &device_info)) {
39878 + RTE_LOG(ERR, EAL, "VFIO_DEVICE_FSL_MC_GET_INFO failed\n");
39882 + if (!strcmp(object_type, "dpni") ||
39883 + !strcmp(object_type, "dpseci")) {
39884 + struct rte_pci_device *dev;
39886 + dev = malloc(sizeof(struct rte_pci_device));
39887 + if (dev == NULL) {
39890 + memset(dev, 0, sizeof(*dev));
39891 + /* store hw_id of dpni/dpseci device */
39892 + dev->addr.devid = object_id;
39893 + dev->id.vendor_id = FSL_VENDOR_ID;
39894 + dev->id.device_id = (strcmp(object_type, "dpseci")) ?
39895 + FSL_MC_DPNI_DEVID : FSL_MC_DPSECI_DEVID;
39897 + TAILQ_INSERT_TAIL(&pci_device_list, dev, next);
39900 + if (!strcmp(object_type, "dpio")) {
39901 + dpaa2_create_dpio_device(vdev, &device_info, object_id);
39904 + if (!strcmp(object_type, "dpbp")) {
39905 + dpaa2_create_dpbp_device(object_id);
39910 + ret = dpaa2_affine_qbman_swp();
39912 + RTE_LOG(ERR, EAL, "%s(): Err in affining qbman swp\n", __func__);
39917 + free(group->vfio_device);
39918 + group->vfio_device = NULL;
39923 + * Scan the content of the PCI bus, and the devices in the devices
39929 + char path[PATH_MAX];
39932 + ls2bus_container = getenv("DPRC");
39934 + if (ls2bus_container == NULL) {
39935 + RTE_LOG(WARNING, EAL, "vfio container not set in env DPRC\n");
39939 + snprintf(path, sizeof(path), "%s/%s", SYSFS_FSL_MC_DEVICES,
39940 + ls2bus_container);
39941 + /* Check whether LS-Container exists or not */
39942 + RTE_LOG(INFO, EAL, "\tcontainer device path = %s\n", path);
39943 + if (stat(path, &st) < 0) {
39944 + RTE_LOG(ERR, EAL, "vfio:fsl-mc device does not exists\n");
39950 +/* Init the FSL-MC- LS2 EAL subsystem */
39952 +rte_eal_dpaa2_init(void)
39954 + if (fsl_mc_scan() < 0)
39957 +#ifdef VFIO_PRESENT
39958 + if (setup_vfio_grp(ls2bus_container)) {
39959 + RTE_LOG(ERR, EAL, "setup_vfio_grp\n");
39962 + if (vfio_process_group_devices()) {
39963 + RTE_LOG(ERR, EAL, "vfio_process_group_devices\n");
39969 diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.h b/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.h
39970 new file mode 100644
39971 index 0000000..cf2bd38
39973 +++ b/lib/librte_eal/linuxapp/eal/eal_vfio_fsl_mc.h
39978 + * Copyright (c) 2014 Freescale Semiconductor, Inc. All rights reserved.
39980 + * Redistribution and use in source and binary forms, with or without
39981 + * modification, are permitted provided that the following conditions
39984 + * * Redistributions of source code must retain the above copyright
39985 + * notice, this list of conditions and the following disclaimer.
39986 + * * Redistributions in binary form must reproduce the above copyright
39987 + * notice, this list of conditions and the following disclaimer in
39988 + * the documentation and/or other materials provided with the
39990 + * * Neither the name of Freescale Semiconductor nor the names of its
39991 + * contributors may be used to endorse or promote products derived
39992 + * from this software without specific prior written permission.
39994 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39995 + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39996 + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
39997 + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
39998 + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
39999 + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
40000 + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
40001 + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
40002 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
40003 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40004 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40007 +#ifndef _EAL_VFIO_FSL_MC_H_
40008 +#define _EAL_VFIO_FSL_MC_H_
40010 +#include <rte_memory.h>
40011 +#include <rte_atomic.h>
40012 +#include "eal_vfio.h"
40014 +#define FSL_VENDOR_ID 0x1957
40015 +#define FSL_MC_DPNI_DEVID 7
40016 +#define FSL_MC_DPSECI_DEVID 3
40018 +#define VFIO_MAX_GRP 1
40019 +#define VFIO_MAX_CONTAINERS 1
40021 +#define DPAA2_MBUF_HW_ANNOTATION 64
40022 +#define DPAA2_FD_PTA_SIZE 64
40024 +#if (DPAA2_MBUF_HW_ANNOTATION + DPAA2_FD_PTA_SIZE) > RTE_PKTMBUF_HEADROOM
40025 +#error "Annotation requirement is more than RTE_PKTMBUF_HEADROOM"
40028 +/* we will re-use the HEADROOM for annotation in RX */
40029 +#define DPAA2_HW_BUF_RESERVE 0
40030 +#define DPAA2_PACKET_LAYOUT_ALIGN 64 /*changing from 256 */
40032 +typedef struct fsl_vfio_device {
40033 + int fd; /* fsl_mc root container device ?? */
40034 + int index; /*index of child object */
40035 + struct fsl_vfio_device *child; /* Child object */
40036 +} fsl_vfio_device;
40038 +typedef struct fsl_vfio_group {
40039 + int fd; /* /dev/vfio/"groupid" */
40041 + struct fsl_vfio_container *container;
40042 + int object_index;
40043 + struct fsl_vfio_device *vfio_device;
40046 +typedef struct fsl_vfio_container {
40047 + int fd; /* /dev/vfio/vfio */
40049 + int index; /* index in group list */
40050 + struct fsl_vfio_group *group_list[VFIO_MAX_GRP];
40051 +} fsl_vfio_container;
40053 +int vfio_dmamap_mem_region(
40058 +/* initialize the NXP/FSL dpaa2 accelerators */
40059 +int rte_eal_dpaa2_init(void);
40061 +int dpaa2_create_dpio_device(struct fsl_vfio_device *vdev,
40062 + struct vfio_device_info *obj_info,
40065 +int dpaa2_create_dpbp_device(int dpbp_id);
40067 +int dpaa2_affine_qbman_swp(void);
40069 +int dpaa2_affine_qbman_swp_sec(void);
40073 diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
40074 index 059ad9e..d620ad1 100644
40075 --- a/lib/librte_mempool/rte_mempool.h
40076 +++ b/lib/librte_mempool/rte_mempool.h
40077 @@ -262,6 +262,14 @@ struct rte_mempool {
40078 #define MEMPOOL_F_POOL_CREATED 0x0010 /**< Internal: pool is created. */
40079 #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020 /**< Don't need physically contiguous objs. */
40081 +#ifdef RTE_LIBRTE_DPAA2_PMD
40082 +/* TODO: This should be removed once mempool integration is complete. Primary
40083 + * reason for this is identification of DPAA1/2 memory pool for forwarding
40086 +#define MEMPOOL_F_HW_PKT_POOL 0x0080
40090 * @internal When debug is enabled, store some statistics.
40092 diff --git a/mk/rte.app.mk b/mk/rte.app.mk
40093 index eb28e11..11ae122 100644
40094 --- a/mk/rte.app.mk
40095 +++ b/mk/rte.app.mk
40096 @@ -101,6 +101,7 @@ _LDLIBS-$(CONFIG_RTE_LIBRTE_CFGFILE) += -lrte_cfgfile
40098 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_BOND) += -lrte_pmd_bond
40099 _LDLIBS-$(CONFIG_RTE_LIBRTE_PMD_XENVIRT) += -lrte_pmd_xenvirt -lxenstore
40100 +_LDLIBS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += -lrte_pmd_dpaa2
40102 ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),n)
40103 # plugins (link only if static libraries)